typescript 4.8.0-dev.20220728 → 4.8.0-dev.20220731

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.
@@ -303,7 +303,7 @@ var ts;
303
303
  // The following is baselined as a literal template type without intervention
304
304
  /** The version of the TypeScript compiler release */
305
305
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
306
- ts.version = ts.versionMajorMinor + ".0-dev.20220728";
306
+ ts.version = ts.versionMajorMinor + ".0-dev.20220731";
307
307
  /* @internal */
308
308
  var Comparison;
309
309
  (function (Comparison) {
@@ -1904,6 +1904,10 @@ var ts;
1904
1904
  /** Does nothing. */
1905
1905
  function noop(_) { }
1906
1906
  ts.noop = noop;
1907
+ ts.noopPush = {
1908
+ push: noop,
1909
+ length: 0
1910
+ };
1907
1911
  /** Do nothing and return false */
1908
1912
  function returnFalse() {
1909
1913
  return false;
@@ -5912,10 +5916,8 @@ var ts;
5912
5916
  TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
5913
5917
  TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
5914
5918
  TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
5915
- // Please leave this as 1 << 29.
5916
- // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
5917
- // It is a good reminder of how much room we have left
5918
- TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags";
5919
+ TransformFlags[TransformFlags["ContainsPrivateIdentifierInExpression"] = 536870912] = "ContainsPrivateIdentifierInExpression";
5920
+ TransformFlags[TransformFlags["HasComputedFlags"] = -2147483648] = "HasComputedFlags";
5919
5921
  // Assertions
5920
5922
  // - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
5921
5923
  TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript";
@@ -5934,23 +5936,23 @@ var ts;
5934
5936
  // Scope Exclusions
5935
5937
  // - Bitmasks that exclude flags from propagating out of a specific context
5936
5938
  // into the subtree flags of their container.
5937
- TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
5938
- TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
5939
- TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
5940
- TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
5941
- TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
5942
- TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
5943
- TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
5944
- TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
5945
- TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
5946
- TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
5939
+ TransformFlags[TransformFlags["OuterExpressionExcludes"] = -2147483648] = "OuterExpressionExcludes";
5940
+ TransformFlags[TransformFlags["PropertyAccessExcludes"] = -2147483648] = "PropertyAccessExcludes";
5941
+ TransformFlags[TransformFlags["NodeExcludes"] = -2147483648] = "NodeExcludes";
5942
+ TransformFlags[TransformFlags["ArrowFunctionExcludes"] = -2072174592] = "ArrowFunctionExcludes";
5943
+ TransformFlags[TransformFlags["FunctionExcludes"] = -1937940480] = "FunctionExcludes";
5944
+ TransformFlags[TransformFlags["ConstructorExcludes"] = -1937948672] = "ConstructorExcludes";
5945
+ TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = -2005057536] = "MethodOrAccessorExcludes";
5946
+ TransformFlags[TransformFlags["PropertyExcludes"] = -2013249536] = "PropertyExcludes";
5947
+ TransformFlags[TransformFlags["ClassExcludes"] = -2147344384] = "ClassExcludes";
5948
+ TransformFlags[TransformFlags["ModuleExcludes"] = -1941676032] = "ModuleExcludes";
5947
5949
  TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
5948
- TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
5949
- TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
5950
- TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
5951
- TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
5952
- TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
5953
- TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
5950
+ TransformFlags[TransformFlags["ObjectLiteralExcludes"] = -2147278848] = "ObjectLiteralExcludes";
5951
+ TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = -2147450880] = "ArrayLiteralOrCallOrNewExcludes";
5952
+ TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = -2146893824] = "VariableDeclarationListExcludes";
5953
+ TransformFlags[TransformFlags["ParameterExcludes"] = -2147483648] = "ParameterExcludes";
5954
+ TransformFlags[TransformFlags["CatchClauseExcludes"] = -2147418112] = "CatchClauseExcludes";
5955
+ TransformFlags[TransformFlags["BindingPatternExcludes"] = -2147450880] = "BindingPatternExcludes";
5954
5956
  TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
5955
5957
  // Propagating flags
5956
5958
  // - Bitmasks for flags that should propagate from a child
