@typescript-deploys/pr-build 5.3.0-pr-55811-15 → 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/tsserver.js CHANGED
@@ -2328,7 +2328,7 @@ module.exports = __toCommonJS(server_exports);
2328
2328
 
2329
2329
  // src/compiler/corePublic.ts
2330
2330
  var versionMajorMinor = "5.3";
2331
- var version = `${versionMajorMinor}.0-insiders.20231023`;
2331
+ var version = `${versionMajorMinor}.0-insiders.20231024`;
2332
2332
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2333
2333
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2334
2334
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -22955,8 +22955,9 @@ function createNodeFactory(flags, baseFactory2) {
22955
22955
  ensureUseStrict,
22956
22956
  liftToBlock,
22957
22957
  mergeLexicalEnvironment,
22958
- updateModifiers,
22959
- updateModifierLike
22958
+ replaceModifiers,
22959
+ replaceDecoratorsAndModifiers,
22960
+ replacePropertyName
22960
22961
  };
22961
22962
  forEach(nodeFactoryPatchers, (fn) => fn(factory2));
22962
22963
  return factory2;
@@ -26464,7 +26465,7 @@ function createNodeFactory(flags, baseFactory2) {
26464
26465
  }
26465
26466
  return statements;
26466
26467
  }
26467
- function updateModifiers(node, modifiers) {
26468
+ function replaceModifiers(node, modifiers) {
26468
26469
  let modifierArray;
26469
26470
  if (typeof modifiers === "number") {
26470
26471
  modifierArray = createModifiersFromModifierFlags(modifiers);
@@ -26473,9 +26474,27 @@ function createNodeFactory(flags, baseFactory2) {
26473
26474
  }
26474
26475
  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) ? updatePropertyDeclaration2(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);
26475
26476
  }
26476
- function updateModifierLike(node, modifierArray) {
26477
+ function replaceDecoratorsAndModifiers(node, modifierArray) {
26477
26478
  return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(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);
26478
26479
  }
26480
+ function replacePropertyName(node, name) {
26481
+ switch (node.kind) {
26482
+ case 177 /* GetAccessor */:
26483
+ return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body);
26484
+ case 178 /* SetAccessor */:
26485
+ return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body);
26486
+ case 174 /* MethodDeclaration */:
26487
+ return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
26488
+ case 173 /* MethodSignature */:
26489
+ return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type);
26490
+ case 172 /* PropertyDeclaration */:
26491
+ return updatePropertyDeclaration2(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer);
26492
+ case 171 /* PropertySignature */:
26493
+ return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type);
26494
+ case 303 /* PropertyAssignment */:
26495
+ return updatePropertyAssignment(node, name, node.initializer);
26496
+ }
26497
+ }
26479
26498
  function asNodeArray(array) {
26480
26499
  return array ? createNodeArray(array) : void 0;
26481
26500
  }
@@ -54645,11 +54664,11 @@ function createTypeChecker(host) {
54645
54664
  }
54646
54665
  function addExportModifier(node) {
54647
54666
  const flags = (getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */;
54648
- return factory.updateModifiers(node, flags);
54667
+ return factory.replaceModifiers(node, flags);
54649
54668
  }
54650
54669
  function removeExportModifier(node) {
54651
54670
  const flags = getEffectiveModifierFlags(node) & ~1 /* Export */;
54652
- return factory.updateModifiers(node, flags);
54671
+ return factory.replaceModifiers(node, flags);
54653
54672
  }
54654
54673
  function visitSymbolTable(symbolTable2, suppressNewPrivateContext, propertyAsAlias) {
54655
54674
  if (!suppressNewPrivateContext) {
@@ -54890,7 +54909,7 @@ function createTypeChecker(host) {
54890
54909
  newModifierFlags |= 1024 /* Default */;
54891
54910
  }
54892
54911
  if (newModifierFlags) {
54893
- node = factory.updateModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
54912
+ node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node));
54894
54913
  }
54895
54914
  }
54896
54915
  results.push(node);
@@ -58763,18 +58782,6 @@ function createTypeChecker(host) {
58763
58782
  function replaceIndexedAccess(instantiable, type, replacement) {
58764
58783
  return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])]));
58765
58784
  }
