-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[consistent-type-imports] False positive with decorator metadata #4608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report! It's good to know that this is a case that happens outside of Vue (#3108). cc @bradzacher - tentatively I think we're stuck here and will just have to take a breaking change on |
The lint rule mostly just relies upon what every is reported by the scope analysis. However, right now we only derive that config from the tsconfig - meaning you need type information to turn on this code path. typescript-eslint/packages/parser/src/parser.ts Lines 167 to 170 in 9d47a8b
We could definitely add a |
I don't quite understand the above, but I am using |
if you are using type-awawre linting then it will work out of the box. |
The above issue was logged with type-aware linting enabled |
Have you got a more complete example of the types you've imported? |
I believe this is a duplicate of #4268 (comment) slash #3108 (comment) The TL;DR is that TS uses type information to resolve that In general the decorator support is not amazing. We've done the best we can with the information we've got - but it's not perfect by any means. |
Repro
Expected Result
Ref
is only used as a type, and is not used by the decorator, no issue should be raised here.Actual Result
ESLint: Type import "Ref" is used by decorator metadata.(@typescript-eslint/consistent-type-imports)
However, typescript compiles the code fine with 'importsNotUsedAsValues'.
When removing
type
, typescript compilation fails:Versions
@typescript-eslint/eslint-plugin
13.1.0
@typescript-eslint/parser
5.12.1
TypeScript
4.5.5
ESLint
8.10.0
node
16.13.0
The text was updated successfully, but these errors were encountered: