Bug: [no-deprecated] Deprecated imported variable used in an object not detected/reported #10828
Closed
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
Uh oh!
There was an error while loading. Please reload this page.
Before You File a Bug Report Please Confirm You Have Done The Following...
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 module
forRoot
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
npm install
npx eslint
or open in VSCode with the ESLint extension-> Lines 10 and 36 are not detected/reported
-> In VSCode, lines 10 and 36 are shown as deprecated by
ts(6385)
, not ESLintVersions
@typescript-eslint/eslint-plugin
8.24.0
@typescript-eslint/parser
8.24.0
@typescript-eslint/scope-manager
8.24.0
@typescript-eslint/typescript-estree
8.24.0
@typescript-eslint/type-utils
8.24.0
@typescript-eslint/utils
8.24.0
TypeScript
5.7.3
ESLint
9.20.1
node
20.16.0
Quick self-analysis
I tried tracking the issue in the no-deprecated rule source for tag 8.24.0.
It fails in
getDeprecationReason
while considering thenode.parent.type
as a property.When the variable is local / not imported, the
getJsDocDeprecation(propertySymbol)
call at line 353 succeeds.It returns
undefined
when the variable is imported.In the debugger, evaluating
searchForDeprecationInAliasesChain
the same way as line 358 returns the right deprecation reason.This seems related, as the comment above
searchForDeprecationInAliasesChain
says:So I guess it's just about applying the right behaviour with imported properties.
Checking for duplicates
I found #10643, but:
so I considered it was a different problem.
The text was updated successfully, but these errors were encountered: