@typescript-deploys/pr-build 5.2.0-pr-54316-2 → 5.2.0-pr-54052-23

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.
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.2";
38
- version = `${versionMajorMinor}.0-insiders.20230518`;
38
+ version = `${versionMajorMinor}.0-insiders.20230526`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -37258,6 +37258,7 @@ ${lanes.join("\n")}
37258
37258
  ["es2015.symbol", "lib.es2015.symbol.d.ts"],
37259
37259
  ["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
37260
37260
  ["es2016.array.include", "lib.es2016.array.include.d.ts"],
37261
+ ["es2017.date", "lib.es2017.date.d.ts"],
37261
37262
  ["es2017.object", "lib.es2017.object.d.ts"],
37262
37263
  ["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
37263
37264
  ["es2017.string", "lib.es2017.string.d.ts"],
@@ -50343,32 +50344,34 @@ ${lanes.join("\n")}
50343
50344
  const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 172 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
50344
50345
  typeElements.push(preserveCommentsOn(methodDeclaration));
50345
50346
  }
50347
+ if (signatures.length || !optionalToken) {
50348
+ return;
50349
+ }
50350
+ }
50351
+ let propertyTypeNode;
50352
+ if (shouldUsePlaceholderForProperty(propertySymbol, context)) {
50353
+ propertyTypeNode = createElidedInformationPlaceholder(context);
50346
50354
  } else {
50347
- let propertyTypeNode;
50348
- if (shouldUsePlaceholderForProperty(propertySymbol, context)) {
50349
- propertyTypeNode = createElidedInformationPlaceholder(context);
50350
- } else {
50351
- if (propertyIsReverseMapped) {
50352
- context.reverseMappedStack || (context.reverseMappedStack = []);
50353
- context.reverseMappedStack.push(propertySymbol);
50354
- }
50355
- propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : factory.createKeywordTypeNode(133 /* AnyKeyword */);
50356
- if (propertyIsReverseMapped) {
50357
- context.reverseMappedStack.pop();
50358
- }
50355
+ if (propertyIsReverseMapped) {
50356
+ context.reverseMappedStack || (context.reverseMappedStack = []);
50357
+ context.reverseMappedStack.push(propertySymbol);
50359
50358
  }
50360
- const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
50361
- if (modifiers) {
50362
- context.approximateLength += 9;
50359
+ propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : factory.createKeywordTypeNode(133 /* AnyKeyword */);
50360
+ if (propertyIsReverseMapped) {
50361
+ context.reverseMappedStack.pop();
50363
50362
  }
50364
- const propertySignature = factory.createPropertySignature(
50365
- modifiers,
50366
- propertyName,
50367
- optionalToken,
50368
- propertyTypeNode
50369
- );
50370
- typeElements.push(preserveCommentsOn(propertySignature));
50371
50363
  }
50364
+ const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
50365
+ if (modifiers) {
50366
+ context.approximateLength += 9;
50367
+ }
50368
+ const propertySignature = factory.createPropertySignature(
50369
+ modifiers,
50370
+ propertyName,
50371
+ optionalToken,
50372
+ propertyTypeNode
50373
+ );
50374
+ typeElements.push(preserveCommentsOn(propertySignature));
50372
50375
  function preserveCommentsOn(node) {
50373
50376
  var _a2;
50374
50377
  if (some(propertySymbol.declarations, (d) => d.kind === 354 /* JSDocPropertyTag */)) {
@@ -56431,7 +56434,7 @@ ${lanes.join("\n")}
56431
56434
  } else if (type !== firstType) {
56432
56435
  checkFlags |= 64 /* HasNonUniformType */;
56433
56436
  }
56434
- if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
56437
+ if (isLiteralType(type) || isPatternLiteralType(type)) {
56435
56438
  checkFlags |= 128 /* HasLiteralType */;
56436
56439
  }
56437
56440
  if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
@@ -58658,31 +58661,28 @@ ${lanes.join("\n")}
58658
58661
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
58659
58662
  }
58660
58663
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
58661
- let first2;
58664
+ let last2;
58662
58665
  const types = [];
58663
58666
  for (const sig of signatures) {
58664
58667
  const pred = getTypePredicateOfSignature(sig);
58665
- if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) {
58666
- if (kind !== 2097152 /* Intersection */) {
58667
- continue;
58668
- } else {
58669
- return;
58670
- }
58671
- }
58672
- if (first2) {
58673
- if (!typePredicateKindsMatch(first2, pred)) {
58668
+ if (pred) {
58669
+ if (pred.kind !== 0 /* This */ && pred.kind !== 1 /* Identifier */ || last2 && !typePredicateKindsMatch(last2, pred)) {
58674
58670
  return void 0;
58675
58671
  }
58672
+ last2 = pred;
58673
+ types.push(pred.type);
58676
58674
  } else {
58677
- first2 = pred;
58675
+ const returnType = kind !== 2097152 /* Intersection */ ? getReturnTypeOfSignature(sig) : void 0;
58676
+ if (returnType !== falseType && returnType !== regularFalseType) {
58677
+ return void 0;
58678
+ }
58678
58679
  }
58679
- types.push(pred.type);
58680
58680
  }
58681
- if (!first2) {
58681
+ if (!last2) {
58682
58682
  return void 0;
58683
58683
  }
58684
58684
  const compositeType = getUnionOrIntersectionType(types, kind);
58685
- return createTypePredicate(first2.kind, first2.parameterName, first2.parameterIndex, compositeType);
58685
+ return createTypePredicate(last2.kind, last2.parameterName, last2.parameterIndex, compositeType);
58686
58686
  }
58687
58687
  function typePredicateKindsMatch(a, b) {
58688
58688
  return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
@@ -59724,9 +59724,9 @@ ${lanes.join("\n")}
59724
59724
  );
59725
59725
  if (freshMapper) {
59726
59726
  const freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
59727
- for (const p of freshParams) {
59728
- if (root.inferTypeParameters.indexOf(p) === -1) {
59729
- p.mapper = freshCombinedMapper;
59727
+ for (let i = 0; i < freshParams.length; i++) {
59728
+ if (freshParams[i] !== root.inferTypeParameters[i]) {
59729
+ freshParams[i].mapper = freshCombinedMapper;
59730
59730
  }
59731
59731
  }
59732
59732
  }
@@ -60563,18 +60563,19 @@ ${lanes.join("\n")}
60563
60563
  case 185 /* TypeQuery */:
60564
60564
  const entityName = node2.exprName;
60565
60565
  const firstIdentifier = getFirstIdentifier(entityName);
60566
- const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
60567
- const tpDeclaration = tp.symbol.declarations[0];
60568
- let tpScope;
60569
- if (tpDeclaration.kind === 167 /* TypeParameter */) {
60570
- tpScope = tpDeclaration.parent;
60571
- } else if (tp.isThisType) {
60572
- tpScope = tpDeclaration;
60573
- } else {
60574
- return true;
60575
- }
60576
- if (firstIdentifierSymbol.declarations) {
60577
- return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
60566
+ if (!isThisIdentifier(firstIdentifier)) {
60567
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
60568
+ const tpDeclaration = tp.symbol.declarations[0];
60569
+ const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
60570
+ // Type parameter is a regular type parameter, e.g. foo<T>
60571
+ tp.isThisType ? tpDeclaration : (
60572
+ // Type parameter is the this type, and its declaration is the class declaration.
60573
+ void 0
60574
+ )
60575
+ );
60576
+ if (firstIdentifierSymbol.declarations && tpScope) {
60577
+ return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
60578
+ }
60578
60579
  }
60579
60580
  return true;
60580
60581
  case 173 /* MethodDeclaration */:
@@ -60628,6 +60629,9 @@ ${lanes.join("\n")}
60628
60629
  const elementFlags = tupleType.target.elementFlags;
60629
60630
  const elementTypes = map(getElementTypes(tupleType), (t, i) => {
60630
60631
  const singleton = elementFlags[i] & 8 /* Variadic */ ? t : elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]);
60632
+ if (singleton === typeVariable) {
60633
+ return mappedType;
60634
+ }
60631
60635
  return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
60632
60636
  });
60633
60637
  const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType));
@@ -60965,6 +60969,10 @@ ${lanes.join("\n")}
60965
60969
  return true;
60966
60970
  }
