Skip to content

Commit af07584

Browse files
authored
fix(54580): Bad operation for find-all-references on import.meta when meta occurs in a comment (#54581)
1 parent eeed721 commit af07584

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/services/findAllReferences.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,10 @@ export namespace Core {
17251725
}
17261726

17271727
function getPossibleSymbolReferenceNodes(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): readonly Node[] {
1728-
return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(pos => getTouchingPropertyName(sourceFile, pos));
1728+
return mapDefined(getPossibleSymbolReferencePositions(sourceFile, symbolName, container), pos => {
1729+
const referenceLocation = getTouchingPropertyName(sourceFile, pos);
1730+
return referenceLocation === sourceFile ? undefined : referenceLocation;
1731+
});
17291732
}
17301733

17311734
function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): readonly number[] {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// === findAllReferences ===
2+
// === /tests/cases/fourslash/findAllReferencesImportMeta.ts ===
3+
// // Haha that's so meta!
4+
//
5+
// let x = import.[|meta|]/*FIND ALL REFS*/;
6+
7+
// === Definitions ===
8+
// === /tests/cases/fourslash/findAllReferencesImportMeta.ts ===
9+
// // Haha that's so meta!
10+
//
11+
// let x = import.[|meta|]/*FIND ALL REFS*/;
12+
13+
// === Details ===
14+
[
15+
{
16+
"containerKind": "",
17+
"containerName": "",
18+
"kind": "keyword",
19+
"displayParts": [
20+
{
21+
"kind": "keyword"
22+
}
23+
]
24+
}
25+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////// Haha that's so meta!
4+
////
5+
////let x = import.meta/**/;
6+
7+
verify.baselineFindAllReferences("");

0 commit comments

Comments
 (0)