typescript 4.6.0-dev.20220113 → 4.6.0-dev.20220117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.6";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220113";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220117";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  function tryGetNativeMap() {
@@ -5502,7 +5502,7 @@ var ts;
5502
5502
  Parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Parameter '{0}' cannot reference identifier '{1}' declared after it."),
5503
5503
  Duplicate_index_signature_for_type_0: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_index_signature_for_type_0_2374", "Duplicate index signature for type '{0}'."),
5504
5504
  Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2375, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2375", "Type '{0}' is not assignable to type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
5505
- A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."),
5505
+ A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_2376", "A 'super' call must be the first statement in the constructor to refer to 'super' or 'this' when a derived class contains initialized properties, parameter properties, or private identifiers."),
5506
5506
  Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."),
5507
5507
  A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."),
5508
5508
  Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2379, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_tr_2379", "Argument of type '{0}' is not assignable to parameter of type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
@@ -5525,6 +5525,7 @@ var ts;
5525
5525
  constructor_cannot_be_used_as_a_parameter_property_name: diag(2398, ts.DiagnosticCategory.Error, "constructor_cannot_be_used_as_a_parameter_property_name_2398", "'constructor' cannot be used as a parameter property name."),
5526
5526
  Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."),
5527
5527
  Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."),
5528
+ A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2401, ts.DiagnosticCategory.Error, "A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_in_2401", "A 'super' call must be a root-level statement within a constructor of a derived class that contains initialized properties, parameter properties, or private identifiers."),
5528
5529
  Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."),
5529
5530
  Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."),
5530
5531
  The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."),
@@ -11924,6 +11925,28 @@ var ts;
11924
11925
  }
11925
11926
  }
11926
11927
  ts.getThisContainer = getThisContainer;
11928
+ function isThisContainerOrFunctionBlock(node) {
11929
+ switch (node.kind) {
11930
+ case 213:
11931
+ case 255:
11932
+ case 212:
11933
+ case 166:
11934
+ return true;
11935
+ case 234:
11936
+ switch (node.parent.kind) {
11937
+ case 170:
11938
+ case 168:
11939
+ case 171:
11940
+ case 172:
11941
+ return true;
11942
+ default:
11943
+ return false;
11944
+ }
11945
+ default:
11946
+ return false;
11947
+ }
11948
+ }
11949
+ ts.isThisContainerOrFunctionBlock = isThisContainerOrFunctionBlock;
11927
11950
  function isInTopLevelContext(node) {
11928
11951
  if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
11929
11952
  node = node.parent;
@@ -20925,7 +20948,7 @@ var ts;
20925
20948
  return getExportName(node, allowComments, allowSourceMaps);
20926
20949
  }
20927
20950
  function copyPrologue(source, target, ensureUseStrict, visitor) {
20928
- var offset = copyStandardPrologue(source, target, ensureUseStrict);
20951
+ var offset = copyStandardPrologue(source, target, 0, ensureUseStrict);
20929
20952
  return copyCustomPrologue(source, target, offset, visitor);
20930
20953
  }
20931
20954
  function isUseStrictPrologue(node) {
@@ -20934,10 +20957,10 @@ var ts;
20934
20957
  function createUseStrictPrologue() {
20935
20958
  return ts.startOnNewLine(createExpressionStatement(createStringLiteral("use strict")));
20936
20959
  }
20937
- function copyStandardPrologue(source, target, ensureUseStrict) {
20960
+ function copyStandardPrologue(source, target, statementOffset, ensureUseStrict) {
20961
+ if (statementOffset === void 0) { statementOffset = 0; }
20938
20962
  ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
20939
20963
  var foundUseStrict = false;
20940
- var statementOffset = 0;
20941
20964
  var numStatements = source.length;
20942
20965
  while (statementOffset < numStatements) {
20943
20966
  var statement = source[statementOffset];
@@ -22087,7 +22110,7 @@ var ts;
22087
22110
  importName: "__createBinding",
22088
22111
  scoped: false,
22089
22112
  priority: 1,
22090
- text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n }) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n }));"
22113
+ text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n }) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n }));"
22091
22114
  };
22092
22115
  ts.setModuleDefaultHelper = {
22093
22116
  name: "typescript:commonjscreatevalue",
@@ -33509,7 +33532,7 @@ var ts;
33509
33532
  ? 1 : 0
33510
33533
  };
33511
33534
  }
33512
- if (ts.isImplicitGlob(spec)) {
33535
+ if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
33513
33536
  return {
33514
33537
  key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
33515
33538
  flags: 1
@@ -65808,25 +65831,29 @@ var ts;
65808
65831
  if (classExtendsNull) {
65809
65832
  error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
65810
65833
  }
65811
- var superCallShouldBeFirst = (ts.getEmitScriptTarget(compilerOptions) !== 99 || !useDefineForClassFields) &&
65834
+ var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 || !useDefineForClassFields) &&
65812
65835
  (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
65813
65836
  ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476); }));