60967
60971
  switch (node.kind) {
60972
+ case 233 /* AsExpression */:
60973
+ if (!isConstAssertion(node)) {
60974
+ break;
60975
+ }
60968
60976
  case 293 /* JsxExpression */:
60969
60977
  case 216 /* ParenthesizedExpression */:
60970
60978
  return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
@@ -64212,7 +64220,7 @@ ${lanes.join("\n")}
64212
64220
  }
64213
64221
  }
64214
64222
  }
64215
- const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
64223
+ const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i]), 0 /* None */) : target;
64216
64224
  return filtered.flags & 131072 /* Never */ ? target : filtered;
64217
64225
  }
64218
64226
  function isWeakType(type) {
@@ -64416,7 +64424,7 @@ ${lanes.join("\n")}
64416
64424
  }
64417
64425
  function getRecursionIdentity(type) {
64418
64426
  if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) {
64419
- if (getObjectFlags(type) && 4 /* Reference */ && type.node) {
64427
+ if (getObjectFlags(type) & 4 /* Reference */ && type.node) {
64420
64428
  return type.node;
64421
64429
  }
64422
64430
  if (type.symbol && !(getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
@@ -67243,7 +67251,7 @@ ${lanes.join("\n")}
67243
67251
  target.antecedents = saveAntecedents;
67244
67252
  } else if (flags & 2 /* Start */) {
67245
67253
  const container = flow.node;
67246
- if (container && container !== flowContainer && reference.kind !== 210 /* PropertyAccessExpression */ && reference.kind !== 211 /* ElementAccessExpression */ && reference.kind !== 110 /* ThisKeyword */) {
67254
+ if (container && container !== flowContainer && reference.kind !== 210 /* PropertyAccessExpression */ && reference.kind !== 211 /* ElementAccessExpression */ && !(reference.kind === 110 /* ThisKeyword */ && container.kind !== 218 /* ArrowFunction */)) {
67247
67255
  flow = container.flowNode;
67248
67256
  continue;
67249
67257
  }
@@ -75730,7 +75738,7 @@ ${lanes.join("\n")}
75730
75738
  Debug.assertIsDefined(leftType);
75731
75739
  const rightType = getLastResult(state);
75732
75740
  Debug.assertIsDefined(rightType);
75733
- result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node);
75741
+ result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, state.checkMode, node);
75734
75742
  }
75735
75743
  state.skip = false;
75736
75744
  setLeftType(
@@ -75792,9 +75800,9 @@ ${lanes.join("\n")}
75792
75800
  leftType = checkExpression(left, checkMode);
75793
75801
  }
75794
75802
  const rightType = checkExpression(right, checkMode);
75795
- return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
75803
+ return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode);
75796
75804
  }
