Skip to content

Union strings for Discriminated Unions #23569

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

Closed
mushishi78 opened this issue Apr 20, 2018 · 2 comments
Closed

Union strings for Discriminated Unions #23569

mushishi78 opened this issue Apr 20, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@mushishi78
Copy link

TypeScript Version: 2.8.1, 2.6.1
Search Terms: Union strings, Discriminated Unions
Code

const a: { type: '1' } | { type: '2' } = null as { type: '1' | '2' }

Expected behavior: The types should be recognized as equivalent

Actual behavior:

Type '"1"' is not assignable to type '"2"'

Playground Link: https://www.typescriptlang.org/play/#src=const%20a%3A%20%7B%20type%3A%20'1'%20%7D%20%7C%20%7B%20type%3A%20'2'%20%7D%20%3D%20null%20as%20%7B%20type%3A%20'1'%20%7C%20'2'%20%7D%0D%0A

@RyanCavanaugh
Copy link
Member

Duplicate of #12052

@RyanCavanaugh RyanCavanaugh marked this as a duplicate of #12052 Apr 20, 2018
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Apr 20, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants