fix(41818): Detached JSDoc class docstring using @extends crashes tsc#41858
Merged
Conversation
Member
|
Your first solution is the right one. |
sandersn
requested changes
Dec 15, 2020
Member
sandersn
left a comment
There was a problem hiding this comment.
I like the checking you added to getEffectiveJSDocHost but it should be pushed down to getJSDocHost, if possible.
8088754 to
6bb5abf
Compare
sandersn
reviewed
Dec 18, 2020
6bb5abf to
6fbbce3
Compare
sandersn
approved these changes
Dec 18, 2020
sandersn
added a commit
that referenced
this pull request
Apr 14, 2021
JSDoc typedefs don't actually have hosts, because they're not semantically attached to a declaration. However, the parser still attaches them to some declaration (or statement), but that declaration is not related to the typedef. Previously, delayedBindJSDocTypedefTag used getJSDocHost to walk past the unrelated declaration, but #41858 correctly started categorising typedefs as unattached, with no host, so the binder began falling back to file scope. The path to skip the unrelated declaration is always the same, though, so this PR uses `typeAlias.parent.parent` instead of `getJSDocHost(typeAlias)`.
sandersn
added a commit
that referenced
this pull request
Apr 14, 2021
JSDoc typedefs don't actually have hosts, because they're not semantically attached to a declaration. However, the parser still attaches them to some declaration (or statement), but that declaration is not related to the typedef. Previously, delayedBindJSDocTypedefTag used getJSDocHost to walk past the unrelated declaration, but #41858 correctly started categorising typedefs as unattached, with no host, so the binder began falling back to file scope. The path to skip the unrelated declaration is always the same, though, so this PR uses `typeAlias.parent.parent` instead of `getJSDocHost(typeAlias)`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #41818
checkJSDocAugmentsTag checks
getEffectiveJSDocHostreturns node related toclass B extends A {}.getJSDocTags(classLike)uses the comment associates withclass B extends A {}that doesn't have
@extends. For that reason TS throwsDebug.assert(augmentsTags.length > 0);.I suppose in this case
getEffectiveJSDocHostshould returnundefined, to throw errorJSDoc_0_is_not_attached_to_a_classOr do we need to check
isJSDocAugmentsTagin all JSDoc comments?/cc @sandersn