Skip to content

Incorrect error message with String Literal Types #7530

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
yves-dolce opened this issue Mar 16, 2016 · 4 comments
Closed

Incorrect error message with String Literal Types #7530

yves-dolce opened this issue Mar 16, 2016 · 4 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Help Wanted You can do this

Comments

@yves-dolce
Copy link

TypeScript Version:

1.8.5

Code

declare type ConstrainedString = "La première" | "La primera" | "The first";

function f(s : ConstrainedString) {
    console.log(s);
}

f("La primera");
f("La première");
f("The first");


f("De eerste"); // Error message is here, as expected.

Expected behavior:

The second sentence of the error message I see under Visual Studio Code doesn't seem to make sense, does it?
Argument of type '"De eerste"' is not assignable to parameter or type '"La première" | "La primera" | "The first"'. Type '"De eerste"' is not assignable to type "The first"'

I wonder if I should not rather open this under VS Code.

Actual behavior:
Removing that second sentence?

@DanielRosenwasser
Copy link
Member

Duplicate of #6541. Thanks for filing!

@DanielRosenwasser DanielRosenwasser added Duplicate An existing issue was already created Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging and removed Duplicate An existing issue was already created labels Mar 16, 2016
@DanielRosenwasser DanielRosenwasser self-assigned this Mar 16, 2016
@DanielRosenwasser
Copy link
Member

Actually, thinking about it more, I think we can potentially make some improvements independent of #6541. When the source is of a primitive or literal type, I don't necessarily see the point in diving into these elaborations. I'll look into it.

@DanielRosenwasser
Copy link
Member

Fixed - thanks for suggesting that @yves-dolce! The fix will be in our nightly builds "tomorrow" | "mañana" | "demain". 😄

@yves-dolce
Copy link
Author

Just saw this, while watching Build 2017... :-)
Thanks for the follow up.

@mhegazy mhegazy removed this from the Community milestone Apr 26, 2018
@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
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants