mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-16 05:58:32 -06:00
Fix handling of default class
This commit is contained in:
parent
d8b359f67b
commit
6400d53394
@ -1801,7 +1801,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getAncestor(node: Node, kind: SyntaxKind): Node {
|
||||
export function getAncestor(node: Node | undefined, kind: SyntaxKind): Node {
|
||||
while (node) {
|
||||
if (node.kind === kind) {
|
||||
return node;
|
||||
|
||||
@ -8,10 +8,11 @@ namespace ts.codefix {
|
||||
const token = getTokenAtPosition(sourceFile, start);
|
||||
const checker = context.program.getTypeChecker();
|
||||
|
||||
if (!(token.kind === SyntaxKind.Identifier && isClassLike(token.parent))) {
|
||||
const classDecl = getAncestor(token, SyntaxKind.ClassDeclaration) as ClassDeclaration;
|
||||
if (!(classDecl && isClassLike(classDecl))) {
|
||||
return undefined;
|
||||
}
|
||||
const classDecl = <ClassDeclaration>token.parent;
|
||||
|
||||
const startPos: number = classDecl.members.pos;
|
||||
|
||||
const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDecl);
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// interface I { x: number; }
|
||||
////
|
||||
//// export default class implements I {[| |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
x: number;
|
||||
`);
|
||||
Loading…
x
Reference in New Issue
Block a user