-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
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
Wrong union behaviour #15778
Comments
@mhegazy Yes, exclusive unions would solve this. Thank you. |
@mhegazy If I use suggested workaround, I can't do anymore: const action: MyAction = {
type: 'type1'
}; I have to do: const action: MyAction = {
type: 'type1',
payload: undefined
}; |
that is correct. consider setting type MyAction = { type: "type1", payload?: undefined } | { type: "type2", payload: number }; |
Cool! This works. |
This works like a charm. Just use it as discussed here: DefinitelyTyped/DefinitelyTyped#16416 (comment) Thanks @mhegazy ! |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.3.2
Code
Expected behavior:
I'd expect to see an error about unexpected
payload
property. And if I use only one type from union I'll get it:Actual behavior:
There is no any errors
The text was updated successfully, but these errors were encountered: