Skip to content

Bug: decorators get duplicated in AST for parameter properties #5581

Closed
@fisker

Description

@fisker

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

parser

Playground Link

https://typescript-eslint.io/play/#ts=4.8.2&sourceType=module&showAST=es&code=MYGwhgzhAECC0G9pgBQAEAm0AOAnAlgG5gAuAptAB4Bc0AdgK4C2ARmbgJSLQC+vQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

> parse = require("@typescript-eslint/typescript-estree").parse
[Function: parse]
> ast = parse('class A {a (@d private x: number) {}}')
{
  type: 'Program',
  body: [
    {
      type: 'ClassDeclaration',
      id: [Object],
      body: [Object],
      superClass: null
    }
  ],
  sourceType: 'script'
}
> ast.body[0].body.body[0].value.params[0].decorators[0]
{ type: 'Decorator', expression: { type: 'Identifier', name: 'd' } }
> ast.body[0].body.body[0].value.params[0].parameter.decorators[0]
{ type: 'Decorator', expression: { type: 'Identifier', name: 'd' } }

ESLint Config

N/A

tsconfig

N/A

Expected Result

Not duplicate the decorator

Actual Result

the decorator get duplicate

Additional Info

No response

Versions

package version
@typescript-eslint/parser 5.36.1
node 18.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions