Skip to content

Double error message when referencing variable of type union of string literals from ambient declarationΒ #63050

@devanshj

Description

@devanshj

πŸ”Ž Search Terms

double error, same message twice, ambient declaration, string literal union

πŸ•— Version & Regression Information

This changed between versions 3.9.7 and 4.0.5

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.3#code/CYUwxgNghgTiAEYD2A7AzgF3gDwFzwCIoD4AfQgIwIChrl0sBPfFAVwFsKQZ4BeHIA

πŸ’» Code

declare const x: "a" | "b"

const y: number = x
//    ~
//    Type 'string' is not assignable to type 'number'.
//      Type 'string' is not assignable to type 'number'. (2322)

πŸ™ Actual behavior

You see same error message twice

πŸ™‚ Expected behavior

The error message should be the one in 3.9.7 ie...

Type '"a" | "b"' is not assignable to type 'number'.
  Type '"a"' is not assignable to type 'number'. (2322)

Or the following message just once also works...

Type 'string' is not assignable to type 'number'. (2322)

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions