Skip to content

Removing parentheses for decorators causes TS1497 error. #16429

@erayhanoglu

Description

@erayhanoglu

TypeScript announces Stricter Parsing for Decorators in v5.5. Prettier removes parentheses for decorators after commit #11849. This breaks the code and tsc throws "TS1497: Expression must be enclosed in parentheses to be used as a decorator".

Prettier 3.3.2
Playground link

--parser typescript

Input:

@(test().x('global').y())
@test().y('global').y()
class X {}

Output:

@test().x("global").y()
@test().y("global").y()
class X {}

Expected behavior:

Input:

@(test().x('global').y())
@test().y('global').y()
class X {}

Output:

@(test().x("global").y())
@(test().y("global").y())
class X {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:needs investigationIssues that need additional investigation, e.g. to understand whether the reported behavior is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions