Skip to content

Confusing error message when value does not match union type #12659

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
Jessidhia opened this issue Dec 5, 2016 · 1 comment
Closed

Confusing error message when value does not match union type #12659

Jessidhia opened this issue Dec 5, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@Jessidhia
Copy link

TypeScript Version: nightly (2.2.0-dev.20161201)

Code

interface X<T extends string, U> {
    type: T
    data: U
}

type Y = X<'a', { a: string }>
type Z = X<'b', { b: string }>

type YZ = Y | Z

const y: YZ = {
    type: 'a',
    data: {}
}

Expected behavior:

Error message to show the union type, or at least the best partial match (type Y)

Actual behavior:

Error says the value of y does not match type Z.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Dec 5, 2016
@RyanCavanaugh
Copy link
Member

Duplicate #6541

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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

2 participants