From 5bd74bd288256a35016c8af1867efc8b0705056a Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 15 Oct 2025 16:03:54 -0700 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20look=20in=20JSExportAssignment?= =?UTF-8?q?=20and=20CommonJSExport=20for=20nodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/ast/utilities.go | 2 +- .../tests/cases/compiler/nestedJSDocImportType.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 testdata/tests/cases/compiler/nestedJSDocImportType.ts diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index 1793bc63ef..f491127d22 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -2641,7 +2641,7 @@ func GetNodeAtPosition(file *SourceFile, position int, includeJSDoc bool) *Node } if child == nil { current.ForEachChild(func(node *Node) bool { - if nodeContainsPosition(node, position) { + if nodeContainsPosition(node, position) && node.Kind != KindJSExportAssignment && node.Kind != KindCommonJSExport { child = node return true } diff --git a/testdata/tests/cases/compiler/nestedJSDocImportType.ts b/testdata/tests/cases/compiler/nestedJSDocImportType.ts new file mode 100644 index 0000000000..8569089738 --- /dev/null +++ b/testdata/tests/cases/compiler/nestedJSDocImportType.ts @@ -0,0 +1,15 @@ +// @checkJs: true +// @noEmit: true +// @noTypesAndSymbols: true + +// @Filename: a.js +/** @typedef {string} A */ + +// @Filename: b.js +module.exports = { + create() { + /** @param {import("./a").A} x */ + function f(x) {} + return f("hi"); + } +} \ No newline at end of file