diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 1d59846a2a8..aa763fc48e3 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -44,6 +44,7 @@ import { isImportEqualsDeclaration, isImportTypeNode, isInJSFile, + isJSDocCallbackTag, isJSDocTypedefTag, isModuleExportsAccessExpression, isNamedExports, @@ -612,7 +613,7 @@ export function getImportOrExportSymbol(node: Node, symbol: Symbol, checker: Typ else if (isBinaryExpression(grandparent)) { return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } - else if (isJSDocTypedefTag(parent)) { + else if (isJSDocTypedefTag(parent) || isJSDocCallbackTag(parent)) { return exportInfo(symbol, ExportKind.Named); } } diff --git a/tests/baselines/reference/findAllRefs_importType_js.4.baseline.jsonc b/tests/baselines/reference/findAllRefs_importType_js.4.baseline.jsonc new file mode 100644 index 00000000000..7dfaaac1b66 --- /dev/null +++ b/tests/baselines/reference/findAllRefs_importType_js.4.baseline.jsonc @@ -0,0 +1,120 @@ +// === /a.js === +// /** +// * @callback /*FIND ALL REFS*/[|A|] +// * @param {unknown} response +// */ +// +// module.exports = {}; + +// === /b.js === +// /** @typedef {import("./a").[|A|]} A */ + +[ + { + "definition": { + "containerKind": "", + "containerName": "", + "fileName": "/a.js", + "kind": "type", + "name": "type A = (response: unknown) => any", + "textSpan": { + "start": 17, + "length": 1 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "response", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "unknown", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + } + ], + "contextSpan": { + "start": 7, + "length": 42 + } + }, + "references": [ + { + "textSpan": { + "start": 17, + "length": 1 + }, + "fileName": "/a.js", + "contextSpan": { + "start": 7, + "length": 42 + }, + "isWriteAccess": true, + "isDefinition": true + }, + { + "textSpan": { + "start": 28, + "length": 1 + }, + "fileName": "/b.js", + "isWriteAccess": false, + "isDefinition": false + } + ] + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefs_importType_js.4.ts b/tests/cases/fourslash/findAllRefs_importType_js.4.ts new file mode 100644 index 00000000000..6fe1643f85e --- /dev/null +++ b/tests/cases/fourslash/findAllRefs_importType_js.4.ts @@ -0,0 +1,18 @@ +/// + +// @module: commonjs +// @allowJs: true +// @checkJs: true + +// @Filename: /a.js +/////** +//// * @callback /**/A +//// * @param {unknown} response +//// */ +//// +////module.exports = {}; + +// @Filename: /b.js +/////** @typedef {import("./a").A} A */ + +verify.baselineFindAllReferences("");