58766
- function getLimitedConstraint(type) {
58767
- const constraint = getConstraintTypeFromMappedType(type.mappedType);
58768
- if (!(constraint.flags & 1048576 /* Union */ || constraint.flags & 2097152 /* Intersection */)) {
58769
- return;
58770
- }
58771
- const origin = constraint.flags & 1048576 /* Union */ ? constraint.origin : constraint;
58772
- if (!origin || !(origin.flags & 2097152 /* Intersection */)) {
58773
- return;
58774
- }
58775
- const limitedConstraint = getIntersectionType(origin.types.filter((t) => t !== type.constraintType));
58776
- return limitedConstraint !== neverType ? limitedConstraint : void 0;
58777
- }
58778
58785
  function resolveReverseMappedTypeMembers(type) {
58779
58786
  const indexInfo = getIndexInfoOfType(type.source, stringType);
58780
58787
  const modifiers = getMappedTypeModifiers(type.mappedType);
@@ -58782,14 +58789,7 @@ function createTypeChecker(host) {
58782
58789
  const optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
58783
58790
  const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : emptyArray;
58784
58791
  const members = createSymbolTable();
58785
- const limitedConstraint = getLimitedConstraint(type);
58786
58792
  for (const prop of getPropertiesOfType(type.source)) {
58787
- if (limitedConstraint) {
58788
- const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
58789
- if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
58790
- continue;
58791
- }
58792
- }
58793
58793
  const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
58794
58794
  const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
58795
58795
  inferredProp.declarations = prop.declarations;
@@ -58871,7 +58871,13 @@ function createTypeChecker(host) {
58871
58871
  const templateModifiers = getMappedTypeModifiers(type);
58872
58872
  const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
58873
58873
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
58874
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
58874
+ if (nameType && isTupleType(modifiersType)) {
58875
+ forEachType(getUnionType(getElementTypes(modifiersType).map((_, i) => getStringLiteralType("" + i))), addMemberForKeyType);
58876
+ } else if (isArrayType(modifiersType)) {
58877
+ addMemberForKeyType(numberType);
58878
+ } else {
58879
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
58880
+ }
58875
58881
  } else {
58876
58882
  forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
58877
58883
  }
@@ -60680,7 +60686,7 @@ function createTypeChecker(host) {
60680
60686
  if (constraint) {
60681
60687
  constraints = append(constraints, constraint);
60682
60688
  }
60683
- } else if (type.flags & 262144 /* TypeParameter */ && parent2.kind === 200 /* MappedType */ && node === parent2.type) {
60689
+ } else if (type.flags & 262144 /* TypeParameter */ && parent2.kind === 200 /* MappedType */ && (node === parent2.type || node === parent2.nameType)) {
60684
60690
  const mappedType = getTypeFromTypeNode(parent2);
60685
60691
  if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
60686
60692
  const typeParameter = getHomomorphicTypeVariable(mappedType);
@@ -68910,7 +68916,7 @@ function createTypeChecker(host) {
68910
68916
  }
68911
68917
  }
68912
68918
  function inferToMappedType(source, target, constraintType) {
68913
- if (constraintType.flags & 1048576 /* Union */ || constraintType.flags & 2097152 /* Intersection */) {
68919
+ if (constraintType.flags & 1048576 /* Union */) {
68914
68920
  let result = false;
68915
68921
  for (const type of constraintType.types) {
68916
68922
  result = inferToMappedType(source, target, type) || result;
@@ -102904,7 +102910,7 @@ function transformES2015(context) {
102904
102910
  hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts;
102905
102911
  }
102906
102912
  function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
102907
- return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
102913
+ return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
102908
102914
  }
102909
102915
  function isOrMayContainReturnCompletion(node) {
102910
102916
  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(
@@ -102914,7 +102920,7 @@ function transformES2015(context) {
102914
102920
  ) || isBlock(node));
102915
102921
  }
102916
102922
  function shouldVisitNode(node) {
102917
- return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node) || isIterationStatement(
102923
+ return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 || convertedLoopState !== void 0 || hierarchyFacts & 8192 /* ConstructorWithSuperCall */ && isOrMayContainReturnCompletion(node) || isIterationStatement(
102918
102924
  node,
102919
102925
  /*lookInLabeledStatements*/
102920
102926
  false
@@ -102947,7 +102953,7 @@ function transformES2015(context) {
102947
102953
  /*expressionResultIsUnused*/
102948
102954
  false
102949
102955
  );
102950
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
102956
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
102951
102957
  return result;
102952
102958
  }
102953
102959
  return visitorWorker(
@@ -102961,6 +102967,7 @@ function transformES2015(context) {
102961
102967
  function callExpressionVisitor(node) {
102962
102968
  if (node.kind === 108 /* SuperKeyword */) {
102963
102969
  return visitSuperKeyword(
102970
+ node,
102964
102971
  /*isExpressionOfCall*/
102965
102972
  true
102966
102973
  );
@@ -103070,6 +103077,7 @@ function transformES2015(context) {
103070
103077
  return visitSpreadElement(node);
103071
103078
  case 108 /* SuperKeyword */:
103072
103079
  return visitSuperKeyword(
103080
+ node,
103073
103081
  /*isExpressionOfCall*/
103074
103082
  false
103075
103083
  );
@@ -103139,7 +103147,10 @@ function transformES2015(context) {
103139
103147
  return updated;
103140
103148
  }
103141
103149
  function returnCapturedThis(node) {
103142
- return setOriginalNode(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node);
103150
+ return setOriginalNode(factory2.createReturnStatement(createCapturedThis()), node);
103151
+ }
103152
+ function createCapturedThis() {
103153
+ return factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */);
103143
103154
  }
103144
103155
  function visitReturnStatement(node) {
103145
103156
  if (convertedLoopState) {
@@ -103163,8 +103174,9 @@ function transformES2015(context) {
103163
103174
  return visitEachChild(node, visitor, context);
103164
103175
  }
103165
103176
  function visitThisKeyword(node) {
103177
+ hierarchyFacts |= 65536 /* LexicalThis */;
103166
103178
  if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
103167
- hierarchyFacts |= 65536 /* CapturedLexicalThis */;
103179
+ hierarchyFacts |= 131072 /* CapturedLexicalThis */;
103168
103180
  }
103169
103181
  if (convertedLoopState) {
103170
103182
  if (hierarchyFacts & 2 /* ArrowFunction */) {
@@ -103303,7 +103315,7 @@ function transformES2015(context) {
103303
103315
  void 0,
103304
103316
  /*dotDotDotToken*/
103305
103317
  void 0,
103306
- factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)
103318
+ createSyntheticSuper()
103307
103319
  )] : [],
103308
103320
  /*type*/
103309
103321
  void 0,
@@ -103393,7 +103405,7 @@ function transformES2015(context) {
103393
103405
  setEmitFlags(constructorFunction, 16 /* CapturesThis */);
103394
103406
  }
103395
103407
  statements.push(constructorFunction);
103396
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
103408
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
103397
103409
  convertedLoopState = savedConvertedLoopState;
103398
103410
  }
103399
103411
  function transformConstructorParameters(constructor, hasSynthesizedSuper) {
@@ -103417,103 +103429,35 @@ function transformES2015(context) {
103417
103429
  setEmitFlags(block, 3072 /* NoComments */);
103418
103430
  return block;
103419
103431
  }
103420
- function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) {
103421
- let mayReplaceThis = false;
103422
- const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1;
103423
- const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length;
103424
- if (isFirstStatement && superStatementIndex >= 0) {
103425
- let firstMaterialIndex = statementOffset;
103426
- while (isFirstStatement && firstMaterialIndex < superStatementIndex) {
103427
- const statement = constructor.body.statements[firstMaterialIndex];
103428
- if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement))
103429
- break;
103430
- firstMaterialIndex++;
103431
- }
103432
- isFirstStatement = superStatementIndex === firstMaterialIndex;
103433
- }
103434
- addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset));
103435
- const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0;
103436
- if (superStatement && isTryStatement(superStatement)) {
103437
- const tryBlockStatements = [];
103438
- mayReplaceThis = transformConstructorBodyWorker(
103439
- prologueOut,
103440
- tryBlockStatements,
103441
- superStatement.tryBlock.statements,
103442
- /*statementOffset*/
103443
- 0,
103444
- superPath,
103445
- superPathDepth + 1,
103446
- constructor,
103447
- isDerivedClass,
103448
- hasSynthesizedSuper,
103449
- isFirstStatement
103450
- );
103451
- const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements);
103452
- setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements);
103453
- statementsOut.push(factory2.updateTryStatement(
103454
- superStatement,
103455
- factory2.updateBlock(superStatement.tryBlock, tryBlockStatements),
103456
- visitNode(superStatement.catchClause, visitor, isCatchClause),
103457
- visitNode(superStatement.finallyBlock, visitor, isBlock)
103458
- ));
103459
- } else {
103460
- const superCall = superStatement && getSuperCallFromStatement(superStatement);
103461
- let superCallExpression;
103462
- if (hasSynthesizedSuper) {
103463
- superCallExpression = createDefaultSuperCallOrThis();
103464
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
103465
- } else if (superCall) {
103466
- superCallExpression = visitSuperCallInBody(superCall);
103467
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
103468
- }
103469
- if (isDerivedClass || superCallExpression) {
103470
- if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
103471
- const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression);
103472
- const returnStatement = factory2.createReturnStatement(superCallExpression);
103473
- setCommentRange(returnStatement, getCommentRange(superCall2));
103474
- setEmitFlags(superCall2, 3072 /* NoComments */);
103475
- statementsOut.push(returnStatement);
103476
- return false;
103477
- } else {
103478
- if (isFirstStatement) {
103479
- insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis());
103480
- } else {
103481
- insertCaptureThisForNode(prologueOut, constructor, createActualThis());
103482
- if (superCallExpression) {
103483
- addSuperThisCaptureThisForNode(statementsOut, superCallExpression);
103484
- }
103485
- }
103486
- mayReplaceThis = true;
103487
- }
103488
- } else {
103489
- insertCaptureThisForNodeIfNeeded(prologueOut, constructor);
103490
- }
103491
- }
103492
- if (superStatementIndex >= 0) {
103493
- addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1));
103494
- }
103495
- return mayReplaceThis;
103496
- }
103497
103432
  function isUninitializedVariableStatement(node) {
103498
103433
  return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer);
