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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220728";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220731";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -1690,6 +1690,10 @@ var ts;
1690
1690
  /** Does nothing. */
1691
1691
  function noop(_) { }
1692
1692
  ts.noop = noop;
1693
+ ts.noopPush = {
1694
+ push: noop,
1695
+ length: 0
1696
+ };
1693
1697
  /** Do nothing and return false */
1694
1698
  function returnFalse() {
1695
1699
  return false;
@@ -5698,10 +5702,8 @@ var ts;
5698
5702
  TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
5699
5703
  TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
5700
5704
  TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
5701
- // Please leave this as 1 << 29.
5702
- // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
5703
- // It is a good reminder of how much room we have left
5704
- TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags";
5705
+ TransformFlags[TransformFlags["ContainsPrivateIdentifierInExpression"] = 536870912] = "ContainsPrivateIdentifierInExpression";
5706
+ TransformFlags[TransformFlags["HasComputedFlags"] = -2147483648] = "HasComputedFlags";
5705
5707
  // Assertions
5706
5708
  // - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
5707
5709
  TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript";
@@ -5720,23 +5722,23 @@ var ts;
5720
5722
  // Scope Exclusions
5721
5723
  // - Bitmasks that exclude flags from propagating out of a specific context
5722
5724
  // into the subtree flags of their container.
5723
- TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
5724
- TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
5725
- TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
5726
- TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
5727
- TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
5728
- TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
5729
- TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
5730
- TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
5731
- TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
5732
- TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
5725
+ TransformFlags[TransformFlags["OuterExpressionExcludes"] = -2147483648] = "OuterExpressionExcludes";
5726
+ TransformFlags[TransformFlags["PropertyAccessExcludes"] = -2147483648] = "PropertyAccessExcludes";
5727
+ TransformFlags[TransformFlags["NodeExcludes"] = -2147483648] = "NodeExcludes";
5728
+ TransformFlags[TransformFlags["ArrowFunctionExcludes"] = -2072174592] = "ArrowFunctionExcludes";
5729
+ TransformFlags[TransformFlags["FunctionExcludes"] = -1937940480] = "FunctionExcludes";
5730
+ TransformFlags[TransformFlags["ConstructorExcludes"] = -1937948672] = "ConstructorExcludes";
5731
+ TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = -2005057536] = "MethodOrAccessorExcludes";
5732
+ TransformFlags[TransformFlags["PropertyExcludes"] = -2013249536] = "PropertyExcludes";
5733
+ TransformFlags[TransformFlags["ClassExcludes"] = -2147344384] = "ClassExcludes";
5734
+ TransformFlags[TransformFlags["ModuleExcludes"] = -1941676032] = "ModuleExcludes";
5733
5735
  TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
5734
- TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
5735
- TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
5736
- TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
5737
- TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
5738
- TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
5739
- TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
5736
+ TransformFlags[TransformFlags["ObjectLiteralExcludes"] = -2147278848] = "ObjectLiteralExcludes";
5737
+ TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = -2147450880] = "ArrayLiteralOrCallOrNewExcludes";
5738
+ TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = -2146893824] = "VariableDeclarationListExcludes";
5739
+ TransformFlags[TransformFlags["ParameterExcludes"] = -2147483648] = "ParameterExcludes";
5740
+ TransformFlags[TransformFlags["CatchClauseExcludes"] = -2147418112] = "CatchClauseExcludes";
5741
+ TransformFlags[TransformFlags["BindingPatternExcludes"] = -2147450880] = "BindingPatternExcludes";
5740
5742
  TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
5741
5743
  // Propagating flags
5742
5744
  // - Bitmasks for flags that should propagate from a child
@@ -8771,6 +8773,7 @@ var ts;
8771
8773
  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."),
8772
8774
  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."),
8773
8775
  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."),
8776
+ 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."),
8774
8777
  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}'."),
8775
8778
  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."),
8776
8779
  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."),
@@ -24074,7 +24077,7 @@ var ts;
24074
24077
  propagateChildFlags(node.expression) |
