Skip to content

Commit 8880946

Browse files
authored
Fixed a crash when trying to find references on NoSubstitutionTemplateLiteral with LiteralType parent (#59889)
1 parent 9f150e0 commit 8880946

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

src/compiler/utilities.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4227,7 +4227,9 @@ export function tryGetImportFromModuleSpecifier(node: StringLiteralLike): AnyVal
42274227
case SyntaxKind.CallExpression:
42284228
return isImportCall(node.parent) || isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false) ? node.parent as RequireOrImportCall : undefined;
42294229
case SyntaxKind.LiteralType:
4230-
Debug.assert(isStringLiteral(node));
4230+
if (!isStringLiteral(node)) {
4231+
break;
4232+
}
42314233
return tryCast(node.parent.parent, isImportTypeNode) as ValidImportTypeNode | undefined;
42324234
default:
42334235
return undefined;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// === findAllReferences ===
2+
// === /tests/cases/fourslash/findAllRefsNoSubstitutionTemplateLiteralNoCrash1.ts ===
3+
// type Test = `[|{| isInString: true |}T|]/*FIND ALL REFS*/`;
4+
5+
// === Definitions ===
6+
// === /tests/cases/fourslash/findAllRefsNoSubstitutionTemplateLiteralNoCrash1.ts ===
7+
// type Test = `[|T|]/*FIND ALL REFS*/`;
8+
9+
// === Details ===
10+
[
11+
{
12+
"containerKind": "",
13+
"containerName": "",
14+
"kind": "var",
15+
"name": "T",
16+
"displayParts": [
17+
{
18+
"text": "`T`",
19+
"kind": "stringLiteral"
20+
}
21+
]
22+
}
23+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//// type Test = `T/*1*/`;
4+
5+
verify.baselineFindAllReferences('1');

0 commit comments

Comments
 (0)