103499
103434
  }
103500
- function isUsingDeclarationStateVariableStatement(node) {
103501
- if (!isVariableStatement(node) || node.declarationList.declarations.length !== 1)
103502
- return false;
103503
- const varDecl = node.declarationList.declarations[0];
103504
- if (!isIdentifier(varDecl.name) || !varDecl.initializer)
103505
- return false;
103506
- const initializer = varDecl.initializer;
103507
- if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3)
103508
- return false;
103509
- const [stackProp, errorProp, hasErrorProp] = initializer.properties;
103510
- if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer))
103511
- return false;
103512
- if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression))
103513
- return false;
103514
- if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== 97 /* FalseKeyword */)
103435
+ function containsSuperCall(node) {
103436
+ if (isSuperCall(node)) {
103437
+ return true;
103438
+ }
103439
+ if (!(node.transformFlags & 134217728 /* ContainsLexicalSuper */)) {
103515
103440
  return false;
103516
- return true;
103441
+ }
103442
+ switch (node.kind) {
103443
+ case 219 /* ArrowFunction */:
103444
+ case 218 /* FunctionExpression */:
103445
+ case 262 /* FunctionDeclaration */:
103446
+ case 176 /* Constructor */:
103447
+ case 175 /* ClassStaticBlockDeclaration */:
103448
+ return false;
103449
+ case 177 /* GetAccessor */:
103450
+ case 178 /* SetAccessor */:
103451
+ case 174 /* MethodDeclaration */:
103452
+ case 172 /* PropertyDeclaration */: {
103453
+ const named = node;
103454
+ if (isComputedPropertyName(named.name)) {
103455
+ return !!forEachChild(named.name, containsSuperCall);
103456
+ }
103457
+ return false;
103458
+ }
103459
+ }
103460
+ return !!forEachChild(node, containsSuperCall);
103517
103461
  }
