-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
JSDoc @import not detecting use in @callback #58368
Comments
Thanks for trying. Looking into it further, in my case it's reporting Here is a video demonstrating in VS Code.
|
More info: I think this only happens when the type is available by ambients. Then the imported type reports that it's not used. This may not be a bug per current spec but it is a bit of a UX hazard because ambient resolution can differ by build order etc. So a type that's "not used" at coding time may be necessary at build time. The message that says it's not used suggests it can be removed, but that breaks the build. |
Looks like a bug, but I can't repro this either. We can investigate if there's a way to reproduce it |
@RyanCavanaugh I am having trouble putting together a reproduction, but the details of my case somewhat match up with this issue. However, I noticed that if I move the JSDoc import statement to happen before the last non-JSDoc I only saw this "unused import" error in some files. Not sure what the root cause might be, there was no pattern (relative imports vs. absolute imports, etc.) I could see in the cases I went through. |
Here’s a reproduction: playground It’s based on this commit, where it happens in |
* support 5.5 * add jsdoc-import test * use import comments * update * remove * install 5.5.2 * try this i guess? * or this? * fix * fix test * skipLibCheck * export types * make types.d.ts a module * export namespace * apply workaround from microsoft/TypeScript#58368
See: https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-import-tag Note that the JSDoc type imports have to be before the real module imports to workaround this TypeScript bug where sometimes the type imports are falsely considered unused: microsoft/TypeScript#58368 (comment) microsoft/TypeScript#58969
See: https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-import-tag Note that the JSDoc type imports have to be before the real module imports to workaround this TypeScript bug where sometimes the type imports are falsely considered unused: microsoft/TypeScript#58368 (comment) microsoft/TypeScript#58969
While issues have not yet been discovered in this project, JSDoc type imports have to be before the real module imports to workaround this TypeScript bug where sometimes the type imports are falsely considered unused: microsoft/TypeScript#58368 (comment) microsoft/TypeScript#58969
I had a file with no value imports, so I messed around with it and found that adding a semicolon or |
🔎 Search Terms
jsdoc import @import callback lsp
🕗 Version & Regression Information
5.5 beta
⏯ Playground Link
No response
💻 Code
🙁 Actual behavior
The
Checker
import is dim in an IDE and hovering says,🙂 Expected behavior
LSP detects that
Checker
is in the return ofGetChecker
.Additional information about the issue
The use is detected in
@typedef
and@type
. E.g. as withPassable
in the example code.The text was updated successfully, but these errors were encountered: