@typescript-deploys/pr-build 5.3.0-pr-56161-5 → 5.3.0-pr-55774-4

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
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.3";
21
- var version = `${versionMajorMinor}.0-insiders.20231020`;
21
+ var version = `${versionMajorMinor}.0-insiders.20231024`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -18747,8 +18747,9 @@ function createNodeFactory(flags, baseFactory2) {
18747
18747
  ensureUseStrict,
18748
18748
  liftToBlock,
18749
18749
  mergeLexicalEnvironment,
18750
- updateModifiers,
18751
- updateModifierLike
18750
+ replaceModifiers,
18751
+ replaceDecoratorsAndModifiers,
18752
+ replacePropertyName
18752
18753
  };
18753
18754
  forEach(nodeFactoryPatchers, (fn) => fn(factory2));
18754
18755
  return factory2;
@@ -22256,7 +22257,7 @@ function createNodeFactory(flags, baseFactory2) {
22256
22257
  }
22257
22258
  return statements;
22258
22259
  }
22259
- function updateModifiers(node, modifiers) {
22260
+ function replaceModifiers(node, modifiers) {
22260
22261
  let modifierArray;
22261
22262
  if (typeof modifiers === "number") {
22262
22263
  modifierArray = createModifiersFromModifierFlags(modifiers);
@@ -22265,9 +22266,27 @@ function createNodeFactory(flags, baseFactory2) {
22265
22266
  }
22266
22267
  return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : isPropertyDeclaration(node) ? updatePropertyDeclaration(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isConstructorDeclaration(node) ? updateConstructorDeclaration(node, modifierArray, node.parameters, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isIndexSignatureDeclaration(node) ? updateIndexSignature(node, modifierArray, node.parameters, node.type) : isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : isFunctionDeclaration(node) ? updateFunctionDeclaration(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, modifierArray, node.name, node.typeParameters, node.type) : isEnumDeclaration(node) ? updateEnumDeclaration(node, modifierArray, node.name, node.members) : isModuleDeclaration(node) ? updateModuleDeclaration(node, modifierArray, node.name, node.body) : isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : isImportDeclaration(node) ? updateImportDeclaration(node, modifierArray, node.importClause, node.moduleSpecifier, node.attributes) : isExportAssignment(node) ? updateExportAssignment(node, modifierArray, node.expression) : isExportDeclaration(node) ? updateExportDeclaration(node, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.attributes) : Debug.assertNever(node);
22267
22268
  }
22268
- function updateModifierLike(node, modifierArray) {
22269
+ function replaceDecoratorsAndModifiers(node, modifierArray) {
22269
22270
  return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : Debug.assertNever(node);
22270
22271
  }
22272
+ function replacePropertyName(node, name) {
22273
+ switch (node.kind) {
22274
+ case 177 /* GetAccessor */:
22275
+ return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body);
22276
+ case 178 /* SetAccessor */:
22277
+ return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body);
22278
+ case 174 /* MethodDeclaration */:
22279
+ return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
22280
+ case 173 /* MethodSignature */:
22281
+ return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type);
22282
+ case 172 /* PropertyDeclaration */:
22283
+ return updatePropertyDeclaration(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer);
22284
+ case 171 /* PropertySignature */:
22285
+ return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type);
22286
+ case 303 /* PropertyAssignment */:
22287
+ return updatePropertyAssignment(node, name, node.initializer);
22288
+ }
22289
+ }
22271
22290
  function asNodeArray(array) {
22272
22291
  return array ? createNodeArray(array) : void 0;
22273
22292
  }
@@ -49933,11 +49952,11 @@ function createTypeChecker(host) {
49933
49952
  }
49934
49953
  function addExportModifier(node) {
49935
49954
  const flags = (getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */;
49936
- return factory.updateModifiers(node, flags);
49955
+ return factory.replaceModifiers(node, flags);
49937
49956
  }
49938
49957
  function removeExportModifier(node) {
49939
49958
  const flags = getEffectiveModifierFlags(node) & ~1 /* Export */;
49940
- return factory.updateModifiers(node, flags);
49959
+ return factory.replaceModifiers(node, flags);
49941
49960
  }
49942
49961
  function visitSymbolTable(symbolTable2, suppressNewPrivateContext, propertyAsAlias) {
49943
49962
  if (!suppressNewPrivateContext) {
@@ -50178,7 +50197,7 @@ function createTypeChecker(host) {
50178
50197
  newModifierFlags |= 1024 /* Default */;
50179
50198
  }
50180
50199
  if (newModifierFlags) {
50181
- node = factory.updateModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
50200
+ node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
50182
50201
  }
50183
50202
  }
50184
50203
  results.push(node);
@@ -54140,7 +54159,13 @@ function createTypeChecker(host) {
54140
54159
  const templateModifiers = getMappedTypeModifiers(type);
54141
54160
  const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
54142
54161
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
54143
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
54162
+ if (nameType && isTupleType(modifiersType)) {
54163
+ forEachType(getUnionType(getElementTypes(modifiersType).map((_, i) => getStringLiteralType("" + i))), addMemberForKeyType);
54164
+ } else if (isArrayType(modifiersType)) {
54165
+ addMemberForKeyType(numberType);
54166
+ } else {
54167
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
54168
+ }
54144
54169
  } else {
54145
54170
  forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
54146
54171
  }
@@ -55949,7 +55974,7 @@ function createTypeChecker(host) {
55949
55974
  if (constraint) {
55950
55975
  constraints = append(constraints, constraint);
55951
55976
  }
55952
- } else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 200 /* MappedType */ && node === parent.type) {
55977
+ } else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 200 /* MappedType */ && (node === parent.type || node === parent.nameType)) {
55953
55978
  const mappedType = getTypeFromTypeNode(parent);
55954
55979
  if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
55955
55980
  const typeParameter = getHomomorphicTypeVariable(mappedType);
@@ -62732,6 +62757,9 @@ function createTypeChecker(host) {
62732
62757
  }
62733
62758
  function isDeeplyNestedType(type, stack, depth, maxDepth = 3) {
62734
62759
  if (depth >= maxDepth) {
62760
+ if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
62761
+ type = getMappedTargetWithSymbol(type);
62762
+ }
62735
62763
  if (type.flags & 2097152 /* Intersection */) {
62736
62764
  return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth));
62737
62765
  }
@@ -62740,7 +62768,7 @@ function createTypeChecker(host) {
62740
62768
  let lastTypeId = 0;
62741
62769
  for (let i = 0; i < depth; i++) {
62742
62770
  const t = stack[i];
62743
- if (t.flags & 2097152 /* Intersection */ ? some(t.types, (u) => getRecursionIdentity(u) === identity2) : getRecursionIdentity(t) === identity2) {
62771
+ if (hasMatchingRecursionIdentity(t, identity2)) {
62744
62772
  if (t.id >= lastTypeId) {
62745
62773
  count++;
62746
62774
  if (count >= maxDepth) {
@@ -62753,18 +62781,29 @@ function createTypeChecker(host) {
62753
62781
  }
62754
62782
  return false;
62755
62783
  }
62784
+ function getMappedTargetWithSymbol(type) {
62785
+ let target;
62786
+ while ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && (target = getModifiersTypeFromMappedType(type)) && (target.symbol || target.flags & 2097152 /* Intersection */ && some(target.types, (t) => !!t.symbol))) {
62787
+ type = target;
62788
+ }
62789
+ return type;
62790
+ }
62791
+ function hasMatchingRecursionIdentity(type, identity2) {
62792
+ if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
62793
+ type = getMappedTargetWithSymbol(type);
62794
+ }
62795
+ if (type.flags & 2097152 /* Intersection */) {
62796
+ return some(type.types, (t) => hasMatchingRecursionIdentity(t, identity2));
62797
+ }
62798
+ return getRecursionIdentity(type) === identity2;
62799
+ }
62756
62800
  function getRecursionIdentity(type) {
62757
62801
  if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) {
62758
62802
  if (getObjectFlags(type) & 4 /* Reference */ && type.node) {
62759
62803
  return type.node;
62760
62804
  }
62761
- if (type.symbol) {
62762
- if (getObjectFlags(type) & 32 /* Mapped */) {
62763
- type = getMappedTargetWithSymbol(type);
62764
- }
62765
- if (!(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
62766
- return type.symbol;
62767
- }
62805
+ if (type.symbol && !(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
62806
+ return type.symbol;
62768
62807
  }
62769
62808
  if (isTupleType(type)) {
62770
62809
  return type.target;
@@ -62784,13 +62823,6 @@ function createTypeChecker(host) {
62784
62823
  }
62785
62824
  return type;
62786
62825
  }
62787
- function getMappedTargetWithSymbol(type) {
62788
- let target = type;
62789
- while ((getObjectFlags(target) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && isMappedTypeWithKeyofConstraintDeclaration(target)) {
62790
- target = getModifiersTypeFromMappedType(target);
62791
- }
62792
- return target.symbol ? target : type;
62793
- }
62794
62826
  function isPropertyIdenticalTo(sourceProp, targetProp) {
62795
62827
  return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
62796
62828
  }
@@ -79690,7 +79722,7 @@ function createTypeChecker(host) {
79690
79722
  error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
79691
79723
  } else {
79692
79724
  const text = getTextOfPropertyName(member.name);
79693
- if (isNumericLiteralName(text)) {
79725
+ if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
79694
79726
  error(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
79695
79727
  }
79696
79728
  }
@@ -97995,7 +98027,7 @@ function transformES2015(context) {
97995
98027
  hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts;
97996
98028
  }
97997
98029
  function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
97998
- return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
98030
+ return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
97999
98031
  }
98000
98032
  function isOrMayContainReturnCompletion(node) {
98001
98033
  return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ && (isReturnStatement(node) || isIfStatement(node) || isWithStatement(node) || isSwitchStatement(node) || isCaseBlock(node) || isCaseClause(node) || isDefaultClause(node) || isTryStatement(node) || isCatchClause(node) || isLabeledStatement(node) || isIterationStatement(
@@ -98005,7 +98037,7 @@ function transformES2015(context) {
98005
98037
  ) || isBlock(node));
98006
98038
  }
98007
98039
  function shouldVisitNode(node) {
98008
- return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node) || isIterationStatement(
98040
+ return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithSuperCall */ && isOrMayContainReturnCompletion(node) || isIterationStatement(
98009
98041
  node,
98010
98042
  /*lookInLabeledStatements*/
98011
98043
  false
@@ -98038,7 +98070,7 @@ function transformES2015(context) {
98038
98070
  /*expressionResultIsUnused*/
98039
98071
  false
98040
98072
  );
98041
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
98073
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
98042
98074
  return result;
98043
98075
  }
98044
98076
  return visitorWorker(
@@ -98052,6 +98084,7 @@ function transformES2015(context) {
98052
98084
  function callExpressionVisitor(node) {
98053
98085
  if (node.kind === 108 /* SuperKeyword */) {
98054
98086
  return visitSuperKeyword(
98087
+ node,
98055
98088
  /*isExpressionOfCall*/
98056
98089
  true
98057
98090
  );
@@ -98161,6 +98194,7 @@ function transformES2015(context) {
98161
98194
  return visitSpreadElement(node);
98162
98195
  case 108 /* SuperKeyword */:
98163
98196
  return visitSuperKeyword(
98197
+ node,
98164
98198
  /*isExpressionOfCall*/
98165
98199
  false
98166
98200
  );
@@ -98230,7 +98264,10 @@ function transformES2015(context) {
98230
98264
  return updated;
98231
98265
  }
98232
98266
  function returnCapturedThis(node) {
98233
- return setOriginalNode(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node);
98267
+ return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node);
98268
+ }
98269
+ function createCapturedThis() {
98270
+ return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */);
98234
98271
  }
98235
98272
  function visitReturnStatement(node) {
98236
98273
  if (convertedLoopState) {
@@ -98254,8 +98291,9 @@ function transformES2015(context) {
98254
98291
  return visitEachChild(node, visitor, context);
98255
98292
  }
98256
98293
  function visitThisKeyword(node) {
98294
+ hierarchyFacts |= 65536 /* LexicalThis */;
98257
98295
  if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
98258
- hierarchyFacts |= 65536 /* CapturedLexicalThis */;
98296
+ hierarchyFacts |= 131072 /* CapturedLexicalThis */;
98259
98297
  }
98260
98298
  if (convertedLoopState) {
98261
98299
  if (hierarchyFacts & 2 /* ArrowFunction */) {
@@ -98394,7 +98432,7 @@ function transformES2015(context) {
98394
98432
  void 0,
98395
98433
  /*dotDotDotToken*/
98396
98434
  void 0,
98397
- factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)
98435
+ createSyntheticSuper()
98398
98436
  )] : [],
98399
98437
  /*type*/
98400
98438
  void 0,
@@ -98484,7 +98522,7 @@ function transformES2015(context) {
98484
98522
  setEmitFlags(constructorFunction, 16 /* CapturesThis */);
98485
98523
  }
98486
98524
  statements.push(constructorFunction);
98487
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
98525
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
98488
98526
  convertedLoopState = savedConvertedLoopState;
98489
98527
  }
98490
98528
  function transformConstructorParameters(constructor, hasSynthesizedSuper) {
@@ -98508,103 +98546,35 @@ function transformES2015(context) {
98508
98546
  setEmitFlags(block, 3072 /* NoComments */);
98509
98547
  return block;
98510
98548
  }
98511
- function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) {
98512
- let mayReplaceThis = false;
98513
- const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1;
98514
- const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length;
98515
- if (isFirstStatement && superStatementIndex >= 0) {
98516
- let firstMaterialIndex = statementOffset;
98517
- while (isFirstStatement && firstMaterialIndex < superStatementIndex) {
98518
- const statement = constructor.body.statements[firstMaterialIndex];
98519
- if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement))
98520
- break;
98521
- firstMaterialIndex++;
98522
- }
98523
- isFirstStatement = superStatementIndex === firstMaterialIndex;
98524
- }
98525
- addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset));
98526
- const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0;
98527
- if (superStatement && isTryStatement(superStatement)) {
98528
- const tryBlockStatements = [];
98529
- mayReplaceThis = transformConstructorBodyWorker(
98530
- prologueOut,
98531
- tryBlockStatements,
98532
- superStatement.tryBlock.statements,
98533
- /*statementOffset*/
98534
- 0,
98535
- superPath,
98536
- superPathDepth + 1,
98537
- constructor,
98538
- isDerivedClass,
98539
- hasSynthesizedSuper,
98540
- isFirstStatement
98541
- );
98542
- const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements);
98543
- setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements);
98544
- statementsOut.push(factory2.updateTryStatement(
98545
- superStatement,
98546
- factory2.updateBlock(superStatement.tryBlock, tryBlockStatements),
98547
- visitNode(superStatement.catchClause, visitor, isCatchClause),
98548
- visitNode(superStatement.finallyBlock, visitor, isBlock)
98549
- ));
98550
- } else {
98551
- const superCall = superStatement && getSuperCallFromStatement(superStatement);
98552
- let superCallExpression;
98553
- if (hasSynthesizedSuper) {
98554
- superCallExpression = createDefaultSuperCallOrThis();
98555
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
98556
- } else if (superCall) {
98557
- superCallExpression = visitSuperCallInBody(superCall);
98558
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
98559
- }
98560
- if (isDerivedClass || superCallExpression) {
98561
- if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
98562
- const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression);
98563
- const returnStatement = factory2.createReturnStatement(superCallExpression);
98564
- setCommentRange(returnStatement, getCommentRange(superCall2));
98565
- setEmitFlags(superCall2, 3072 /* NoComments */);
98566
- statementsOut.push(returnStatement);
98567
- return false;
98568
- } else {
98569
- if (isFirstStatement) {
98570
- insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis());
98571
- } else {
98572
- insertCaptureThisForNode(prologueOut, constructor, createActualThis());
98573
- if (superCallExpression) {
98574
- addSuperThisCaptureThisForNode(statementsOut, superCallExpression);
98575
- }
98576
- }
98577
- mayReplaceThis = true;
98578
- }
98579
- } else {
98580
- insertCaptureThisForNodeIfNeeded(prologueOut, constructor);
98581
- }
98582
- }
98583
- if (superStatementIndex >= 0) {
98584
- addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1));
98585
- }
98586
- return mayReplaceThis;
98587
- }
98588
98549
  function isUninitializedVariableStatement(node) {
98589
98550
  return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer);
98590
98551
  }
98591
- function isUsingDeclarationStateVariableStatement(node) {
98592
- if (!isVariableStatement(node) || node.declarationList.declarations.length !== 1)
98593
- return false;
98594
- const varDecl = node.declarationList.declarations[0];
98595
- if (!isIdentifier(varDecl.name) || !varDecl.initializer)
98596
- return false;
98597
- const initializer = varDecl.initializer;
98598
- if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3)
98599
- return false;
98600
- const [stackProp, errorProp, hasErrorProp] = initializer.properties;
98601
- if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer))
98602
- return false;
98603
- if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression))
98604
- return false;
98605
- if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== 97 /* FalseKeyword */)
98552
+ function containsSuperCall(node) {
98553
+ if (isSuperCall(node)) {
98554
+ return true;
98555
+ }
98556
+ if (!(node.transformFlags & 134217728 /* ContainsLexicalSuper */)) {
98606
98557
  return false;
98607
- return true;
98558
+ }
98559
+ switch (node.kind) {
98560
+ case 219 /* ArrowFunction */:
98561
+ case 218 /* FunctionExpression */:
98562
+ case 262 /* FunctionDeclaration */:
98563
+ case 176 /* Constructor */:
98564
+ case 175 /* ClassStaticBlockDeclaration */:
98565
+ return false;
98566
+ case 177 /* GetAccessor */:
98567
+ case 178 /* SetAccessor */:
98568
+ case 174 /* MethodDeclaration */:
98569
+ case 172 /* PropertyDeclaration */: {
98570
+ const named = node;
98571
+ if (isComputedPropertyName(named.name)) {
98572
+ return !!forEachChild(named.name, containsSuperCall);
98573
+ }
98574
+ return false;
98575
+ }
98576
+ }
98577
+ return !!forEachChild(node, containsSuperCall);
98608
98578
  }