103518
103462
  function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
103519
103463
  const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */;
@@ -103528,31 +103472,22 @@ function transformES2015(context) {
103528
103472
  /*statementOffset*/
103529
103473
  0
103530
103474
  );
103531
- const superStatementIndices = findSuperStatementIndexPath(constructor.body.statements, standardPrologueEnd);
103532
- if (hasSynthesizedSuper || superStatementIndices.length > 0) {
103533
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
103475
+ if (hasSynthesizedSuper || containsSuperCall(constructor.body)) {
103476
+ hierarchyFacts |= 8192 /* ConstructorWithSuperCall */;
103534
103477
  }
103535
- const mayReplaceThis = transformConstructorBodyWorker(
103536
- prologue,
103537
- statements,
103538
- constructor.body.statements,
103539
- standardPrologueEnd,
103540
- superStatementIndices,
103541
- /*superPathDepth*/
103542
- 0,
103543
- constructor,
103544
- isDerivedClass,
103545
- hasSynthesizedSuper,
103546
- /*isFirstStatement*/
103547
- true
103548
- // NOTE: this will be recalculated inside of transformConstructorBodyWorker
103549
- );
103478
+ addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd));
103479
+ const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */;
103550
103480
  addDefaultValueAssignmentsIfNeeded2(prologue, constructor);
103551
103481
  addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
103552
103482
  insertCaptureNewTargetIfNeeded(prologue, constructor);
103483
+ if (mayReplaceThis) {
103484
+ insertCaptureThisForNode(prologue, constructor, createActualThis());
103485
+ } else {
103486
+ insertCaptureThisForNodeIfNeeded(prologue, constructor);
103487
+ }
103553
103488
  factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
