Skip to content

Unexpected type listed in error message #29861

Closed
@getify

Description

@getify

TypeScript Version: 3.2? (whatever version is currently on the playground)

Search Terms: "error message", "unexpected", "type", "is not assignable to"

Code

var a = 3;
a = "hello";

vs:

var a = 3;
var b = "hello";
a = b;

Expected behavior:

Expect both error messages to say: "Type 'string' is not assignable to type 'number'."

Actual behavior:

The error message in the first snippet says: "Type '"hello"' is not assignable to type 'number'."

The error message for the second snippet correctly says: "Type 'string' is not assignable to type 'number'."

Playground Link:

Unexpected type listed error message: https://www.typescriptlang.org/play/#src=var%20a%20%3D%203%3B%0D%0Aa%20%3D%20%22hello%22%3B

Expected type listed error message: https://www.typescriptlang.org/play/#src=var%20a%20%3D%203%3B%0D%0Avar%20b%20%3D%20%22hello%22%3B%0D%0Aa%20%3D%20b%3B

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Error MessagesThe issue relates to error messagingEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Experience EnhancementNoncontroversial enhancementsFixedA PR has been merged for this issueHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions