mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix extract type crash
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// import {Renderer} from '';
|
||||
////
|
||||
//// export class X {
|
||||
//// constructor(renderer: /**/[|Renderer|]) {}
|
||||
//// }
|
||||
|
||||
goTo.selectRange(test.ranges()[0]);
|
||||
verify.refactorAvailable("Extract type", "Extract to type alias");
|
||||
Reference in New Issue
Block a user