24075
24078
  (ts.isIdentifier(node.name) ?
24076
24079
  propagateIdentifierNameFlags(node.name) :
24077
- propagateChildFlags(node.name));
24080
+ propagateChildFlags(node.name) | 536870912 /* ContainsPrivateIdentifierInExpression */);
24078
24081
  if (ts.isSuperKeyword(expression)) {
24079
24082
  // super method calls require a lexical 'this'
24080
24083
  // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
@@ -24107,7 +24110,7 @@ var ts;
24107
24110
  propagateChildFlags(node.questionDotToken) |
24108
24111
  (ts.isIdentifier(node.name) ?
24109
24112
  propagateIdentifierNameFlags(node.name) :
24110
- propagateChildFlags(node.name));
24113
+ propagateChildFlags(node.name) | 536870912 /* ContainsPrivateIdentifierInExpression */);
24111
24114
  return node;
24112
24115
  }
24113
24116
  // @api
@@ -24511,6 +24514,9 @@ var ts;
24511
24514
  else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
24512
24515
  node.transformFlags |= 16 /* ContainsES2021 */;
24513
24516
  }
24517
+ if (operatorKind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) {
24518
+ node.transformFlags |= 536870912 /* ContainsPrivateIdentifierInExpression */;
24519
+ }
24514
24520
  return node;
24515
24521
  }
24516
24522
  function propagateAssignmentPatternFlags(node) {
@@ -27465,29 +27471,29 @@ var ts;
27465
27471
  case 208 /* CallExpression */:
27466
27472
  case 209 /* NewExpression */:
27467
27473
  case 204 /* ArrayLiteralExpression */:
27468
- return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
27474
+ return -2147450880 /* ArrayLiteralOrCallOrNewExcludes */;
27469
27475
  case 261 /* ModuleDeclaration */:
27470
- return 742678528 /* ModuleExcludes */;
27476
+ return -1941676032 /* ModuleExcludes */;
27471
27477
  case 164 /* Parameter */:
27472
- return 536870912 /* ParameterExcludes */;
27478
+ return -2147483648 /* ParameterExcludes */;
27473
27479
  case 214 /* ArrowFunction */:
27474
- return 612179968 /* ArrowFunctionExcludes */;
27480
+ return -2072174592 /* ArrowFunctionExcludes */;
27475
27481
  case 213 /* FunctionExpression */:
27476
27482
  case 256 /* FunctionDeclaration */:
27477
- return 746414080 /* FunctionExcludes */;
27483
+ return -1937940480 /* FunctionExcludes */;
27478
27484
  case 255 /* VariableDeclarationList */:
27479
- return 537460736 /* VariableDeclarationListExcludes */;
27485
+ return -2146893824 /* VariableDeclarationListExcludes */;
27480
27486
  case 257 /* ClassDeclaration */:
27481
27487
  case 226 /* ClassExpression */:
27482
- return 537010176 /* ClassExcludes */;
27488
+ return -2147344384 /* ClassExcludes */;
27483
27489
  case 171 /* Constructor */:
27484
- return 746405888 /* ConstructorExcludes */;
27490
+ return -1937948672 /* ConstructorExcludes */;
27485
27491
  case 167 /* PropertyDeclaration */:
27486
- return 671105024 /* PropertyExcludes */;
27492
+ return -2013249536 /* PropertyExcludes */;
27487
27493
  case 169 /* MethodDeclaration */:
27488
27494
  case 172 /* GetAccessor */:
27489
27495
  case 173 /* SetAccessor */:
27490
- return 679297024 /* MethodOrAccessorExcludes */;
27496
+ return -2005057536 /* MethodOrAccessorExcludes */;
27491
27497
  case 130 /* AnyKeyword */:
27492
27498
  case 147 /* NumberKeyword */:
27493
27499
  case 158 /* BigIntKeyword */:
@@ -27507,23 +27513,23 @@ var ts;
27507
27513
  case 259 /* TypeAliasDeclaration */:
27508
27514
  return -2 /* TypeExcludes */;
27509
27515
  case 205 /* ObjectLiteralExpression */:
27510
- return 537075712 /* ObjectLiteralExcludes */;
27516
+ return -2147278848 /* ObjectLiteralExcludes */;
27511
27517
  case 292 /* CatchClause */:
27512
- return 536936448 /* CatchClauseExcludes */;
27518
+ return -2147418112 /* CatchClauseExcludes */;
27513
27519
  case 201 /* ObjectBindingPattern */:
27514
27520
  case 202 /* ArrayBindingPattern */:
27515
- return 536903680 /* BindingPatternExcludes */;
27521
+ return -2147450880 /* BindingPatternExcludes */;
27516
27522
  case 211 /* TypeAssertionExpression */:
27517
27523
  case 229 /* AsExpression */:
27518
27524
  case 350 /* PartiallyEmittedExpression */:
27519
27525
  case 212 /* ParenthesizedExpression */:
27520
27526
  case 106 /* SuperKeyword */:
27521
- return 536870912 /* OuterExpressionExcludes */;
27527
+ return -2147483648 /* OuterExpressionExcludes */;
27522
27528
  case 206 /* PropertyAccessExpression */:
27523
27529
  case 207 /* ElementAccessExpression */:
27524
- return 536870912 /* PropertyAccessExcludes */;
27530
+ return -2147483648 /* PropertyAccessExcludes */;
27525
27531
  default:
27526
- return 536870912 /* NodeExcludes */;
27532
+ return -2147483648 /* NodeExcludes */;
27527
27533
  }
