Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug:getNodeByRangeIndex returns incorrect node for decoratedClassDeclaration insideExportDeclaration #11578

Open
Labels
breaking changeThis change will require a new major version to be releasedbugSomething isn't workingtriageWaiting for team members to take a look
@9romise

Description

@9romise

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 havesearched for related issues and found none that matched my issue.
  • I haveread the FAQ and my problem is not listed.

Relevant Package

utils

Playground Link

https://typescript-eslint.io/play/#ts=5.9.2&showAST=es&fileType=.ts&code=AIMw9mAUDeBQAE8B2BDAtgUwFzwIwBpYBfASlgwA8AHMAJwBd4BjAGxQGd34AxCeaeEVhA&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Please focus on the range of the nodes.

Repro Code

@foo({name:1,})exportclassFoo{}

Expected Result

  • RunsourceCode.getNodeByRangeIndex(14)
  • ReturnProperty

Actual Result

ReturnProgram

Additional Info

When aClassDeclaration has a parent node of typeExportNamedDeclaration orExportDefaultDeclaration,sourceCode.getNodeByRangeIndex fails to return the correct node based on the provided index.

This occurs because the range ofExportDeclaration andClassDeclaration nodes does not include the range of decorators, causing decorators to be skipped during node retrieval.

This appears to be a design limitation in the ESTree specification. However, is it possible to override thegetNodeByRangeIndex to ensure it returns the correct node in such cases?

Versions

packageversion
@typescript-eslint/eslint-plugin8.41.0
@typescript-eslint/parser8.41.0
@typescript-eslint/rule-tester8.41.0
@typescript-eslint/scope-manager8.41.0
@typescript-eslint/typescript-estree8.41.0
@typescript-eslint/type-utils8.41.0
@typescript-eslint/utils8.41.0
TypeScript5.8.3
ESLint9.34.0
node22.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeThis change will require a new major version to be releasedbugSomething isn't workingtriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp