Skip to content

Conversation

@ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented Jan 26, 2026

With this PR we track reparsed clones of JSDoc nodes such that ast.GetReparsedNodeForNode can consistently map from JSDoc nodes to their reparsed clones (which are the ones that are assigned symbols by the binder). The PR changes the checker.GetSymbolAtLocation and checker.TryGetThisTypeAtEx functions to use ast.GetReparsedNodeFromNode.

Fixes #2490.

Copy link
Member

@DanielRosenwasser DanielRosenwasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there are some nice improvements on find-all-references/go-to-definition, so that's great.

Can you add both examples (the original repro from the issue, and the one you are trying to fix with the parent cache) to the test suite?

Would you say that generally all exposed checker methods should guard on nodes and try to get the reparsed node?

Comment on lines 11015 to 11016
key := TokenCacheKey{Loc: loc, Parent: parent}
if token, ok := node.tokenCache[key]; ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know precisely what was happening that requires caching on the parent?

Copy link
Member Author

@ahejlsberg ahejlsberg Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm realizing that the completions logic is asking for tokens in both JSDoc comments and their reparsed clones. Such nodes have the same location but different parents. I'm changing the logic to only ask for tokens in the original JSDoc nodes. That will then allow me to get rid of the parent in the cache key.

// === /foo.js ===
// /**
// * @overload
// * @param {number} [|x|]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is a regression - what changed here?

Copilot AI review requested due to automatic review settings January 27, 2026 00:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@DanielRosenwasser
Copy link
Member

@copilot try again

Copy link
Contributor

Copilot AI commented Jan 27, 2026

@DanielRosenwasser I've opened a new pull request, #2588, to work on those changes. Once the pull request is ready, I'll request review from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Completions panic (nil pointer) in JSDoc union return type of method with params

3 participants