Skip to content

Commit

Permalink
Fixed a crash when trying to find references on `NoSubstitutionTempla…
Browse files Browse the repository at this point in the history
…teLiteral` with `LiteralType` parent (#59889)
  • Loading branch information
Andarist authored Sep 19, 2024
1 parent 9f150e0 commit 8880946
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4227,7 +4227,9 @@ export function tryGetImportFromModuleSpecifier(node: StringLiteralLike): AnyVal
case SyntaxKind.CallExpression:
return isImportCall(node.parent) || isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false) ? node.parent as RequireOrImportCall : undefined;
case SyntaxKind.LiteralType:
Debug.assert(isStringLiteral(node));
if (!isStringLiteral(node)) {
break;
}
return tryCast(node.parent.parent, isImportTypeNode) as ValidImportTypeNode | undefined;
default:
return undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// === findAllReferences ===
// === /tests/cases/fourslash/findAllRefsNoSubstitutionTemplateLiteralNoCrash1.ts ===
// type Test = `[|{| isInString: true |}T|]/*FIND ALL REFS*/`;

// === Definitions ===
// === /tests/cases/fourslash/findAllRefsNoSubstitutionTemplateLiteralNoCrash1.ts ===
// type Test = `[|T|]/*FIND ALL REFS*/`;

// === Details ===
[
{
"containerKind": "",
"containerName": "",
"kind": "var",
"name": "T",
"displayParts": [
{
"text": "`T`",
"kind": "stringLiteral"
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference path='fourslash.ts' />

//// type Test = `T/*1*/`;

verify.baselineFindAllReferences('1');

0 comments on commit 8880946

Please sign in to comment.