98609
98579
  function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
98610
98580
  const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */;
@@ -98619,31 +98589,22 @@ function transformES2015(context) {
98619
98589
  /*statementOffset*/
98620
98590
  0
98621
98591
  );
98622
- const superStatementIndices = findSuperStatementIndexPath(constructor.body.statements, standardPrologueEnd);
98623
- if (hasSynthesizedSuper || superStatementIndices.length > 0) {
98624
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
98592
+ if (hasSynthesizedSuper || containsSuperCall(constructor.body)) {
98593
+ hierarchyFacts |= 8192 /* ConstructorWithSuperCall */;
98625
98594
  }
98626
- const mayReplaceThis = transformConstructorBodyWorker(
98627
- prologue,
98628
- statements,
98629
- constructor.body.statements,
98630
- standardPrologueEnd,
98631
- superStatementIndices,
98632
- /*superPathDepth*/
98633
- 0,
98634
- constructor,
98635
- isDerivedClass,
98636
- hasSynthesizedSuper,
98637
- /*isFirstStatement*/
98638
- true
98639
- // NOTE: this will be recalculated inside of transformConstructorBodyWorker
98640
- );
98595
+ addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd));
98596
+ const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */;
98641
98597
  addDefaultValueAssignmentsIfNeeded2(prologue, constructor);
98642
98598
  addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
98643
98599
  insertCaptureNewTargetIfNeeded(prologue, constructor);
98600
+ if (mayReplaceThis) {
98601
+ insertCaptureThisForNode(prologue, constructor, createActualThis());
98602
+ } else {
98603
+ insertCaptureThisForNodeIfNeeded(prologue, constructor);
98604
+ }
98644
98605
  factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
98645
98606
  if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) {
98646
- statements.push(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
98607
+ statements.push(factory2.createReturnStatement(createCapturedThis()));
98647
98608
  }
98648
98609
  const body = factory2.createBlock(
98649
98610
  setTextRange(
@@ -98660,6 +98621,230 @@ function transformES2015(context) {
98660
98621
  true
98661
98622
  );
98662
98623
  setTextRange(body, constructor.body);
98624
+ return simplifyConstructor(body, constructor.body, hasSynthesizedSuper);
98625
+ }
98626
+ function isCapturedThis(node) {
98627
+ return isGeneratedIdentifier(node) && idText(node) === "_this";
98628
+ }
98629
+ function isSyntheticSuper(node) {
98630
+ return isGeneratedIdentifier(node) && idText(node) === "_super";
98631
+ }
98632
+ function isThisCapturingVariableStatement(node) {
98633
+ return isVariableStatement(node) && node.declarationList.declarations.length === 1 && isThisCapturingVariableDeclaration(node.declarationList.declarations[0]);
98634
+ }
98635
+ function isThisCapturingVariableDeclaration(node) {
98636
+ return isVariableDeclaration(node) && isCapturedThis(node.name) && !!node.initializer;
98637
+ }
98638
+ function isThisCapturingAssignment(node) {
98639
+ return isAssignmentExpression(
98640
+ node,
98641
+ /*excludeCompoundAssignment*/
98642
+ true
98643
+ ) && isCapturedThis(node.left);
98644
+ }
98645
+ function isTransformedSuperCall(node) {
98646
+ return isCallExpression(node) && isPropertyAccessExpression(node.expression) && isSyntheticSuper(node.expression.expression) && isIdentifier(node.expression.name) && (idText(node.expression.name) === "call" || idText(node.expression.name) === "apply") && node.arguments.length >= 1 && node.arguments[0].kind === 110 /* ThisKeyword */;
98647
+ }
98648
+ function isTransformedSuperCallWithFallback(node) {
98649
+ return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isTransformedSuperCall(node.left);
98650
+ }
98651
+ function isImplicitSuperCall(node) {
98652
+ return isBinaryExpression(node) && node.operatorToken.kind === 56 /* AmpersandAmpersandToken */ && isBinaryExpression(node.left) && node.left.operatorToken.kind === 38 /* ExclamationEqualsEqualsToken */ && isSyntheticSuper(node.left.left) && node.left.right.kind === 106 /* NullKeyword */ && isTransformedSuperCall(node.right) && idText(node.right.expression.name) === "apply";
98653
+ }
98654
+ function isImplicitSuperCallWithFallback(node) {
98655
+ return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isImplicitSuperCall(node.left);
98656
+ }
98657
+ function isThisCapturingTransformedSuperCallWithFallback(node) {
98658
+ return isThisCapturingAssignment(node) && isTransformedSuperCallWithFallback(node.right);
98659
+ }
98660
+ function isThisCapturingImplicitSuperCallWithFallback(node) {
98661
+ return isThisCapturingAssignment(node) && isImplicitSuperCallWithFallback(node.right);
98662
+ }
98663
+ function isTransformedSuperCallLike(node) {
98664
+ return isTransformedSuperCall(node) || isTransformedSuperCallWithFallback(node) || isThisCapturingTransformedSuperCallWithFallback(node) || isImplicitSuperCall(node) || isImplicitSuperCallWithFallback(node) || isThisCapturingImplicitSuperCallWithFallback(node);
98665
+ }
98666
+ function simplifyConstructorInlineSuperInThisCaptureVariable(body) {
98667
+ for (let i = 0; i < body.statements.length - 1; i++) {
98668
+ const statement = body.statements[i];
98669
+ if (!isThisCapturingVariableStatement(statement)) {
98670
+ continue;
98671
+ }
98672
+ const varDecl = statement.declarationList.declarations[0];
98673
+ if (varDecl.initializer.kind !== 110 /* ThisKeyword */) {
98674
+ continue;
98675
+ }
98676
+ const thisCaptureStatementIndex = i;
98677
+ let superCallIndex = i + 1;
98678
+ while (superCallIndex < body.statements.length) {
98679
+ const statement2 = body.statements[superCallIndex];
98680
+ if (isExpressionStatement(statement2)) {
98681
+ if (isTransformedSuperCallLike(skipOuterExpressions(statement2.expression))) {
98682
+ break;
98683
+ }
98684
+ }
98685
+ if (isUninitializedVariableStatement(statement2)) {
98686
+ superCallIndex++;
98687
+ continue;
98688
+ }
98689
+ return body;
98690
+ }
98691
+ const following = body.statements[superCallIndex];
98692
+ let expression = following.expression;
98693
+ if (isThisCapturingAssignment(expression)) {
98694
+ expression = expression.right;
98695
+ }
98696
+ const newVarDecl = factory2.updateVariableDeclaration(
98697
+ varDecl,
98698
+ varDecl.name,
98699
+ /*exclamationToken*/
98700
+ void 0,
98701
+ /*type*/
98702
+ void 0,
98703
+ expression
98704
+ );
98705
+ const newDeclList = factory2.updateVariableDeclarationList(statement.declarationList, [newVarDecl]);
98706
+ const newVarStatement = factory2.createVariableStatement(statement.modifiers, newDeclList);
98707
+ setOriginalNode(newVarStatement, following);
98708
+ setTextRange(newVarStatement, following);
98709
+ const newStatements = factory2.createNodeArray([
98710
+ ...body.statements.slice(0, thisCaptureStatementIndex),
98711
+ // copy statements preceding to `var _this`
98712
+ ...body.statements.slice(thisCaptureStatementIndex + 1, superCallIndex),
98713
+ // copy intervening temp variables
98714
+ newVarStatement,
98715
+ ...body.statements.slice(superCallIndex + 1)
98716
+ // copy statements following `super.call(this, ...)`
98717
+ ]);
98718
+ setTextRange(newStatements, body.statements);
98719
+ return factory2.updateBlock(body, newStatements);
98720
+ }
98721
+ return body;
98722
+ }
98723
+ function simplifyConstructorInlineSuperReturn(body, original) {
98724
+ for (const statement of original.statements) {
98725
+ if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
98726
+ return body;
98727
+ }
98728
+ }
98729
+ const canElideThisCapturingVariable = !(original.transformFlags & 16384 /* ContainsLexicalThis */) && !(hierarchyFacts & 65536 /* LexicalThis */) && !(hierarchyFacts & 131072 /* CapturedLexicalThis */);
98730
+ for (let i = body.statements.length - 1; i > 0; i--) {
98731
+ const statement = body.statements[i];
98732
+ if (isReturnStatement(statement) && statement.expression && isCapturedThis(statement.expression)) {
98733
+ const preceding = body.statements[i - 1];
98734
+ let expression;
98735
+ if (isExpressionStatement(preceding) && isThisCapturingTransformedSuperCallWithFallback(skipOuterExpressions(preceding.expression))) {
98736
+ expression = preceding.expression;
98737
+ } else if (canElideThisCapturingVariable && isThisCapturingVariableStatement(preceding)) {
98738
+ const varDecl = preceding.declarationList.declarations[0];
98739
+ if (isTransformedSuperCallLike(skipOuterExpressions(varDecl.initializer))) {
98740
+ expression = factory2.createAssignment(
98741
+ createCapturedThis(),
98742
+ varDecl.initializer
98743
+ );
98744
+ }
98745
+ }
98746
+ if (!expression) {
98747
+ break;
98748
+ }
98749
+ const newReturnStatement = factory2.createReturnStatement(expression);
98750
+ setOriginalNode(newReturnStatement, preceding);
98751
+ setTextRange(newReturnStatement, preceding);
98752
+ const newStatements = factory2.createNodeArray([
98753
+ ...body.statements.slice(0, i - 1),
98754
+ // copy all statements preceding `_super.call(this, ...)`
98755
+ newReturnStatement,
98756
+ ...body.statements.slice(i + 1)
98757
+ // copy all statements following `return _this;`
98758
+ ]);
98759
+ setTextRange(newStatements, body.statements);
98760
+ return factory2.updateBlock(body, newStatements);
98761
+ }
98762
+ }
98763
+ return body;
98764
+ }
98765
+ function elideUnusedThisCaptureWorker(node) {
98766
+ if (isThisCapturingVariableStatement(node)) {
98767
+ const varDecl = node.declarationList.declarations[0];
98768
+ if (varDecl.initializer.kind === 110 /* ThisKeyword */) {
98769
+ return void 0;
98770
+ }
98771
+ } else if (isThisCapturingAssignment(node)) {
98772
+ return factory2.createPartiallyEmittedExpression(node.right, node);
98773
+ }
98774
+ switch (node.kind) {
98775
+ case 219 /* ArrowFunction */:
98776
+ case 218 /* FunctionExpression */:
98777
+ case 262 /* FunctionDeclaration */:
98778
+ case 176 /* Constructor */:
98779
+ case 175 /* ClassStaticBlockDeclaration */:
98780
+ return node;
98781
+ case 177 /* GetAccessor */:
98782
+ case 178 /* SetAccessor */:
98783
+ case 174 /* MethodDeclaration */:
98784
+ case 172 /* PropertyDeclaration */: {
98785
+ const named = node;
98786
+ if (isComputedPropertyName(named.name)) {
98787
+ return factory2.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext));
98788
+ }
98789
+ return node;
98790
+ }
98791
+ }
98792
+ return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext);
98793
+ }
98794
+ function simplifyConstructorElideUnusedThisCapture(body, original) {
98795
+ if (original.transformFlags & 16384 /* ContainsLexicalThis */ || hierarchyFacts & 65536 /* LexicalThis */ || hierarchyFacts & 131072 /* CapturedLexicalThis */) {
98796
+ return body;
98797
+ }
98798
+ for (const statement of original.statements) {
98799
+ if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
98800
+ return body;
98801
+ }
98802
+ }
98803
+ return factory2.updateBlock(body, visitNodes2(body.statements, elideUnusedThisCaptureWorker, isStatement));
98804
+ }
98805
+ function injectSuperPresenceCheckWorker(node) {
98806
+ if (isTransformedSuperCall(node) && node.arguments.length === 2 && isIdentifier(node.arguments[1]) && idText(node.arguments[1]) === "arguments") {
98807
+ return factory2.createLogicalAnd(
98808
+ factory2.createStrictInequality(
98809
+ createSyntheticSuper(),
98810
+ factory2.createNull()
98811
+ ),
98812
+ node
98813
+ );
98814
+ }
98815
+ switch (node.kind) {
98816
+ case 219 /* ArrowFunction */:
98817
+ case 218 /* FunctionExpression */:
98818
+ case 262 /* FunctionDeclaration */:
98819
+ case 176 /* Constructor */:
98820
+ case 175 /* ClassStaticBlockDeclaration */:
98821
+ return node;
98822
+ case 177 /* GetAccessor */:
98823
+ case 178 /* SetAccessor */:
98824
+ case 174 /* MethodDeclaration */:
98825
+ case 172 /* PropertyDeclaration */: {
98826
+ const named = node;
98827
+ if (isComputedPropertyName(named.name)) {
98828
+ return factory2.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext));
98829
+ }
98830
+ return node;
98831
+ }
98832
+ }
98833
+ return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext);
98834
+ }
98835
+ function complicateConstructorInjectSuperPresenceCheck(body) {
98836
+ return factory2.updateBlock(body, visitNodes2(body.statements, injectSuperPresenceCheckWorker, isStatement));
98837
+ }
98838
+ function simplifyConstructor(body, original, hasSynthesizedSuper) {
98839
+ const inputBody = body;
98840
+ body = simplifyConstructorInlineSuperInThisCaptureVariable(body);
98841
+ body = simplifyConstructorInlineSuperReturn(body, original);
98842
+ if (body !== inputBody) {
98843
+ body = simplifyConstructorElideUnusedThisCapture(body, original);
98844
+ }
98845
+ if (hasSynthesizedSuper) {
98846
+ body = complicateConstructorInjectSuperPresenceCheck(body);
98847
+ }
98663
98848
  return body;
98664
98849
  }
