Skip to content

5.3.0 regression - as const is being ignored in assignment, leading to false negativesΒ #56128

@MichaelMitchell-at

Description

@MichaelMitchell-at

πŸ”Ž Search Terms

"as const", 5.3.0, assignment

πŸ•— Version & Regression Information

  • This changed between versions 5.2.2 and 5.3.0 (nightly)

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.3.0-dev.20231016#code/PTAEAEBcGcFoFMAeAHeBjSCBOWD2XQAVACwEtpRpjcBXAGwBNQAjeUAQ1EgE9VR4c+FunY1obAAZZ47BrgB2dbqADaAFgBMAXQmhyoebkgdo0UgHN57ZnTaRcoCQEEc7bgB55NALassAPgkAKFtjRAAuUBcsN08fP39QAF5VTS0TUDQFaEgAbiCgA

πŸ’» Code

// This should be a type error because `readonly [42]` is not assignable to `Array<number>`
let x: Array<number> = [42] as const;

πŸ™ Actual behavior

No type error

πŸ™‚ Expected behavior

Type error

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