@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/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.20231020`;
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);
@@ -58852,7 +58871,13 @@ function createTypeChecker(host) {
58852
58871
  const templateModifiers = getMappedTypeModifiers(type);
58853
58872
  const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
58854
58873
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
58855
- 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
+ }
58856
58881
  } else {
58857
58882
  forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
58858
58883
  }
@@ -60661,7 +60686,7 @@ function createTypeChecker(host) {
60661
60686
  if (constraint) {
60662
60687
  constraints = append(constraints, constraint);
60663
60688
  }
60664
- } 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)) {
60665
60690
  const mappedType = getTypeFromTypeNode(parent2);
60666
60691
  if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
60667
60692
  const typeParameter = getHomomorphicTypeVariable(mappedType);
@@ -67444,6 +67469,9 @@ function createTypeChecker(host) {
67444
67469
  }
67445
67470
  function isDeeplyNestedType(type, stack, depth, maxDepth = 3) {
67446
67471
  if (depth >= maxDepth) {
67472
+ if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
67473
+ type = getMappedTargetWithSymbol(type);
67474
+ }
67447
67475
  if (type.flags & 2097152 /* Intersection */) {
67448
67476
  return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth));
67449
67477
  }
@@ -67452,7 +67480,7 @@ function createTypeChecker(host) {
67452
67480
  let lastTypeId = 0;
67453
67481
  for (let i = 0; i < depth; i++) {
67454
67482
  const t = stack[i];
67455
- if (t.flags & 2097152 /* Intersection */ ? some(t.types, (u) => getRecursionIdentity(u) === identity2) : getRecursionIdentity(t) === identity2) {
67483
+ if (hasMatchingRecursionIdentity(t, identity2)) {
67456
67484
  if (t.id >= lastTypeId) {
67457
67485
  count++;
67458
67486
  if (count >= maxDepth) {
@@ -67465,18 +67493,29 @@ function createTypeChecker(host) {
67465
67493
  }
67466
67494
  return false;
67467
67495
  }
67496
+ function getMappedTargetWithSymbol(type) {
67497
+ let target;
67498
+ while ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && (target = getModifiersTypeFromMappedType(type)) && (target.symbol || target.flags & 2097152 /* Intersection */ && some(target.types, (t) => !!t.symbol))) {
67499
+ type = target;
67500
+ }
67501
+ return type;
67502
+ }
67503
+ function hasMatchingRecursionIdentity(type, identity2) {
67504
+ if ((getObjectFlags(type) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */) {
67505
+ type = getMappedTargetWithSymbol(type);
67506
+ }
67507
+ if (type.flags & 2097152 /* Intersection */) {
67508
+ return some(type.types, (t) => hasMatchingRecursionIdentity(t, identity2));
67509
+ }
67510
+ return getRecursionIdentity(type) === identity2;
67511
+ }
67468
67512
  function getRecursionIdentity(type) {
67469
67513
  if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) {
67470
67514
  if (getObjectFlags(type) & 4 /* Reference */ && type.node) {
67471
67515
  return type.node;
67472
67516
  }
67473
- if (type.symbol) {
67474
- if (getObjectFlags(type) & 32 /* Mapped */) {
67475
- type = getMappedTargetWithSymbol(type);
67476
- }
67477
- if (!(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
67478
- return type.symbol;
67479
- }
67517
+ if (type.symbol && !(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
67518
+ return type.symbol;
67480
67519
  }
67481
67520
  if (isTupleType(type)) {
67482
67521
  return type.target;
@@ -67496,13 +67535,6 @@ function createTypeChecker(host) {
67496
67535
  }
67497
67536
  return type;
67498
67537
  }
67499
- function getMappedTargetWithSymbol(type) {
67500
- let target = type;
67501
- while ((getObjectFlags(target) & 96 /* InstantiatedMapped */) === 96 /* InstantiatedMapped */ && isMappedTypeWithKeyofConstraintDeclaration(target)) {
67502
- target = getModifiersTypeFromMappedType(target);
67503
- }
67504
- return target.symbol ? target : type;
67505
- }
67506
67538
  function isPropertyIdenticalTo(sourceProp, targetProp) {
67507
67539
  return compareProperties2(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
67508
67540
  }
@@ -84402,7 +84434,7 @@ function createTypeChecker(host) {
84402
84434
  error2(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
84403
84435
  } else {
84404
84436
  const text = getTextOfPropertyName(member.name);
84405
- if (isNumericLiteralName(text)) {
84437
+ if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
84406
84438
  error2(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
84407
84439
  }
84408
84440
  }
@@ -102878,7 +102910,7 @@ function transformES2015(context) {
102878
102910
  hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts;
102879
102911
  }
102880
102912
  function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
102881
- return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
102913
+ return (hierarchyFacts & 8192 /* ConstructorWithSuperCall */) !== 0 && node.kind === 253 /* ReturnStatement */ && !node.expression;
102882
102914
  }
102883
102915
  function isOrMayContainReturnCompletion(node) {
102884
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(
@@ -102888,7 +102920,7 @@ function transformES2015(context) {
102888
102920
  ) || isBlock(node));
102889
102921
  }
102890
102922
  function shouldVisitNode(node) {
102891
- 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(
102892
102924
  node,
102893
102925
  /*lookInLabeledStatements*/
102894
102926
  false
@@ -102921,7 +102953,7 @@ function transformES2015(context) {
102921
102953
  /*expressionResultIsUnused*/
102922
102954
  false
102923
102955
  );
102924
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
102956
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
102925
102957
  return result;
102926
102958
  }
102927
102959
  return visitorWorker(
@@ -102935,6 +102967,7 @@ function transformES2015(context) {
102935
102967
  function callExpressionVisitor(node) {
102936
102968
  if (node.kind === 108 /* SuperKeyword */) {
102937
102969
  return visitSuperKeyword(
102970
+ node,
102938
102971
  /*isExpressionOfCall*/
102939
102972
  true
102940
102973
  );
@@ -103044,6 +103077,7 @@ function transformES2015(context) {
103044
103077
  return visitSpreadElement(node);
103045
103078
  case 108 /* SuperKeyword */:
103046
103079
  return visitSuperKeyword(
103080
+ node,
103047
103081
  /*isExpressionOfCall*/
103048
103082
  false
103049
103083
  );
@@ -103113,7 +103147,10 @@ function transformES2015(context) {
103113
103147
  return updated;
103114
103148
  }
103115
103149
  function returnCapturedThis(node) {
103116
- 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 */);
103117
103154
  }
103118
103155
  function visitReturnStatement(node) {
103119
103156
  if (convertedLoopState) {
@@ -103137,8 +103174,9 @@ function transformES2015(context) {
103137
103174
  return visitEachChild(node, visitor, context);
103138
103175
  }
103139
103176
  function visitThisKeyword(node) {
103177
+ hierarchyFacts |= 65536 /* LexicalThis */;
103140
103178
  if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
103141
- hierarchyFacts |= 65536 /* CapturedLexicalThis */;
103179
+ hierarchyFacts |= 131072 /* CapturedLexicalThis */;
103142
103180
  }
103143
103181
  if (convertedLoopState) {
103144
103182
  if (hierarchyFacts & 2 /* ArrowFunction */) {
@@ -103277,7 +103315,7 @@ function transformES2015(context) {
103277
103315
  void 0,
103278
103316
  /*dotDotDotToken*/
103279
103317
  void 0,
103280
- factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)
103318
+ createSyntheticSuper()
103281
103319
  )] : [],
103282
103320
  /*type*/
103283
103321
  void 0,
@@ -103367,7 +103405,7 @@ function transformES2015(context) {
103367
103405
  setEmitFlags(constructorFunction, 16 /* CapturesThis */);
103368
103406
  }
103369
103407
  statements.push(constructorFunction);
103370
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
103408
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
103371
103409
  convertedLoopState = savedConvertedLoopState;
103372
103410
  }
103373
103411
  function transformConstructorParameters(constructor, hasSynthesizedSuper) {
@@ -103391,103 +103429,35 @@ function transformES2015(context) {
103391
103429
  setEmitFlags(block, 3072 /* NoComments */);
103392
103430
  return block;
103393
103431
  }
103394
- function transformConstructorBodyWorker(prologueOut, statementsOut, statementsIn, statementOffset, superPath, superPathDepth, constructor, isDerivedClass, hasSynthesizedSuper, isFirstStatement) {
103395
- let mayReplaceThis = false;
103396
- const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1;
103397
- const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length;
103398
- if (isFirstStatement && superStatementIndex >= 0) {
103399
- let firstMaterialIndex = statementOffset;
103400
- while (isFirstStatement && firstMaterialIndex < superStatementIndex) {
103401
- const statement = constructor.body.statements[firstMaterialIndex];
103402
- if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement))
103403
- break;
103404
- firstMaterialIndex++;
103405
- }
103406
- isFirstStatement = superStatementIndex === firstMaterialIndex;
103407
- }
103408
- addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset));
103409
- const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : void 0;
103410
- if (superStatement && isTryStatement(superStatement)) {
103411
- const tryBlockStatements = [];
103412
- mayReplaceThis = transformConstructorBodyWorker(
103413
- prologueOut,
103414
- tryBlockStatements,
103415
- superStatement.tryBlock.statements,
103416
- /*statementOffset*/
103417
- 0,
103418
- superPath,
103419
- superPathDepth + 1,
103420
- constructor,
103421
- isDerivedClass,
103422
- hasSynthesizedSuper,
103423
- isFirstStatement
103424
- );
103425
- const tryBlockStatementsArray = factory2.createNodeArray(tryBlockStatements);
103426
- setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements);
103427
- statementsOut.push(factory2.updateTryStatement(
103428
- superStatement,
103429
- factory2.updateBlock(superStatement.tryBlock, tryBlockStatements),
103430
- visitNode(superStatement.catchClause, visitor, isCatchClause),
103431
- visitNode(superStatement.finallyBlock, visitor, isBlock)
103432
- ));
103433
- } else {
103434
- const superCall = superStatement && getSuperCallFromStatement(superStatement);
103435
- let superCallExpression;
103436
- if (hasSynthesizedSuper) {
103437
- superCallExpression = createDefaultSuperCallOrThis();
103438
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
103439
- } else if (superCall) {
103440
- superCallExpression = visitSuperCallInBody(superCall);
103441
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
103442
- }
103443
- if (isDerivedClass || superCallExpression) {
103444
- if (superCallExpression && superStatementIndex === statementsIn.length - 1 && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
103445
- const superCall2 = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression);
103446
- const returnStatement = factory2.createReturnStatement(superCallExpression);
103447
- setCommentRange(returnStatement, getCommentRange(superCall2));
103448
- setEmitFlags(superCall2, 3072 /* NoComments */);
103449
- statementsOut.push(returnStatement);
103450
- return false;
103451
- } else {
103452
- if (isFirstStatement) {
103453
- insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis());
103454
- } else {
103455
- insertCaptureThisForNode(prologueOut, constructor, createActualThis());
103456
- if (superCallExpression) {
103457
- addSuperThisCaptureThisForNode(statementsOut, superCallExpression);
103458
- }
103459
- }
103460
- mayReplaceThis = true;
103461
- }
103462
- } else {
103463
- insertCaptureThisForNodeIfNeeded(prologueOut, constructor);
103464
- }
103465
- }
103466
- if (superStatementIndex >= 0) {
103467
- addRange(statementsOut, visitNodes2(statementsIn, visitor, isStatement, superStatementIndex + 1));
103468
- }
103469
- return mayReplaceThis;
103470
- }
103471
103432
  function isUninitializedVariableStatement(node) {
103472
103433
  return isVariableStatement(node) && every(node.declarationList.declarations, (decl) => isIdentifier(decl.name) && !decl.initializer);
103473
103434
  }
103474
- function isUsingDeclarationStateVariableStatement(node) {
103475
- if (!isVariableStatement(node) || node.declarationList.declarations.length !== 1)
103476
- return false;
103477
- const varDecl = node.declarationList.declarations[0];
103478
- if (!isIdentifier(varDecl.name) || !varDecl.initializer)
103479
- return false;
103480
- const initializer = varDecl.initializer;
103481
- if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3)
103482
- return false;
103483
- const [stackProp, errorProp, hasErrorProp] = initializer.properties;
103484
- if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer))
103485
- return false;
103486
- if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression))
103487
- return false;
103488
- 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 */)) {
103489
103440
  return false;
103490
- 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);
103491
103461
  }
103492
103462
  function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
103493
103463
  const isDerivedClass = !!extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== 106 /* NullKeyword */;
@@ -103502,31 +103472,22 @@ function transformES2015(context) {
103502
103472
  /*statementOffset*/
103503
103473
  0
103504
103474
  );
103505
- const superStatementIndices = findSuperStatementIndexPath(constructor.body.statements, standardPrologueEnd);
103506
- if (hasSynthesizedSuper || superStatementIndices.length > 0) {
103507
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
103475
+ if (hasSynthesizedSuper || containsSuperCall(constructor.body)) {
103476
+ hierarchyFacts |= 8192 /* ConstructorWithSuperCall */;
103508
103477
  }
103509
- const mayReplaceThis = transformConstructorBodyWorker(
103510
- prologue,
103511
- statements,
103512
- constructor.body.statements,
103513
- standardPrologueEnd,
103514
- superStatementIndices,
103515
- /*superPathDepth*/
103516
- 0,
103517
- constructor,
103518
- isDerivedClass,
103519
- hasSynthesizedSuper,
103520
- /*isFirstStatement*/
103521
- true
103522
- // NOTE: this will be recalculated inside of transformConstructorBodyWorker
103523
- );
103478
+ addRange(statements, visitNodes2(constructor.body.statements, visitor, isStatement, standardPrologueEnd));
103479
+ const mayReplaceThis = isDerivedClass || hierarchyFacts & 8192 /* ConstructorWithSuperCall */;
103524
103480
  addDefaultValueAssignmentsIfNeeded2(prologue, constructor);
103525
103481
  addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
103526
103482
  insertCaptureNewTargetIfNeeded(prologue, constructor);
103483
+ if (mayReplaceThis) {
103484
+ insertCaptureThisForNode(prologue, constructor, createActualThis());
103485
+ } else {
103486
+ insertCaptureThisForNodeIfNeeded(prologue, constructor);
103487
+ }
103527
103488
  factory2.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
103528
103489
  if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) {
103529
- statements.push(factory2.createReturnStatement(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
103490
+ statements.push(factory2.createReturnStatement(createCapturedThis()));
103530
103491
  }
103531
103492
  const body = factory2.createBlock(
103532
103493
  setTextRange(
@@ -103543,6 +103504,230 @@ function transformES2015(context) {
103543
103504
  true
103544
103505
  );
103545
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
+ }
103546
103731
  return body;
103547
103732
  }
103548
103733
  function isSufficientlyCoveredByReturnStatements(statement) {
@@ -103568,11 +103753,11 @@ function transformES2015(context) {
103568
103753
  return factory2.createLogicalOr(
103569
103754
  factory2.createLogicalAnd(
103570
103755
  factory2.createStrictInequality(
103571
- factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */),
103756
+ createSyntheticSuper(),
103572
103757
  factory2.createNull()
103573
103758
  ),
103574
103759
  factory2.createFunctionApplyCall(
103575
- factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */),
103760
+ createSyntheticSuper(),
103576
103761
  createActualThis(),
103577
103762
  factory2.createIdentifier("arguments")
103578
103763
  )
@@ -103827,24 +104012,12 @@ function transformES2015(context) {
103827
104012
  return true;
103828
104013
  }
103829
104014
  function insertCaptureThisForNodeIfNeeded(statements, node) {
103830
- if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
104015
+ if (hierarchyFacts & 131072 /* CapturedLexicalThis */ && node.kind !== 219 /* ArrowFunction */) {
103831
104016
  insertCaptureThisForNode(statements, node, factory2.createThis());
103832
104017
  return true;
103833
104018
  }
103834
104019
  return false;
103835
104020
  }
103836
- function addSuperThisCaptureThisForNode(statements, superExpression) {
103837
- enableSubstitutionsForCapturedThis();
103838
- const assignSuperExpression = factory2.createExpressionStatement(
103839
- factory2.createBinaryExpression(
103840
- factory2.createThis(),
103841
- 64 /* EqualsToken */,
103842
- superExpression
103843
- )
103844
- );
103845
- statements.push(assignSuperExpression);
103846
- setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent);
103847
- }
103848
104021
  function insertCaptureThisForNode(statements, node, initializer) {
103849
104022
  enableSubstitutionsForCapturedThis();
103850
104023
  const captureThisStatement = factory2.createVariableStatement(
@@ -103852,7 +104025,7 @@ function transformES2015(context) {
103852
104025
  void 0,
103853
104026
  factory2.createVariableDeclarationList([
103854
104027
  factory2.createVariableDeclaration(
103855
- factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */),
104028
+ createCapturedThis(),
103856
104029
  /*exclamationToken*/
103857
104030
  void 0,
103858
104031
  /*type*/
@@ -104073,7 +104246,7 @@ function transformES2015(context) {
104073
104246
  }
104074
104247
  function visitArrowFunction(node) {
104075
104248
  if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
104076
- hierarchyFacts |= 65536 /* CapturedLexicalThis */;
104249
+ hierarchyFacts |= 131072 /* CapturedLexicalThis */;
104077
104250
  }
104078
104251
  const savedConvertedLoopState = convertedLoopState;
104079
104252
  convertedLoopState = void 0;
@@ -104106,7 +104279,7 @@ function transformES2015(context) {
104106
104279
  const parameters = visitParameterList(node.parameters, visitor, context);
104107
104280
  const body = transformFunctionBody2(node);
104108
104281
  const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
104109
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
104282
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
104110
104283
  convertedLoopState = savedConvertedLoopState;
104111
104284
  return factory2.updateFunctionExpression(
104112
104285
  node,
@@ -104129,7 +104302,7 @@ function transformES2015(context) {
104129
104302
  const parameters = visitParameterList(node.parameters, visitor, context);
104130
104303
  const body = transformFunctionBody2(node);
104131
104304
  const name = hierarchyFacts & 32768 /* NewTarget */ ? factory2.getLocalName(node) : node.name;
104132
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
104305
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
104133
104306
  convertedLoopState = savedConvertedLoopState;
104134
104307
  return factory2.updateFunctionDeclaration(
104135
104308
  node,
@@ -104153,7 +104326,7 @@ function transformES2015(context) {
104153
104326
  if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 262 /* FunctionDeclaration */ || node.kind === 218 /* FunctionExpression */)) {
104154
104327
  name = factory2.getGeneratedNameForNode(node);
104155
104328
  }
104156
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
104329
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
104157
104330
  convertedLoopState = savedConvertedLoopState;
104158
104331
  return setOriginalNode(
104159
104332
  setTextRange(
@@ -105562,7 +105735,7 @@ function transformES2015(context) {
105562
105735
  } else {
105563
105736
  updated = factory2.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body);
105564
105737
  }
105565
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
105738
+ exitSubtree(ancestorFacts, 229376 /* FunctionSubtreeExcludes */, 0 /* None */);
105566
105739
  convertedLoopState = savedConvertedLoopState;
105567
105740
  return updated;
105568
105741
  }
@@ -105712,13 +105885,6 @@ function transformES2015(context) {
105712
105885
  )
105713
105886
  );
105714
105887
  }
105715
- function visitSuperCallInBody(node) {
105716
- return visitCallExpressionWithPotentialCapturedThisAssignment(
105717
- node,
105718
- /*assignToCapturedThis*/
105719
- false
105720
- );
105721
- }
105722
105888
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
105723
105889
  if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || node.expression.kind === 108 /* SuperKeyword */ || isSuperProperty(skipOuterExpressions(node.expression))) {
105724
105890
  const { target, thisArg } = factory2.createCallBinding(node.expression, hoistVariableDeclaration);
@@ -105755,10 +105921,13 @@ function transformES2015(context) {
105755
105921
  resultingCall,
105756
105922
  createActualThis()
105757
105923
  );
105758
- resultingCall = assignToCapturedThis ? factory2.createAssignment(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) : initializer;
105924
+ resultingCall = assignToCapturedThis ? factory2.createAssignment(createCapturedThis(), initializer) : initializer;
105759
105925
  }
105760
105926
  return setOriginalNode(resultingCall, node);
105761
105927
  }
105928
+ if (isSuperCall(node)) {
105929
+ hierarchyFacts |= 131072 /* CapturedLexicalThis */;
105930
+ }
105762
105931
  return visitEachChild(node, visitor, context);
105763
105932
  }
105764
105933
  function visitNewExpression(node) {
@@ -105885,8 +106054,15 @@ function transformES2015(context) {
105885
106054
  }
105886
106055
  return setTextRange(expression, node);
105887
106056
  }
105888
- function visitSuperKeyword(isExpressionOfCall) {
105889
- 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;
105890
106066
  }
105891
106067
  function visitMetaProperty(node) {
105892
106068
  if (node.keywordToken === 105 /* NewKeyword */ && node.name.escapedText === "target") {
@@ -105992,7 +106168,7 @@ function transformES2015(context) {
105992
106168
  }
105993
106169
  function substituteThisKeyword(node) {
105994
106170
  if (enabledSubstitutions & 1 /* CapturedThis */ && hierarchyFacts & 16 /* CapturesThis */) {
105995
- return setTextRange(factory2.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node);
106171
+ return setTextRange(createCapturedThis(), node);
105996
106172
  }
105997
106173
  return node;
105998
106174
  }
@@ -113090,7 +113266,7 @@ function transformDeclarations(context) {
113090
113266
  return statement;
113091
113267
  }
113092
113268
  const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
113093
- return factory2.updateModifiers(statement, modifiers);
113269
+ return factory2.replaceModifiers(statement, modifiers);
113094
113270
  }
113095
113271
  function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
113096
113272
  const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
@@ -113221,7 +113397,7 @@ function transformDeclarations(context) {
113221
113397
  return factory2.createVariableStatement(isNonContextualKeywordName ? void 0 : [factory2.createToken(95 /* ExportKeyword */)], factory2.createVariableDeclarationList([varDecl]));
113222
113398
  });
113223
113399
  if (!exportMappings.length) {
113224
- declarations = mapDefined(declarations, (declaration) => factory2.updateModifiers(declaration, 0 /* None */));
113400
+ declarations = mapDefined(declarations, (declaration) => factory2.replaceModifiers(declaration, 0 /* None */));
113225
113401
  } else {
113226
113402
  declarations.push(factory2.createExportDeclaration(
113227
113403
  /*modifiers*/
@@ -146896,7 +147072,7 @@ function makeChange2(changeTracker, sourceFile, insertionSite, fixedDeclarations
146896
147072
  }
146897
147073
  }
146898
147074
  fixedDeclarations == null ? void 0 : fixedDeclarations.add(getNodeId(insertionSite));
146899
- const cloneWithModifier = factory.updateModifiers(
147075
+ const cloneWithModifier = factory.replaceModifiers(
146900
147076
  getSynthesizedDeepClone(
146901
147077
  insertionSite,
146902
147078
  /*includeTrivia*/
@@ -149961,7 +150137,8 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
149961
150137
  defaultImport,
149962
150138
  namedImports && arrayFrom(namedImports.entries(), ([name, addAsTypeOnly]) => ({ addAsTypeOnly, name })),
149963
150139
  namespaceLikeImport,
149964
- compilerOptions
150140
+ compilerOptions,
150141
+ preferences
149965
150142
  );
149966
150143
  newDeclarations = combine(newDeclarations, declarations);
149967
150144
  });
@@ -150666,7 +150843,8 @@ function codeActionForFixWorker(changes, sourceFile, symbolName2, fix, includeSy
150666
150843
  defaultImport,
150667
150844
  namedImports,
150668
150845
  namespaceLikeImport,
150669
- program.getCompilerOptions()
150846
+ program.getCompilerOptions(),
150847
+ preferences
150670
150848
  ),
150671
150849
  /*blankLineBetween*/
150672
150850
  true,
@@ -150798,7 +150976,7 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
150798
150976
  const newSpecifiers = stableSort(
150799
150977
  namedImports.map(
150800
150978
  (namedImport) => factory.createImportSpecifier(
150801
- (!clause.isTypeOnly || promoteFromTypeOnly2) && needsTypeOnly(namedImport),
150979
+ (!clause.isTypeOnly || promoteFromTypeOnly2) && shouldUseTypeOnly(namedImport, preferences),
150802
150980
  /*propertyName*/
150803
150981
  void 0,
150804
150982
  factory.createIdentifier(namedImport.name)
@@ -150862,21 +151040,24 @@ function getImportTypePrefix(moduleSpecifier, quotePreference) {
150862
151040
  function needsTypeOnly({ addAsTypeOnly }) {
150863
151041
  return addAsTypeOnly === 2 /* Required */;
150864
151042
  }
150865
- function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport, compilerOptions) {
151043
+ function shouldUseTypeOnly(info, preferences) {
151044
+ return needsTypeOnly(info) || !!preferences.preferTypeOnlyAutoImports && info.addAsTypeOnly !== 4 /* NotAllowed */;
151045
+ }
151046
+ function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport, compilerOptions, preferences) {
150866
151047
  const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference);
150867
151048
  let statements;
150868
151049
  if (defaultImport !== void 0 || (namedImports == null ? void 0 : namedImports.length)) {
150869
- const topLevelTypeOnly = (!defaultImport || needsTypeOnly(defaultImport)) && every(namedImports, needsTypeOnly) || compilerOptions.verbatimModuleSyntax && (defaultImport == null ? void 0 : defaultImport.addAsTypeOnly) !== 4 /* NotAllowed */ && !some(namedImports, (i) => i.addAsTypeOnly === 4 /* NotAllowed */);
151050
+ const topLevelTypeOnly = (!defaultImport || needsTypeOnly(defaultImport)) && every(namedImports, needsTypeOnly) || (compilerOptions.verbatimModuleSyntax || preferences.preferTypeOnlyAutoImports) && (defaultImport == null ? void 0 : defaultImport.addAsTypeOnly) !== 4 /* NotAllowed */ && !some(namedImports, (i) => i.addAsTypeOnly === 4 /* NotAllowed */);
150870
151051
  statements = combine(
150871
151052
  statements,
150872
151053
  makeImport(
150873
151054
  defaultImport && factory.createIdentifier(defaultImport.name),
150874
151055
  namedImports == null ? void 0 : namedImports.map(
150875
- ({ addAsTypeOnly, name }) => factory.createImportSpecifier(
150876
- !topLevelTypeOnly && addAsTypeOnly === 2 /* Required */,
151056
+ (namedImport) => factory.createImportSpecifier(
151057
+ !topLevelTypeOnly && shouldUseTypeOnly(namedImport, preferences),
150877
151058
  /*propertyName*/
150878
151059
  void 0,
150879
- factory.createIdentifier(name)
151060
+ factory.createIdentifier(namedImport.name)
150880
151061
  )
150881
151062
  ),
150882
151063
  moduleSpecifier,
@@ -150889,14 +151070,14 @@ function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImp
150889
151070
  const declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ ? factory.createImportEqualsDeclaration(
150890
151071
  /*modifiers*/
150891
151072
  void 0,
150892
- needsTypeOnly(namespaceLikeImport),
151073
+ shouldUseTypeOnly(namespaceLikeImport, preferences),
150893
151074
  factory.createIdentifier(namespaceLikeImport.name),
150894
151075
  factory.createExternalModuleReference(quotedModuleSpecifier)
150895
151076
  ) : factory.createImportDeclaration(
150896
151077
  /*modifiers*/
150897
151078
  void 0,
150898
151079
  factory.createImportClause(
150899
- needsTypeOnly(namespaceLikeImport),
151080
+ shouldUseTypeOnly(namespaceLikeImport, preferences),
150900
151081
  /*name*/
150901
151082
  void 0,
150902
151083
  factory.createNamespaceImport(factory.createIdentifier(namespaceLikeImport.name))
@@ -157856,7 +158037,7 @@ function getEntryForMemberCompletion(host, program, options, preferences, name,
157856
158037
  if (!completionNodes.length) {
157857
158038
  modifiers = node.modifierFlagsCache | requiredModifiers;
157858
158039
  }
157859
- node = factory.updateModifiers(node, modifiers);
158040
+ node = factory.replaceModifiers(node, modifiers);
157860
158041
  completionNodes.push(node);
157861
158042
  },
157862
158043
  body,
@@ -157882,11 +158063,11 @@ function getEntryForMemberCompletion(host, program, options, preferences, name,
157882
158063
  modifiers &= ~4 /* Public */;
157883
158064
  }
157884
158065
  modifiers |= allowedAndPresent;
157885
- completionNodes = completionNodes.map((node) => factory.updateModifiers(node, modifiers));
158066
+ completionNodes = completionNodes.map((node) => factory.replaceModifiers(node, modifiers));
157886
158067
  if (presentDecorators == null ? void 0 : presentDecorators.length) {
157887
158068
  const lastNode = completionNodes[completionNodes.length - 1];
157888
158069
  if (canHaveDecorators(lastNode)) {
157889
- completionNodes[completionNodes.length - 1] = factory.updateModifierLike(lastNode, presentDecorators.concat(getModifiers(lastNode) || []));
158070
+ completionNodes[completionNodes.length - 1] = factory.replaceDecoratorsAndModifiers(lastNode, presentDecorators.concat(getModifiers(lastNode) || []));
157890
158071
  }
157891
158072
  }
157892
158073
  const format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;