-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
no-undefined-types should check @type
#721
Comments
Is this promoting an anti-pattern though? With "typescript" |
It could be that this is considered an anti-pattern. I would argue that if I would need a variable of a certain type, that this code needs to be imported at some point in the software anyways. If I would write the same code in typescript I would need an import, too. Also this seems to be inconsistent. If I use a type in a It might be an option to make the whole 'marking as used' functionality optional so the user could decide which way of importing they would prefer. |
What are the benefits for using esm import over JSDoc |
As per #721 (comment) , I think the argument here is for consistency rather than endorsing the practice. |
Yes, my main point is: Either mark all types / variables in type annotation as used or none. I just wanted to elaborate that there might be cases in which it is possible to argue in favor of es6 imports. I think it might be nice to allow users to make this decision by themselves and make the whole 'marking as used' optional. |
Also the same should be true if you declare a variable / type in a file and only use it in an annotation. |
As mentioned just now here, I'm not sure how this got by me, but:
We are discussing removing the |
I wanted to share my use-case: The code that will be relying on this will be bundled using Rollup, which will effectively tree-shake anything that wasn't actually referenced by actual code. So this won't cause unnecessary module loading at runtime. |
I agree. I just tested and |
Motivation
Eslint complains about unused-vars if they only occur in
@type
annotations.For example:
Current behavior
no-undefined-types
does not check@type
annotationsDesired behavior
no-undefined-types
should check@type
annotationsWant to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: