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
typeA1={foo: number,};typeB1=A1&{bar: {x: boolean}};constb1: B1={foo: 5,bar: {x: true,zoo: 5}// OK but expected: "'zoo' does not exist on type '{x: boolean}'"}b1.bar.zoo=5;// Error as expected: "'zoo' does not exist on type '{x: boolean}'"b1.bar={x: true,zoo: 5};// Error as expected: "'zoo' does not exist on type '{x: boolean}'"typeA2={foo: number,bar: {x: boolean}// this is the only difference from case 1 (type intersection is avoided)};consta2: A2={foo: 5,bar: {x: true,zoo: 5}// Error as expected: "'zoo' does not exist on type '{x: boolean}'"}
Expected behavior:
When assigning to an intersection type, the types of the merged properties should be checked as if they were being assigned individually.
Actual behavior:
Type errors are missed, as described.
The text was updated successfully, but these errors were encountered:
My workaround was to use classes instead. This works:
classC1{foo: number;}classC2extendsC1{bar: {x: boolean}}constc2: C2={foo: 5,bar: {x: true,zoo: 5}// Error as expected: "'zoo' does not exist on type '{x: boolean}'"};
TypeScript Version: 2.1.5
Code
Expected behavior:
When assigning to an intersection type, the types of the merged properties should be checked as if they were being assigned individually.
Actual behavior:
Type errors are missed, as described.
The text was updated successfully, but these errors were encountered: