Skip to content

Parse error on type assertion with contextual keyword in parentheses (override as Type) #44466

@zxbodya

Description

@zxbodya

Bug Report

🔎 Search Terms

typecast, parentheses, override

🕗 Version & Regression Information

Started to see the issue after updating from TypeScript 4.2 to 4.3, initially noticing this when running prettier after updating it prettier/prettier#11018

It also is happening in current 'Nightly' version in the playground.

⏯ Playground Link

Playground link with relevant code

💻 Code

const override = {};
const b = (override as any);

🙁 Actual behavior

Code results in a syntax error.

However it works fine when renaming variable override to something else.

🙂 Expected behavior

Code above should work

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFix AvailableA PR has been opened for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions