mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
fix(47782): forbid super() extraction outside this container (#47784)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
6
tests/cases/fourslash/extractSuperOutsideClass.ts
Normal file
6
tests/cases/fourslash/extractSuperOutsideClass.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*a*/super()/*b*/
|
||||
|
||||
goTo.select("a", "b");
|
||||
verify.not.refactorAvailable("Extract Symbol");
|
||||
Reference in New Issue
Block a user