@@ -8985,6 +8987,7 @@ var ts;
8985
8987
  Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."),
8986
8988
  Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."),
8987
8989
  Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."),
8990
+ A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."),
8988
8991
  Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."),
8989
8992
  All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."),
8990
8993
  Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."),
@@ -24288,7 +24291,7 @@ var ts;
24288
24291
  propagateChildFlags(node.expression) |
24289
24292
  (ts.isIdentifier(node.name) ?
24290
24293
  propagateIdentifierNameFlags(node.name) :
24291
- propagateChildFlags(node.name));
24294
+ propagateChildFlags(node.name) | 536870912 /* ContainsPrivateIdentifierInExpression */);
24292
24295
  if (ts.isSuperKeyword(expression)) {
24293
24296
  // super method calls require a lexical 'this'
24294
24297
  // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
@@ -24321,7 +24324,7 @@ var ts;
24321
24324
  propagateChildFlags(node.questionDotToken) |
24322
24325
  (ts.isIdentifier(node.name) ?
24323
24326
  propagateIdentifierNameFlags(node.name) :
24324
- propagateChildFlags(node.name));
24327
+ propagateChildFlags(node.name) | 536870912 /* ContainsPrivateIdentifierInExpression */);
24325
24328
  return node;
24326
24329
  }
24327
24330
  // @api
@@ -24725,6 +24728,9 @@ var ts;
24725
24728
  else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
24726
24729
  node.transformFlags |= 16 /* ContainsES2021 */;
24727
24730
  }
24731
+ if (operatorKind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) {
24732
+ node.transformFlags |= 536870912 /* ContainsPrivateIdentifierInExpression */;
24733
+ }
24728
24734
  return node;
24729
24735
  }
24730
24736
  function propagateAssignmentPatternFlags(node) {
@@ -27679,29 +27685,29 @@ var ts;
27679
27685
  case 208 /* CallExpression */:
27680
27686
  case 209 /* NewExpression */:
27681
27687
  case 204 /* ArrayLiteralExpression */:
27682
- return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
27688
+ return -2147450880 /* ArrayLiteralOrCallOrNewExcludes */;
27683
27689
  case 261 /* ModuleDeclaration */:
27684
- return 742678528 /* ModuleExcludes */;
27690
+ return -1941676032 /* ModuleExcludes */;
27685
27691
  case 164 /* Parameter */:
27686
- return 536870912 /* ParameterExcludes */;
27692
+ return -2147483648 /* ParameterExcludes */;
27687
27693
  case 214 /* ArrowFunction */:
27688
- return 612179968 /* ArrowFunctionExcludes */;
27694
+ return -2072174592 /* ArrowFunctionExcludes */;
27689
27695
  case 213 /* FunctionExpression */:
27690
27696
  case 256 /* FunctionDeclaration */:
27691
- return 746414080 /* FunctionExcludes */;
27697
+ return -1937940480 /* FunctionExcludes */;
27692
27698
  case 255 /* VariableDeclarationList */:
27693
- return 537460736 /* VariableDeclarationListExcludes */;
27699
+ return -2146893824 /* VariableDeclarationListExcludes */;
27694
27700
  case 257 /* ClassDeclaration */:
27695
27701
  case 226 /* ClassExpression */:
27696
- return 537010176 /* ClassExcludes */;
27702
+ return -2147344384 /* ClassExcludes */;
27697
27703
  case 171 /* Constructor */:
27698
- return 746405888 /* ConstructorExcludes */;
27704
+ return -1937948672 /* ConstructorExcludes */;
27699
27705
  case 167 /* PropertyDeclaration */:
27700
- return 671105024 /* PropertyExcludes */;
27706
+ return -2013249536 /* PropertyExcludes */;
27701
27707
  case 169 /* MethodDeclaration */:
27702
27708
  case 172 /* GetAccessor */:
27703
27709
  case 173 /* SetAccessor */:
27704
- return 679297024 /* MethodOrAccessorExcludes */;
27710
+ return -2005057536 /* MethodOrAccessorExcludes */;
27705
27711
  case 130 /* AnyKeyword */:
27706
27712
  case 147 /* NumberKeyword */:
27707
27713
  case 158 /* BigIntKeyword */:
@@ -27721,23 +27727,23 @@ var ts;
27721
27727
  case 259 /* TypeAliasDeclaration */:
27722
27728
  return -2 /* TypeExcludes */;
27723
27729
  case 205 /* ObjectLiteralExpression */:
27724
- return 537075712 /* ObjectLiteralExcludes */;
27730
+ return -2147278848 /* ObjectLiteralExcludes */;
27725
27731
  case 292 /* CatchClause */:
27726
- return 536936448 /* CatchClauseExcludes */;
27732
+ return -2147418112 /* CatchClauseExcludes */;
27727
27733
  case 201 /* ObjectBindingPattern */:
27728
27734
  case 202 /* ArrayBindingPattern */:
27729
- return 536903680 /* BindingPatternExcludes */;
27735
+ return -2147450880 /* BindingPatternExcludes */;
27730
27736
  case 211 /* TypeAssertionExpression */:
27731
27737
  case 229 /* AsExpression */:
27732
27738
  case 350 /* PartiallyEmittedExpression */:
27733
27739
  case 212 /* ParenthesizedExpression */:
27734
27740
  case 106 /* SuperKeyword */:
27735
- return 536870912 /* OuterExpressionExcludes */;
27741
+ return -2147483648 /* OuterExpressionExcludes */;
27736
27742
  case 206 /* PropertyAccessExpression */:
27737
27743
  case 207 /* ElementAccessExpression */:
27738
- return 536870912 /* PropertyAccessExcludes */;
27744
+ return -2147483648 /* PropertyAccessExcludes */;
27739
27745
  default:
27740
- return 536870912 /* NodeExcludes */;
27746
+ return -2147483648 /* NodeExcludes */;
27741
27747
  }