75797
- function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
75805
+ function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode) {
75798
75806
  const operator = operatorToken.kind;
75799
75807
  switch (operator) {
75800
75808
  case 42 /* AsteriskToken */:
@@ -75951,12 +75959,14 @@ ${lanes.join("\n")}
75951
75959
  case 36 /* ExclamationEqualsToken */:
75952
75960
  case 37 /* EqualsEqualsEqualsToken */:
75953
75961
  case 38 /* ExclamationEqualsEqualsToken */:
75954
- if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
75955
- const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
75956
- error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
75962
+ if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
75963
+ if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
75964
+ const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
75965
+ error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
75966
+ }
75967
+ checkNaNEquality(errorNode, operator, left, right);
75968
+ reportOperatorErrorUnless((left2, right2) => isTypeEqualityComparableTo(left2, right2) || isTypeEqualityComparableTo(right2, left2));
75957
75969
  }
75958
- checkNaNEquality(errorNode, operator, left, right);
75959
- reportOperatorErrorUnless((left2, right2) => isTypeEqualityComparableTo(left2, right2) || isTypeEqualityComparableTo(right2, left2));
75960
75970
  return booleanType;
75961
75971
  case 104 /* InstanceOfKeyword */:
75962
75972
  return checkInstanceOfExpression(left, right, leftType, rightType);
@@ -76267,7 +76277,7 @@ ${lanes.join("\n")}
76267
76277
  }
76268
76278
  }
76269
76279
  function checkConditionalExpression(node, checkMode) {
76270
- const type = checkTruthinessExpression(node.condition);
76280
+ const type = checkTruthinessExpression(node.condition, checkMode);
76271
76281
  checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue);
76272
76282
  const type1 = checkExpression(node.whenTrue, checkMode);
76273
76283
  const type2 = checkExpression(node.whenFalse, checkMode);
@@ -76608,7 +76618,7 @@ ${lanes.join("\n")}
76608
76618
  }
76609
76619
  }
76610
76620
  const startInvocationCount = flowInvocationCount;
