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
Actual behavior:
TypeScript reports this error for the const c: A | B = { x: 1 || "a" }; statement:
Type '{ x: number | string; }' is not assignable to type 'A | B'.
Type '{ x: number | string; }' is not assignable to type 'B'.
Types of property 'x' are incompatible.
Type 'number | string' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
The text was updated successfully, but these errors were encountered:
nicolo-ribaudo
changed the title
Union doesn't merge object properties' type
Union doesn't merge objects properties' type
Apr 25, 2016
I should add that we've gotten this request around single-property types a bunch. It turns out to be very difficult to detect all of these cases properly in the compiler.
TypeScript Version:
This is reproducible both in VSCode 1.0 and in the playground (https://www.typescriptlang.org/play/#src=...)
Code
Expected behavior:
Both
c
andd
should be fineActual behavior:
TypeScript reports this error for the
const c: A | B = { x: 1 || "a" };
statement:The text was updated successfully, but these errors were encountered: