Skip to content

Commit afeacf4

Browse files
authored
fix(47782): forbid super() extraction outside this container (microsoft#47784)
1 parent 14feed9 commit afeacf4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/services/refactors/extractSymbol.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ namespace ts.refactor.extractSymbol {
486486
// but a super *method call* simply implies a 'this' reference
487487
if (node.parent.kind === SyntaxKind.CallExpression) {
488488
// Super constructor call
489-
const containingClass = getContainingClass(node)!; // TODO:GH#18217
490-
if (containingClass.pos < span.start || containingClass.end >= (span.start + span.length)) {
489+
const containingClass = getContainingClass(node);
490+
if (containingClass === undefined || containingClass.pos < span.start || containingClass.end >= (span.start + span.length)) {
491491
(errors ||= []).push(createDiagnosticForNode(node, Messages.cannotExtractSuper));
492492
return true;
493493
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
/////*a*/super()/*b*/
4+
5+
goTo.select("a", "b");
6+
verify.not.refactorAvailable("Extract Symbol");

0 commit comments

Comments
 (0)