103554
103489
  if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) {
103555
- statements.push(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
103490
+ statements.push(factory2.createReturnStatement(createCapturedThis()));
103556
103491
  }
103557
103492
  const body = factory2.createBlock(
103558
103493
  setTextRange(
@@ -103569,6 +103504,230 @@ function transformES2015(context) {
103569
103504
  true
103570
103505
  );
103571
103506
  setTextRange(body, constructor.body);
103507
+ return simplifyConstructor(body, constructor.body, hasSynthesizedSuper);
103508
+ }
103509
+ function isCapturedThis(node) {
103510
+ return isGeneratedIdentifier(node) && idText(node) === "_this";
103511
+ }
103512
+ function isSyntheticSuper(node) {
103513
+ return isGeneratedIdentifier(node) && idText(node) === "_super";
103514
+ }
103515
+ function isThisCapturingVariableStatement(node) {
103516
+ return isVariableStatement(node) && node.declarationList.declarations.length === 1 && isThisCapturingVariableDeclaration(node.declarationList.declarations[0]);
103517
+ }
103518
+ function isThisCapturingVariableDeclaration(node) {
103519
+ return isVariableDeclaration(node) && isCapturedThis(node.name) && !!node.initializer;
103520
+ }
103521
+ function isThisCapturingAssignment(node) {
103522
+ return isAssignmentExpression(
103523
+ node,
103524
+ /*excludeCompoundAssignment*/
103525
+ true
103526
+ ) && isCapturedThis(node.left);
103527
+ }
103528
+ function isTransformedSuperCall(node) {
103529
+ 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 */;
103530
+ }
103531
+ function isTransformedSuperCallWithFallback(node) {
103532
+ return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isTransformedSuperCall(node.left);
103533
+ }
103534
+ function isImplicitSuperCall(node) {
103535
+ 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";
103536
+ }
103537
+ function isImplicitSuperCallWithFallback(node) {
103538
+ return isBinaryExpression(node) && node.operatorToken.kind === 57 /* BarBarToken */ && node.right.kind === 110 /* ThisKeyword */ && isImplicitSuperCall(node.left);
103539
+ }
103540
+ function isThisCapturingTransformedSuperCallWithFallback(node) {
103541
+ return isThisCapturingAssignment(node) && isTransformedSuperCallWithFallback(node.right);
103542
+ }
103543
+ function isThisCapturingImplicitSuperCallWithFallback(node) {
103544
+ return isThisCapturingAssignment(node) && isImplicitSuperCallWithFallback(node.right);
103545
+ }
103546
+ function isTransformedSuperCallLike(node) {
103547
+ return isTransformedSuperCall(node) || isTransformedSuperCallWithFallback(node) || isThisCapturingTransformedSuperCallWithFallback(node) || isImplicitSuperCall(node) || isImplicitSuperCallWithFallback(node) || isThisCapturingImplicitSuperCallWithFallback(node);
103548
+ }
103549
+ function simplifyConstructorInlineSuperInThisCaptureVariable(body) {
103550
+ for (let i = 0; i < body.statements.length - 1; i++) {
103551
+ const statement = body.statements[i];
103552
+ if (!isThisCapturingVariableStatement(statement)) {
103553
+ continue;
103554
+ }
103555
+ const varDecl = statement.declarationList.declarations[0];
103556
+ if (varDecl.initializer.kind !== 110 /* ThisKeyword */) {
103557
+ continue;
103558
+ }
103559
+ const thisCaptureStatementIndex = i;
103560
+ let superCallIndex = i + 1;
103561
+ while (superCallIndex < body.statements.length) {
103562
+ const statement2 = body.statements[superCallIndex];
103563
+ if (isExpressionStatement(statement2)) {
103564
+ if (isTransformedSuperCallLike(skipOuterExpressions(statement2.expression))) {
103565
+ break;
103566
+ }
103567
+ }
103568
+ if (isUninitializedVariableStatement(statement2)) {
103569
+ superCallIndex++;
103570
+ continue;
103571
+ }
103572
+ return body;
103573
+ }
103574
+ const following = body.statements[superCallIndex];
103575
+ let expression = following.expression;
103576
+ if (isThisCapturingAssignment(expression)) {
103577
+ expression = expression.right;
103578
+ }
103579
+ const newVarDecl = factory2.updateVariableDeclaration(
103580
+ varDecl,
103581
+ varDecl.name,
103582
+ /*exclamationToken*/
103583
+ void 0,
103584
+ /*type*/
103585
+ void 0,
103586
+ expression
103587
+ );
103588
+ const newDeclList = factory2.updateVariableDeclarationList(statement.declarationList, [newVarDecl]);
103589
+ const newVarStatement = factory2.createVariableStatement(statement.modifiers, newDeclList);
103590
+ setOriginalNode(newVarStatement, following);
103591
+ setTextRange(newVarStatement, following);
103592
+ const newStatements = factory2.createNodeArray([
103593
+ ...body.statements.slice(0, thisCaptureStatementIndex),
103594
+ // copy statements preceding to `var _this`
103595
+ ...body.statements.slice(thisCaptureStatementIndex + 1, superCallIndex),
103596
+ // copy intervening temp variables
103597
+ newVarStatement,
103598
+ ...body.statements.slice(superCallIndex + 1)
103599
+ // copy statements following `super.call(this, ...)`
103600
+ ]);
103601
+ setTextRange(newStatements, body.statements);
103602
+ return factory2.updateBlock(body, newStatements);
103603
+ }
103604
+ return body;
103605
+ }
103606
+ function simplifyConstructorInlineSuperReturn(body, original) {
103607
+ for (const statement of original.statements) {
103608
+ if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
103609
+ return body;
103610
+ }
103611
+ }
103612
+ const canElideThisCapturingVariable = !(original.transformFlags & 16384 /* ContainsLexicalThis */) && !(hierarchyFacts & 65536 /* LexicalThis */) && !(hierarchyFacts & 131072 /* CapturedLexicalThis */);
103613
+ for (let i = body.statements.length - 1; i > 0; i--) {
103614
+ const statement = body.statements[i];
103615
+ if (isReturnStatement(statement) && statement.expression && isCapturedThis(statement.expression)) {
103616
+ const preceding = body.statements[i - 1];
103617
+ let expression;
103618
+ if (isExpressionStatement(preceding) && isThisCapturingTransformedSuperCallWithFallback(skipOuterExpressions(preceding.expression))) {
103619
+ expression = preceding.expression;
103620
+ } else if (canElideThisCapturingVariable && isThisCapturingVariableStatement(preceding)) {
103621
+ const varDecl = preceding.declarationList.declarations[0];
103622
+ if (isTransformedSuperCallLike(skipOuterExpressions(varDecl.initializer))) {
103623
+ expression = factory2.createAssignment(
103624
+ createCapturedThis(),
103625
+ varDecl.initializer
103626
+ );
103627
+ }
103628
+ }
103629
+ if (!expression) {
103630
+ break;
103631
+ }
103632
+ const newReturnStatement = factory2.createReturnStatement(expression);
103633
+ setOriginalNode(newReturnStatement, preceding);
103634
+ setTextRange(newReturnStatement, preceding);
103635
+ const newStatements = factory2.createNodeArray([
103636
+ ...body.statements.slice(0, i - 1),
103637
+ // copy all statements preceding `_super.call(this, ...)`
103638
+ newReturnStatement,
103639
+ ...body.statements.slice(i + 1)
103640
+ // copy all statements following `return _this;`
103641
+ ]);
103642
+ setTextRange(newStatements, body.statements);
103643
+ return factory2.updateBlock(body, newStatements);
103644
+ }
103645
+ }
103646
+ return body;
103647
+ }
103648
+ function elideUnusedThisCaptureWorker(node) {
103649
+ if (isThisCapturingVariableStatement(node)) {
103650
+ const varDecl = node.declarationList.declarations[0];
103651
+ if (varDecl.initializer.kind === 110 /* ThisKeyword */) {
103652
+ return void 0;
103653
+ }
103654
+ } else if (isThisCapturingAssignment(node)) {
103655
+ return factory2.createPartiallyEmittedExpression(node.right, node);
103656
+ }
103657
+ switch (node.kind) {
103658
+ case 219 /* ArrowFunction */:
103659
+ case 218 /* FunctionExpression */:
103660
+ case 262 /* FunctionDeclaration */:
103661
+ case 176 /* Constructor */:
103662
+ case 175 /* ClassStaticBlockDeclaration */:
103663
+ return node;
103664
+ case 177 /* GetAccessor */:
103665
+ case 178 /* SetAccessor */:
103666
+ case 174 /* MethodDeclaration */:
103667
+ case 172 /* PropertyDeclaration */: {
103668
+ const named = node;
103669
+ if (isComputedPropertyName(named.name)) {
103670
+ return factory2.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext));
103671
+ }
103672
+ return node;
103673
+ }
103674
+ }
103675
+ return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext);
103676
+ }
103677
+ function simplifyConstructorElideUnusedThisCapture(body, original) {
103678
+ if (original.transformFlags & 16384 /* ContainsLexicalThis */ || hierarchyFacts & 65536 /* LexicalThis */ || hierarchyFacts & 131072 /* CapturedLexicalThis */) {
103679
+ return body;
103680
+ }
103681
+ for (const statement of original.statements) {
103682
+ if (statement.transformFlags & 134217728 /* ContainsLexicalSuper */ && !getSuperCallFromStatement(statement)) {
103683
+ return body;
103684
+ }
103685
+ }
103686
+ return factory2.updateBlock(body, visitNodes2(body.statements, elideUnusedThisCaptureWorker, isStatement));
103687
+ }
103688
+ function injectSuperPresenceCheckWorker(node) {
103689
+ if (isTransformedSuperCall(node) && node.arguments.length === 2 && isIdentifier(node.arguments[1]) && idText(node.arguments[1]) === "arguments") {
103690
+ return factory2.createLogicalAnd(
103691
+ factory2.createStrictInequality(
103692
+ createSyntheticSuper(),
103693
+ factory2.createNull()
103694
+ ),
103695
+ node
103696
+ );
103697
+ }
103698
+ switch (node.kind) {
103699
+ case 219 /* ArrowFunction */:
103700
+ case 218 /* FunctionExpression */:
103701
+ case 262 /* FunctionDeclaration */:
103702
+ case 176 /* Constructor */:
103703
+ case 175 /* ClassStaticBlockDeclaration */:
103704
+ return node;
103705
+ case 177 /* GetAccessor */:
103706
+ case 178 /* SetAccessor */:
103707
+ case 174 /* MethodDeclaration */:
103708
+ case 172 /* PropertyDeclaration */: {
103709
+ const named = node;
103710
+ if (isComputedPropertyName(named.name)) {
103711
+ return factory2.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext));
103712
+ }
103713
+ return node;
103714
+ }
103715
+ }
103716
+ return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext);
103717
+ }
103718
+ function complicateConstructorInjectSuperPresenceCheck(body) {
103719
+ return factory2.updateBlock(body, visitNodes2(body.statements, injectSuperPresenceCheckWorker, isStatement));
103720
+ }
103721
+ function simplifyConstructor(body, original, hasSynthesizedSuper) {
103722
+ const inputBody = body;
103723
+ body = simplifyConstructorInlineSuperInThisCaptureVariable(body);
103724
+ body = simplifyConstructorInlineSuperReturn(body, original);
103725
+ if (body !== inputBody) {
103726
+ body = simplifyConstructorElideUnusedThisCapture(body, original);
103727
+ }
103728
+ if (hasSynthesizedSuper) {
103729
+ body = complicateConstructorInjectSuperPresenceCheck(body);
103730
+ }
103572
103731
  return body;
103573
103732
  }