27528
27534
  }
27529
27535
  ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
@@ -43125,18 +43131,7 @@ var ts;
43125
43131
  * Does not try `@types/${packageName}` - use a second pass if needed.
43126
43132
  */
43127
43133
  function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
43128
- var moduleResolutionState = {
43129
- compilerOptions: options,
43130
- host: host,
43131
- traceEnabled: isTraceEnabled(options, host),
43132
- failedLookupLocations: [],
43133
- affectingLocations: [],
43134
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43135
- conditions: ts.emptyArray,
43136
- features: NodeResolutionFeatures.None,
43137
- requestContainingDirectory: containingDirectory,
43138
- reportDiagnostic: ts.noop
43139
- };
43134
+ var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
43140
43135
  return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
43141
43136
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
43142
43137
  var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
@@ -44096,18 +44091,9 @@ var ts;
44096
44091
  var entrypoints;
44097
44092
  var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
44098
44093
  var features = getDefaultNodeResolutionFeatures(options);
44099
- var requireState = {
44100
- compilerOptions: options,
44101
- host: host,
44102
- traceEnabled: isTraceEnabled(options, host),
44103
- failedLookupLocations: [],
44104
- affectingLocations: [],
44105
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
44106
- conditions: ["node", "require", "types"],
44107
- features: features,
44108
- requestContainingDirectory: packageJsonInfo.packageDirectory,
44109
- reportDiagnostic: ts.noop
44110
- };
44094
+ var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
44095
+ requireState.conditions = ["node", "require", "types"];
44096
+ requireState.requestContainingDirectory = packageJsonInfo.packageDirectory;
44111
44097
  var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
44112
44098
  /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
44113
44099
  entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
@@ -44180,23 +44166,27 @@ var ts;
44180
44166
  }
44181
44167
  }
44182
44168
  }
44183
- /**
44184
- * A function for locating the package.json scope for a given path
44185
- */
44186
44169
  /*@internal*/