98665
98850
  function isSufficientlyCoveredByReturnStatements(statement) {
@@ -98685,11 +98870,11 @@ function transformES2015(context) {
98685
98870
  return factory2.createLogicalOr(
98686
98871
  factory2.createLogicalAnd(
98687
98872
  factory2.createStrictInequality(
98688
- factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */),
98873
+ createSyntheticSuper(),
98689
98874
  factory2.createNull()
98690
98875
  ),
98691
98876
  factory2.createFunctionApplyCall(
98692
- factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */),
98877
+ createSyntheticSuper(),
98693
98878
  createActualThis(),
98694
98879
  factory2.createIdentifier("arguments")
98695
98880
  )
@@ -98944,24 +99129,12 @@ function transformES2015(context) {
98944
99129
  return true;
98945
99130
  }
98946
99131
  function insertCaptureThisForNodeIfNeeded(statements, node) {
98947
- if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
99132
+ if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
98948
99133
  insertCaptureThisForNode(statements, node, factory2.createThis());
98949
99134
  return true;
98950
99135
  }
98951
99136
  return false;
98952
99137
  }
98953
- function addSuperThisCaptureThisForNode(statements, superExpression) {
98954
- enableSubstitutionsForCapturedThis();
98955
- const assignSuperExpression = factory2.createExpressionStatement(
98956
- factory2.createBinaryExpression(
98957
- factory2.createThis(),
98958
- 64 /* EqualsToken */,
98959
- superExpression
98960
- )
98961
- );
98962
- statements.push(assignSuperExpression);
98963
- setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent);
98964
- }
98965
99138
  function insertCaptureThisForNode(statements, node, initializer) {
98966
99139
  enableSubstitutionsForCapturedThis();
98967
99140
  const captureThisStatement = factory2.createVariableStatement(
@@ -98969,7 +99142,7 @@ function transformES2015(context) {
98969
99142
  void 0,
98970
99143
  factory2.createVariableDeclarationList([
98971
99144
  factory2.createVariableDeclaration(
98972
- factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */),
99145
+ createCapturedThis(),
98973
99146
  /*exclamationToken*/
98974
99147
  void 0,
98975
99148
  /*type*/
@@ -99190,7 +99363,7 @@ function transformES2015(context) {
99190
99363
  }
99191
99364
  function visitArrowFunction(node) {
99192
99365
  if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
99193
- hierarchyFacts |= 65536 /* CapturedLexicalThis */;
99366
+ hierarchyFacts |= 131072 /* CapturedLexicalThis */;
99194
99367
  }
99195
99368
  const savedConvertedLoopState = convertedLoopState;
99196
99369
  convertedLoopState = void 0;
@@ -99223,7 +99396,7 @@ function transformES2015(context) {
99223
99396
  const parameters = visitParameterList(node.parameters, visitor, context);
99224
99397
  const body = transformFunctionBody(node);
99225
99398
  const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
99226
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
99399
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
99227
99400
  convertedLoopState = savedConvertedLoopState;
99228
99401
  return factory2.updateFunctionExpression(
99229
99402
  node,
@@ -99246,7 +99419,7 @@ function transformES2015(context) {
99246
99419
  const parameters = visitParameterList(node.parameters, visitor, context);
99247
99420
  const body = transformFunctionBody(node);
99248
99421
  const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
99249
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
99422
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
99250
99423
  convertedLoopState = savedConvertedLoopState;
99251
99424
  return factory2.updateFunctionDeclaration(
99252
99425
  node,
@@ -99270,7 +99443,7 @@ function transformES2015(context) {
99270
99443
  if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) {
99271
99444
  name = factory2.getGeneratedNameForNode(node);
99272
99445
  }
99273
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
99446
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
99274
99447
  convertedLoopState = savedConvertedLoopState;
99275
99448
  return setOriginalNode(
99276
99449
  setTextRange(
@@ -100679,7 +100852,7 @@ function transformES2015(context) {
100679
100852
  } else {
100680
100853
  updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body);
100681
100854
  }
100682
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
100855
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
100683
100856
  convertedLoopState = savedConvertedLoopState;
100684
100857
  return updated;
100685
100858
  }
@@ -100829,13 +101002,6 @@ function transformES2015(context) {
100829
101002
  )
100830
101003
  );
100831
101004
  }
100832
- function visitSuperCallInBody(node) {
100833
- return visitCallExpressionWithPotentialCapturedThisAssignment(
100834
- node,
100835
- /*assignToCapturedThis*/
100836
- false
100837
- );
100838
- }
100839
101005
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
100840
101006
  if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) {
100841
101007
  const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration);
@@ -100872,10 +101038,13 @@ function transformES2015(context) {
100872
101038
  resultingCall,
100873
101039
  createActualThis()
100874
101040
  );
100875
- resultingCall = assignToCapturedThis ? factory2.createAssignment(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) : initializer;
101041
+ resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer;
100876
101042
  }
100877
101043
  return setOriginalNode(resultingCall, node);
100878
101044
  }
101045
+ if (isSuperCall(node)) {
101046
+ hierarchyFacts |= 131072 /* CapturedLexicalThis */;
101047
+ }
100879
101048
  return visitEachChild(node, visitor, context);
100880
101049
  }
100881
101050
  function visitNewExpression(node) {
@@ -101002,8 +101171,15 @@ function transformES2015(context) {
101002
101171
  }
101003
101172
  return setTextRange(expression, node);
101004
101173
  }
101005
- function visitSuperKeyword(isExpressionOfCall) {
101006
- return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") : factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */);
101174
+ function createSyntheticSuper() {
101175
+ return factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */);
101176
+ }
101177
+ function visitSuperKeyword(node, isExpressionOfCall) {
101178
+ const expression = hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(setOriginalNode(createSyntheticSuper(), node), "prototype") : createSyntheticSuper();
101179
+ setOriginalNode(expression, node);
101180
+ setCommentRange(expression, node);
101181
+ setSourceMapRange(expression, node);
101182
+ return expression;
101007
101183
  }
101008
101184
  function visitMetaProperty(node) {
101009
101185
  if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") {
@@ -101109,7 +101285,7 @@ function transformES2015(context) {
101109
101285
  }
101110
101286
  function substituteThisKeyword(node) {
101111
101287
  if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) {
101112
- return setTextRange(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node);
101288
+ return setTextRange(createCapturedThis(), node);
101113
101289
  }
101114
101290
  return node;
101115
101291
  }
@@ -108207,7 +108383,7 @@ function transformDeclarations(context) {
108207
108383
  return statement;
108208
108384
  }
108209
108385
  const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
108210
- return factory2.updateModifiers(statement, modifiers);
108386
+ return factory2.replaceModifiers(statement, modifiers);
108211
108387
  }
108212
108388
  function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
108213
108389
  const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
@@ -108338,7 +108514,7 @@ function transformDeclarations(context) {
108338
108514
  return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl]));
108339
108515
  });
108340
108516
  if (!exportMappings.length) {
108341
- declarations = mapDefined(declarations, (declaration) => factory2.updateModifiers(declaration, 0 /* None */));
108517
+ declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */));
108342
108518
  } else {
108343
108519
  declarations.push(factory2.createExportDeclaration(
108344
108520
  /*modifiers*/