Skip to content

Unexpected incompatible type with string literal type #16450

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
vilicvane opened this issue Jun 12, 2017 · 2 comments
Closed

Unexpected incompatible type with string literal type #16450

vilicvane opened this issue Jun 12, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@vilicvane
Copy link

TypeScript Version: nightly (2.4.0-dev.20170612)

Code

interface X {
    type: 'x';
    value: string;
}

interface Y {
    type: 'y';
    value: 'none' | 'done';
}

function foo(bar: X | Y) { }

foo({
    type: 'y',
    value: 'done',
});

Expected behavior:

No error.

Actual behavior:

Argument of type '{ type: "y"; value: string; }' is not assignable to parameter of type 'X | Y'.
  Type '{ type: "y"; value: string; }' is not assignable to type 'Y'.
    Types of property 'value' are incompatible.
      Type 'string' is not assignable to type '"none" | "done"'.
@opavader
Copy link

temporary workaround in #11465

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 12, 2017
@RyanCavanaugh
Copy link
Member

Going to track this at #16457

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