44187
- function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) {
44188
- var state = {
44170
+ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) {
44171
+ return {
44189
44172
  host: host,
44190
44173
  compilerOptions: options,
44191
44174
  traceEnabled: isTraceEnabled(options, host),
44192
- failedLookupLocations: [],
44193
- affectingLocations: [],
44175
+ failedLookupLocations: ts.noopPush,
44176
+ affectingLocations: ts.noopPush,
44194
44177
  packageJsonInfoCache: packageJsonInfoCache,
44195
- features: 0,
44196
- conditions: [],
44178
+ features: NodeResolutionFeatures.None,
44179
+ conditions: ts.emptyArray,
44197
44180
  requestContainingDirectory: undefined,
44198
44181
  reportDiagnostic: ts.noop
44199
44182
  };
44183
+ }
44184
+ ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
44185
+ /**
44186
+ * A function for locating the package.json scope for a given path
44187
+ */
44188
+ /*@internal*/
44189
+ function getPackageScopeForPath(fileName, state) {
44200
44190
  var parts = ts.getPathComponents(fileName);
44201
44191
  parts.pop();
44202
44192
  while (parts.length > 0) {
@@ -44367,7 +44357,7 @@ var ts;
44367
44357
  var _a, _b;
44368
44358
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
44369
44359
  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));
44370
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
44360
+ var scope = getPackageScopeForPath(directoryPath, state);
44371
44361
  if (!scope || !scope.packageJsonContent.exports) {
44372
44362
  return undefined;
44373
44363
  }
@@ -44426,7 +44416,7 @@ var ts;
44426
44416
  }
44427
44417
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
44428
44418
  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));
44429
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
44419
+ var scope = getPackageScopeForPath(directoryPath, state);
44430
44420
  if (!scope) {
44431
44421
  if (state.traceEnabled) {
44432
44422
  trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
@@ -52886,6 +52876,12 @@ var ts;
52886
52876
  return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
52887
52877
  }
52888
52878
  function typeToTypeNodeHelper(type, context) {
52879
+ var savedFlags = context.flags;
52880
+ var typeNode = typeToTypeNodeWorker(type, context);
52881
+ context.flags = savedFlags;
52882
+ return typeNode;
52883
+ }
52884
+ function typeToTypeNodeWorker(type, context) {
52889
52885
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
52890
52886
  cancellationToken.throwIfCancellationRequested();
52891
52887
  }
@@ -62624,21 +62620,28 @@ var ts;
62624
62620
  getFlowTypeOfReference(accessExpression, propType) :
62625
62621
  propType;
62626
62622
  }
62627
- if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
62623
+ if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) {
62624
+ var index = +propName;
62628
62625
  if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
62629
62626
  var indexNode = getIndexNodeForAccessExpression(accessNode);
62630
62627
  if (isTupleType(objectType)) {
62628
+ if (index < 0) {
62629
+ error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value);
62630
+ return undefinedType;
62631
+ }
62631
62632
  error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
62632
62633
  }
62633
62634
  else {
62634
62635
  error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
62635
62636
  }
62636
62637
  }
62637
- errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
62638
- return mapType(objectType, function (t) {
62639
- var restType = getRestTypeOfTupleType(t) || undefinedType;
62640
- return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType;
62641
- });
62638
+ if (index >= 0) {
62639
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
62640
+ return mapType(objectType, function (t) {
62641
+ var restType = getRestTypeOfTupleType(t) || undefinedType;
62642
+ return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType;
62643
+ });
62644
+ }
62642
62645
  }
62643
62646
  }
62644
62647
  if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) {
@@ -80772,7 +80775,7 @@ var ts;
80772
80775
  error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
80773
80776
  }
80774
80777
  }
80775
- if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
80778
+ if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) {
80776
80779
  error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
80777
80780
  }
80778
80781
  if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
@@ -96577,39 +96580,72 @@ var ts;
96577
96580
  function visitClassDeclaration(node) {
96578
96581
  if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
96579
96582
  return ts.visitEachChild(node, visitor, context);
96580
- var classStatement = ts.hasDecorators(node) ?
96581
- createClassDeclarationHeadWithDecorators(node, node.name) :
96582
- createClassDeclarationHeadWithoutDecorators(node, node.name);
96583
- var statements = [classStatement];
96584
- // Write any decorators of the node.
96585
- addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
96586
- addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
96587
- addConstructorDecorationStatement(statements, node);
96583
+ var statements = ts.hasDecorators(node) ?
96584
+ transformClassDeclarationWithClassDecorators(node, node.name) :
96585
+ transformClassDeclarationWithoutClassDecorators(node, node.name);
96588
96586
  if (statements.length > 1) {
96589
96587
  // Add a DeclarationMarker as a marker for the end of the declaration
96590
96588
  statements.push(factory.createEndOfDeclarationMarker(node));
96591
- ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
96589
+ ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304 /* HasEndOfDeclarationMarker */);
96592
96590
  }
