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: [no-deprecated] Deprecated imported variable used in an object not detected/reported #10828

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
@StephaneSeyvoz

Description

@StephaneSeyvoz

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.

Issue Description

When using an imported deprecated variable inside an object to assign it to a field, the usage is not detected/reported by the rule, both in CLI (npx eslint) and the VSCode ESLint extension.

When the variable is not imported, declared in the same file, the issue is reported correctly.
When using an intermediate variable, the issue is reported correctly.

The original case I was handling was in an Angular moduleforRoot method returning aModuleWithProviders configuration object, so as to bind the now deprecatedNGXS_PLUGINS injection token from the NGXS library (since v18.1.6) to an implementation service/provider.

Reproduction Repository Link

https://github.com/StephaneSeyvoz/typescript-eslint-no-deprecated

Repro Steps

  1. clone the repo
  2. npm install
  3. npx eslint or open in VSCode with the ESLint extension
src\main.ts  18:18  error  `deprecatedVar` is deprecated. For some reason; Usually would be an Angular injection token        @typescript-eslint/no-deprecated    24:26  error  `deprecatedModuleVar` is deprecated. For some reason; Usually would be an Angular injection token  @typescript-eslint/no-deprecated    45:16  error  `deprecatedVar` is deprecated. For some reason; Usually would be an Angular injection token        @typescript-eslint/no-deprecated    52:24  error  `deprecatedModuleVar` is deprecated. For some reason; Usually would be an Angular injection token  @typescript-eslint/no-deprecated  ✖ 4 problems (4 errors, 0 warnings)

-> Lines 10 and 36 are not detected/reported
-> In VSCode, lines 10 and 36 are shown as deprecated byts(6385), not ESLint

Versions

packageversion
@typescript-eslint/eslint-plugin8.24.0
@typescript-eslint/parser8.24.0
@typescript-eslint/scope-manager8.24.0
@typescript-eslint/typescript-estree8.24.0
@typescript-eslint/type-utils8.24.0
@typescript-eslint/utils8.24.0
TypeScript5.7.3
ESLint9.20.1
node20.16.0

Quick self-analysis

I tried tracking the issue in theno-deprecated rule source for tag 8.24.0.
It fails ingetDeprecationReason while considering thenode.parent.type as a property.

When the variable is local / not imported, thegetJsDocDeprecation(propertySymbol) call at line 353 succeeds.
It returnsundefined when the variable is imported.

In the debugger, evaluatingsearchForDeprecationInAliasesChain the same way as line 358 returns the right deprecation reason.
This seems related, as the comment abovesearchForDeprecationInAliasesChain says:

// Deprecated jsdoc tags can be added on some symbol alias, e.g.
//
// export { /**@deprecated */ foo }
//
// When we import foo, its symbol is an alias of the exported foo (the one
// with the deprecated tag), which is itself an alias of the original foo.
// Therefore, we carefully go through the chain of aliases and check each
// immediate alias for deprecated tags

So I guess it's just about applying the right behaviour with imported properties.

Checking for duplicates

I found#10643, but:

  • it seems different since no import is used there,
  • the issue isn't here when the variable is local.

so I considered it was a different problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

    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