76611
- const type = checkExpression(node);
76621
+ const type = checkExpression(node, 128 /* TypeOnly */);
76612
76622
  if (flowInvocationCount !== startInvocationCount) {
76613
76623
  const cache = flowTypeCache || (flowTypeCache = []);
76614
76624
  cache[getNodeId(node)] = type;
@@ -76684,7 +76694,7 @@ ${lanes.join("\n")}
76684
76694
  if (getIsolatedModules(compilerOptions)) {
76685
76695
  Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
76686
76696
  const constEnumDeclaration = type.symbol.valueDeclaration;
76687
- if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
76697
+ if (constEnumDeclaration.flags & 16777216 /* Ambient */ && !isValidTypeOnlyAliasUseSite(node)) {
76688
76698
  error(node, Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, isolatedModulesLikeFlagName);
76689
76699
  }
76690
76700
  }
@@ -77113,6 +77123,9 @@ ${lanes.join("\n")}
77113
77123
  case "length":
77114
77124
  case "caller":
77115
77125
  case "arguments":
77126
+ if (compilerOptions.useDefineForClassFields) {
77127
+ break;
77128
+ }
77116
77129
  case "prototype":
77117
77130
  const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
77118
77131
  const className = getNameOfSymbolAsWritten(getSymbolOfDeclaration(node));
@@ -84119,7 +84132,7 @@ ${lanes.join("\n")}
84119
84132
  if (requestedExternalEmitHelperNames.has(name))
84120
84133
  continue;
84121
84134
  requestedExternalEmitHelperNames.add(name);
84122
- const symbol = getSymbol2(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
84135
+ const symbol = getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */);
84123
84136
  if (!symbol) {
84124
84137
  error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
84125
84138
  } else if (helper & 524288 /* ClassPrivateFieldGet */) {
@@ -85815,6 +85828,7 @@ ${lanes.join("\n")}
85815
85828
  CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
85816
85829
  CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
85817
85830
  CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
85831
+ CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
85818
85832
  return CheckMode3;
85819
85833
  })(CheckMode || {});
85820
85834
  SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
@@ -121831,7 +121845,7 @@ ${lanes.join("\n")}
121831
121845
  let filesWithChangedSetOfUnresolvedImports;
121832
121846
  let filesWithInvalidatedResolutions;
121833
121847
  let filesWithInvalidatedNonRelativeUnresolvedImports;
121834
- const nonRelativeExternalModuleResolutions = /* @__PURE__ */ new Set();
121848
+ const nonRelativeExternalModuleResolutions = createMultiMap();
121835
121849
  const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
121836
121850
  const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
121837
121851
  const resolvedFileToResolution = /* @__PURE__ */ new Map();
@@ -121965,7 +121979,8 @@ ${lanes.join("\n")}
121965
121979
  moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
121966
121980
  typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
121967
121981
  libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
121968
- watchFailedLookupLocationOfNonRelativeModuleResolutions();
121982
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
121983
+ nonRelativeExternalModuleResolutions.clear();
121969
121984
  }
121970
121985
  function cleanupLibResolutionWatching(newProgram) {
121971
121986
  resolvedLibraries.forEach((resolution, libFileName) => {
@@ -121983,7 +121998,8 @@ ${lanes.join("\n")}
121983
121998
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
121984
121999
  filesWithInvalidatedNonRelativeUnresolvedImports = void 0;
121985
122000
  allModuleAndTypeResolutionsAreInvalidated = false;
121986
- watchFailedLookupLocationOfNonRelativeModuleResolutions();
122001
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
122002
+ nonRelativeExternalModuleResolutions.clear();
121987
122003
  if (newProgram !== oldProgram) {
121988
122004
  cleanupLibResolutionWatching(newProgram);
121989
122005
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
@@ -122264,7 +122280,7 @@ ${lanes.join("\n")}
122264
122280
  if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
122265
122281
  watchFailedLookupLocationOfResolution(resolution);
122266
122282
  } else {
122267
- nonRelativeExternalModuleResolutions.add(resolution);
122283
+ nonRelativeExternalModuleResolutions.add(name, resolution);
122268
122284
  }
122269
122285
  const resolved = getResolutionWithResolvedFileName(resolution);
122270
122286
  if (resolved && resolved.resolvedFileName) {
@@ -122394,9 +122410,17 @@ ${lanes.join("\n")}
122394
122410
  paths.add(affectingLocation);
122395
122411
  }
122396
122412
  }
122397
- function watchFailedLookupLocationOfNonRelativeModuleResolutions() {
122398
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfResolution);
122399
- nonRelativeExternalModuleResolutions.clear();
122413
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
122414
+ const program = resolutionHost.getCurrentProgram();
122415
+ if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
122416
+ resolutions.forEach(watchFailedLookupLocationOfResolution);
122417
+ } else {
122418
+ resolutions.forEach((resolution) => watchAffectingLocationsOfResolution(
122419
+ resolution,
122420
+ /*addToResolutionsWithOnlyAffectingLocations*/
122421
+ true
122422
+ ));
122423
+ }
122400
122424
  }