65814
- if (superCallShouldBeFirst) {
65815
- var statements = node.body.statements;
65816
- var superCallStatement = void 0;
65817
- for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
65818
- var statement = statements_4[_i];
65819
- if (statement.kind === 237 && ts.isSuperCall(statement.expression)) {
65820
- superCallStatement = statement;
65821
- break;
65837
+ if (superCallShouldBeRootLevel) {
65838
+ if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
65839
+ error(superCall, ts.Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
65840
+ }
65841
+ else {
65842
+ var superCallStatement = void 0;
65843
+ for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
65844
+ var statement = _a[_i];
65845
+ if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
65846
+ superCallStatement = statement;
65847
+ break;
65848
+ }
65849
+ if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
65850
+ break;
65851
+ }
65822
65852
  }
65823
- if (!ts.isPrologueDirective(statement)) {
65824
- break;
65853
+ if (superCallStatement === undefined) {
65854
+ error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
65825
65855
  }
65826
65856
  }
65827
- if (!superCallStatement) {
65828
- error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
65829
- }
65830
65857
  }
65831
65858
  }
65832
65859
  else if (!classExtendsNull) {
@@ -65834,6 +65861,19 @@ var ts;
65834
65861
  }
65835
65862
  }
65836
65863
  }
65864
+ function superCallIsRootLevelInConstructor(superCall, body) {
65865
+ var superCallParent = ts.walkUpParenthesizedExpressions(superCall.parent);
65866
+ return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body;
65867
+ }
65868
+ function nodeImmediatelyReferencesSuperOrThis(node) {
65869
+ if (node.kind === 106 || node.kind === 108) {
65870
+ return true;
65871
+ }
65872
+ if (ts.isThisContainerOrFunctionBlock(node)) {
65873
+ return false;
65874
+ }
65875
+ return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
65876
+ }
65837
65877
  function checkAccessorDeclaration(node) {
65838
65878
  if (produceDiagnostics) {
65839
65879
  if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
@@ -74697,25 +74737,26 @@ var ts;
74697
74737
  }
74698
74738
  }
74699
74739
  ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
74700
- function addPrologueDirectivesAndInitialSuperCall(factory, ctor, result, visitor) {
74701
- if (ctor.body) {
74702
- var statements = ctor.body.statements;
74703
- var index = factory.copyPrologue(statements, result, false, visitor);
74704
- if (index === statements.length) {
74705
- return index;
74706
- }
74707
- var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
74708
- if (superIndex > -1) {
74709
- for (var i = index; i <= superIndex; i++) {
74710
- result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
74711
- }
74712
- return superIndex + 1;
74740
+ function getSuperCallFromStatement(statement) {
74741
+ if (!ts.isExpressionStatement(statement)) {
74742
+ return undefined;
74743
+ }
74744
+ var expression = ts.skipParentheses(statement.expression);
74745
+ return ts.isSuperCall(expression)
74746
+ ? expression
74747
+ : undefined;
74748
+ }
74749
+ ts.getSuperCallFromStatement = getSuperCallFromStatement;
74750
+ function findSuperStatementIndex(statements, indexAfterLastPrologueStatement) {
74751
+ for (var i = indexAfterLastPrologueStatement; i < statements.length; i += 1) {
74752
+ var statement = statements[i];
74753
+ if (getSuperCallFromStatement(statement)) {
74754
+ return i;
74713
74755
  }
74714
- return index;
74715
74756
  }
74716
- return 0;
74757
+ return -1;
74717
74758
  }
74718
- ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
74759
+ ts.findSuperStatementIndex = findSuperStatementIndex;
74719
74760
  function getProperties(node, requireInitializer, isStatic) {
74720
74761
  return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
74721
74762
  }
@@ -76156,11 +76197,20 @@ var ts;
76156
76197
  return ts.visitFunctionBody(body, visitor, context);
76157
76198
  }
76158
76199
  var statements = [];
76159
- var indexOfFirstStatement = 0;
76160
76200
  resumeLexicalEnvironment();
76161
- indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
76162
- ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
76163
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
76201
+ var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, false, visitor);
76202
+ var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
76203
+ if (superStatementIndex >= 0) {
76204
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
76205
+ }
76206
+ var parameterPropertyAssignments = ts.mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment);
76207
+ if (superStatementIndex >= 0) {
76208
+ ts.addRange(statements, parameterPropertyAssignments);
76209
+ }
76210
+ else {
76211
+ statements = ts.addRange(parameterPropertyAssignments, statements);
76212
+ }
76213
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
76164
76214
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
76165
76215
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), true);
76166
76216
  ts.setTextRange(block, body);
