Skip to content
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

@imports marked as unused #58969

Open
lishaduck opened this issue Jun 22, 2024 · 1 comment
Open

@imports marked as unused #58969

lishaduck opened this issue Jun 22, 2024 · 1 comment
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@lishaduck
Copy link

🔎 Search Terms

@import noUnused

🕗 Version & Regression Information

  • I was unable to test this on prior versions because it uses @import

⏯ Playground Link

No response

💻 Code

This requires multiple files, so the TS playground won't work. Sorry.

// bar.js
/** @import {foo} from "foo"; */

/**
 * @param baz {foo}
 */
function bar(baz) {}

With this in the TSConfig

"noUnusedLocals": true,
"noUnusedParameters": true,

🙁 Actual behavior

Foo is marked as unused.
It's being used in a JSDoc

🙂 Expected behavior

It shouldn't be marked as unused.

Additional information about the issue

This doesn't appear all the time, usually when there's multiple imports.
The example doesn't actually error, the code erroring got force-pushed away. However, it's the general issue.

I thought it might need a type qualifier, but that doesn't seem to be valid.

@lishaduck lishaduck changed the title @import Jun 22, 2024
@lishaduck
Copy link
Author

Oh, I didn't look at PR comments. I think this still needs an issue though: #57207 (comment)

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jun 24, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.6.0 milestone Jun 24, 2024
jaydenseric added a commit to jaydenseric/graphql-react that referenced this issue Jul 12, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
3 participants