mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
Component commits: e61702c7df Fix extract type crash Co-authored-by: Andrew Branch <andrew@wheream.io>
This commit is contained in:
parent
a5ebd5382b
commit
0854a93040
@ -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);
|
||||
}
|
||||
|
||||
10
tests/cases/fourslash/extractTypeUnresolvedAlias.ts
Normal file
10
tests/cases/fourslash/extractTypeUnresolvedAlias.ts
Normal file
@ -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");
|
||||
Loading…
x
Reference in New Issue
Block a user