103574
103733
  function isSufficientlyCoveredByReturnStatements(statement) {
@@ -103594,11 +103753,11 @@ function transformES2015(context) {
103594
103753
  return factory2.createLogicalOr(
103595
103754
  factory2.createLogicalAnd(
103596
103755
  factory2.createStrictInequality(
103597
- factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */),
103756
+ createSyntheticSuper(),
103598
103757
  factory2.createNull()
103599
103758
  ),
103600
103759
  factory2.createFunctionApplyCall(
103601
- factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */),
103760
+ createSyntheticSuper(),
103602
103761
  createActualThis(),
103603
103762
  factory2.createIdentifier("arguments")
103604
103763
  )
@@ -103853,24 +104012,12 @@ function transformES2015(context) {
103853
104012
  return true;
103854
104013
  }
103855
104014
  function insertCaptureThisForNodeIfNeeded(statements, node) {
103856
- if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
104015
+ if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
103857
104016
  insertCaptureThisForNode(statements, node, factory2.createThis());
103858
104017
  return true;
103859
104018
  }
103860
104019
  return false;
103861
104020
  }
103862
- function addSuperThisCaptureThisForNode(statements, superExpression) {
103863
- enableSubstitutionsForCapturedThis();
103864
- const assignSuperExpression = factory2.createExpressionStatement(
103865
- factory2.createBinaryExpression(
103866
- factory2.createThis(),
103867
- 64 /* EqualsToken */,
103868
- superExpression
103869
- )
103870
- );
103871
- statements.push(assignSuperExpression);
103872
- setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent);
103873
- }
103874
104021
  function insertCaptureThisForNode(statements, node, initializer) {
103875
104022
  enableSubstitutionsForCapturedThis();
103876
104023
  const captureThisStatement = factory2.createVariableStatement(
@@ -103878,7 +104025,7 @@ function transformES2015(context) {
103878
104025
  void 0,
103879
104026
  factory2.createVariableDeclarationList([
103880
104027
  factory2.createVariableDeclaration(
103881
- factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */),
104028
+ createCapturedThis(),
103882
104029
  /*exclamationToken*/
103883
104030
  void 0,
103884
104031
  /*type*/
@@ -104099,7 +104246,7 @@ function transformES2015(context) {
104099
104246
  }
104100
104247
  function visitArrowFunction(node) {
104101
104248
  if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
104102
- hierarchyFacts |= 65536 /* CapturedLexicalThis */;
104249
+ hierarchyFacts |= 131072 /* CapturedLexicalThis */;
104103
104250
  }
104104
104251
  const savedConvertedLoopState = convertedLoopState;
104105
104252
  convertedLoopState = void 0;
@@ -104132,7 +104279,7 @@ function transformES2015(context) {
104132
104279
  const parameters = visitParameterList(node.parameters, visitor, context);
104133
104280
  const body = transformFunctionBody2(node);
104134
104281
  const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
104135
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
104282
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
104136
104283
  convertedLoopState = savedConvertedLoopState;
104137
104284
  return factory2.updateFunctionExpression(
104138
104285
  node,
@@ -104155,7 +104302,7 @@ function transformES2015(context) {
104155
104302
  const parameters = visitParameterList(node.parameters, visitor, context);
104156
104303
  const body = transformFunctionBody2(node);
104157
104304
  const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
104158
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
104305
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
104159
104306
  convertedLoopState = savedConvertedLoopState;
104160
104307
  return factory2.updateFunctionDeclaration(
104161
104308
  node,
@@ -104179,7 +104326,7 @@ function transformES2015(context) {
104179
104326
  if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) {
104180
104327
  name = factory2.getGeneratedNameForNode(node);
104181
104328
  }
104182
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
104329
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
104183
104330
  convertedLoopState = savedConvertedLoopState;
104184
104331
  return setOriginalNode(
104185
104332
  setTextRange(
@@ -105588,7 +105735,7 @@ function transformES2015(context) {
105588
105735
  } else {
105589
105736
  updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body);
105590
105737
  }
105591
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
105738
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
105592
105739
  convertedLoopState = savedConvertedLoopState;
105593
105740
  return updated;
105594
105741
  }
@@ -105738,13 +105885,6 @@ function transformES2015(context) {
105738
105885
  )
105739
105886
  );
105740
105887
  }
105741
- function visitSuperCallInBody(node) {
105742
- return visitCallExpressionWithPotentialCapturedThisAssignment(
105743
- node,
105744
- /*assignToCapturedThis*/
105745
- false
105746
- );
105747
- }
105748
105888
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
105749
105889
  if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) {
105750
105890
  const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration);
@@ -105781,10 +105921,13 @@ function transformES2015(context) {
105781
105921
  resultingCall,
105782
105922
  createActualThis()
105783
105923
  );
105784
- resultingCall = assignToCapturedThis ? factory2.createAssignment(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) : initializer;
105924
+ resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer;
105785
105925
  }
105786
105926
  return setOriginalNode(resultingCall, node);
105787
105927
  }
105928
+ if (isSuperCall(node)) {
105929
+ hierarchyFacts |= 131072 /* CapturedLexicalThis */;
105930
+ }
105788
105931
  return visitEachChild(node, visitor, context);
105789
105932
  }
105790
105933
  function visitNewExpression(node) {
@@ -105911,8 +106054,15 @@ function transformES2015(context) {
105911
106054
  }
105912
106055
  return setTextRange(expression, node);
105913
106056
  }
105914
- function visitSuperKeyword(isExpressionOfCall) {
105915
- return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") : factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */);
106057
+ function createSyntheticSuper() {
106058
+ return factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */);
106059
+ }
106060
+ function visitSuperKeyword(node, isExpressionOfCall) {
106061
+ const expression = hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? factory2.createPropertyAccessExpression(setOriginalNode(createSyntheticSuper(), node), "prototype") : createSyntheticSuper();
106062
+ setOriginalNode(expression, node);
106063
+ setCommentRange(expression, node);
106064
+ setSourceMapRange(expression, node);
106065
+ return expression;
105916
106066
  }
105917
106067
  function visitMetaProperty(node) {
105918
106068
  if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") {
@@ -106018,7 +106168,7 @@ function transformES2015(context) {
106018
106168
  }
106019
106169
  function substituteThisKeyword(node) {
106020
106170
  if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) {
106021
- return setTextRange(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node);
106171
+ return setTextRange(createCapturedThis(), node);
106022
106172
  }
106023
106173
  return node;
106024
106174
  }
@@ -113116,7 +113266,7 @@ function transformDeclarations(context) {
113116
113266
  return statement;
113117
113267
  }
113118
113268
  const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
113119
- return factory2.updateModifiers(statement, modifiers);
113269
+ return factory2.replaceModifiers(statement, modifiers);
113120
113270
  }
113121
113271
  function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
113122
113272
  const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
@@ -113247,7 +113397,7 @@ function transformDeclarations(context) {
113247
113397
  return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl]));