27742
27748
  }
27743
27749
  ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
@@ -43339,18 +43345,7 @@ var ts;
43339
43345
  * Does not try `@types/${packageName}` - use a second pass if needed.
43340
43346
  */
43341
43347
  function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
43342
- var moduleResolutionState = {
43343
- compilerOptions: options,
43344
- host: host,
43345
- traceEnabled: isTraceEnabled(options, host),
43346
- failedLookupLocations: [],
43347
- affectingLocations: [],
43348
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43349
- conditions: ts.emptyArray,
43350
- features: NodeResolutionFeatures.None,
43351
- requestContainingDirectory: containingDirectory,
43352
- reportDiagnostic: ts.noop
43353
- };
43348
+ var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
43354
43349
  return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
43355
43350
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
43356
43351
  var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
@@ -44310,18 +44305,9 @@ var ts;
44310
44305
  var entrypoints;
44311
44306
  var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
44312
44307
  var features = getDefaultNodeResolutionFeatures(options);
44313
- var requireState = {
44314
- compilerOptions: options,
44315
- host: host,
44316
- traceEnabled: isTraceEnabled(options, host),
44317
- failedLookupLocations: [],
44318
- affectingLocations: [],
44319
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
44320
- conditions: ["node", "require", "types"],
44321
- features: features,
44322
- requestContainingDirectory: packageJsonInfo.packageDirectory,
44323
- reportDiagnostic: ts.noop
44324
- };
44308
+ var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
44309
+ requireState.conditions = ["node", "require", "types"];
44310
+ requireState.requestContainingDirectory = packageJsonInfo.packageDirectory;
44325
44311
  var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
44326
44312
  /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
44327
44313
  entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
@@ -44394,23 +44380,27 @@ var ts;
44394
44380
  }
44395
44381
  }
44396
44382
  }
44397
- /**
44398
- * A function for locating the package.json scope for a given path
44399
- */
44400
44383
  /*@internal*/