96593
96591
  return ts.singleOrMany(statements);
96594
96592
  }
96593
+ function decoratorContainsPrivateIdentifierInExpression(decorator) {
96594
+ return !!(decorator.transformFlags & 536870912 /* ContainsPrivateIdentifierInExpression */);
96595
+ }
96596
+ function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) {
96597
+ return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression);
96598
+ }
96599
+ function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) {
96600
+ for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
96601
+ var member = _a[_i];
96602
+ if (!ts.canHaveDecorators(member))
96603
+ continue;
96604
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
96605
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression))
96606
+ return true;
96607
+ if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression))
96608
+ return true;
96609
+ }
96610
+ return false;
96611
+ }
96612
+ function transformDecoratorsOfClassElements(node, members) {
96613
+ var decorationStatements = [];
96614
+ addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false);
96615
+ addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true);
96616
+ if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) {
96617
+ members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [
96618
+ factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, /*multiLine*/ true))
96619
+ ], false)), members);
96620
+ decorationStatements = undefined;
96621
+ }
96622
+ return { decorationStatements: decorationStatements, members: members };
96623
+ }
96595
96624
  /**
96596
96625
  * Transforms a non-decorated class declaration.
96597
96626
  *
96598
96627
  * @param node A ClassDeclaration node.
96599
96628
  * @param name The name of the class.
96600
96629
  */
96601
- function createClassDeclarationHeadWithoutDecorators(node, name) {
96630
+ function transformClassDeclarationWithoutClassDecorators(node, name) {
96602
96631
  // ${modifiers} class ${name} ${heritageClauses} {
96603
96632
  // ${members}
96604
96633
  // }
96605
- return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name,
96606
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96634
+ var _a;
96635
+ var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
96636
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96637
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96638
+ var decorationStatements = [];
96639
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
96640
+ var updated = factory.updateClassDeclaration(node, modifiers, name,
96641
+ /*typeParameters*/ undefined, heritageClauses, members);
96642
+ return ts.addRange([updated], decorationStatements);
96607
96643
  }
96608
96644
  /**
96609
96645
  * Transforms a decorated class declaration and appends the resulting statements. If
96610
96646
  * the class requires an alias to avoid issues with double-binding, the alias is returned.
96611
96647
  */
96612
- function createClassDeclarationHeadWithDecorators(node, name) {
96648
+ function transformClassDeclarationWithClassDecorators(node, name) {
96613
96649
  // When we emit an ES6 class that has a class decorator, we must tailor the
96614
96650
  // emit to certain specific cases.
96615
96651
  //
@@ -96695,6 +96731,7 @@ var ts;
96695
96731
  // | var C_1;
96696
96732
  // ---------------------------------------------------------------------
96697
96733
  //
96734
+ var _a;
96698
96735
  var location = ts.moveRangePastModifiers(node);
96699
96736
  var classAlias = getClassAliasIfNeeded(node);
96700
96737
  // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
@@ -96707,7 +96744,11 @@ var ts;
96707
96744
  // }
96708
96745
  var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96709
96746
  var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96710
- var classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
96747
+ var decorationStatements = [];
96748
+ (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements);
96749
+ var classExpression = factory.createClassExpression(
96750
+ /*modifiers*/ undefined, name,
96751
+ /*typeParameters*/ undefined, heritageClauses, members);
96711
96752
  ts.setOriginalNode(classExpression, node);
96712
96753
  ts.setTextRange(classExpression, location);
96713
96754
  // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
@@ -96721,7 +96762,10 @@ var ts;
96721
96762
  ts.setOriginalNode(statement, node);
96722
96763
  ts.setTextRange(statement, location);
96723
96764
  ts.setCommentRange(statement, node);
96724
- return statement;
96765
+ var statements = [statement];
96766
+ ts.addRange(statements, decorationStatements);
96767
+ addConstructorDecorationStatement(statements, node);
96768
+ return statements;
96725
96769
  }
96726
96770
  function visitClassExpression(node) {
96727
96771
  // Legacy decorators were not supported on class expressions
@@ -117649,7 +117693,7 @@ var ts;
117649
117693
  return undefined;
117650
117694
  }
117651
117695
  function lookupFromPackageJson() {
117652
- var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
117696
+ var scope = ts.getPackageScopeForPath(fileName, ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options));
117653
117697
  return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117654
117698
  }
117655
117699
  }