113248
113398
  });
113249
113399
  if (!exportMappings.length) {
113250
- declarations = mapDefined(declarations, (declaration) => factory2.updateModifiers(declaration, 0 /* None */));
113400
+ declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */));
113251
113401
  } else {
113252
113402
  declarations.push(factory2.createExportDeclaration(
113253
113403
  /*modifiers*/
@@ -146922,7 +147072,7 @@ function makeChange2(changeTracker, sourceFile, insertionSite, fixedDeclarations
146922
147072
  }
146923
147073
  }
146924
147074
  fixedDeclarations == null ? void 0 : fixedDeclarations.add(getNodeId(insertionSite));
146925
- const cloneWithModifier = factory.updateModifiers(
147075
+ const cloneWithModifier = factory.replaceModifiers(
146926
147076
  getSynthesizedDeepClone(
146927
147077
  insertionSite,
146928
147078
  /*includeTrivia*/
@@ -157887,7 +158037,7 @@ function getEntryForMemberCompletion(host, program, options, preferences, name,
157887
158037
  if (!completionNodes.length) {
157888
158038
  modifiers = node.modifierFlagsCache | requiredModifiers;
157889
158039
  }
157890
- node = factory.updateModifiers(node, modifiers);
158040
+ node = factory.replaceModifiers(node, modifiers);
157891
158041
  completionNodes.push(node);
157892
158042
  },
157893
158043
  body,
@@ -157913,11 +158063,11 @@ function getEntryForMemberCompletion(host, program, options, preferences, name,
157913
158063
  modifiers &= ~4 /* Public */;
157914
158064
  }
157915
158065
  modifiers |= allowedAndPresent;
157916
- completionNodes = completionNodes.map((node) => factory.updateModifiers(node, modifiers));
158066
+ completionNodes = completionNodes.map((node) => factory.replaceModifiers(node, modifiers));
157917
158067
  if (presentDecorators == null ? void 0 : presentDecorators.length) {
157918
158068
  const lastNode = completionNodes[completionNodes.length - 1];
157919
158069
  if (canHaveDecorators(lastNode)) {
157920
- completionNodes[completionNodes.length - 1] = factory.updateModifierLike(lastNode, presentDecorators.concat(getModifiers(lastNode) || []));
158070
+ completionNodes[completionNodes.length - 1] = factory.replaceDecoratorsAndModifiers(lastNode, presentDecorators.concat(getModifiers(lastNode) || []));
157921
158071
  }
157922
158072
  }
157923
158073
  const format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;