44401
- function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) {
44402
- var state = {
44384
+ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) {
44385
+ return {
44403
44386
  host: host,
44404
44387
  compilerOptions: options,
44405
44388
  traceEnabled: isTraceEnabled(options, host),
44406
- failedLookupLocations: [],
44407
- affectingLocations: [],
44389
+ failedLookupLocations: ts.noopPush,
44390
+ affectingLocations: ts.noopPush,
44408
44391
  packageJsonInfoCache: packageJsonInfoCache,
44409
- features: 0,
44410
- conditions: [],
44392
+ features: NodeResolutionFeatures.None,
44393
+ conditions: ts.emptyArray,
44411
44394
  requestContainingDirectory: undefined,
44412
44395
  reportDiagnostic: ts.noop
44413
44396
  };
44397
+ }
44398
+ ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
44399
+ /**
44400
+ * A function for locating the package.json scope for a given path
44401
+ */
44402
+ /*@internal*/
44403
+ function getPackageScopeForPath(fileName, state) {
44414
44404
  var parts = ts.getPathComponents(fileName);
44415
44405
  parts.pop();
44416
44406
  while (parts.length > 0) {
@@ -44581,7 +44571,7 @@ var ts;
44581
44571
  var _a, _b;
44582
44572
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
44583
44573
  var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
44584
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
44574
+ var scope = getPackageScopeForPath(directoryPath, state);
44585
44575
  if (!scope || !scope.packageJsonContent.exports) {
44586
44576
  return undefined;
44587
44577
  }
@@ -44640,7 +44630,7 @@ var ts;
44640
44630
  }
44641
44631
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
44642
44632
  var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
44643
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
44633
+ var scope = getPackageScopeForPath(directoryPath, state);
44644
44634
  if (!scope) {
44645
44635
  if (state.traceEnabled) {
44646
44636
  trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
@@ -53100,6 +53090,12 @@ var ts;
53100
53090
  return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
53101
53091
  }
53102
53092
  function typeToTypeNodeHelper(type, context) {
53093
+ var savedFlags = context.flags;
53094
+ var typeNode = typeToTypeNodeWorker(type, context);
53095
+ context.flags = savedFlags;
53096
+ return typeNode;
53097
+ }
53098
+ function typeToTypeNodeWorker(type, context) {
53103
53099
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
53104
53100
  cancellationToken.throwIfCancellationRequested();
53105
53101
  }
@@ -62838,21 +62834,28 @@ var ts;
62838
62834
  getFlowTypeOfReference(accessExpression, propType) :
62839
62835
  propType;
62840
62836
  }
62841
- if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
62837
+ if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) {
62838
+ var index = +propName;
62842
62839
  if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
62843
62840
  var indexNode = getIndexNodeForAccessExpression(accessNode);
62844
62841
  if (isTupleType(objectType)) {
62842
+ if (index < 0) {
62843
+ error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value);
62844
+ return undefinedType;
62845
+ }
62845
62846
  error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
62846
62847
  }
62847
62848
  else {
62848
62849
  error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
62849
62850
  }
62850
62851
  }
62851
- errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
62852
- return mapType(objectType, function (t) {
62853
- var restType = getRestTypeOfTupleType(t) || undefinedType;
62854
- return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType;
62855
- });
62852
+ if (index >= 0) {
62853
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
62854
+ return mapType(objectType, function (t) {
62855
+ var restType = getRestTypeOfTupleType(t) || undefinedType;
62856
+ return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType;
62857
+ });
62858
+ }
62856
62859
  }
62857
62860
  }
62858
62861
  if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) {
@@ -80986,7 +80989,7 @@ var ts;
80986
80989
  error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
80987
80990
  }
80988
80991
  }
80989
- if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
80992
+ if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) {
80990
80993
  error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
80991
80994
  }
80992
80995
  if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
@@ -96791,39 +96794,72 @@ var ts;
96791
96794
  function visitClassDeclaration(node) {
96792
96795
  if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
96793
96796
  return ts.visitEachChild(node, visitor, context);
96794
- var classStatement = ts.hasDecorators(node) ?
96795
- createClassDeclarationHeadWithDecorators(node, node.name) :
96796
- createClassDeclarationHeadWithoutDecorators(node, node.name);
96797
- var statements = [classStatement];
96798
- // Write any decorators of the node.
96799
- addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
96800
- addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
96801
- addConstructorDecorationStatement(statements, node);
96797
+ var statements = ts.hasDecorators(node) ?
96798
+ transformClassDeclarationWithClassDecorators(node, node.name) :
96799
+ transformClassDeclarationWithoutClassDecorators(node, node.name);
96802
96800
  if (statements.length > 1) {
96803
96801
  // Add a DeclarationMarker as a marker for the end of the declaration
96804
96802
  statements.push(factory.createEndOfDeclarationMarker(node));
96805
- ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
96803
+ ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304 /* HasEndOfDeclarationMarker */);
96806
96804
  }