@@ -77542,6 +77592,7 @@ var ts;
77542
77592
  return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(factory.createConstructorDeclaration(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
77543
77593
  }
77544
77594
  function transformConstructorBody(node, constructor, isDerivedClass) {
77595
+ var _a;
77545
77596
  var properties = ts.getProperties(node, false, false);
77546
77597
  if (!useDefineForClassFields) {
77547
77598
  properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
@@ -77552,34 +77603,65 @@ var ts;
77552
77603
  return ts.visitFunctionBody(undefined, visitor, context);
77553
77604
  }
77554
77605
  resumeLexicalEnvironment();
77555
- var indexOfFirstStatement = 0;
77606
+ var needsSyntheticConstructor = !constructor && isDerivedClass;
77607
+ var indexOfFirstStatementAfterSuper = 0;
77608
+ var prologueStatementCount = 0;
77609
+ var superStatementIndex = -1;
77556
77610
  var statements = [];
77557
- if (!constructor && isDerivedClass) {
77558
- statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(), undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
77611
+ if ((_a = constructor === null || constructor === void 0 ? void 0 : constructor.body) === null || _a === void 0 ? void 0 : _a.statements) {
77612
+ prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, false, visitor);
77613
+ superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
77614
+ if (superStatementIndex >= 0) {
77615
+ indexOfFirstStatementAfterSuper = superStatementIndex + 1;
77616
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
77617
+ }
77559
77618
  }
77560
- if (constructor) {
77561
- indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
77619
+ if (needsSyntheticConstructor) {
77620
+ statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(), undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
77562
77621
  }
77622
+ var parameterPropertyDeclarationCount = 0;
77563
77623
  if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
77564
- var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
77565
- if (afterParameterProperties === -1) {
77566
- afterParameterProperties = constructor.body.statements.length;
77624
+ if (useDefineForClassFields) {
77625
+ statements = statements.filter(function (statement) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor); });
77567
77626
  }
77568
- if (afterParameterProperties > indexOfFirstStatement) {
77569
- if (!useDefineForClassFields) {
77570
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
77627
+ else {
77628
+ for (var _i = 0, _b = constructor.body.statements; _i < _b.length; _i++) {
77629
+ var statement = _b[_i];
77630
+ if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
77631
+ parameterPropertyDeclarationCount++;
77632
+ }
77633
+ }
77634
+ if (parameterPropertyDeclarationCount > 0) {
77635
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
77636
+ if (superStatementIndex >= 0) {
77637
+ ts.addRange(statements, parameterProperties);
77638
+ }
77639
+ else if (needsSyntheticConstructor) {
77640
+ statements = __spreadArray(__spreadArray([
77641
+ statements[0]
77642
+ ], parameterProperties, true), statements.slice(1), true);
77643
+ }
77644
+ else {
77645
+ statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
77646
+ }
77647
+ indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
77571
77648
  }
77572
- indexOfFirstStatement = afterParameterProperties;
77573
77649
  }
77574
77650
  }
77575
77651
  var receiver = factory.createThis();
77576
77652
  addMethodStatements(statements, privateMethodsAndAccessors, receiver);
77577
77653
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
77578
77654
  if (constructor) {
77579
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
77655
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
77580
77656
  }
77581
77657
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
77582
77658
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
77659
+ function visitBodyStatement(statement) {
77660
+ if (useDefineForClassFields && ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
77661
+ return undefined;
77662
+ }
77663
+ return visitor(statement);
77664
+ }
77583
77665
  }
77584
77666
  function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
77585
77667
  for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
@@ -80640,40 +80722,47 @@ var ts;
80640
80722
  var prologue = [];
80641
80723
  var statements = [];
80642
80724
  resumeLexicalEnvironment();
80643
- var statementOffset = 0;
80725
+ var existingPrologue = ts.takeWhile(constructor.body.statements, ts.isPrologueDirective);
80726
+ var _a = findSuperCallAndStatementIndex(constructor.body.statements, existingPrologue), superCall = _a.superCall, superStatementIndex = _a.superStatementIndex;
80727
+ var postSuperStatementsStart = superStatementIndex === -1 ? existingPrologue.length : superStatementIndex + 1;
80728
+ var statementOffset = postSuperStatementsStart;
80644
80729
  if (!hasSynthesizedSuper)
80645
- statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, false);
80646
- addDefaultValueAssignmentsIfNeeded(statements, constructor);
80647
- addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
80730
+ statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, statementOffset, false);
80648
80731
  if (!hasSynthesizedSuper)
80649
- statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
80732
+ statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor, undefined);
80650
80733
  var superCallExpression;
80651
80734
  if (hasSynthesizedSuper) {
80652
80735
  superCallExpression = createDefaultSuperCallOrThis();
80653
80736
  }
