@@ -9421,8 +9421,8 @@ namespace ts {
94219421 let container = getSuperContainer(node, /*stopOnFunctions*/ true);
94229422 let needToCaptureLexicalThis = false;
94239423
9424+ // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
94249425 if (!isCallExpression) {
9425- // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
94269426 while (container && container.kind === SyntaxKind.ArrowFunction) {
94279427 container = getSuperContainer(container, /*stopOnFunctions*/ true);
94289428 needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
@@ -14439,6 +14439,7 @@ namespace ts {
1443914439 // constructors of derived classes must contain at least one super call somewhere in their function body.
1444014440 const containingClassDecl = <ClassDeclaration>node.parent;
1444114441 if (getClassExtendsHeritageClauseElement(containingClassDecl)) {
14442+ captureLexicalThis(node.parent, containingClassDecl);
1444214443 const classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
1444314444 const superCall = getSuperCallInConstructor(node);
1444414445 if (superCall) {
@@ -17713,9 +17714,11 @@ namespace ts {
1771317714 }
1771417715
1771517716 function checkGrammarModuleElementContext(node: Statement, errorMessage: DiagnosticMessage): boolean {
17716- if (node.parent.kind !== SyntaxKind.SourceFile && node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.ModuleDeclaration) {
17717- return grammarErrorOnFirstToken(node, errorMessage);
17717+ const isInAppropriateContext = node.parent.kind === SyntaxKind.SourceFile || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.ModuleDeclaration;
17718+ if (!isInAppropriateContext) {
17719+ grammarErrorOnFirstToken(node, errorMessage);
1771817720 }
17721+ return !isInAppropriateContext;
1771917722 }
1772017723
1772117724 function checkExportSpecifier(node: ExportSpecifier) {
@@ -17756,7 +17759,7 @@ namespace ts {
1775617759 checkExpressionCached(node.expression);
1775717760 }
1775817761
17759- checkExternalModuleExports(<SourceFile | ModuleDeclaration> container);
17762+ checkExternalModuleExports(container);
1776017763
1776117764 if (node.isExportEquals && !isInAmbientContext(node)) {
1776217765 if (modulekind === ModuleKind.ES6) {
0 commit comments