96807
96805
  return ts.singleOrMany(statements);
96808
96806
  }
96807
+ function decoratorContainsPrivateIdentifierInExpression(decorator) {
96808
+ return !!(decorator.transformFlags & 536870912 /* ContainsPrivateIdentifierInExpression */);
96809
+ }
96810
+ function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) {
96811
+ return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression);
96812
+ }
96813
+ function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) {
96814
+ for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
96815
+ var member = _a[_i];
96816
+ if (!ts.canHaveDecorators(member))
96817
+ continue;
96818
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
96819
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression))
96820
+ return true;
96821
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression))
96822
+ return true;
96823
+ }
96824
+ return false;
96825
+ }
96826
+ function transformDecoratorsOfClassElements(node, members) {
96827
+ var decorationStatements = [];
96828
+ addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false);
96829
+ addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true);
96830
+ if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) {
96831
+ members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [
96832
+ factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, /*multiLine*/ true))
96833
+ ], false)), members);
96834
+ decorationStatements = undefined;
96835
+ }
96836
+ return { decorationStatements: decorationStatements, members: members };
96837
+ }
96809
96838
  /**
96810
96839
  * Transforms a non-decorated class declaration.
96811
96840
  *
96812
96841
  * @param node A ClassDeclaration node.
96813
96842
  * @param name The name of the class.
96814
96843
  */
96815
- function createClassDeclarationHeadWithoutDecorators(node, name) {
96844
+ function transformClassDeclarationWithoutClassDecorators(node, name) {
96816
96845
  // ${modifiers} class ${name} ${heritageClauses} {
96817
96846
  // ${members}
96818
96847
  // }
96819
- return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name,
96820
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96848
+ var _a;
96849
+ var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
96850
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96851
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96852
+ var decorationStatements = [];
96853
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
96854
+ var updated = factory.updateClassDeclaration(node, modifiers, name,
96855
+ /*typeParameters*/ undefined, heritageClauses, members);
96856
+ return ts.addRange([updated], decorationStatements);
96821
96857
  }
96822
96858
  /**
96823
96859
  * Transforms a decorated class declaration and appends the resulting statements. If
96824
96860
  * the class requires an alias to avoid issues with double-binding, the alias is returned.
96825
96861
  */
96826
- function createClassDeclarationHeadWithDecorators(node, name) {
96862
+ function transformClassDeclarationWithClassDecorators(node, name) {
96827
96863
  // When we emit an ES6 class that has a class decorator, we must tailor the
96828
96864
  // emit to certain specific cases.
96829
96865
  //
@@ -96909,6 +96945,7 @@ var ts;
96909
96945
  // | var C_1;
96910
96946
  // ---------------------------------------------------------------------
96911
96947
  //
96948
+ var _a;
96912
96949
  var location = ts.moveRangePastModifiers(node);
96913
96950
  var classAlias = getClassAliasIfNeeded(node);
96914
96951
  // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
@@ -96921,7 +96958,11 @@ var ts;
96921
96958
  // }
96922
96959
  var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96923
96960
  var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96924
- var classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
96961
+ var decorationStatements = [];
96962
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
96963
+ var classExpression = factory.createClassExpression(
96964
+ /*modifiers*/ undefined, name,
96965
+ /*typeParameters*/ undefined, heritageClauses, members);
96925
96966
  ts.setOriginalNode(classExpression, node);
96926
96967
  ts.setTextRange(classExpression, location);
96927
96968
  // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
@@ -96935,7 +96976,10 @@ var ts;
96935
96976
  ts.setOriginalNode(statement, node);
96936
96977
  ts.setTextRange(statement, location);
96937
96978
  ts.setCommentRange(statement, node);
96938
- return statement;
96979
+ var statements = [statement];
96980
+ ts.addRange(statements, decorationStatements);
96981
+ addConstructorDecorationStatement(statements, node);
96982
+ return statements;
96939
96983
  }
96940
96984
  function visitClassExpression(node) {
96941
96985
  // Legacy decorators were not supported on class expressions
@@ -117863,7 +117907,7 @@ var ts;
117863
117907
  return undefined;
117864
117908
  }
117865
117909
  function lookupFromPackageJson() {
117866
- var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
117910
+ var scope = ts.getPackageScopeForPath(fileName, ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options));
117867
117911
  return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117868
117912
  }
117869
117913
  }
