mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
fix(51716): find all references in imported JSDoc types (#51729)
This commit is contained in:
parent
cf68a12d69
commit
6f4d340458
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
18
tests/cases/fourslash/findAllRefs_importType_js.4.ts
Normal file
18
tests/cases/fourslash/findAllRefs_importType_js.4.ts
Normal file
@ -0,0 +1,18 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @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("");
|
||||
Loading…
x
Reference in New Issue
Block a user