You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exporttypeView<T>={[KinkeyofT]: T[K]extendsobject ? boolean|View<T[K]> : boolean};interfaceTypeC{foo: string;bar: string;}interfaceTypeB{foo: string,bar: TypeC}interfaceTypeA{foo: string,bar: TypeB,}lettest: 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!
The text was updated successfully, but these errors were encountered:
This is covered by #20863. After the first bar property check which has type boolean | View<TypeB> excesses property checking gets disabled for nested properties because of the union type.
See this code in checker.ts
// Above we check for excess properties with respect to the entire target type. When union
// and intersection types are further deconstructed on the target side, we don't want to
// make the check again (as it might fail for a partial target type). Therefore we obtain
// the regular source type and proceed with that.
if (isUnionOrIntersectionTypeWithoutNullableConstituents(target) && !discriminantType) {
source = getRegularTypeOfObjectLiteral(source);
}
TypeScript Version: 3.2.0-dev.20181117
Code
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: