Skip to content

Incorrect error message with String Literal Types #7530

Closed
@yves-dolce

Description

@yves-dolce

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?

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions