Skip to content

Commit cecad27

Browse files
author
Andy
authored
findAllReferences: Treat a nested property in a jsdoc type literal as a definition (microsoft#23901)
* findAllReferences: Treat a nested property in a jsdoc type literal as a definition * Fix lint
1 parent 21a6a9a commit cecad27

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/compiler/utilities.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,8 +2102,14 @@ namespace ts {
21022102
if (isDeclaration(name.parent)) {
21032103
return name.parent.name === name;
21042104
}
2105-
const binExp = name.parent.parent;
2106-
return isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== SpecialPropertyAssignmentKind.None && getNameOfDeclaration(binExp) === name;
2105+
else if (isQualifiedName(name.parent)) {
2106+
const tag = name.parent.parent;
2107+
return isJSDocParameterTag(tag) && tag.name === name.parent;
2108+
}
2109+
else {
2110+
const binExp = name.parent.parent;
2111+
return isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== SpecialPropertyAssignmentKind.None && getNameOfDeclaration(binExp) === name;
2112+
}
21072113
default:
21082114
return false;
21092115
}

tests/cases/fourslash/findAllReferencesJsDocTypeLiteral.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
//// * @param {string} o.x - a thing, its ok
99
//// * @param {number} o.y - another thing
1010
//// * @param {Object} o.nested - very nested
11-
//// * @param {boolean} o.nested.[|great|] - much greatness
11+
//// * @param {boolean} o.nested.[|{| "isWriteAccess": true, "isDefinition": true |}great|] - much greatness
1212
//// * @param {number} o.nested.times - twice? probably!??
1313
//// */
1414
//// function f(o) { return o.nested.[|great|]; }
1515

16-
verify.rangesReferenceEachOther();
16+
verify.singleReferenceGroup("(property) great: boolean");

0 commit comments

Comments
 (0)