Closed
Description
We do a pretty poor job of reporting errors when mapped type inference fails. Primary issue seems to be that when something goes wrong in mapped type inference we infer an empty type. It would be better to infer an object type with the right set of properties (which is never in question) and {}
types for the properties that failed.
Code
type ComputedOf<T> = {
[K in keyof T]: () => T[K];
}
declare function foo<P, C>(options: { props: P, computed: ComputedOf<C> } & ThisType<P & C>): void;
foo({
props: { x: 10, y: 20 },
computed: {
bar(): number {
let z = this.bar; // Shouldn't be an error, but is
return 42;
},
baz: 42 // Should be an error, but isn't
}
});
Expected behavior:
Better error reporting.
Actual behavior:
Confusing errors.