@@ -94,6 +94,7 @@
94
94
  "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "\"this\" 类型仅在类或接口的非静态成员中可用。",
95
95
  "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "已在“{0}”中定义了 \"tsconfig.json\" 文件。",
96
96
  "A_tuple_member_cannot_be_both_optional_and_rest_5085": "元组成员不能既是可选的又是 rest。",
97
+ "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "不能使用负值为元组类型编制索引。",
97
98
  "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "乘方表达式的左侧不允许出现类型断言表达式。请考虑用括号将表达式括起。",
98
99
  "A_type_literal_property_cannot_have_an_initializer_1247": "类型文字数据不可具有初始化表达式。",
99
100
  "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "仅类型导入可以指定默认导入或命名绑定,但不能同时指定这两者。",
@@ -775,6 +776,7 @@
775
776
  "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "应为标识符。\"{0}\" 是保留字,不能在此处使用。",
776
777
  "Identifier_expected_1003": "应为标识符。",
777
778
  "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "应为标识符。转换 ECMAScript 模块时,\"__esModule\" 保留为导出标记。",
779
+ "Identifier_or_string_literal_expected_1478": "应为标识符或字符串字面量。",
778
780
  "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "如果“{0}”包实际上公开此模块,请考虑发送拉取请求以修正“https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}”",
779
781
  "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "如果“{0}”包实际公开了此模块,请尝试添加包含 `declare module‘{1}';` 的新声明(.d.ts)文件",
780
782
  "Ignore_this_error_message_90019": "忽略此错误信息",
@@ -94,6 +94,7 @@
94
94
  "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "'this' 類型只適用於類別或介面的非靜態成員。",
95
95
  "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "'tsconfig.json' 檔案已定義於: '{0}'。",
96
96
  "A_tuple_member_cannot_be_both_optional_and_rest_5085": "元組成員不能同時為選用及待用。",
97
+ "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "元組類型無法以負值編製索引。",
97
98
  "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "乘冪運算式左邊不允許類型宣告運算式。請考慮以括弧括住運算式。",
98
99
  "A_type_literal_property_cannot_have_an_initializer_1247": "類型常值屬性不得有初始設定式。",
99
100
  "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "僅限類型的匯入可以指定預設匯入或具名繫結,但不能同時指定兩者。",
@@ -775,6 +776,7 @@
775
776
  "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "必須為識別碼。'{0}' 為保留字,此處不可使用。",
776
777
  "Identifier_expected_1003": "必須是識別碼。",
777
778
  "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "必須有識別碼。'__esModule' 已保留為轉換 ECMAScript 模組時匯出的標記。",
779
+ "Identifier_or_string_literal_expected_1478": "需要識別碼或字串常值。",
778
780
  "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "如果「{0}」套件實際上公開了此模組,請考慮傳送提取要求以修改 「https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}」",
779
781
  "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "如果 '{0}' 套件的確公開了此模組,請嘗試新增包含 `declare module '{1}';` 的宣告 (.d.ts) 檔案。",
780
782
  "Ignore_this_error_message_90019": "略過此錯誤訊息",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.8.0-dev.20220728",
5
+ "version": "4.8.0-dev.20220731",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [