Skip to content

Conversation

@andrewbranch
Copy link
Member

When looking for imports to resolve, we were hitting the cloned function inside the fake reparsed export, which says it has JSDoc attached, but isn’t actually the key into the JSDoc map because it’s the clone.

Copilot AI review requested due to automatic review settings October 15, 2025 23:08
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.

Pull Request Overview

This PR fixes a bug where the import resolver would incorrectly find nodes within synthetic/cloned functions created for JSExportAssignment and CommonJSExport nodes. These cloned nodes have JSDoc references but aren't valid keys in the JSDoc map, causing resolution failures.

  • Prevents traversal into JSExportAssignment and CommonJSExport nodes when searching for nodes at a position
  • Adds a regression test with nested JSDoc import types in a CommonJS export

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/ast/utilities.go Filters out JSExportAssignment and CommonJSExport nodes from position-based node search
testdata/tests/cases/compiler/nestedJSDocImportType.ts Adds test case for nested JSDoc import type within CommonJS module export

@andrewbranch andrewbranch requested a review from sandersn October 15, 2025 23:18
@andrewbranch andrewbranch added this pull request to the merge queue Oct 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 16, 2025
@andrewbranch andrewbranch added this pull request to the merge queue Oct 16, 2025
Merged via the queue into microsoft:main with commit 0f6b0a7 Oct 16, 2025
22 checks passed
@andrewbranch andrewbranch deleted the bug/nested-jsdoc-import-type branch October 16, 2025 18:17
@jakebailey
Copy link
Member

I missed this while I was gone, but I find this special casing strange; why is it that such a generic algorithm needs an exception for these two nodes and not other JSDoc related stuff? Shouldn't we make the map have both keys or something rather than checking everywhere?

GGomez99 pushed a commit to GGomez99/typescript-go that referenced this pull request Oct 21, 2025
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.

3 participants