-
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
fix(60908): Unexpected "'Type' is declared but its value is never read." error with jsdoc @import syntax #60921
base: main
Are you sure you want to change the base?
Conversation
@typescript-bot test it |
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
@jakebailey Here are the results of running the user tests with tsc comparing Everything looks good! |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
Looking at the playground, I believe this does fix #58368, yes.
|
if (isJSDocImportTag(node)) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the import tag special here?
Also, this early return will leave inAssignmentPattern
in a bad state, so I think it's better to skip the steps below that are broken with import tags if needed, or maybe there's something else wrong otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakebailey thanks for the feedback. These changes are open for discussion :). This applies to the case when we have
/** @import { Foo } from 'foo' */
function foo() {}
The function acts as a container that holds locals, including the symbol Foo. Since this symbol is unused (and doesn't have an exportSymbol
like the typedef
does), the checker triggers an error.
if (.... local.exportSymbol) {
return;
}
Perhaps the container for the import tag should be treated like a SourceFile
...
ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals;
Anyway, I’d be grateful for any ideas or suggestions regarding this case. thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly, I'm trying to understand why import tags have to be special cased, but other JSDoc "declarations" don't.
Fixes #60908
Fixes #58368