Closed
Description
TypeScript Version: 3.2.0-dev.20181117
Code
export type View<T> = { [K in keyof T]: T[K] extends object ? boolean | View<T[K]> : boolean };
interface TypeC {
foo: string;
bar: string;
}
interface TypeB {
foo: string,
bar: TypeC
}
interface TypeA {
foo: string,
bar: TypeB,
}
let test: View<TypeA>;
test = { foo: true, bar: true, boo: true } // error TS2322: Type '{ foo: true; bar: true; boo: boolean; }' is not assignable to type 'View<TypeA>'. Object literal may only specify known properties, and 'boo' does not exist in type 'View<TypeA>'.
test = { foo: true, bar: { foo: true, bar: true, boo: true } } // error TS2322: Type '{ foo: true; bar: { foo: true; bar: true; boo: boolean; }; }' is not assignable to type 'View<TypeA>'. Types of property 'bar' are incompatible. Type '{ foo: true; bar: true; boo: boolean; }' is not assignable to type 'boolean | View<TypeB>'. Object literal may only specify known properties, and 'boo' does not exist in type 'boolean | View<TypeB>'.
Expected behavior:
test = { foo: true, bar: { foo: true, bar: { foo: true, bar: true, boo: true } } } // error TS2322: Type '{ foo: true; bar: { foo: true; bar: { foo: true; bar: true; boo: true }; }; }' is not assignable to type 'View<TypeA>'. Types of property 'bar' are incompatible...
Actual behavior:
test = { foo: true, bar: { foo: true, bar: { foo: true, bar: true, boo: true } } } // no error!