122401
122425
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
122402
122426
  const dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
@@ -134169,12 +134193,12 @@ ${lanes.join("\n")}
134169
134193
  refactorName = "Convert export";
134170
134194
  defaultToNamedAction = {
134171
134195
  name: "Convert default export to named export",
134172
- description: Diagnostics.Convert_default_export_to_named_export.message,
134196
+ description: getLocaleSpecificMessage(Diagnostics.Convert_default_export_to_named_export),
134173
134197
  kind: "refactor.rewrite.export.named"
134174
134198
  };
134175
134199
  namedToDefaultAction = {
134176
134200
  name: "Convert named export to default export",
134177
- description: Diagnostics.Convert_named_export_to_default_export.message,
134201
+ description: getLocaleSpecificMessage(Diagnostics.Convert_named_export_to_default_export),
134178
134202
  kind: "refactor.rewrite.export.default"
134179
134203
  };
134180
134204
  registerRefactor(refactorName, {
@@ -134192,7 +134216,7 @@ ${lanes.join("\n")}
134192
134216
  }
134193
134217
  if (context.preferences.provideRefactorNotApplicableReason) {
134194
134218
  return [
134195
- { name: refactorName, description: Diagnostics.Convert_default_export_to_named_export.message, actions: [
134219
+ { name: refactorName, description: getLocaleSpecificMessage(Diagnostics.Convert_default_export_to_named_export), actions: [
134196
134220
  { ...defaultToNamedAction, notApplicableReason: info.error },
134197
134221
  { ...namedToDefaultAction, notApplicableReason: info.error }
134198
134222
  ] }
@@ -134394,17 +134418,17 @@ ${lanes.join("\n")}
134394
134418
  actions = {
134395
134419
  [0 /* Named */]: {
134396
134420
  name: "Convert namespace import to named imports",
134397
- description: Diagnostics.Convert_namespace_import_to_named_imports.message,
134421
+ description: getLocaleSpecificMessage(Diagnostics.Convert_namespace_import_to_named_imports),
134398
134422
  kind: "refactor.rewrite.import.named"
134399
134423
  },
134400
134424
  [2 /* Namespace */]: {
134401
134425
  name: "Convert named imports to namespace import",
134402
- description: Diagnostics.Convert_named_imports_to_namespace_import.message,
134426
+ description: getLocaleSpecificMessage(Diagnostics.Convert_named_imports_to_namespace_import),
134403
134427
  kind: "refactor.rewrite.import.namespace"
134404
134428
  },
134405
134429
  [1 /* Default */]: {
134406
134430
  name: "Convert named imports to default import",
134407
- description: Diagnostics.Convert_named_imports_to_default_import.message,
134431
+ description: getLocaleSpecificMessage(Diagnostics.Convert_named_imports_to_default_import),
134408
134432
  kind: "refactor.rewrite.import.default"
134409
134433
  }
134410
134434
  };
@@ -134873,10 +134897,9 @@ ${lanes.join("\n")}
134873
134897
 
134874
134898
  // src/services/refactors/moveToFile.ts
134875
134899
  function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
134876
- var _a;
134877
134900
  const checker = program.getTypeChecker();
134878
134901
  const usage = getUsageInfo(oldFile, toMove.all, checker);
134879
- if (!host.fileExists(targetFile) || host.fileExists(targetFile) && ((_a = program.getSourceFile(targetFile)) == null ? void 0 : _a.statements.length) === 0) {
134902
+ if (!host.fileExists(targetFile)) {
134880
134903
  changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
134881
134904
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
134882
134905
  } else {
@@ -134914,6 +134937,13 @@ ${lanes.join("\n")}
134914
134937
  if (typeof targetFile !== "string") {
134915
134938
  if (targetFile.statements.length > 0) {
134916
134939
  changes.insertNodesAfter(targetFile, targetFile.statements[targetFile.statements.length - 1], body);
134940
+ } else {
134941
+ changes.insertNodesAtEndOfFile(
134942
+ targetFile,
134943
+ body,
134944
+ /*blankLineBetween*/
134945
+ false
134946
+ );
134917
134947
  }
134918
134948
  if (imports.length > 0) {
134919
134949
  insertImports(
@@ -135500,6 +135530,10 @@ ${lanes.join("\n")}
135500
135530
  if (isNamedDeclaration(startStatement) && startStatement.name && rangeContainsRange(startStatement.name, range)) {
135501
135531
  return { toMove: [statements[startNodeIndex]], afterLast: statements[startNodeIndex + 1] };
135502
135532
  }
135533
+ const overloadRangeToMove = getOverloadRangeToMove(file, startStatement);
135534
+ if (overloadRangeToMove) {
135535
+ return overloadRangeToMove;
135536
+ }
135503
135537
  if (range.pos > startStatement.getStart(file))
135504
135538
  return void 0;
135505
135539
  const afterEndNodeIndex = findIndex(statements, (s) => s.end > range.end, startNodeIndex);
@@ -135695,6 +135729,19 @@ ${lanes.join("\n")}
135695
135729
  return false;
135696
135730
  }
135697
135731
  }
135732
+ function getOverloadRangeToMove(sourceFile, statement) {
135733
+ if (isFunctionLikeDeclaration(statement)) {
135734
+ const declarations = statement.symbol.declarations;
135735
+ if (declarations === void 0 || length(declarations) <= 1 || !contains(declarations, statement)) {
135736
+ return void 0;
135737
+ }
135738
+ const lastDecl = declarations[length(declarations) - 1];
135739
+ const statementsToMove = mapDefined(declarations, (d) => getSourceFileOfNode(d) === sourceFile && isStatement(d) ? d : void 0);
135740
+ const end = findLastIndex(sourceFile.statements, (s) => s.end > lastDecl.end);
135741
+ return { toMove: statementsToMove, afterLast: end >= 0 ? sourceFile.statements[end] : void 0 };
135742
+ }
135743
+ return void 0;
135744
+ }
135698
135745
  var refactorNameForMoveToFile, description2, moveToFileAction;
135699
135746
  var init_moveToFile = __esm({
135700
135747
  "src/services/refactors/moveToFile.ts"() {
@@ -135949,7 +135996,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
135949
135996
  init_ts4();
135950
135997
  init_ts_refactor();
135951
135998
  refactorName5 = "Convert overload list to single signature";
135952
- refactorDescription = Diagnostics.Convert_overload_list_to_single_signature.message;
135999
+ refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_overload_list_to_single_signature);
135953
136000
  functionOverloadAction = {
135954
136001
  name: refactorName5,
135955
136002
  description: refactorDescription,
@@ -136079,15 +136126,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
136079
136126
  init_ts4();
136080
136127
  init_ts_refactor();
136081
136128
  refactorName6 = "Add or remove braces in an arrow function";
136082
- refactorDescription2 = Diagnostics.Add_or_remove_braces_in_an_arrow_function.message;
136129
+ refactorDescription2 = getLocaleSpecificMessage(Diagnostics.Add_or_remove_braces_in_an_arrow_function);
136083
136130
  addBracesAction = {
136084
136131
  name: "Add braces to arrow function",
136085
- description: Diagnostics.Add_braces_to_arrow_function.message,
136132
+ description: getLocaleSpecificMessage(Diagnostics.Add_braces_to_arrow_function),
136086
136133
  kind: "refactor.rewrite.arrow.braces.add"
136087
136134
  };
136088
136135
  removeBracesAction = {
136089
136136
  name: "Remove braces from arrow function",
136090
- description: Diagnostics.Remove_braces_from_arrow_function.message,
136137
+ description: getLocaleSpecificMessage(Diagnostics.Remove_braces_from_arrow_function),
136091
136138
  kind: "refactor.rewrite.arrow.braces.remove"
136092
136139
  };
136093
136140
  registerRefactor(refactorName6, {
@@ -136958,7 +137005,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
136958
137005
  }
136959
137006
  }
136960
137007
  function isNotEqualsOperator(node) {
136961
- return node.operatorToken.kind !== 64 /* EqualsToken */;
137008
+ return !(node.operatorToken.kind === 64 /* EqualsToken */ || node.operatorToken.kind === 65 /* PlusEqualsToken */);
136962
137009
  }
136963
137010
  function getParentBinaryExpression(expr) {
136964
137011
  const container = findAncestor(expr.parent, (n) => {
@@ -138993,7 +139040,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
138993
139040
  init_ts4();
138994
139041
  init_ts_refactor();
138995
139042
  actionName = "Generate 'get' and 'set' accessors";
138996
- actionDescription = Diagnostics.Generate_get_and_set_accessors.message;
139043
+ actionDescription = getLocaleSpecificMessage(Diagnostics.Generate_get_and_set_accessors);
138997
139044
  generateGetSetAction = {
138998
139045
  name: actionName,
138999
139046
  description: actionDescription,
@@ -139145,7 +139192,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139145
139192
  init_ts4();
139146
139193
  init_ts_refactor();
139147
139194
  refactorName12 = "Infer function return type";
139148
- refactorDescription6 = Diagnostics.Infer_function_return_type.message;
139195
+ refactorDescription6 = getLocaleSpecificMessage(Diagnostics.Infer_function_return_type);
139149
139196
  inferReturnTypeAction = {
139150
139197
  name: refactorName12,
139151
139198
  description: refactorDescription6,
@@ -139816,7 +139863,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139816
139863
  onUnRecoverableConfigFileDiagnostic: noop
139817
139864
  };
139818
139865
  const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
139866
+ let releasedScriptKinds = /* @__PURE__ */ new Set();
139819
139867
  if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
139868
+ compilerHost = void 0;
139869
+ parsedCommandLines = void 0;
139870
+ releasedScriptKinds = void 0;
139820
139871
  return;
139821
139872
  }
139822
139873
  const options = {
@@ -139829,6 +139880,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139829
139880
  program = createProgram(options);
139830
139881
  compilerHost = void 0;
139831
139882
  parsedCommandLines = void 0;
139883
+ releasedScriptKinds = void 0;
139832
139884
  sourceMapper.clearCache();
139833
139885
  program.getTypeChecker();
139834
139886
  return;
@@ -139883,10 +139935,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139883
139935
  if (!shouldCreateNewSourceFile) {
139884
139936
  const oldSourceFile = program && program.getSourceFileByPath(path);
139885
139937
  if (oldSourceFile) {
139886
- if (scriptKind === oldSourceFile.scriptKind) {
139938
+ if (scriptKind === oldSourceFile.scriptKind || releasedScriptKinds.has(oldSourceFile.resolvedPath)) {
139887
139939
  return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
139888
139940
  } else {
139889
139941
  documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
139942
+ releasedScriptKinds.add(oldSourceFile.resolvedPath);
139890
139943
  }
139891
139944
  }
139892
139945
  }
@@ -149182,9 +149235,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
149182
149235
  if (call === void 0) {
149183
149236
  return void 0;
149184
149237
  }
149185
- if (isPrivateIdentifier(token)) {
149186
- return void 0;
149187
- }
149188
149238
  const methodName = token.text;
149189
149239
  const addMethodDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addMethodDeclaration(context, t, call, token, modifierFlags2, parentDeclaration, declSourceFile));
149190
149240
  const actions2 = [createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0, methodName], fixMissingMember, Diagnostics.Add_all_missing_members)];
@@ -152521,6 +152571,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
152521
152571
  type === void 0 ? factory.createKeywordTypeNode(159 /* UnknownKeyword */) : type
152522
152572
  );
152523
152573
  case 261 /* FunctionDeclaration */:
152574
+ Debug.assert(typeof name === "string" || isIdentifier(name), "Unexpected name");
152524
152575
  return factory.createFunctionDeclaration(
152525
152576
  modifiers,
152526
152577
  asteriskToken,
@@ -160806,9 +160857,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
160806
160857
  if (refNode.parent.kind === 303 /* ShorthandPropertyAssignment */) {
160807
160858
  getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference2);
160808
160859
  }
160809
- const containingClass = getContainingClassIfInHeritageClause(refNode);
160810
- if (containingClass) {
160811
- addReference2(containingClass);
160860
+ const containingNode = getContainingNodeIfInHeritageClause(refNode);
160861
+ if (containingNode) {
160862
+ addReference2(containingNode);
160812
160863
  return;
160813
160864
  }
160814
160865
  const typeNode = findAncestor(refNode, (a) => !isQualifiedName(a.parent) && !isTypeNode(a.parent) && !isTypeElement(a.parent));
@@ -160835,8 +160886,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
160835
160886
  addReference2(e);
160836
160887
  }
160837
160888
  }
160838
- function getContainingClassIfInHeritageClause(node) {
160839
- return isIdentifier(node) || isPropertyAccessExpression(node) ? getContainingClassIfInHeritageClause(node.parent) : isExpressionWithTypeArguments(node) ? tryCast(node.parent.parent, isClassLike) : void 0;
160889
+ function getContainingNodeIfInHeritageClause(node) {
160890
+ return isIdentifier(node) || isPropertyAccessExpression(node) ? getContainingNodeIfInHeritageClause(node.parent) : isExpressionWithTypeArguments(node) ? tryCast(node.parent.parent, or(isClassLike, isInterfaceDeclaration)) : void 0;
160840
160891
  }
160841
160892
  function isImplementationExpression(node) {
160842
160893
  switch (node.kind) {
@@ -162348,7 +162399,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
162348
162399
  const tags = (parameters ? parameterDocComments(parameters || [], isJavaScriptFile, indentationStr, newLine) : "") + (hasReturn2 ? returnsDocComment(indentationStr, newLine) : "");
162349
162400
  const openComment = "/**";
162350
162401
  const closeComment = " */";
162351
- const hasTag = (commentOwnerJsDoc || []).some((jsDoc) => !!jsDoc.tags);
162402
+ const hasTag = length(getJSDocTags(commentOwner)) > 0;
162352
162403
  if (tags && !hasTag) {
162353
162404
  const preamble = openComment + newLine + indentationStr + " * ";
162354
162405
  const endLine = tokenStart === position ? newLine + indentationStr : "";
@@ -165869,6 +165920,17 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
165869
165920
  this.insertNodeAt(sourceFile, pos, insert, options);
165870
165921
  }
165871
165922
  }
165923
+ insertNodesAtEndOfFile(sourceFile, newNodes, blankLineBetween) {
165924
+ this.insertAtEndOfFile(sourceFile, newNodes, blankLineBetween);
165925
+ }
165926
+ insertAtEndOfFile(sourceFile, insert, blankLineBetween) {
165927
+ const pos = sourceFile.end + 1;
165928
+ const options = {
165929
+ prefix: this.newLineCharacter,
165930
+ suffix: this.newLineCharacter + (blankLineBetween ? this.newLineCharacter : "")
165931
+ };
165932
+ this.insertNodesAt(sourceFile, pos, insert, options);
165933
+ }
165872
165934
  insertStatementsInNewFile(fileName, statements, oldFile) {
165873
165935
  if (!this.newFileChanges) {
165874
165936
  this.newFileChanges = createMultiMap();
@@ -167901,7 +167963,8 @@ ${options.prefix}` : "\n" : options.prefix
167901
167963
  }
167902
167964
  processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta);
167903
167965
  }
167904
- if (!formattingScanner.isOnToken()) {
167966
+ const remainingTrivia = formattingScanner.getCurrentLeadingTrivia();
167967
+ if (remainingTrivia) {
167905
167968
  const indentation = SmartIndenter.nodeWillIndentChild(
167906
167969
  options,
167907
167970
  enclosingNode,
@@ -167911,25 +167974,30 @@ ${options.prefix}` : "\n" : options.prefix
167911
167974
  /*indentByDefault*/
167912
167975
  false
167913
167976
  ) ? initialIndentation + options.indentSize : initialIndentation;
167914
- const leadingTrivia = formattingScanner.getCurrentLeadingTrivia();
167915
- if (leadingTrivia) {
167916
- indentTriviaItems(
167917
- leadingTrivia,
167918
- indentation,
167919
- /*indentNextTokenOrTrivia*/
167920
- false,
167921
- (item) => processRange(
167977
+ indentTriviaItems(
167978
+ remainingTrivia,
167979
+ indentation,
167980
+ /*indentNextTokenOrTrivia*/
167981
+ true,
167982
+ (item) => {
167983
+ processRange(
167922
167984
  item,
167923
167985
  sourceFile.getLineAndCharacterOfPosition(item.pos),
167924
167986
  enclosingNode,
167925
167987
  enclosingNode,
167926
167988
  /*dynamicIndentation*/
167927
167989
  void 0
167928
- )
167929
- );
167930
- if (options.trimTrailingWhitespace !== false) {
167931
- trimTrailingWhitespacesForRemainingRange(leadingTrivia);
167990
+ );
167991
+ insertIndentation(
167992
+ item.pos,
167993
+ indentation,
167994
+ /*lineAdded*/
167995
+ false
167996
+ );
167932
167997
  }
167998
+ );
167999
+ if (options.trimTrailingWhitespace !== false) {
168000
+ trimTrailingWhitespacesForRemainingRange(remainingTrivia);
167933
168001
  }
167934
168002
  }
167935
168003
  if (previousRange && formattingScanner.getTokenFullStart() >= originalRange.end) {