80654
- else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
80655
- var firstStatement = constructor.body.statements[statementOffset];
80656
- if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
80657
- superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
80658
- }
80737
+ else if (superCall) {
80738
+ superCallExpression = visitSuperCallInBody(superCall);
80659
80739
  }
80660
80740
  if (superCallExpression) {
80661
80741
  hierarchyFacts |= 8192;
80662
- statementOffset++;
80663
80742
  }
80743
+ addDefaultValueAssignmentsIfNeeded(prologue, constructor);
80744
+ addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
80664
80745
  ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset));
80665
80746
  factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
80666
80747
  insertCaptureNewTargetIfNeeded(prologue, constructor, false);
80667
- if (isDerivedClass) {
80668
- if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192)) {
80669
- var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
80748
+ if (isDerivedClass || superCallExpression) {
80749
+ if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192)) {
80750
+ var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
80670
80751
  var returnStatement = factory.createReturnStatement(superCallExpression);
80671
- ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
80672
- ts.setEmitFlags(superCall, 1536);
80752
+ ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1));
80753
+ ts.setEmitFlags(superCall_1, 1536);
80673
80754
  statements.push(returnStatement);
80674
80755
  }
80675
80756
  else {
80676
- insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
80757
+ if (superStatementIndex <= existingPrologue.length) {
80758
+ insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
80759
+ }
80760
+ else {
80761
+ insertCaptureThisForNode(prologue, constructor, createActualThis());
80762
+ if (superCallExpression) {
80763
+ insertSuperThisCaptureThisForNode(statements, superCallExpression);
80764
+ }
80765
+ }
80677
80766
  if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
80678
80767
  statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 | 32)));
80679
80768
  }
@@ -80682,9 +80771,23 @@ var ts;
80682
80771
  else {
80683
80772
  insertCaptureThisForNodeIfNeeded(prologue, constructor);
80684
80773
  }
80685
- var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), constructor.body.statements), true);
80686
- ts.setTextRange(block, constructor.body);
80687
- return block;
80774
+ var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)), constructor.body.statements), true);
80775
+ ts.setTextRange(body, constructor.body);
80776
+ return body;
80777
+ }
80778
+ function findSuperCallAndStatementIndex(originalBodyStatements, existingPrologue) {
80779
+ for (var i = existingPrologue.length; i < originalBodyStatements.length; i += 1) {
80780
+ var superCall = ts.getSuperCallFromStatement(originalBodyStatements[i]);
80781
+ if (superCall) {
80782
+ return {
80783
+ superCall: superCall,
80784
+ superStatementIndex: i,
80785
+ };
80786
+ }
80787
+ }
80788
+ return {
80789
+ superStatementIndex: -1,
80790
+ };
80688
80791
  }
80689
80792
  function isSufficientlyCoveredByReturnStatements(statement) {
80690
80793
  if (statement.kind === 246) {
@@ -80811,6 +80914,12 @@ var ts;
80811
80914
  }
80812
80915
  return false;
80813
80916
  }
80917
+ function insertSuperThisCaptureThisForNode(statements, superExpression) {
80918
+ enableSubstitutionsForCapturedThis();
80919
+ var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63, superExpression));
80920
+ ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression);
80921
+ ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent);
80922
+ }
80814
80923
  function insertCaptureThisForNode(statements, node, initializer) {
80815
80924
  enableSubstitutionsForCapturedThis();
80816
80925
  var captureThisStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
@@ -81020,7 +81129,7 @@ var ts;
81020
81129
  var statementOffset;
81021
81130
  resumeLexicalEnvironment();
81022
81131
  if (ts.isBlock(body)) {
81023
- statementOffset = factory.copyStandardPrologue(body.statements, prologue, false);
81132
+ statementOffset = factory.copyStandardPrologue(body.statements, prologue, 0, false);
81024
81133
  statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
81025
81134
  statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
81026
81135
  }
@@ -81937,7 +82046,7 @@ var ts;
81937
82046
  ts.addRange(statements, classStatements, 1);
81938
82047
  return factory.restoreOuterExpressions(node.expression, factory.restoreOuterExpressions(variable.initializer, factory.restoreOuterExpressions(aliasAssignment && aliasAssignment.right, factory.updateCallExpression(call, factory.restoreOuterExpressions(call.expression, factory.updateFunctionExpression(func, undefined, undefined, undefined, undefined, func.parameters, undefined, factory.updateBlock(func.body, statements))), undefined, call.arguments))));
81939
82048
  }
81940
- function visitImmediateSuperCallInBody(node) {
82049
+ function visitSuperCallInBody(node) {
81941
82050
  return visitCallExpressionWithPotentialCapturedThisAssignment(node, false);
81942
82051
  }
81943
82052
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {