fix(47782): forbid super() extraction outside this container (#47784)

This commit is contained in:
Oleksandr T
2022-02-07 23:26:39 +02:00
committed by GitHub
parent 14feed97a0
commit afeacf41bd
2 changed files with 8 additions and 2 deletions

View File

@@ -486,8 +486,8 @@ namespace ts.refactor.extractSymbol {
// but a super *method call* simply implies a 'this' reference
if (node.parent.kind === SyntaxKind.CallExpression) {
// Super constructor call
const containingClass = getContainingClass(node)!; // TODO:GH#18217
if (containingClass.pos < span.start || containingClass.end >= (span.start + span.length)) {
const containingClass = getContainingClass(node);
if (containingClass === undefined || containingClass.pos < span.start || containingClass.end >= (span.start + span.length)) {
(errors ||= []).push(createDiagnosticForNode(node, Messages.cannotExtractSuper));
return true;
}

View File

@@ -0,0 +1,6 @@
/// <reference path='fourslash.ts' />
/////*a*/super()/*b*/
goTo.select("a", "b");
verify.not.refactorAvailable("Extract Symbol");