Skip to content

Commit e8a3f61

Browse files
committed
fix(61867): fix find-all-refs for constructors involving string literals
1 parent dd1e258 commit e8a3f61

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

src/services/findAllReferences.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,13 +1838,13 @@ export namespace Core {
18381838
case SyntaxKind.NoSubstitutionTemplateLiteral:
18391839
case SyntaxKind.StringLiteral: {
18401840
const str = node as StringLiteralLike;
1841-
return str.text.length === searchSymbolName.length && (
1841+
return (
18421842
isLiteralNameOfPropertyDeclarationOrIndexAccess(str) ||
18431843
isNameOfModuleDeclaration(node) ||
18441844
isExpressionOfExternalModuleImportEqualsDeclaration(node) ||
18451845
(isCallExpression(node.parent) && isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node) ||
18461846
isImportOrExportSpecifier(node.parent)
1847-
);
1847+
) && str.text.length === searchSymbolName.length;
18481848
}
18491849

18501850
case SyntaxKind.NumericLiteral:
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// === findAllReferences ===
2+
// === lib.d.ts ===
3+
// --- (line: --) skipped ---
4+
//
5+
// interface Object {
6+
// /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */
7+
// <|[|{| isWriteAccess: true |}constructor|]: Function;|>
8+
//
9+
// /** Returns a string representation of an object. */
10+
// toString(): string;
11+
// --- (line: --) skipped ---
12+
13+
// === /tests/cases/fourslash/findAllRefsConstructor.ts ===
14+
// class A {
15+
// 'constructor'() { }
16+
// }
17+
// const a = new A()
18+
// console.log(a.[|constructor|]/*FIND ALL REFS*/)
19+
20+
// === Definitions ===
21+
// === lib.d.ts ===
22+
// --- (line: --) skipped ---
23+
//
24+
// interface Object {
25+
// /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */
26+
// <|[|constructor|]: Function;|>
27+
//
28+
// /** Returns a string representation of an object. */
29+
// toString(): string;
30+
// --- (line: --) skipped ---
31+
32+
// === Details ===
33+
[
34+
{
35+
"containerKind": "",
36+
"containerName": "",
37+
"kind": "property",
38+
"name": "(property) Object.constructor: Function",
39+
"displayParts": [
40+
{
41+
"text": "(",
42+
"kind": "punctuation"
43+
},
44+
{
45+
"text": "property",
46+
"kind": "text"
47+
},
48+
{
49+
"text": ")",
50+
"kind": "punctuation"
51+
},
52+
{
53+
"text": " ",
54+
"kind": "space"
55+
},
56+
{
57+
"text": "Object",
58+
"kind": "localName"
59+
},
60+
{
61+
"text": ".",
62+
"kind": "punctuation"
63+
},
64+
{
65+
"text": "constructor",
66+
"kind": "propertyName"
67+
},
68+
{
69+
"text": ":",
70+
"kind": "punctuation"
71+
},
72+
{
73+
"text": " ",
74+
"kind": "space"
75+
},
76+
{
77+
"text": "Function",
78+
"kind": "localName"
79+
}
80+
]
81+
}
82+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path="fourslash.ts" />
2+
// @target: esnext
3+
4+
////class A {
5+
//// 'constructor'() { }
6+
////}
7+
////const a = new A()
8+
////console.log(a.constructor/**/)
9+
10+
verify.baselineFindAllReferences('');

0 commit comments

Comments
 (0)