Closed
Description
TypeScript Version: 1.8.0
Is this a bug or does it work as intended?
Code
type Test = { a: string; } | { b:number };
var t1 : Test = { a: '...', b: 3 }; // ok
var t2 : Test = { a: '...', b: '...' }; // ok but should be error!?
var t3 : Test = { a: '...', c: '...' }; // error
var a4 : { a: string; } = { a: '...', b: '...' }; // error
Expected behavior:
var t2 : Test = { a: '...', b: '...' };
should throw a compiler error as well because b
is of type string
and not number
.
Actual behavior:
There is no compiler error.