Cherry-pick PR #47136 into release-4.5 (#47379)

Component commits:
e61702c7df Fix extract type crash

Co-authored-by: Andrew Branch <andrew@wheream.io>
This commit is contained in:
TypeScript Bot
2022-01-12 11:26:13 -08:00
committed by GitHub
co-authored by Andrew Branch
parent a5ebd5382b
commit 0854a93040
2 changed files with 12 additions and 2 deletions
+2 -2
View File
@@ -145,8 +145,8 @@ namespace ts.refactor {
if (isTypeReferenceNode(node)) {
if (isIdentifier(node.typeName)) {
const symbol = checker.resolveName(node.typeName.text, node.typeName, SymbolFlags.TypeParameter, /* excludeGlobals */ true);
if (symbol?.declarations) {
const declaration = cast(first(symbol.declarations), isTypeParameterDeclaration);
const declaration = tryCast(symbol?.declarations?.[0], isTypeParameterDeclaration);
if (declaration) {
if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) {
pushIfUnique(result, declaration);
}