We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
var t2 : Test = { a: '...', b: '...' };
b
string
number
Actual behavior: There is no compiler error.
The text was updated successfully, but these errors were encountered:
Linking to a previous discussion at #4452.
Sorry, something went wrong.
@Lenne231 is there a specific scenario you were hit by this?
Not a specific scenario, i was just playing around with union types.
No branches or pull requests
TypeScript Version: 1.8.0
Is this a bug or does it work as intended?
Code
Expected behavior:
var t2 : Test = { a: '...', b: '...' };
should throw a compiler error as well becauseb
is of typestring
and notnumber
.Actual behavior:
There is no compiler error.
The text was updated successfully, but these errors were encountered: