Fixed a crash when trying to find references on NoSubstitutionTemplateLiteral with LiteralType parent (#59889)

This commit is contained in:
Mateusz Burzyński
2024-09-20 00:59:36 +02:00
committed by GitHub
parent 9f150e00df
commit 88809467e8
3 changed files with 31 additions and 1 deletions

View File

@@ -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;

View File

@@ -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"
}
]
}
]

View File

@@ -0,0 +1,5 @@
/// <reference path='fourslash.ts' />
//// type Test = `T/*1*/`;
verify.baselineFindAllReferences('1');