@@ -149245,6 +149289,7 @@ var ts;
149245
149289
  var options = _a.options, getRules = _a.getRules, host = _a.host;
149246
149290
  // formatting context is used by rules provider
149247
149291
  var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options);
149292
+ var previousRangeTriviaEnd;
149248
149293
  var previousRange;
149249
149294
  var previousParent;
149250
149295
  var previousRangeStartLine;
@@ -149273,10 +149318,30 @@ var ts;
149273
149318
  }
149274
149319
  }
149275
149320
  if (previousRange && formattingScanner.getStartPos() >= originalRange.end) {
149321
+ // Formatting edits happen by looking at pairs of contiguous tokens (see `processPair`),
149322
+ // typically inserting or deleting whitespace between them. The recursive `processNode`
149323
+ // logic above bails out as soon as it encounters a token that is beyond the end of the
149324
+ // range we're supposed to format (or if we reach the end of the file). But this potentially
149325
+ // leaves out an edit that would occur *inside* the requested range but cannot be discovered
149326
+ // without looking at one token *beyond* the end of the range: consider the line `x = { }`
149327
+ // with a selection from the beginning of the line to the space inside the curly braces,
149328
+ // inclusive. We would expect a format-selection would delete the space (if rules apply),
149329
+ // but in order to do that, we need to process the pair ["{", "}"], but we stopped processing
149330
+ // just before getting there. This block handles this trailing edit.
149276
149331
  var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
149277
149332
  formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token :
149278
149333
  undefined;
149279
- if (tokenInfo) {
149334
+ if (tokenInfo && tokenInfo.pos === previousRangeTriviaEnd) {
149335
+ // We need to check that tokenInfo and previousRange are contiguous: the `originalRange`
149336
+ // may have ended in the middle of a token, which means we will have stopped formatting
149337
+ // on that token, leaving `previousRange` pointing to the token before it, but already
149338
+ // having moved the formatting scanner (where we just got `tokenInfo`) to the next token.
149339
+ // If this happens, our supposed pair [previousRange, tokenInfo] actually straddles the
149340
+ // token that intersects the end of the range we're supposed to format, so the pair will
149341
+ // produce bogus edits if we try to `processPair`. Recall that the point of this logic is
149342
+ // to perform a trailing edit at the end of the selection range: but there can be no valid
149343
+ // edit in the middle of a token where the range ended, so if we have a non-contiguous
149344
+ // pair here, we're already done and we can ignore it.
149280
149345
  var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent;
149281
149346
  processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent,
149282
149347
  /*dynamicIndentation*/ undefined);
@@ -149634,6 +149699,7 @@ var ts;
149634
149699
  }
149635
149700
  }
149636
149701
  if (currentTokenInfo.trailingTrivia) {
149702
+ previousRangeTriviaEnd = ts.last(currentTokenInfo.trailingTrivia).end;
149637
149703
  processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation);
149638
149704
  }
149639
149705
  if (indentToken) {
@@ -149704,6 +149770,7 @@ var ts;
149704
149770
  }
149705
149771
  }
149706
149772
  previousRange = range;
149773
+ previousRangeTriviaEnd = range.end;
149707
149774
  previousParent = parent;
149708
149775
  previousRangeStartLine = rangeStart.line;
149709
149776
  return lineAction;
@@ -178634,7 +178701,7 @@ var ts;
178634
178701
  var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex);
178635
178702
  var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache();
178636
178703
  var compilerOptions = project.getCompilationSettings();
178637
- var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions);
178704
+ var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), ts.getTemporaryModuleResolutionState(packageJsonCache, project, compilerOptions));
178638
178705
  if (!packageJson)
178639
178706
  return undefined;
178640
178707
  // Use fake options instead of actual compiler options to avoid following export map if the project uses node16 or nodenext -