typescript 4.7.0-dev.20220405 → 4.7.0-dev.20220415

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.20220405";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220415";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -4404,10 +4404,11 @@ var ts;
4404
4404
  NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext";
4405
4405
  NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext";
4406
4406
  NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext";
4407
- NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError";
4408
- NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile";
4409
- NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError";
4410
- NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData";
4407
+ NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 65536] = "DisallowConditionalTypesContext";
4408
+ NodeFlags[NodeFlags["ThisNodeHasError"] = 131072] = "ThisNodeHasError";
4409
+ NodeFlags[NodeFlags["JavaScriptFile"] = 262144] = "JavaScriptFile";
4410
+ NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 524288] = "ThisNodeOrAnySubNodesHasError";
4411
+ NodeFlags[NodeFlags["HasAggregatedChildData"] = 1048576] = "HasAggregatedChildData";
4411
4412
  // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
4412
4413
  // walking the tree if the flags are not set. However, these flags are just a approximation
4413
4414
  // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
@@ -4417,25 +4418,25 @@ var ts;
4417
4418
  // removal, it is likely that users will add the import anyway.
4418
4419
  // The advantage of this approach is its simplicity. For the case of batch compilation,
4419
4420
  // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
4420
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport";
4421
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta";
4422
- NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc";
4423
- /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient";
4424
- /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement";
4425
- NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile";
4426
- /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 67108864] = "TypeCached";
4427
- /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 134217728] = "Deprecated";
4421
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 2097152] = "PossiblyContainsDynamicImport";
4422
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 4194304] = "PossiblyContainsImportMeta";
4423
+ NodeFlags[NodeFlags["JSDoc"] = 8388608] = "JSDoc";
4424
+ /* @internal */ NodeFlags[NodeFlags["Ambient"] = 16777216] = "Ambient";
4425
+ /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 33554432] = "InWithStatement";
4426
+ NodeFlags[NodeFlags["JsonFile"] = 67108864] = "JsonFile";
4427
+ /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
4428
+ /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
4428
4429
  NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
4429
4430
  NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
4430
4431
  NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
4431
4432
  // Parsing context flags
4432
- NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags";
4433
+ NodeFlags[NodeFlags["ContextFlags"] = 50720768] = "ContextFlags";
4433
4434
  // Exclude these flags when parsing a Type
4434
4435
  NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags";
4435
4436
  // Represents all flags that are potentially set once and
4436
4437
  // never cleared on SourceFiles which get re-used in between incremental parses.
4437
4438
  // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
4438
- /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags";
4439
+ /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 6291456] = "PermanentlySetIncrementalFlags";
4439
4440
  })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {}));
4440
4441
  var ModifierFlags;
4441
4442
  (function (ModifierFlags) {
@@ -4648,7 +4649,6 @@ var ts;
4648
4649
  NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
4649
4650
  NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
4650
4651
  NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
4651
- NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
4652
4652
  // Error handling
4653
4653
  NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
4654
4654
  NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
@@ -8705,6 +8705,7 @@ var ts;
8705
8705
  _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
8706
8706
  Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
8707
8707
  Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."),
8708
+ Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."),
8708
8709
  Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
8709
8710
  A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
8710
8711
  Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
@@ -8877,6 +8878,7 @@ var ts;
8877
8878
  Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
8878
8879
  Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
8879
8880
  Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
8881
+ All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
8880
8882
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
8881
8883
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
8882
8884
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -14291,24 +14293,24 @@ var ts;
14291
14293
  // Returns true if this node contains a parse error anywhere underneath it.
14292
14294
  function containsParseError(node) {
14293
14295
  aggregateChildData(node);
14294
- return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0;
14296
+ return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0;
14295
14297
  }
14296
14298
  ts.containsParseError = containsParseError;
14297
14299
  function aggregateChildData(node) {
14298
- if (!(node.flags & 524288 /* HasAggregatedChildData */)) {
14300
+ if (!(node.flags & 1048576 /* HasAggregatedChildData */)) {
14299
14301
  // A node is considered to contain a parse error if:
14300
14302
  // a) the parser explicitly marked that it had an error
14301
14303
  // b) any of it's children reported that it had an error.
14302
- var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) ||
14304
+ var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) ||
14303
14305
  ts.forEachChild(node, containsParseError);
14304
14306
  // If so, mark ourselves accordingly.
14305
14307
  if (thisNodeOrAnySubNodesHasError) {
14306
- node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */;
14308
+ node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */;
14307
14309
  }
14308
14310
  // Also mark that we've propagated the child information to this node. This way we can
14309
14311
  // always consult the bit directly on this node without needing to check its children
14310
14312
  // again.
14311
- node.flags |= 524288 /* HasAggregatedChildData */;
14313
+ node.flags |= 1048576 /* HasAggregatedChildData */;
14312
14314
  }
14313
14315
  }
14314
14316
  function getSourceFileOfNode(node) {
@@ -14952,6 +14954,10 @@ var ts;
14952
14954
  }
14953
14955
  }
14954
14956
  ts.isAnyImportSyntax = isAnyImportSyntax;
14957
+ function isAnyImportOrBareOrAccessedRequire(node) {
14958
+ return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
14959
+ }
14960
+ ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
14955
14961
  function isLateVisibilityPaintedStatement(node) {
14956
14962
  switch (node.kind) {
14957
14963
  case 266 /* ImportDeclaration */:
@@ -16115,11 +16121,11 @@ var ts;
16115
16121
  }
16116
16122
  ts.isSourceFileNotJS = isSourceFileNotJS;
16117
16123
  function isInJSFile(node) {
16118
- return !!node && !!(node.flags & 131072 /* JavaScriptFile */);
16124
+ return !!node && !!(node.flags & 262144 /* JavaScriptFile */);
16119
16125
  }
16120
16126
  ts.isInJSFile = isInJSFile;
16121
16127
  function isInJsonFile(node) {
16122
- return !!node && !!(node.flags & 33554432 /* JsonFile */);
16128
+ return !!node && !!(node.flags & 67108864 /* JsonFile */);
16123
16129
  }
16124
16130
  ts.isInJsonFile = isInJsonFile;
16125
16131
  function isSourceFileNotJson(file) {
@@ -16127,7 +16133,7 @@ var ts;
16127
16133
  }
16128
16134
  ts.isSourceFileNotJson = isSourceFileNotJson;
16129
16135
  function isInJSDoc(node) {
16130
- return !!node && !!(node.flags & 4194304 /* JSDoc */);
16136
+ return !!node && !!(node.flags & 8388608 /* JSDoc */);
16131
16137
  }
16132
16138
  ts.isInJSDoc = isInJSDoc;
16133
16139
  function isJSDocIndexSignature(node) {
@@ -16312,17 +16318,13 @@ var ts;
16312
16318
  if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
16313
16319
  return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
16314
16320
  }
16315
- if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
16321
+ if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
16316
16322
  (initializer.expression.kind === 108 /* ThisKeyword */ ||
16317
16323
  ts.isIdentifier(initializer.expression) &&
16318
16324
  (initializer.expression.escapedText === "window" ||
16319
16325
  initializer.expression.escapedText === "self" ||
16320
16326
  initializer.expression.escapedText === "global"))) {
16321
- var nameOrArgument = getNameOrArgument(initializer);
16322
- if (ts.isPrivateIdentifier(nameOrArgument)) {
16323
- ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
16324
- }
16325
- return isSameEntityName(name, nameOrArgument);
16327
+ return isSameEntityName(name, getNameOrArgument(initializer));
16326
16328
  }
16327
16329
  if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
16328
16330
  return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
@@ -16513,7 +16515,7 @@ var ts;
16513
16515
  function setValueDeclaration(symbol, node) {
16514
16516
  var valueDeclaration = symbol.valueDeclaration;
16515
16517
  if (!valueDeclaration ||
16516
- !(node.flags & 8388608 /* Ambient */ && !(valueDeclaration.flags & 8388608 /* Ambient */)) &&
16518
+ !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) &&
16517
16519
  (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
16518
16520
  (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
16519
16521
  // other kinds of value declarations take precedence over modules and assignment declarations
@@ -16530,14 +16532,14 @@ var ts;
16530
16532
  }
16531
16533
  ts.isFunctionSymbol = isFunctionSymbol;
16532
16534
  function tryGetModuleSpecifierFromDeclaration(node) {
16533
- var _a, _b, _c;
16535
+ var _a, _b;
16534
16536
  switch (node.kind) {
16535
16537
  case 254 /* VariableDeclaration */:
16536
- return node.initializer.arguments[0].text;
16538
+ return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
16537
16539
  case 266 /* ImportDeclaration */:
16538
- return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text;
16540
+ return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
16539
16541
  case 265 /* ImportEqualsDeclaration */:
16540
- return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text;
16542
+ return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
16541
16543
  default:
16542
16544
  ts.Debug.assertNever(node);
16543
16545
  }
@@ -17052,7 +17054,10 @@ var ts;
17052
17054
  return parent.propertyName === node;
17053
17055
  case 275 /* ExportSpecifier */:
17054
17056
  case 285 /* JsxAttribute */:
17055
- // Any name in an export specifier or JSX Attribute
17057
+ case 279 /* JsxSelfClosingElement */:
17058
+ case 280 /* JsxOpeningElement */:
17059
+ case 281 /* JsxClosingElement */:
17060
+ // Any name in an export specifier or JSX Attribute or Jsx Element
17056
17061
  return true;
17057
17062
  }
17058
17063
  return false;
@@ -17068,21 +17073,28 @@ var ts;
17068
17073
  // export = <EntityNameExpression>
17069
17074
  // export default <EntityNameExpression>
17070
17075
  // module.exports = <EntityNameExpression>
17071
- // {<Identifier>}
17072
- // {name: <EntityNameExpression>}
17076
+ // module.exports.x = <EntityNameExpression>
17077
+ // const x = require("...")
17078
+ // const { x } = require("...")
17079
+ // const x = require("...").y
17080
+ // const { x } = require("...").y
17073
17081
  function isAliasSymbolDeclaration(node) {
17074
- return node.kind === 265 /* ImportEqualsDeclaration */ ||
17082
+ if (node.kind === 265 /* ImportEqualsDeclaration */ ||
17075
17083
  node.kind === 264 /* NamespaceExportDeclaration */ ||
17076
17084
  node.kind === 267 /* ImportClause */ && !!node.name ||
17077
17085
  node.kind === 268 /* NamespaceImport */ ||
17078
17086
  node.kind === 274 /* NamespaceExport */ ||
17079
17087
  node.kind === 270 /* ImportSpecifier */ ||
17080
17088
  node.kind === 275 /* ExportSpecifier */ ||
17081
- node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
17082
- ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17083
- ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) ||
17084
- node.kind === 297 /* ShorthandPropertyAssignment */ ||
17085
- node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer);
17089
+ node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
17090
+ return true;
17091
+ }
17092
+ return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17093
+ ts.isPropertyAccessExpression(node)
17094
+ && ts.isBinaryExpression(node.parent)
17095
+ && node.parent.left === node
17096
+ && node.parent.operatorToken.kind === 63 /* EqualsToken */
17097
+ && isAliasableExpression(node.parent.right));
17086
17098
  }
17087
17099
  ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
17088
17100
  function getAliasDeclarationFromName(node) {
@@ -17093,6 +17105,7 @@ var ts;
17093
17105
  case 275 /* ExportSpecifier */:
17094
17106
  case 271 /* ExportAssignment */:
17095
17107
  case 265 /* ImportEqualsDeclaration */:
17108
+ case 274 /* NamespaceExport */:
17096
17109
  return node.parent;
17097
17110
  case 161 /* QualifiedName */:
17098
17111
  do {
@@ -18919,6 +18932,11 @@ var ts;
18919
18932
  (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
18920
18933
  }
18921
18934
  ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
18935
+ function isRightSideOfAccessExpression(node) {
18936
+ return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
18937
+ || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
18938
+ }
18939
+ ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression;
18922
18940
  function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
18923
18941
  return ts.isQualifiedName(node.parent) && node.parent.right === node
18924
18942
  || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
@@ -19570,6 +19588,41 @@ var ts;
19570
19588
  return expr;
19571
19589
  }
19572
19590
  ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
19591
+ function forEachNameInAccessChainWalkingLeft(name, action) {
19592
+ if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
19593
+ return walkAccessExpression(name.parent);
19594
+ }
19595
+ function walkAccessExpression(access) {
19596
+ if (access.kind === 206 /* PropertyAccessExpression */) {
19597
+ var res = action(access.name);
19598
+ if (res !== undefined) {
19599
+ return res;
19600
+ }
19601
+ }
19602
+ else if (access.kind === 207 /* ElementAccessExpression */) {
19603
+ if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) {
19604
+ var res = action(access.argumentExpression);
19605
+ if (res !== undefined) {
19606
+ return res;
19607
+ }
19608
+ }
19609
+ else {
19610
+ // Chain interrupted by non-static-name access 'x[expr()].y.z'
19611
+ return undefined;
19612
+ }
19613
+ }
19614
+ if (isAccessExpression(access.expression)) {
19615
+ return walkAccessExpression(access.expression);
19616
+ }
19617
+ if (ts.isIdentifier(access.expression)) {
19618
+ // End of chain at Identifier 'x.y.z'
19619
+ return action(access.expression);
19620
+ }
19621
+ // End of chain at non-Identifier 'x().y.z'
19622
+ return undefined;
19623
+ }
19624
+ }
19625
+ ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft;
19573
19626
  function getLeftmostExpression(node, stopAtCallExpressions) {
19574
19627
  while (true) {
19575
19628
  switch (node.kind) {
@@ -20517,6 +20570,7 @@ var ts;
20517
20570
  ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
20518
20571
  var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]];
20519
20572
  var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
20573
+ ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
20520
20574
  function getSupportedExtensions(options, extraFileExtensions) {
20521
20575
  var needJsExtensions = options && getAllowJSCompilerOption(options);
20522
20576
  if (!extraFileExtensions || extraFileExtensions.length === 0) {
@@ -20815,7 +20869,7 @@ var ts;
20815
20869
  }
20816
20870
  ts.pseudoBigIntToString = pseudoBigIntToString;
20817
20871
  function isValidTypeOnlyAliasUseSite(useSite) {
20818
- return !!(useSite.flags & 8388608 /* Ambient */)
20872
+ return !!(useSite.flags & 16777216 /* Ambient */)
20819
20873
  || isPartOfTypeQuery(useSite)
20820
20874
  || isIdentifierInNonEmittingHeritageClause(useSite)
20821
20875
  || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
@@ -21205,6 +21259,11 @@ var ts;
21205
21259
  return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
21206
21260
  }
21207
21261
  ts.getNodeModulePathParts = getNodeModulePathParts;
21262
+ function getParameterTypeNode(parameter) {
21263
+ var _a;
21264
+ return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
21265
+ }
21266
+ ts.getParameterTypeNode = getParameterTypeNode;
21208
21267
  })(ts || (ts = {}));
21209
21268
  /* @internal */
21210
21269
  var ts;
@@ -21268,11 +21327,20 @@ var ts;
21268
21327
  parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
21269
21328
  parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
21270
21329
  parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
21271
- parenthesizeMemberOfConditionalType: parenthesizeMemberOfConditionalType,
21272
- parenthesizeMemberOfElementType: parenthesizeMemberOfElementType,
21273
- parenthesizeElementTypeOfArrayType: parenthesizeElementTypeOfArrayType,
21274
- parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType,
21330
+ parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
21331
+ parenthesizeExtendsTypeOfConditionalType: parenthesizeExtendsTypeOfConditionalType,
21332
+ parenthesizeConstituentTypesOfUnionType: parenthesizeConstituentTypesOfUnionType,
21333
+ parenthesizeConstituentTypeOfUnionType: parenthesizeConstituentTypeOfUnionType,
21334
+ parenthesizeConstituentTypesOfIntersectionType: parenthesizeConstituentTypesOfIntersectionType,
21335
+ parenthesizeConstituentTypeOfIntersectionType: parenthesizeConstituentTypeOfIntersectionType,
21336
+ parenthesizeOperandOfTypeOperator: parenthesizeOperandOfTypeOperator,
21337
+ parenthesizeOperandOfReadonlyTypeOperator: parenthesizeOperandOfReadonlyTypeOperator,
21338
+ parenthesizeNonArrayTypeOfPostfixType: parenthesizeNonArrayTypeOfPostfixType,
21339
+ parenthesizeElementTypesOfTupleType: parenthesizeElementTypesOfTupleType,
21340
+ parenthesizeElementTypeOfTupleType: parenthesizeElementTypeOfTupleType,
21341
+ parenthesizeTypeOfOptionalType: parenthesizeTypeOfOptionalType,
21275
21342
  parenthesizeTypeArguments: parenthesizeTypeArguments,
21343
+ parenthesizeLeadingTypeArgument: parenthesizeLeadingTypeArgument,
21276
21344
  };
21277
21345
  function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
21278
21346
  binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map());
@@ -21584,33 +21652,191 @@ var ts;
21584
21652
  }
21585
21653
  return body;
21586
21654
  }
21587
- function parenthesizeMemberOfConditionalType(member) {
21588
- return member.kind === 189 /* ConditionalType */ ? factory.createParenthesizedType(member) : member;
21655
+ // Type[Extends] :
21656
+ // FunctionOrConstructorType
21657
+ // ConditionalType[?Extends]
21658
+ // ConditionalType[Extends] :
21659
+ // UnionType[?Extends]
21660
+ // [~Extends] UnionType[~Extends] `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
21661
+ //
21662
+ // - The check type (the `UnionType`, above) does not allow function, constructor, or conditional types (they must be parenthesized)
21663
+ // - The extends type (the first `Type`, above) does not allow conditional types (they must be parenthesized). Function and constructor types are fine.
21664
+ // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type
21665
+ function parenthesizeCheckTypeOfConditionalType(checkType) {
21666
+ switch (checkType.kind) {
21667
+ case 179 /* FunctionType */:
21668
+ case 180 /* ConstructorType */:
21669
+ case 189 /* ConditionalType */:
21670
+ return factory.createParenthesizedType(checkType);
21671
+ }
21672
+ return checkType;
21589
21673
  }
21590
- function parenthesizeMemberOfElementType(member) {
21591
- switch (member.kind) {
21674
+ function parenthesizeExtendsTypeOfConditionalType(extendsType) {
21675
+ switch (extendsType.kind) {
21676
+ case 189 /* ConditionalType */:
21677
+ return factory.createParenthesizedType(extendsType);
21678
+ }
21679
+ return extendsType;
21680
+ }
21681
+ // UnionType[Extends] :
21682
+ // `|`? IntersectionType[?Extends]
21683
+ // UnionType[?Extends] `|` IntersectionType[?Extends]
21684
+ //
21685
+ // - A union type constituent has the same precedence as the check type of a conditional type
21686
+ function parenthesizeConstituentTypeOfUnionType(type) {
21687
+ switch (type.kind) {
21688
+ case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened
21689
+ case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
21690
+ return factory.createParenthesizedType(type);
21691
+ }
21692
+ return parenthesizeCheckTypeOfConditionalType(type);
21693
+ }
21694
+ function parenthesizeConstituentTypesOfUnionType(members) {
21695
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfUnionType));
21696
+ }
21697
+ // IntersectionType[Extends] :
21698
+ // `&`? TypeOperator[?Extends]
21699
+ // IntersectionType[?Extends] `&` TypeOperator[?Extends]
21700
+ //
21701
+ // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized)
21702
+ function parenthesizeConstituentTypeOfIntersectionType(type) {
21703
+ switch (type.kind) {
21592
21704
  case 187 /* UnionType */:
21705
+ case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened
21706
+ return factory.createParenthesizedType(type);
21707
+ }
21708
+ return parenthesizeConstituentTypeOfUnionType(type);
21709
+ }
21710
+ function parenthesizeConstituentTypesOfIntersectionType(members) {
21711
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
21712
+ }
21713
+ // TypeOperator[Extends] :
21714
+ // PostfixType
21715
+ // InferType[?Extends]
21716
+ // `keyof` TypeOperator[?Extends]
21717
+ // `unique` TypeOperator[?Extends]
21718
+ // `readonly` TypeOperator[?Extends]
21719
+ //
21720
+ function parenthesizeOperandOfTypeOperator(type) {
21721
+ switch (type.kind) {
21593
21722
  case 188 /* IntersectionType */:
21594
- case 179 /* FunctionType */:
21595
- case 180 /* ConstructorType */:
21596
- return factory.createParenthesizedType(member);
21723
+ return factory.createParenthesizedType(type);
21597
21724
  }
21598
- return parenthesizeMemberOfConditionalType(member);
21725
+ return parenthesizeConstituentTypeOfIntersectionType(type);
21599
21726
  }
21600
- function parenthesizeElementTypeOfArrayType(member) {
21601
- switch (member.kind) {
21602
- case 181 /* TypeQuery */:
21727
+ function parenthesizeOperandOfReadonlyTypeOperator(type) {
21728
+ switch (type.kind) {
21603
21729
  case 193 /* TypeOperator */:
21730
+ return factory.createParenthesizedType(type);
21731
+ }
21732
+ return parenthesizeOperandOfTypeOperator(type);
21733
+ }
21734
+ // PostfixType :
21735
+ // NonArrayType
21736
+ // NonArrayType [no LineTerminator here] `!` // JSDoc
21737
+ // NonArrayType [no LineTerminator here] `?` // JSDoc
21738
+ // IndexedAccessType
21739
+ // ArrayType
21740
+ //
21741
+ // IndexedAccessType :
21742
+ // NonArrayType `[` Type[~Extends] `]`
21743
+ //
21744
+ // ArrayType :
21745
+ // NonArrayType `[` `]`
21746
+ //
21747
+ function parenthesizeNonArrayTypeOfPostfixType(type) {
21748
+ switch (type.kind) {
21604
21749
  case 190 /* InferType */:
21605
- return factory.createParenthesizedType(member);
21750
+ case 193 /* TypeOperator */:
21751
+ case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
21752
+ return factory.createParenthesizedType(type);
21606
21753
  }
21607
- return parenthesizeMemberOfElementType(member);
21754
+ return parenthesizeOperandOfTypeOperator(type);
21608
21755
  }
21609
- function parenthesizeConstituentTypesOfUnionOrIntersectionType(members) {
21610
- return factory.createNodeArray(ts.sameMap(members, parenthesizeMemberOfElementType));
21756
+ // TupleType :
21757
+ // `[` Elision? `]`
21758
+ // `[` NamedTupleElementTypes `]`
21759
+ // `[` NamedTupleElementTypes `,` Elision? `]`
21760
+ // `[` TupleElementTypes `]`
21761
+ // `[` TupleElementTypes `,` Elision? `]`
21762
+ //
21763
+ // NamedTupleElementTypes :
21764
+ // Elision? NamedTupleMember
21765
+ // NamedTupleElementTypes `,` Elision? NamedTupleMember
21766
+ //
21767
+ // NamedTupleMember :
21768
+ // Identifier `?`? `:` Type[~Extends]
21769
+ // `...` Identifier `:` Type[~Extends]
21770
+ //
21771
+ // TupleElementTypes :
21772
+ // Elision? TupleElementType
21773
+ // TupleElementTypes `,` Elision? TupleElementType
21774
+ //
21775
+ // TupleElementType :
21776
+ // Type[~Extends] // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
21777
+ // OptionalType
21778
+ // RestType
21779
+ //
21780
+ // OptionalType :
21781
+ // Type[~Extends] `?` // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
21782
+ //
21783
+ // RestType :
21784
+ // `...` Type[~Extends]
21785
+ //
21786
+ function parenthesizeElementTypesOfTupleType(types) {
21787
+ return factory.createNodeArray(ts.sameMap(types, parenthesizeElementTypeOfTupleType));
21788
+ }
21789
+ function parenthesizeElementTypeOfTupleType(type) {
21790
+ if (hasJSDocPostfixQuestion(type))
21791
+ return factory.createParenthesizedType(type);
21792
+ return type;
21793
+ }
21794
+ function hasJSDocPostfixQuestion(type) {
21795
+ if (ts.isJSDocNullableType(type))
21796
+ return type.postfix;
21797
+ if (ts.isNamedTupleMember(type))
21798
+ return hasJSDocPostfixQuestion(type.type);
21799
+ if (ts.isFunctionTypeNode(type) || ts.isConstructorTypeNode(type) || ts.isTypeOperatorNode(type))
21800
+ return hasJSDocPostfixQuestion(type.type);
21801
+ if (ts.isConditionalTypeNode(type))
21802
+ return hasJSDocPostfixQuestion(type.falseType);
21803
+ if (ts.isUnionTypeNode(type))
21804
+ return hasJSDocPostfixQuestion(ts.last(type.types));
21805
+ if (ts.isIntersectionTypeNode(type))
21806
+ return hasJSDocPostfixQuestion(ts.last(type.types));
21807
+ if (ts.isInferTypeNode(type))
21808
+ return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
21809
+ return false;
21810
+ }
21811
+ function parenthesizeTypeOfOptionalType(type) {
21812
+ if (hasJSDocPostfixQuestion(type))
21813
+ return factory.createParenthesizedType(type);
21814
+ return parenthesizeNonArrayTypeOfPostfixType(type);
21815
+ }
21816
+ // function parenthesizeMemberOfElementType(member: TypeNode): TypeNode {
21817
+ // switch (member.kind) {
21818
+ // case SyntaxKind.UnionType:
21819
+ // case SyntaxKind.IntersectionType:
21820
+ // case SyntaxKind.FunctionType:
21821
+ // case SyntaxKind.ConstructorType:
21822
+ // return factory.createParenthesizedType(member);
21823
+ // }
21824
+ // return parenthesizeMemberOfConditionalType(member);
21825
+ // }
21826
+ // function parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode {
21827
+ // switch (member.kind) {
21828
+ // case SyntaxKind.TypeQuery:
21829
+ // case SyntaxKind.TypeOperator:
21830
+ // case SyntaxKind.InferType:
21831
+ // return factory.createParenthesizedType(member);
21832
+ // }
21833
+ // return parenthesizeMemberOfElementType(member);
21834
+ // }
21835
+ function parenthesizeLeadingTypeArgument(node) {
21836
+ return ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
21611
21837
  }
21612
21838
  function parenthesizeOrdinalTypeArgument(node, i) {
21613
- return i === 0 && ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
21839
+ return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
21614
21840
  }
21615
21841
  function parenthesizeTypeArguments(typeArguments) {
21616
21842
  if (ts.some(typeArguments)) {
@@ -21636,11 +21862,20 @@ var ts;
21636
21862
  parenthesizeExpressionForDisallowedComma: ts.identity,
21637
21863
  parenthesizeExpressionOfExpressionStatement: ts.identity,
21638
21864
  parenthesizeConciseBodyOfArrowFunction: ts.identity,
21639
- parenthesizeMemberOfConditionalType: ts.identity,
21640
- parenthesizeMemberOfElementType: ts.identity,
21641
- parenthesizeElementTypeOfArrayType: ts.identity,
21642
- parenthesizeConstituentTypesOfUnionOrIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21865
+ parenthesizeCheckTypeOfConditionalType: ts.identity,
21866
+ parenthesizeExtendsTypeOfConditionalType: ts.identity,
21867
+ parenthesizeConstituentTypesOfUnionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21868
+ parenthesizeConstituentTypeOfUnionType: ts.identity,
21869
+ parenthesizeConstituentTypesOfIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21870
+ parenthesizeConstituentTypeOfIntersectionType: ts.identity,
21871
+ parenthesizeOperandOfTypeOperator: ts.identity,
21872
+ parenthesizeOperandOfReadonlyTypeOperator: ts.identity,
21873
+ parenthesizeNonArrayTypeOfPostfixType: ts.identity,
21874
+ parenthesizeElementTypesOfTupleType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21875
+ parenthesizeElementTypeOfTupleType: ts.identity,
21876
+ parenthesizeTypeOfOptionalType: ts.identity,
21643
21877
  parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
21878
+ parenthesizeLeadingTypeArgument: ts.identity,
21644
21879
  };
21645
21880
  })(ts || (ts = {}));
21646
21881
  /* @internal */
@@ -21780,6 +22015,8 @@ var ts;
21780
22015
  var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
21781
22016
  var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
21782
22017
  var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
22018
+ var getJSDocPrePostfixUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type, postfix) { return createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix); }; });
22019
+ var getJSDocPrePostfixUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocPrePostfixUnaryTypeWorker(kind, node, type); }; });
21783
22020
  var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
21784
22021
  var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
21785
22022
  var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
@@ -21787,6 +22024,8 @@ var ts;
21787
22024
  var factory = {
21788
22025
  get parenthesizer() { return parenthesizerRules(); },
21789
22026
  get converters() { return converters(); },
22027
+ baseFactory: baseFactory,
22028
+ flags: flags,
21790
22029
  createNodeArray: createNodeArray,
21791
22030
  createNumericLiteral: createNumericLiteral,
21792
22031
  createBigIntLiteral: createBigIntLiteral,
@@ -22062,10 +22301,10 @@ var ts;
22062
22301
  // lazily load factory members for JSDoc types with similar structure
22063
22302
  get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); },
22064
22303
  get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); },
22065
- get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
22066
- get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
22067
- get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
22068
- get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
22304
+ get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
22305
+ get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
22306
+ get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
22307
+ get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
22069
22308
  get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); },
22070
22309
  get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); },
22071
22310
  get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); },
@@ -23181,7 +23420,7 @@ var ts;
23181
23420
  // @api
23182
23421
  function createArrayTypeNode(elementType) {
23183
23422
  var node = createBaseNode(183 /* ArrayType */);
23184
- node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType);
23423
+ node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
23185
23424
  node.transformFlags = 1 /* ContainsTypeScript */;
23186
23425
  return node;
23187
23426
  }
@@ -23194,7 +23433,7 @@ var ts;
23194
23433
  // @api
23195
23434
  function createTupleTypeNode(elements) {
23196
23435
  var node = createBaseNode(184 /* TupleType */);
23197
- node.elements = createNodeArray(elements);
23436
+ node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
23198
23437
  node.transformFlags = 1 /* ContainsTypeScript */;
23199
23438
  return node;
23200
23439
  }
@@ -23226,7 +23465,7 @@ var ts;
23226
23465
  // @api
23227
23466
  function createOptionalTypeNode(type) {
23228
23467
  var node = createBaseNode(185 /* OptionalType */);
23229
- node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type);
23468
+ node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
23230
23469
  node.transformFlags = 1 /* ContainsTypeScript */;
23231
23470
  return node;
23232
23471
  }
@@ -23249,38 +23488,38 @@ var ts;
23249
23488
  ? update(createRestTypeNode(type), node)
23250
23489
  : node;
23251
23490
  }
23252
- function createUnionOrIntersectionTypeNode(kind, types) {
23491
+ function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
23253
23492
  var node = createBaseNode(kind);
23254
- node.types = parenthesizerRules().parenthesizeConstituentTypesOfUnionOrIntersectionType(types);
23493
+ node.types = factory.createNodeArray(parenthesize(types));
23255
23494
  node.transformFlags = 1 /* ContainsTypeScript */;
23256
23495
  return node;
23257
23496
  }
23258
- function updateUnionOrIntersectionTypeNode(node, types) {
23497
+ function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
23259
23498
  return node.types !== types
23260
- ? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
23499
+ ? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node)
23261
23500
  : node;
23262
23501
  }
23263
23502
  // @api
23264
23503
  function createUnionTypeNode(types) {
23265
- return createUnionOrIntersectionTypeNode(187 /* UnionType */, types);
23504
+ return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
23266
23505
  }
23267
23506
  // @api
23268
23507
  function updateUnionTypeNode(node, types) {
23269
- return updateUnionOrIntersectionTypeNode(node, types);
23508
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
23270
23509
  }
23271
23510
  // @api
23272
23511
  function createIntersectionTypeNode(types) {
23273
- return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types);
23512
+ return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
23274
23513
  }
23275
23514
  // @api
23276
23515
  function updateIntersectionTypeNode(node, types) {
23277
- return updateUnionOrIntersectionTypeNode(node, types);
23516
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
23278
23517
  }
23279
23518
  // @api
23280
23519
  function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
23281
23520
  var node = createBaseNode(189 /* ConditionalType */);
23282
- node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType);
23283
- node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType);
23521
+ node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
23522
+ node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
23284
23523
  node.trueType = trueType;
23285
23524
  node.falseType = falseType;
23286
23525
  node.transformFlags = 1 /* ContainsTypeScript */;
@@ -23375,7 +23614,9 @@ var ts;
23375
23614
  function createTypeOperatorNode(operator, type) {
23376
23615
  var node = createBaseNode(193 /* TypeOperator */);
23377
23616
  node.operator = operator;
23378
- node.type = parenthesizerRules().parenthesizeMemberOfElementType(type);
23617
+ node.type = operator === 145 /* ReadonlyKeyword */ ?
23618
+ parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) :
23619
+ parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
23379
23620
  node.transformFlags = 1 /* ContainsTypeScript */;
23380
23621
  return node;
23381
23622
  }
@@ -23388,7 +23629,7 @@ var ts;
23388
23629
  // @api
23389
23630
  function createIndexedAccessTypeNode(objectType, indexType) {
23390
23631
  var node = createBaseNode(194 /* IndexedAccessType */);
23391
- node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType);
23632
+ node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
23392
23633
  node.indexType = indexType;
23393
23634
  node.transformFlags = 1 /* ContainsTypeScript */;
23394
23635
  return node;
@@ -25124,8 +25365,15 @@ var ts;
25124
25365
  return createBaseNode(kind);
25125
25366
  }
25126
25367
  // @api
25127
- // createJSDocNonNullableType
25128
25368
  // createJSDocNullableType
25369
+ // createJSDocNonNullableType
25370
+ function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix) {
25371
+ if (postfix === void 0) { postfix = false; }
25372
+ var node = createJSDocUnaryTypeWorker(kind, postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type);
25373
+ node.postfix = postfix;
25374
+ return node;
25375
+ }
25376
+ // @api
25129
25377
  // createJSDocOptionalType
25130
25378
  // createJSDocVariadicType
25131
25379
  // createJSDocNamepathType
@@ -25137,6 +25385,12 @@ var ts;
25137
25385
  // @api
25138
25386
  // updateJSDocNonNullableType
25139
25387
  // updateJSDocNullableType
25388
+ function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
25389
+ return node.type !== type
25390
+ ? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node)
25391
+ : node;
25392
+ }
25393
+ // @api
25140
25394
  // updateJSDocOptionalType
25141
25395
  // updateJSDocVariadicType
25142
25396
  // updateJSDocNamepathType
@@ -30217,7 +30471,7 @@ var ts;
30217
30471
  || ts.isExportDeclaration(node) ? node : undefined;
30218
30472
  }
30219
30473
  function getImportMetaIfNecessary(sourceFile) {
30220
- return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
30474
+ return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ?
30221
30475
  walkTreeForImportMeta(sourceFile) :
30222
30476
  undefined;
30223
30477
  }
@@ -30872,7 +31126,7 @@ var ts;
30872
31126
  var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
30873
31127
  // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import.
30874
31128
  // We will manually port the flag to the new source file.
30875
- newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */);
31129
+ newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */);
30876
31130
  return newSourceFile;
30877
31131
  }
30878
31132
  ts.updateSourceFile = updateSourceFile;
@@ -31156,10 +31410,10 @@ var ts;
31156
31410
  switch (scriptKind) {
31157
31411
  case 1 /* JS */:
31158
31412
  case 2 /* JSX */:
31159
- contextFlags = 131072 /* JavaScriptFile */;
31413
+ contextFlags = 262144 /* JavaScriptFile */;
31160
31414
  break;
31161
31415
  case 6 /* JSON */:
31162
- contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */;
31416
+ contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */;
31163
31417
  break;
31164
31418
  default:
31165
31419
  contextFlags = 0 /* None */;
@@ -31194,7 +31448,7 @@ var ts;
31194
31448
  function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
31195
31449
  var isDeclarationFile = isDeclarationFileName(fileName);
31196
31450
  if (isDeclarationFile) {
31197
- contextFlags |= 8388608 /* Ambient */;
31451
+ contextFlags |= 16777216 /* Ambient */;
31198
31452
  }
31199
31453
  sourceFlags = contextFlags;
31200
31454
  // Prime the scanner.
@@ -31233,7 +31487,7 @@ var ts;
31233
31487
  node.jsDoc = jsDoc;
31234
31488
  if (hasDeprecatedTag) {
31235
31489
  hasDeprecatedTag = false;
31236
- node.flags |= 134217728 /* Deprecated */;
31490
+ node.flags |= 268435456 /* Deprecated */;
31237
31491
  }
31238
31492
  return node;
31239
31493
  }
@@ -31428,6 +31682,12 @@ var ts;
31428
31682
  function disallowInAnd(func) {
31429
31683
  return doInsideOfContext(4096 /* DisallowInContext */, func);
31430
31684
  }
31685
+ function allowConditionalTypesAnd(func) {
31686
+ return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
31687
+ }
31688
+ function disallowConditionalTypesAnd(func) {
31689
+ return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
31690
+ }
31431
31691
  function doInYieldContext(func) {
31432
31692
  return doInsideOfContext(8192 /* YieldContext */, func);
31433
31693
  }
@@ -31455,6 +31715,9 @@ var ts;
31455
31715
  function inDisallowInContext() {
31456
31716
  return inContext(4096 /* DisallowInContext */);
31457
31717
  }
31718
+ function inDisallowConditionalTypesContext() {
31719
+ return inContext(65536 /* DisallowConditionalTypesContext */);
31720
+ }
31458
31721
  function inDecoratorContext() {
31459
31722
  return inContext(16384 /* DecoratorContext */);
31460
31723
  }
@@ -31839,7 +32102,7 @@ var ts;
31839
32102
  // flag so that we don't mark any subsequent nodes.
31840
32103
  if (parseErrorBeforeNextFinishedNode) {
31841
32104
  parseErrorBeforeNextFinishedNode = false;
31842
- node.flags |= 65536 /* ThisNodeHasError */;
32105
+ node.flags |= 131072 /* ThisNodeHasError */;
31843
32106
  }
31844
32107
  return node;
31845
32108
  }
@@ -32297,7 +32560,7 @@ var ts;
32297
32560
  // differently depending on what mode it is in.
32298
32561
  //
32299
32562
  // This also applies to all our other context flags as well.
32300
- var nodeContextFlags = node.flags & 25358336 /* ContextFlags */;
32563
+ var nodeContextFlags = node.flags & 50720768 /* ContextFlags */;
32301
32564
  if (nodeContextFlags !== contextFlags) {
32302
32565
  return undefined;
32303
32566
  }
@@ -32822,7 +33085,7 @@ var ts;
32822
33085
  function parseJSDocNonNullableType() {
32823
33086
  var pos = getNodePos();
32824
33087
  nextToken();
32825
- return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
33088
+ return finishNode(factory.createJSDocNonNullableType(parseNonArrayType(), /*postfix*/ false), pos);
32826
33089
  }
32827
33090
  function parseJSDocUnknownOrNullableType() {
32828
33091
  var pos = getNodePos();
@@ -32846,7 +33109,7 @@ var ts;
32846
33109
  return finishNode(factory.createJSDocUnknownType(), pos);
32847
33110
  }
32848
33111
  else {
32849
- return finishNode(factory.createJSDocNullableType(parseType()), pos);
33112
+ return finishNode(factory.createJSDocNullableType(parseType(), /*postfix*/ false), pos);
32850
33113
  }
32851
33114
  }
32852
33115
  function parseJSDocFunctionType() {
@@ -33018,7 +33281,7 @@ var ts;
33018
33281
  }
33019
33282
  function parseReturnType(returnToken, isType) {
33020
33283
  if (shouldParseReturnType(returnToken, isType)) {
33021
- return parseTypeOrTypePredicate();
33284
+ return allowConditionalTypesAnd(parseTypeOrTypePredicate);
33022
33285
  }
33023
33286
  }
33024
33287
  function shouldParseReturnType(returnToken, isType) {
@@ -33433,7 +33696,7 @@ var ts;
33433
33696
  return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
33434
33697
  }
33435
33698
  function parseImportType() {
33436
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
33699
+ sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
33437
33700
  var pos = getNodePos();
33438
33701
  var isTypeOf = parseOptional(112 /* TypeOfKeyword */);
33439
33702
  parseExpected(100 /* ImportKeyword */);
@@ -33583,7 +33846,7 @@ var ts;
33583
33846
  switch (token()) {
33584
33847
  case 53 /* ExclamationToken */:
33585
33848
  nextToken();
33586
- type = finishNode(factory.createJSDocNonNullableType(type), pos);
33849
+ type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos);
33587
33850
  break;
33588
33851
  case 57 /* QuestionToken */:
33589
33852
  // If next token is start of a type we have a conditional type
@@ -33591,7 +33854,7 @@ var ts;
33591
33854
  return type;
33592
33855
  }
33593
33856
  nextToken();
33594
- type = finishNode(factory.createJSDocNullableType(type), pos);
33857
+ type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos);
33595
33858
  break;
33596
33859
  case 22 /* OpenBracketToken */:
33597
33860
  parseExpected(22 /* OpenBracketToken */);
@@ -33616,12 +33879,20 @@ var ts;
33616
33879
  parseExpected(operator);
33617
33880
  return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
33618
33881
  }
33882
+ function tryParseConstraintOfInferType() {
33883
+ if (parseOptional(94 /* ExtendsKeyword */)) {
33884
+ var constraint = disallowConditionalTypesAnd(parseType);
33885
+ if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) {
33886
+ return constraint;
33887
+ }
33888
+ }
33889
+ }
33619
33890
  function parseTypeParameterOfInferType() {
33620
33891
  var pos = getNodePos();
33621
- return finishNode(factory.createTypeParameterDeclaration(
33622
- /*modifiers*/ undefined, parseIdentifier(),
33623
- /*constraint*/ undefined,
33624
- /*defaultType*/ undefined), pos);
33892
+ var name = parseIdentifier();
33893
+ var constraint = tryParse(tryParseConstraintOfInferType);
33894
+ var node = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint);
33895
+ return finishNode(node, pos);
33625
33896
  }
33626
33897
  function parseInferType() {
33627
33898
  var pos = getNodePos();
@@ -33638,7 +33909,7 @@ var ts;
33638
33909
  case 137 /* InferKeyword */:
33639
33910
  return parseInferType();
33640
33911
  }
33641
- return parsePostfixTypeOrHigher();
33912
+ return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
33642
33913
  }
33643
33914
  function parseFunctionOrConstructorTypeToError(isInUnionType) {
33644
33915
  // the function type and constructor type shorthand notation
@@ -33768,23 +34039,21 @@ var ts;
33768
34039
  return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
33769
34040
  }
33770
34041
  function parseType() {
33771
- // The rules about 'yield' only apply to actual code/expression contexts. They don't
33772
- // apply to 'type' contexts. So we disable these parameters here before moving on.
33773
- return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker);
33774
- }
33775
- function parseTypeWorker(noConditionalTypes) {
34042
+ if (contextFlags & 40960 /* TypeExcludesFlags */) {
34043
+ return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType);
34044
+ }
33776
34045
  if (isStartOfFunctionTypeOrConstructorType()) {
33777
34046
  return parseFunctionOrConstructorType();
33778
34047
  }
33779
34048
  var pos = getNodePos();
33780
34049
  var type = parseUnionTypeOrHigher();
33781
- if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
34050
+ if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
33782
34051
  // The type following 'extends' is not permitted to be another conditional type
33783
- var extendsType = parseTypeWorker(/*noConditionalTypes*/ true);
34052
+ var extendsType = disallowConditionalTypesAnd(parseType);
33784
34053
  parseExpected(57 /* QuestionToken */);
33785
- var trueType = parseTypeWorker();
34054
+ var trueType = allowConditionalTypesAnd(parseType);
33786
34055
  parseExpected(58 /* ColonToken */);
33787
- var falseType = parseTypeWorker();
34056
+ var falseType = allowConditionalTypesAnd(parseType);
33788
34057
  return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
33789
34058
  }
33790
34059
  return type;
@@ -34621,7 +34890,7 @@ var ts;
34621
34890
  // var foo3 = require("subfolder
34622
34891
  // import * as foo1 from "module-from-node
34623
34892
  // We want this import to be a statement rather than import call expression
34624
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
34893
+ sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
34625
34894
  expression = parseTokenNode();
34626
34895
  }
34627
34896
  else if (lookAhead(nextTokenIsDot)) {
@@ -34629,7 +34898,7 @@ var ts;
34629
34898
  nextToken(); // advance past the 'import'
34630
34899
  nextToken(); // advance past the dot
34631
34900
  expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos);
34632
- sourceFlags |= 2097152 /* PossiblyContainsImportMeta */;
34901
+ sourceFlags |= 4194304 /* PossiblyContainsImportMeta */;
34633
34902
  }
34634
34903
  else {
34635
34904
  expression = parseMemberExpressionOrHigher();
@@ -34845,7 +35114,7 @@ var ts;
34845
35114
  return finishNode(factory.createJsxOpeningFragment(), pos);
34846
35115
  }
34847
35116
  var tagName = parseJsxElementName();
34848
- var typeArguments = (contextFlags & 131072 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
35117
+ var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
34849
35118
  var attributes = parseJsxAttributes();
34850
35119
  var node;
34851
35120
  if (token() === 31 /* GreaterThanToken */) {
@@ -35123,7 +35392,7 @@ var ts;
35123
35392
  return result;
35124
35393
  }
35125
35394
  function parseTypeArgumentsInExpression() {
35126
- if ((contextFlags & 131072 /* JavaScriptFile */) !== 0) {
35395
+ if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) {
35127
35396
  // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators.
35128
35397
  return undefined;
35129
35398
  }
@@ -35148,34 +35417,10 @@ var ts;
35148
35417
  case 20 /* OpenParenToken */: // foo<x>(
35149
35418
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35150
35419
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35151
- // These tokens can't follow in a call expression, nor can they start an
35152
- // expression. So, consider the type argument list part of an instantiation
35153
- // expression.
35154
- // falls through
35155
- case 27 /* CommaToken */: // foo<x>,
35156
- case 24 /* DotToken */: // foo<x>.
35157
- case 28 /* QuestionDotToken */: // foo<x>?.
35158
- case 21 /* CloseParenToken */: // foo<x>)
35159
- case 23 /* CloseBracketToken */: // foo<x>]
35160
- case 58 /* ColonToken */: // foo<x>:
35161
- case 26 /* SemicolonToken */: // foo<x>;
35162
- case 57 /* QuestionToken */: // foo<x>?
35163
- case 34 /* EqualsEqualsToken */: // foo<x> ==
35164
- case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
35165
- case 35 /* ExclamationEqualsToken */: // foo<x> !=
35166
- case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
35167
- case 55 /* AmpersandAmpersandToken */: // foo<x> &&
35168
- case 56 /* BarBarToken */: // foo<x> ||
35169
- case 60 /* QuestionQuestionToken */: // foo<x> ??
35170
- case 52 /* CaretToken */: // foo<x> ^
35171
- case 50 /* AmpersandToken */: // foo<x> &
35172
- case 51 /* BarToken */: // foo<x> |
35173
- case 19 /* CloseBraceToken */: // foo<x> }
35174
- case 1 /* EndOfFileToken */: // foo<x>
35175
35420
  return true;
35176
35421
  }
35177
- // Treat anything else as an expression.
35178
- return false;
35422
+ // Consider something a type argument list only if the following token can't start an expression.
35423
+ return !isStartOfExpression();
35179
35424
  }
35180
35425
  function parsePrimaryExpression() {
35181
35426
  switch (token()) {
@@ -35519,7 +35764,7 @@ var ts;
35519
35764
  var openParenParsed = parseExpected(20 /* OpenParenToken */);
35520
35765
  var expression = allowInAnd(parseExpression);
35521
35766
  parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35522
- var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
35767
+ var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement);
35523
35768
  return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
35524
35769
  }
35525
35770
  function parseCaseClause() {
@@ -35894,16 +36139,16 @@ var ts;
35894
36139
  if (isAmbient) {
35895
36140
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
35896
36141
  var m = _a[_i];
35897
- m.flags |= 8388608 /* Ambient */;
36142
+ m.flags |= 16777216 /* Ambient */;
35898
36143
  }
35899
- return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
36144
+ return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
35900
36145
  }
35901
36146
  else {
35902
36147
  return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
35903
36148
  }
35904
36149
  }
35905
36150
  function tryReuseAmbientDeclaration() {
35906
- return doInsideOfContext(8388608 /* Ambient */, function () {
36151
+ return doInsideOfContext(16777216 /* Ambient */, function () {
35907
36152
  var node = currentNode(parsingContext);
35908
36153
  if (node) {
35909
36154
  return consumeNode(node);
@@ -36370,9 +36615,9 @@ var ts;
36370
36615
  if (isAmbient) {
36371
36616
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36372
36617
  var m = _a[_i];
36373
- m.flags |= 8388608 /* Ambient */;
36618
+ m.flags |= 16777216 /* Ambient */;
36374
36619
  }
36375
- return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
36620
+ return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
36376
36621
  }
36377
36622
  else {
36378
36623
  return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
@@ -36937,7 +37182,7 @@ var ts;
36937
37182
  function parseJSDocTypeExpression(mayOmitBraces) {
36938
37183
  var pos = getNodePos();
36939
37184
  var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */);
36940
- var type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
37185
+ var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
36941
37186
  if (!mayOmitBraces || hasBrace) {
36942
37187
  parseExpectedJSDoc(19 /* CloseBraceToken */);
36943
37188
  }
@@ -36966,7 +37211,7 @@ var ts;
36966
37211
  JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
36967
37212
  function parseIsolatedJSDocComment(content, start, length) {
36968
37213
  initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
36969
- var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37214
+ var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
36970
37215
  var sourceFile = { languageVariant: 0 /* Standard */, text: content };
36971
37216
  var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
36972
37217
  clearState();
@@ -36977,9 +37222,9 @@ var ts;
36977
37222
  var saveToken = currentToken;
36978
37223
  var saveParseDiagnosticsLength = parseDiagnostics.length;
36979
37224
  var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
36980
- var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37225
+ var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
36981
37226
  ts.setParent(comment, parent);
36982
- if (contextFlags & 131072 /* JavaScriptFile */) {
37227
+ if (contextFlags & 262144 /* JavaScriptFile */) {
36983
37228
  if (!jsDocDiagnostics) {
36984
37229
  jsDocDiagnostics = [];
36985
37230
  }
@@ -37795,7 +38040,7 @@ var ts;
37795
38040
  if (isBracketed) {
37796
38041
  skipWhitespace();
37797
38042
  parseExpected(63 /* EqualsToken */);
37798
- defaultType = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
38043
+ defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
37799
38044
  parseExpected(23 /* CloseBracketToken */);
37800
38045
  }
37801
38046
  if (ts.nodeIsMissing(name)) {
@@ -38393,7 +38638,7 @@ var ts;
38393
38638
  })(IncrementalParser || (IncrementalParser = {}));
38394
38639
  /** @internal */
38395
38640
  function isDeclarationFileName(fileName) {
38396
- return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
38641
+ return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
38397
38642
  }
38398
38643
  ts.isDeclarationFileName = isDeclarationFileName;
38399
38644
  function parseResolutionMode(mode, pos, end, reportDiagnostic) {
@@ -41901,7 +42146,8 @@ var ts;
41901
42146
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
41902
42147
  Extensions[Extensions["Json"] = 2] = "Json";
41903
42148
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
41904
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
42149
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
42150
+ Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
41905
42151
  })(Extensions || (Extensions = {}));
41906
42152
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
41907
42153
  function resolvedTypeScriptOnly(resolved) {
@@ -42846,7 +43092,21 @@ var ts;
42846
43092
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
42847
43093
  }
42848
43094
  function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
42849
- return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
43095
+ var extensions;
43096
+ if (lookupConfig) {
43097
+ extensions = tsconfigExtensions;
43098
+ }
43099
+ else if (compilerOptions.noDtsResolution) {
43100
+ extensions = [Extensions.TsOnly];
43101
+ if (compilerOptions.allowJs)
43102
+ extensions.push(Extensions.JavaScript);
43103
+ if (compilerOptions.resolveJsonModule)
43104
+ extensions.push(Extensions.Json);
43105
+ }
43106
+ else {
43107
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
43108
+ }
43109
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
42850
43110
  }
42851
43111
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
42852
43112
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -42855,6 +43115,10 @@ var ts;
42855
43115
  var failedLookupLocations = [];
42856
43116
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
42857
43117
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43118
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
43119
+ if (compilerOptions.noDtsResolution) {
43120
+ conditions.pop();
43121
+ }
42858
43122
  var state = {
42859
43123
  compilerOptions: compilerOptions,
42860
43124
  host: host,
@@ -42862,7 +43126,7 @@ var ts;
42862
43126
  failedLookupLocations: failedLookupLocations,
42863
43127
  packageJsonInfoCache: cache,
42864
43128
  features: features,
42865
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
43129
+ conditions: conditions,
42866
43130
  };
42867
43131
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
42868
43132
  return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
@@ -43038,9 +43302,9 @@ var ts;
43038
43302
  }
43039
43303
  }
43040
43304
  function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
43041
- if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) {
43305
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
43042
43306
  var result = tryFile(candidate, onlyRecordFailures, state);
43043
- return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43307
+ return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43044
43308
  }
43045
43309
  return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
43046
43310
  }
@@ -43070,20 +43334,22 @@ var ts;
43070
43334
  default: return tryExtension(".d.ts" /* Dts */);
43071
43335
  }
43072
43336
  case Extensions.TypeScript:
43337
+ case Extensions.TsOnly:
43338
+ var useDts = extensions === Extensions.TypeScript;
43073
43339
  switch (originalExtension) {
43074
43340
  case ".mjs" /* Mjs */:
43075
43341
  case ".mts" /* Mts */:
43076
43342
  case ".d.mts" /* Dmts */:
43077
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43343
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
43078
43344
  case ".cjs" /* Cjs */:
43079
43345
  case ".cts" /* Cts */:
43080
43346
  case ".d.cts" /* Dcts */:
43081
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43347
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
43082
43348
  case ".json" /* Json */:
43083
43349
  candidate += ".json" /* Json */;
43084
- return tryExtension(".d.ts" /* Dts */);
43350
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
43085
43351
  default:
43086
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
43352
+ return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
43087
43353
  }
43088
43354
  case Extensions.JavaScript:
43089
43355
  switch (originalExtension) {
@@ -43310,6 +43576,7 @@ var ts;
43310
43576
  switch (extensions) {
43311
43577
  case Extensions.JavaScript:
43312
43578
  case Extensions.Json:
43579
+ case Extensions.TsOnly:
43313
43580
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43314
43581
  break;
43315
43582
  case Extensions.TypeScript:
@@ -43382,14 +43649,16 @@ var ts;
43382
43649
  function extensionIsOk(extensions, extension) {
43383
43650
  switch (extensions) {
43384
43651
  case Extensions.JavaScript:
43385
- return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
43652
+ return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
43386
43653
  case Extensions.TSConfig:
43387
43654
  case Extensions.Json:
43388
43655
  return extension === ".json" /* Json */;
43389
43656
  case Extensions.TypeScript:
43390
- return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43657
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
43658
+ case Extensions.TsOnly:
43659
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
43391
43660
  case Extensions.DtsOnly:
43392
- return extension === ".d.ts" /* Dts */;
43661
+ return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
43393
43662
  }
43394
43663
  }
43395
43664
  /* @internal */
@@ -45549,6 +45818,7 @@ var ts;
45549
45818
  case 261 /* ModuleDeclaration */:
45550
45819
  case 259 /* TypeAliasDeclaration */:
45551
45820
  case 195 /* MappedType */:
45821
+ case 176 /* IndexSignature */:
45552
45822
  return 1 /* IsContainer */ | 32 /* HasLocals */;
45553
45823
  case 305 /* SourceFile */:
45554
45824
  return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
@@ -45567,7 +45837,6 @@ var ts;
45567
45837
  case 317 /* JSDocFunctionType */:
45568
45838
  case 179 /* FunctionType */:
45569
45839
  case 175 /* ConstructSignature */:
45570
- case 176 /* IndexSignature */:
45571
45840
  case 180 /* ConstructorType */:
45572
45841
  case 170 /* ClassStaticBlockDeclaration */:
45573
45842
  return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
@@ -45683,7 +45952,7 @@ var ts;
45683
45952
  function setExportContextFlag(node) {
45684
45953
  // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
45685
45954
  // declarations with export modifiers) is an export context in which declarations are implicitly exported.
45686
- if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) {
45955
+ if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) {
45687
45956
  node.flags |= 64 /* ExportContext */;
45688
45957
  }
45689
45958
  else {
@@ -45886,8 +46155,8 @@ var ts;
45886
46155
  function checkContextualIdentifier(node) {
45887
46156
  // Report error only if there are no parse errors in file
45888
46157
  if (!file.parseDiagnostics.length &&
45889
- !(node.flags & 8388608 /* Ambient */) &&
45890
- !(node.flags & 4194304 /* JSDoc */) &&
46158
+ !(node.flags & 16777216 /* Ambient */) &&
46159
+ !(node.flags & 8388608 /* JSDoc */) &&
45891
46160
  !ts.isIdentifierName(node)) {
45892
46161
  // strict mode identifiers
45893
46162
  if (inStrictMode &&
@@ -46916,7 +47185,7 @@ var ts;
46916
47185
  if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) {
46917
47186
  return;
46918
47187
  }
46919
- if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) {
47188
+ if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) {
46920
47189
  // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
46921
47190
  // strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
46922
47191
  checkStrictModeEvalOrArguments(node, node.name);
@@ -46935,7 +47204,7 @@ var ts;
46935
47204
  }
46936
47205
  }
46937
47206
  function bindFunctionDeclaration(node) {
46938
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
47207
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
46939
47208
  if (ts.isAsyncFunction(node)) {
46940
47209
  emitFlags |= 2048 /* HasAsyncFunctions */;
46941
47210
  }
@@ -46950,7 +47219,7 @@ var ts;
46950
47219
  }
46951
47220
  }
46952
47221
  function bindFunctionExpression(node) {
46953
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
47222
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
46954
47223
  if (ts.isAsyncFunction(node)) {
46955
47224
  emitFlags |= 2048 /* HasAsyncFunctions */;
46956
47225
  }
@@ -46963,7 +47232,7 @@ var ts;
46963
47232
  return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
46964
47233
  }
46965
47234
  function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
46966
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) {
47235
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) {
46967
47236
  emitFlags |= 2048 /* HasAsyncFunctions */;
46968
47237
  }
46969
47238
  if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
@@ -47036,7 +47305,7 @@ var ts;
47036
47305
  // Rationale: we don't want to report errors on non-initialized var's since they are hoisted
47037
47306
  // On the other side we do want to report errors on non-initialized 'lets' because of TDZ
47038
47307
  var isError_1 = ts.unreachableCodeIsError(options) &&
47039
- !(node.flags & 8388608 /* Ambient */) &&
47308
+ !(node.flags & 16777216 /* Ambient */) &&
47040
47309
  (!ts.isVariableStatement(node) ||
47041
47310
  !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) ||
47042
47311
  node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
@@ -47936,7 +48205,7 @@ var ts;
47936
48205
  ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
47937
48206
  diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
47938
48207
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
47939
- if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
48208
+ if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
47940
48209
  (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
47941
48210
  }
47942
48211
  });
@@ -48387,7 +48656,7 @@ var ts;
48387
48656
  return diagnostic;
48388
48657
  }
48389
48658
  function isDeprecatedSymbol(symbol) {
48390
- return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
48659
+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
48391
48660
  }
48392
48661
  function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
48393
48662
  var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
@@ -48615,7 +48884,7 @@ var ts;
48615
48884
  else {
48616
48885
  // find a module that about to be augmented
48617
48886
  // do not validate names of augmentations that are defined in ambient context
48618
- var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */)
48887
+ var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */)
48619
48888
  ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
48620
48889
  : undefined;
48621
48890
  var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
@@ -48729,7 +48998,7 @@ var ts;
48729
48998
  if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
48730
48999
  (!ts.outFile(compilerOptions)) ||
48731
49000
  isInTypeQuery(usage) ||
48732
- declaration.flags & 8388608 /* Ambient */) {
49001
+ declaration.flags & 16777216 /* Ambient */) {
48733
49002
  // nodes are in different files and order cannot be determined
48734
49003
  return true;
48735
49004
  }
@@ -48791,7 +49060,7 @@ var ts;
48791
49060
  if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) {
48792
49061
  return true;
48793
49062
  }
48794
- if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
49063
+ if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
48795
49064
  return true;
48796
49065
  }
48797
49066
  if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
@@ -49056,7 +49325,7 @@ var ts;
49056
49325
  // falls through
49057
49326
  case 261 /* ModuleDeclaration */:
49058
49327
  var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
49059
- if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
49328
+ if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
49060
49329
  // It's an external module. First see if the module has an export default and if the local
49061
49330
  // name of that export default matches.
49062
49331
  if (result = moduleExports.get("default" /* Default */)) {
@@ -49379,7 +49648,7 @@ var ts;
49379
49648
  }
49380
49649
  }
49381
49650
  // If we're in an external module, we can't reference value symbols created from UMD export declarations
49382
- if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
49651
+ if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) {
49383
49652
  var merged = getMergedSymbol(result);
49384
49653
  if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
49385
49654
  errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name));
@@ -49634,7 +49903,7 @@ var ts;
49634
49903
  var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); });
49635
49904
  if (declaration === undefined)
49636
49905
  return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
49637
- if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
49906
+ if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
49638
49907
  var diagnosticMessage = void 0;
49639
49908
  var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
49640
49909
  if (result.flags & 2 /* BlockScopedVariable */) {
@@ -50145,27 +50414,27 @@ var ts;
50145
50414
  function resolveAlias(symbol) {
50146
50415
  ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
50147
50416
  var links = getSymbolLinks(symbol);
50148
- if (!links.target) {
50149
- links.target = resolvingSymbol;
50417
+ if (!links.aliasTarget) {
50418
+ links.aliasTarget = resolvingSymbol;
50150
50419
  var node = getDeclarationOfAliasSymbol(symbol);
50151
50420
  if (!node)
50152
50421
  return ts.Debug.fail();
50153
50422
  var target = getTargetOfAliasDeclaration(node);
50154
- if (links.target === resolvingSymbol) {
50155
- links.target = target || unknownSymbol;
50423
+ if (links.aliasTarget === resolvingSymbol) {
50424
+ links.aliasTarget = target || unknownSymbol;
50156
50425
  }
50157
50426
  else {
50158
50427
  error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
50159
50428
  }
50160
50429
  }
50161
- else if (links.target === resolvingSymbol) {
50162
- links.target = unknownSymbol;
50430
+ else if (links.aliasTarget === resolvingSymbol) {
50431
+ links.aliasTarget = unknownSymbol;
50163
50432
  }
50164
- return links.target;
50433
+ return links.aliasTarget;
50165
50434
  }
50166
50435
  function tryResolveAlias(symbol) {
50167
50436
  var links = getSymbolLinks(symbol);
50168
- if (links.target !== resolvingSymbol) {
50437
+ if (links.aliasTarget !== resolvingSymbol) {
50169
50438
  return resolveAlias(symbol);
50170
50439
  }
50171
50440
  return undefined;
@@ -50407,7 +50676,7 @@ var ts;
50407
50676
  }
50408
50677
  }
50409
50678
  function getAssignmentDeclarationLocation(node) {
50410
- var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
50679
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
50411
50680
  if (typeAlias) {
50412
50681
  return;
50413
50682
  }
@@ -51875,7 +52144,20 @@ var ts;
51875
52144
  if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
51876
52145
  if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
51877
52146
  context.approximateLength += (ts.symbolName(type.symbol).length + 6);
51878
- return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined));
52147
+ var constraintNode = void 0;
52148
+ var constraint = getConstraintOfTypeParameter(type);
52149
+ if (constraint) {
52150
+ // If the infer type has a constraint that is not the same as the constraint
52151
+ // we would have normally inferred based on context, we emit the constraint
52152
+ // using `infer T extends ?`. We omit inferred constraints from type references
52153
+ // as they may be elided.
52154
+ var inferredConstraint = getInferredTypeParameterConstraint(type, /*omitTypeReferences*/ true);
52155
+ if (!(inferredConstraint && isTypeIdenticalTo(constraint, inferredConstraint))) {
52156
+ context.approximateLength += 9;
52157
+ constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
52158
+ }
52159
+ }
52160
+ return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
51879
52161
  }
51880
52162
  if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
51881
52163
  type.flags & 262144 /* TypeParameter */ &&
@@ -51949,13 +52231,37 @@ var ts;
51949
52231
  return ts.Debug.fail("Should be unreachable.");
51950
52232
  function conditionalTypeToTypeNode(type) {
51951
52233
  var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
52234
+ context.approximateLength += 15;
52235
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) {
52236
+ var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
52237
+ var name = typeParameterToName(newParam, context);
52238
+ var newTypeVariable = ts.factory.createTypeReferenceNode(name);
52239
+ context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
52240
+ var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
52241
+ var saveInferTypeParameters_1 = context.inferTypeParameters;
52242
+ context.inferTypeParameters = type.root.inferTypeParameters;
52243
+ var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
52244
+ context.inferTypeParameters = saveInferTypeParameters_1;
52245
+ var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
52246
+ var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
52247
+ // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
52248
+ // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
52249
+ // inner conditional runs the check the user provided on the check type (distributively) and returns the result
52250
+ // checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
52251
+ // this is potentially simplifiable to
52252
+ // checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
52253
+ // but that may confuse users who read the output more.
52254
+ // On the other hand,
52255
+ // checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
52256
+ // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
52257
+ return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
52258
+ }
51952
52259
  var saveInferTypeParameters = context.inferTypeParameters;
51953
52260
  context.inferTypeParameters = type.root.inferTypeParameters;
51954
52261
  var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
51955
52262
  context.inferTypeParameters = saveInferTypeParameters;
51956
52263
  var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
51957
52264
  var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
51958
- context.approximateLength += 15;
51959
52265
  return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
51960
52266
  }
51961
52267
  function typeToTypeNodeOrCircularityElision(type) {
@@ -52654,9 +52960,6 @@ var ts;
52654
52960
  if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
52655
52961
  parameterType = getOptionalType(parameterType);
52656
52962
  }
52657
- if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
52658
- parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
52659
- }
52660
52963
  var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
52661
52964
  var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
52662
52965
  var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
@@ -53215,7 +53518,7 @@ var ts;
53215
53518
  if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
53216
53519
  // try to reuse the existing annotation
53217
53520
  var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
53218
- if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53521
+ if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53219
53522
  var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
53220
53523
  if (result_6) {
53221
53524
  return result_6;
@@ -53232,6 +53535,16 @@ var ts;
53232
53535
  context.flags = oldFlags;
53233
53536
  return result;
53234
53537
  }
53538
+ function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
53539
+ var typeFromTypeNode = getTypeFromTypeNode(typeNode);
53540
+ if (typeFromTypeNode === type) {
53541
+ return true;
53542
+ }
53543
+ if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
53544
+ return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
53545
+ }
53546
+ return false;
53547
+ }
53235
53548
  function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
53236
53549
  if (!isErrorType(type) && context.enclosingDeclaration) {
53237
53550
  var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
@@ -53831,7 +54144,7 @@ var ts;
53831
54144
  newModifierFlags |= 1 /* Export */;
53832
54145
  }
53833
54146
  if (addingDeclare && !(newModifierFlags & 1 /* Export */) &&
53834
- (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* Ambient */)) &&
54147
+ (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) &&
53835
54148
  (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
53836
54149
  // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
53837
54150
  newModifierFlags |= 2 /* Ambient */;
@@ -54801,7 +55114,7 @@ var ts;
54801
55114
  var parent = getDeclarationContainer(node);
54802
55115
  // If the node is not exported or it is not ambient module element (except import declaration)
54803
55116
  if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) &&
54804
- !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) {
55117
+ !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) {
54805
55118
  return isGlobalSourceFile(parent);
54806
55119
  }
54807
55120
  // Exported members/ambient module elements (exception import declaration) are visible if parent is visible
@@ -55141,7 +55454,7 @@ var ts;
55141
55454
  }
55142
55455
  var pattern = declaration.parent;
55143
55456
  // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
55144
- if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
55457
+ if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
55145
55458
  parentType = getNonNullableType(parentType);
55146
55459
  }
55147
55460
  // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
@@ -55257,7 +55570,7 @@ var ts;
55257
55570
  }
55258
55571
  if ((noImplicitAny || ts.isInJSFile(declaration)) &&
55259
55572
  ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
55260
- !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) {
55573
+ !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) {
55261
55574
  // If --noImplicitAny is on or the declaration is in a Javascript file,
55262
55575
  // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
55263
55576
  // initializer or a 'null' or 'undefined' initializer.
@@ -55503,7 +55816,7 @@ var ts;
55503
55816
  }
55504
55817
  }
55505
55818
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55506
- type = getUnionType(sourceTypes, 2 /* Subtype */);
55819
+ type = getUnionType(sourceTypes);
55507
55820
  }
55508
55821
  }
55509
55822
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -56713,7 +57026,7 @@ var ts;
56713
57026
  function isLiteralEnumMember(member) {
56714
57027
  var expr = member.initializer;
56715
57028
  if (!expr) {
56716
- return !(member.flags & 8388608 /* Ambient */);
57029
+ return !(member.flags & 16777216 /* Ambient */);
56717
57030
  }
56718
57031
  switch (expr.kind) {
56719
57032
  case 10 /* StringLiteral */:
@@ -58252,8 +58565,9 @@ var ts;
58252
58565
  // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
58253
58566
  // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
58254
58567
  // nesting, so it is effectively just a safety stop.
58255
- if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) {
58256
- stack.push(t);
58568
+ var identity_1 = getRecursionIdentity(t);
58569
+ if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
58570
+ stack.push(identity_1);
58257
58571
  result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
58258
58572
  stack.pop();
58259
58573
  }
@@ -59346,7 +59660,7 @@ var ts;
59346
59660
  function getConstraintDeclaration(type) {
59347
59661
  return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
59348
59662
  }
59349
- function getInferredTypeParameterConstraint(typeParameter) {
59663
+ function getInferredTypeParameterConstraint(typeParameter, omitTypeReferences) {
59350
59664
  var _a;
59351
59665
  var inferences;
59352
59666
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
@@ -59358,7 +59672,7 @@ var ts;
59358
59672
  // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are
59359
59673
  // present, we form an intersection of the inferred constraint types.
59360
59674
  var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
59361
- if (grandParent.kind === 178 /* TypeReference */) {
59675
+ if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
59362
59676
  var typeReference = grandParent;
59363
59677
  var typeParameters = getTypeParametersForTypeReference(typeReference);
59364
59678
  if (typeParameters) {
@@ -59780,7 +60094,7 @@ var ts;
59780
60094
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
59781
60095
  }
59782
60096
  function isJSDocTypeReference(node) {
59783
- return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
60097
+ return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
59784
60098
  }
59785
60099
  function checkNoTypeArguments(node, symbol) {
59786
60100
  if (node.typeArguments) {
@@ -61339,7 +61653,7 @@ var ts;
61339
61653
  if (ts.isCallLikeExpression(parent)) {
61340
61654
  return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
61341
61655
  }
61342
- return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
61656
+ return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
61343
61657
  }
61344
61658
  return true;
61345
61659
  }
@@ -62032,7 +62346,7 @@ var ts;
62032
62346
  links.resolvedSymbol = unknownSymbol;
62033
62347
  return links.resolvedType = errorType;
62034
62348
  }
62035
- var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
62349
+ var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
62036
62350
  // TODO: Future work: support unions/generics/whatever via a deferred import-type
62037
62351
  var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
62038
62352
  if (!innerModuleSymbol) {
@@ -62368,7 +62682,7 @@ var ts;
62368
62682
  }
62369
62683
  // /** @return {this} */
62370
62684
  // x.prototype.m = function() { ... }
62371
- var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
62685
+ var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
62372
62686
  if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) {
62373
62687
  return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
62374
62688
  }
@@ -62443,7 +62757,7 @@ var ts;
62443
62757
  case 143 /* NeverKeyword */:
62444
62758
  return neverType;
62445
62759
  case 148 /* ObjectKeyword */:
62446
- return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
62760
+ return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
62447
62761
  case 138 /* IntrinsicKeyword */:
62448
62762
  return intrinsicMarkerType;
62449
62763
  case 192 /* ThisType */:
@@ -66451,12 +66765,12 @@ var ts;
66451
66765
  function isDeeplyNestedType(type, stack, depth, maxDepth) {
66452
66766
  if (maxDepth === void 0) { maxDepth = 3; }
66453
66767
  if (depth >= maxDepth) {
66454
- var identity_1 = getRecursionIdentity(type);
66768
+ var identity_2 = getRecursionIdentity(type);
66455
66769
  var count = 0;
66456
66770
  var lastTypeId = 0;
66457
66771
  for (var i = 0; i < depth; i++) {
66458
66772
  var t = stack[i];
66459
- if (getRecursionIdentity(t) === identity_1) {
66773
+ if (getRecursionIdentity(t) === identity_2) {
66460
66774
  // We only count occurrences with a higher type id than the previous occurrence, since higher
66461
66775
  // type ids are an indicator of newer instantiations caused by recursion.
66462
66776
  if (t.id >= lastTypeId) {
@@ -67320,6 +67634,9 @@ var ts;
67320
67634
  var inference = inferences[i];
67321
67635
  if (t === inference.typeParameter) {
67322
67636
  if (fix && !inference.isFixed) {
67637
+ // Before we commit to a particular inference (and thus lock out any further inferences),
67638
+ // we infer from any intra-expression inference sites we have collected.
67639
+ inferFromIntraExpressionSites(context);
67323
67640
  clearCachedInferences(inferences);
67324
67641
  inference.isFixed = true;
67325
67642
  }
@@ -67336,6 +67653,37 @@ var ts;
67336
67653
  }
67337
67654
  }
67338
67655
  }
67656
+ function addIntraExpressionInferenceSite(context, node, type) {
67657
+ var _a;
67658
+ ((_a = context.intraExpressionInferenceSites) !== null && _a !== void 0 ? _a : (context.intraExpressionInferenceSites = [])).push({ node: node, type: type });
67659
+ }
67660
+ // We collect intra-expression inference sites within object and array literals to handle cases where
67661
+ // inferred types flow between context sensitive element expressions. For example:
67662
+ //
67663
+ // declare function foo<T>(arg: [(n: number) => T, (x: T) => void]): void;
67664
+ // foo([_a => 0, n => n.toFixed()]);
67665
+ //
67666
+ // Above, both arrow functions in the tuple argument are context sensitive, thus both are omitted from the
67667
+ // pass that collects inferences from the non-context sensitive parts of the arguments. In the subsequent
67668
+ // pass where nothing is omitted, we need to commit to an inference for T in order to contextually type the
67669
+ // parameter in the second arrow function, but we want to first infer from the return type of the first
67670
+ // arrow function. This happens automatically when the arrow functions are discrete arguments (because we
67671
+ // infer from each argument before processing the next), but when the arrow functions are elements of an
67672
+ // object or array literal, we need to perform intra-expression inferences early.
67673
+ function inferFromIntraExpressionSites(context) {
67674
+ if (context.intraExpressionInferenceSites) {
67675
+ for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) {
67676
+ var _b = _a[_i], node = _b.node, type = _b.type;
67677
+ var contextualType = node.kind === 169 /* MethodDeclaration */ ?
67678
+ getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) :
67679
+ getContextualType(node, 2 /* NoConstraints */);
67680
+ if (contextualType) {
67681
+ inferTypes(context.inferences, type, contextualType);
67682
+ }
67683
+ }
67684
+ context.intraExpressionInferenceSites = undefined;
67685
+ }
67686
+ }
67339
67687
  function createInferenceInfo(typeParameter) {
67340
67688
  return {
67341
67689
  typeParameter: typeParameter,
@@ -69318,7 +69666,7 @@ var ts;
69318
69666
  // parameter symbols with declarations that have explicit type annotations. Such references are
69319
69667
  // resolvable with no possibility of triggering circularities in control flow analysis.
69320
69668
  function getTypeOfDottedName(node, diagnostic) {
69321
- if (!(node.flags & 16777216 /* InWithStatement */)) {
69669
+ if (!(node.flags & 33554432 /* InWithStatement */)) {
69322
69670
  switch (node.kind) {
69323
69671
  case 79 /* Identifier */:
69324
69672
  var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
@@ -70722,6 +71070,7 @@ var ts;
70722
71070
  // a generic type without a nullable constraint and x is a generic type. This is because when both obj
70723
71071
  // and x are of generic types T and K, we want the resulting type to be T[K].
70724
71072
  return parent.kind === 206 /* PropertyAccessExpression */ ||
71073
+ parent.kind === 161 /* QualifiedName */ ||
70725
71074
  parent.kind === 208 /* CallExpression */ && parent.expression === node ||
70726
71075
  parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node &&
70727
71076
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
@@ -71015,7 +71364,7 @@ var ts;
71015
71364
  isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) ||
71016
71365
  node.parent.kind === 230 /* NonNullExpression */ ||
71017
71366
  declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken ||
71018
- declaration.flags & 8388608 /* Ambient */;
71367
+ declaration.flags & 16777216 /* Ambient */;
71019
71368
  var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
71020
71369
  type === autoType || type === autoArrayType ? undefinedType :
71021
71370
  getOptionalType(type);
@@ -72023,7 +72372,7 @@ var ts;
72023
72372
  // exists. Otherwise, it is the type of the string index signature in T, if one exists.
72024
72373
  function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
72025
72374
  ts.Debug.assert(ts.isObjectLiteralMethod(node));
72026
- if (node.flags & 16777216 /* InWithStatement */) {
72375
+ if (node.flags & 33554432 /* InWithStatement */) {
72027
72376
  // We cannot answer semantic questions within a with block, do not proceed any further
72028
72377
  return undefined;
72029
72378
  }
@@ -72211,7 +72560,7 @@ var ts;
72211
72560
  * @returns the contextual type of an expression.
72212
72561
  */
72213
72562
  function getContextualType(node, contextFlags) {
72214
- if (node.flags & 16777216 /* InWithStatement */) {
72563
+ if (node.flags & 33554432 /* InWithStatement */) {
72215
72564
  // We cannot answer semantic questions within a with block, do not proceed any further
72216
72565
  return undefined;
72217
72566
  }
@@ -72629,6 +72978,11 @@ var ts;
72629
72978
  var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
72630
72979
  elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression));
72631
72980
  elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
72981
+ if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
72982
+ var inferenceContext = getInferenceContext(node);
72983
+ ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
72984
+ addIntraExpressionInferenceSite(inferenceContext, e, type);
72985
+ }
72632
72986
  }
72633
72987
  }
72634
72988
  if (inDestructuringPattern) {
@@ -72830,6 +73184,13 @@ var ts;
72830
73184
  prop.target = member;
72831
73185
  member = prop;
72832
73186
  allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
73187
+ if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) &&
73188
+ (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
73189
+ var inferenceContext = getInferenceContext(node);
73190
+ ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
73191
+ var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
73192
+ addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
73193
+ }
72833
73194
  }
72834
73195
  else if (memberDecl.kind === 298 /* SpreadAssignment */) {
72835
73196
  if (languageVersion < 2 /* ES2015 */) {
@@ -73922,7 +74283,7 @@ var ts;
73922
74283
  if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
73923
74284
  error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
73924
74285
  }
73925
- if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
74286
+ if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) {
73926
74287
  addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
73927
74288
  }
73928
74289
  }
@@ -73990,7 +74351,7 @@ var ts;
73990
74351
  if (declaration && isPropertyWithoutInitializer(declaration)) {
73991
74352
  if (!ts.isStatic(declaration)) {
73992
74353
  var flowContainer = getControlFlowContainer(node);
73993
- if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) {
74354
+ if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) {
73994
74355
  assumeUninitialized = true;
73995
74356
  }
73996
74357
  }
@@ -74027,7 +74388,7 @@ var ts;
74027
74388
  }
74028
74389
  else if (valueDeclaration.kind === 257 /* ClassDeclaration */ &&
74029
74390
  node.parent.kind !== 178 /* TypeReference */ &&
74030
- !(valueDeclaration.flags & 8388608 /* Ambient */) &&
74391
+ !(valueDeclaration.flags & 16777216 /* Ambient */) &&
74031
74392
  !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
74032
74393
  diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
74033
74394
  }
@@ -74692,34 +75053,36 @@ var ts;
74692
75053
  if (node.kind !== 165 /* Decorator */) {
74693
75054
  var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
74694
75055
  if (contextualType) {
74695
- // We clone the inference context to avoid disturbing a resolution in progress for an
74696
- // outer call expression. Effectively we just want a snapshot of whatever has been
74697
- // inferred for any outer call expression so far.
74698
- var outerContext = getInferenceContext(node);
74699
- var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
74700
- var instantiatedType = instantiateType(contextualType, outerMapper);
74701
- // If the contextual type is a generic function type with a single call signature, we
74702
- // instantiate the type with its own type parameters and type arguments. This ensures that
74703
- // the type parameters are not erased to type any during type inference such that they can
74704
- // be inferred as actual types from the contextual type. For example:
74705
- // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
74706
- // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
74707
- // Above, the type of the 'value' parameter is inferred to be 'A'.
74708
- var contextualSignature = getSingleCallSignature(instantiatedType);
74709
- var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
74710
- getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
74711
- instantiatedType;
74712
75056
  var inferenceTargetType = getReturnTypeOfSignature(signature);
74713
- // Inferences made from return types have lower priority than all other inferences.
74714
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
74715
- // Create a type mapper for instantiating generic contextual types using the inferences made
74716
- // from the return type. We need a separate inference pass here because (a) instantiation of
74717
- // the source type uses the outer context's return mapper (which excludes inferences made from
74718
- // outer arguments), and (b) we don't want any further inferences going into this context.
74719
- var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
74720
- var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
74721
- inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
74722
- context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
75057
+ if (couldContainTypeVariables(inferenceTargetType)) {
75058
+ // We clone the inference context to avoid disturbing a resolution in progress for an
75059
+ // outer call expression. Effectively we just want a snapshot of whatever has been
75060
+ // inferred for any outer call expression so far.
75061
+ var outerContext = getInferenceContext(node);
75062
+ var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
75063
+ var instantiatedType = instantiateType(contextualType, outerMapper);
75064
+ // If the contextual type is a generic function type with a single call signature, we
75065
+ // instantiate the type with its own type parameters and type arguments. This ensures that
75066
+ // the type parameters are not erased to type any during type inference such that they can
75067
+ // be inferred as actual types from the contextual type. For example:
75068
+ // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
75069
+ // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
75070
+ // Above, the type of the 'value' parameter is inferred to be 'A'.
75071
+ var contextualSignature = getSingleCallSignature(instantiatedType);
75072
+ var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
75073
+ getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
75074
+ instantiatedType;
75075
+ // Inferences made from return types have lower priority than all other inferences.
75076
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
75077
+ // Create a type mapper for instantiating generic contextual types using the inferences made
75078
+ // from the return type. We need a separate inference pass here because (a) instantiation of
75079
+ // the source type uses the outer context's return mapper (which excludes inferences made from
75080
+ // outer arguments), and (b) we don't want any further inferences going into this context.
75081
+ var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
75082
+ var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
75083
+ inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
75084
+ context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
75085
+ }
74723
75086
  }
74724
75087
  }
74725
75088
  var restType = getNonArrayRestType(signature);
@@ -74731,7 +75094,7 @@ var ts;
74731
75094
  }
74732
75095
  }
74733
75096
  var thisType = getThisTypeOfSignature(signature);
74734
- if (thisType) {
75097
+ if (thisType && couldContainTypeVariables(thisType)) {
74735
75098
  var thisArgumentNode = getThisArgumentOfCall(node);
74736
75099
  inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
74737
75100
  }
@@ -74739,11 +75102,13 @@ var ts;
74739
75102
  var arg = args[i];
74740
75103
  if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
74741
75104
  var paramType = getTypeAtPosition(signature, i);
74742
- var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
74743
- inferTypes(context.inferences, argType, paramType);
75105
+ if (couldContainTypeVariables(paramType)) {
75106
+ var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
75107
+ inferTypes(context.inferences, argType, paramType);
75108
+ }
74744
75109
  }
74745
75110
  }
74746
- if (restType) {
75111
+ if (restType && couldContainTypeVariables(restType)) {
74747
75112
  var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
74748
75113
  inferTypes(context.inferences, spreadType, restType);
74749
75114
  }
@@ -76323,7 +76688,7 @@ var ts;
76323
76688
  return returnType;
76324
76689
  }
76325
76690
  function checkDeprecatedSignature(signature, node) {
76326
- if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) {
76691
+ if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) {
76327
76692
  var suggestionNode = getDeprecatedSuggestionNode(node);
76328
76693
  var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
76329
76694
  addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
@@ -76407,7 +76772,7 @@ var ts;
76407
76772
  var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
76408
76773
  newSymbol.parent = originalSymbol;
76409
76774
  newSymbol.nameType = getStringLiteralType("default");
76410
- newSymbol.target = resolveSymbol(symbol);
76775
+ newSymbol.aliasTarget = resolveSymbol(symbol);
76411
76776
  memberTable.set("default" /* Default */, newSymbol);
76412
76777
  return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
76413
76778
  }
@@ -76467,7 +76832,7 @@ var ts;
76467
76832
  if (targetDeclarationKind !== 0 /* Unknown */) {
76468
76833
  var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
76469
76834
  // function/variable declaration should be ambient
76470
- return !!decl && !!(decl.flags & 8388608 /* Ambient */);
76835
+ return !!decl && !!(decl.flags & 16777216 /* Ambient */);
76471
76836
  }
76472
76837
  return false;
76473
76838
  }
@@ -76662,7 +77027,7 @@ var ts;
76662
77027
  error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
76663
77028
  }
76664
77029
  var file = ts.getSourceFileOfNode(node);
76665
- ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
77030
+ ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
76666
77031
  return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
76667
77032
  }
76668
77033
  function getTypeOfParameter(symbol) {
@@ -78676,6 +79041,11 @@ var ts;
78676
79041
  context.contextualType = contextualType;
78677
79042
  context.inferenceContext = inferenceContext;
78678
79043
  var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0));
79044
+ // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type
79045
+ // parameters. This information is no longer needed after the call to checkExpression.
79046
+ if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
79047
+ inferenceContext.intraExpressionInferenceSites = undefined;
79048
+ }
78679
79049
  // We strip literal freshness when an appropriate contextual type is present such that contextually typed
78680
79050
  // literals always preserve their literal types (otherwise they might widen during type inference). An alternative
78681
79051
  // here would be to not mark contextually typed literals as fresh in the first place.
@@ -78967,7 +79337,7 @@ var ts;
78967
79337
  return quickType;
78968
79338
  }
78969
79339
  // If a type has been cached for the node, return it.
78970
- if (node.flags & 67108864 /* TypeCached */ && flowTypeCache) {
79340
+ if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) {
78971
79341
  var cachedType = flowTypeCache[getNodeId(node)];
78972
79342
  if (cachedType) {
78973
79343
  return cachedType;
@@ -78979,7 +79349,7 @@ var ts;
78979
79349
  if (flowInvocationCount !== startInvocationCount) {
78980
79350
  var cache = flowTypeCache || (flowTypeCache = []);
78981
79351
  cache[getNodeId(node)] = type;
78982
- ts.setNodeFlags(node, node.flags | 67108864 /* TypeCached */);
79352
+ ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */);
78983
79353
  }
78984
79354
  return type;
78985
79355
  }
@@ -79065,7 +79435,7 @@ var ts;
79065
79435
  if (compilerOptions.isolatedModules) {
79066
79436
  ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
79067
79437
  var constEnumDeclaration = type.symbol.valueDeclaration;
79068
- if (constEnumDeclaration.flags & 8388608 /* Ambient */) {
79438
+ if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
79069
79439
  error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
79070
79440
  }
79071
79441
  }
@@ -79214,19 +79584,28 @@ var ts;
79214
79584
  if (constraintType && defaultType) {
79215
79585
  checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
79216
79586
  }
79217
- if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) {
79587
+ checkNodeDeferred(node);
79588
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79589
+ }
79590
+ function checkTypeParameterDeferred(node) {
79591
+ if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
79592
+ var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
79218
79593
  var modifiers = getVarianceModifiers(typeParameter);
79219
- if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
79594
+ if (modifiers) {
79220
79595
  var symbol = getSymbolOfNode(node.parent);
79221
- var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
79222
- var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
79223
- var saveVarianceTypeParameter = typeParameter;
79224
- varianceTypeParameter = typeParameter;
79225
- checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
79226
- varianceTypeParameter = saveVarianceTypeParameter;
79596
+ if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
79597
+ error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
79598
+ }
79599
+ else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
79600
+ var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
79601
+ var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
79602
+ var saveVarianceTypeParameter = typeParameter;
79603
+ varianceTypeParameter = typeParameter;
79604
+ checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
79605
+ varianceTypeParameter = saveVarianceTypeParameter;
79606
+ }
79227
79607
  }
79228
79608
  }
79229
- addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79230
79609
  }
79231
79610
  function checkParameter(node) {
79232
79611
  // Grammar checking
@@ -79716,7 +80095,7 @@ var ts;
79716
80095
  superCallStatement = statement;
79717
80096
  break;
79718
80097
  }
79719
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
80098
+ if (nodeImmediatelyReferencesSuperOrThis(statement)) {
79720
80099
  break;
79721
80100
  }
79722
80101
  }
@@ -79758,7 +80137,7 @@ var ts;
79758
80137
  checkDecorators(node);
79759
80138
  checkSignatureDeclaration(node);
79760
80139
  if (node.kind === 172 /* GetAccessor */) {
79761
- if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
80140
+ if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
79762
80141
  if (!(node.flags & 512 /* HasExplicitReturn */)) {
79763
80142
  error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
79764
80143
  }
@@ -79853,7 +80232,7 @@ var ts;
79853
80232
  }
79854
80233
  var symbol = getNodeLinks(node).resolvedSymbol;
79855
80234
  if (symbol) {
79856
- if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) {
80235
+ if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) {
79857
80236
  addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
79858
80237
  }
79859
80238
  if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
@@ -80013,6 +80392,23 @@ var ts;
80013
80392
  grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
80014
80393
  }
80015
80394
  checkSourceElement(node.typeParameter);
80395
+ var symbol = getSymbolOfNode(node.typeParameter);
80396
+ if (symbol.declarations && symbol.declarations.length > 1) {
80397
+ var links = getSymbolLinks(symbol);
80398
+ if (!links.typeParametersChecked) {
80399
+ links.typeParametersChecked = true;
80400
+ var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
80401
+ var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */);
80402
+ if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
80403
+ // Report an error on every conflicting declaration.
80404
+ var name = symbolToString(symbol);
80405
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
80406
+ var declaration = declarations_4[_i];
80407
+ error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
80408
+ }
80409
+ }
80410
+ }
80411
+ }
80016
80412
  registerForUnusedIdentifiersCheck(node);
80017
80413
  }
80018
80414
  function checkTemplateLiteralType(node) {
@@ -80050,7 +80446,7 @@ var ts;
80050
80446
  getTypeFromTypeNode(node);
80051
80447
  }
80052
80448
  function isPrivateWithinAmbient(node) {
80053
- return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
80449
+ return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */);
80054
80450
  }
80055
80451
  function getEffectiveDeclarationFlags(n, flagsToCheck) {
80056
80452
  var flags = ts.getCombinedModifierFlags(n);
@@ -80059,7 +80455,7 @@ var ts;
80059
80455
  if (n.parent.kind !== 258 /* InterfaceDeclaration */ &&
80060
80456
  n.parent.kind !== 257 /* ClassDeclaration */ &&
80061
80457
  n.parent.kind !== 226 /* ClassExpression */ &&
80062
- n.flags & 8388608 /* Ambient */) {
80458
+ n.flags & 16777216 /* Ambient */) {
80063
80459
  if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
80064
80460
  // It is nested in an ambient context, which means it is automatically exported
80065
80461
  flags |= 1 /* Export */;
@@ -80192,10 +80588,10 @@ var ts;
80192
80588
  var hasNonAmbientClass = false;
80193
80589
  var functionDeclarations = [];
80194
80590
  if (declarations) {
80195
- for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
80196
- var current = declarations_4[_i];
80591
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
80592
+ var current = declarations_5[_i];
80197
80593
  var node = current;
80198
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
80594
+ var inAmbientContext = node.flags & 16777216 /* Ambient */;
80199
80595
  var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext;
80200
80596
  if (inAmbientContextOrInterface) {
80201
80597
  // check if declarations are consecutive only if they are non-ambient
@@ -81047,7 +81443,7 @@ var ts;
81047
81443
  // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
81048
81444
  var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(
81049
81445
  // Get first non javascript function declaration
81050
- function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); });
81446
+ function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); });
81051
81447
  // Only type check the symbol once
81052
81448
  if (node === firstDeclaration) {
81053
81449
  checkFunctionOrConstructorSymbol(localSymbol);
@@ -81169,7 +81565,7 @@ var ts;
81169
81565
  var symbol = getSymbolOfNode(member);
81170
81566
  if (!symbol.isReferenced
81171
81567
  && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
81172
- && !(member.flags & 8388608 /* Ambient */)) {
81568
+ && !(member.flags & 16777216 /* Ambient */)) {
81173
81569
  addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
81174
81570
  }
81175
81571
  break;
@@ -81359,8 +81755,8 @@ var ts;
81359
81755
  : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
81360
81756
  }
81361
81757
  else {
81362
- for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
81363
- var decl = declarations_5[_i];
81758
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
81759
+ var decl = declarations_6[_i];
81364
81760
  addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
81365
81761
  }
81366
81762
  }
@@ -81402,7 +81798,7 @@ var ts;
81402
81798
  }
81403
81799
  function checkCollisionWithArgumentsInGeneratedCode(node) {
81404
81800
  // no rest parameters \ declaration context \ overload - no codegen impact
81405
- if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) {
81801
+ if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) {
81406
81802
  return;
81407
81803
  }
81408
81804
  ts.forEach(node.parameters, function (p) {
@@ -81430,7 +81826,7 @@ var ts;
81430
81826
  // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified
81431
81827
  return false;
81432
81828
  }
81433
- if (node.flags & 8388608 /* Ambient */) {
81829
+ if (node.flags & 16777216 /* Ambient */) {
81434
81830
  // ambient context - no codegen impact
81435
81831
  return false;
81436
81832
  }
@@ -81569,7 +81965,7 @@ var ts;
81569
81965
  recordPotentialCollisionWithReflectInGeneratedCode(node, name);
81570
81966
  if (ts.isClassLike(node)) {
81571
81967
  checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0);
81572
- if (!(node.flags & 8388608 /* Ambient */)) {
81968
+ if (!(node.flags & 16777216 /* Ambient */)) {
81573
81969
  checkClassNameCollisionWithObject(name);
81574
81970
  }
81575
81971
  }
@@ -83163,23 +83559,23 @@ var ts;
83163
83559
  return;
83164
83560
  }
83165
83561
  var type = getDeclaredTypeOfSymbol(symbol);
83166
- if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
83562
+ if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
83167
83563
  // Report an error on every conflicting declaration.
83168
83564
  var name = symbolToString(symbol);
83169
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
83170
- var declaration = declarations_6[_i];
83565
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
83566
+ var declaration = declarations_7[_i];
83171
83567
  error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
83172
83568
  }
83173
83569
  }
83174
83570
  }
83175
83571
  }
83176
- function areTypeParametersIdentical(declarations, targetParameters) {
83572
+ function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
83177
83573
  var maxTypeArgumentCount = ts.length(targetParameters);
83178
83574
  var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
83179
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
83180
- var declaration = declarations_7[_i];
83575
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
83576
+ var declaration = declarations_8[_i];
83181
83577
  // If this declaration has too few or too many type parameters, we report an error
83182
- var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
83578
+ var sourceParameters = getTypeParameterDeclarations(declaration);
83183
83579
  var numTypeParameters = sourceParameters.length;
83184
83580
  if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
83185
83581
  return false;
@@ -83247,7 +83643,7 @@ var ts;
83247
83643
  checkFunctionOrConstructorSymbol(symbol);
83248
83644
  checkClassForDuplicateDeclarations(node);
83249
83645
  // Only check for reserved static identifiers on non-ambient context.
83250
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
83646
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
83251
83647
  if (!nodeInAmbientContext) {
83252
83648
  checkClassForStaticPropertyNameConflicts(node);
83253
83649
  }
@@ -83397,7 +83793,7 @@ var ts;
83397
83793
  */
83398
83794
  function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
83399
83795
  var isJs = ts.isInJSFile(node);
83400
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
83796
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
83401
83797
  if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
83402
83798
  var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
83403
83799
  var thisType = memberIsStatic ? staticType : typeWithThis;
@@ -83625,7 +84021,7 @@ var ts;
83625
84021
  && !(derived.flags & 33554432 /* Transient */)
83626
84022
  && !(baseDeclarationFlags & 128 /* Abstract */)
83627
84023
  && !(derivedDeclarationFlags & 128 /* Abstract */)
83628
- && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) {
84024
+ && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
83629
84025
  var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
83630
84026
  var propName = uninitialized.name;
83631
84027
  if (uninitialized.exclamationToken
@@ -83717,7 +84113,7 @@ var ts;
83717
84113
  return ok;
83718
84114
  }
83719
84115
  function checkPropertyInitialization(node) {
83720
- if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) {
84116
+ if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) {
83721
84117
  return;
83722
84118
  }
83723
84119
  var constructor = findConstructorDeclaration(node);
@@ -83854,7 +84250,7 @@ var ts;
83854
84250
  }
83855
84251
  // In ambient non-const numeric enum declarations, enum members without initializers are
83856
84252
  // considered computed members (as opposed to having auto-incremented values).
83857
- if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
84253
+ if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
83858
84254
  return undefined;
83859
84255
  }
83860
84256
  // If the member declaration specifies no value, the member is considered a constant enum member.
@@ -83886,7 +84282,7 @@ var ts;
83886
84282
  else if (isConstEnum) {
83887
84283
  error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
83888
84284
  }
83889
- else if (member.parent.flags & 8388608 /* Ambient */) {
84285
+ else if (member.parent.flags & 16777216 /* Ambient */) {
83890
84286
  error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
83891
84287
  }
83892
84288
  else {
@@ -84054,11 +84450,11 @@ var ts;
84054
84450
  function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
84055
84451
  var declarations = symbol.declarations;
84056
84452
  if (declarations) {
84057
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
84058
- var declaration = declarations_8[_i];
84453
+ for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
84454
+ var declaration = declarations_9[_i];
84059
84455
  if ((declaration.kind === 257 /* ClassDeclaration */ ||
84060
84456
  (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
84061
- !(declaration.flags & 8388608 /* Ambient */)) {
84457
+ !(declaration.flags & 16777216 /* Ambient */)) {
84062
84458
  return declaration;
84063
84459
  }
84064
84460
  }
@@ -84089,7 +84485,7 @@ var ts;
84089
84485
  function checkModuleDeclarationDiagnostics() {
84090
84486
  // Grammar checking
84091
84487
  var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
84092
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
84488
+ var inAmbientContext = node.flags & 16777216 /* Ambient */;
84093
84489
  if (isGlobalAugmentation && !inAmbientContext) {
84094
84490
  error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
84095
84491
  }
@@ -84307,7 +84703,7 @@ var ts;
84307
84703
  }
84308
84704
  if (compilerOptions.isolatedModules
84309
84705
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
84310
- && !(node.flags & 8388608 /* Ambient */)) {
84706
+ && !(node.flags & 16777216 /* Ambient */)) {
84311
84707
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
84312
84708
  var isType = !(target.flags & 111551 /* Value */);
84313
84709
  if (isType || typeOnlyAlias) {
@@ -84353,7 +84749,7 @@ var ts;
84353
84749
  }
84354
84750
  }
84355
84751
  function isDeprecatedAliasedSymbol(symbol) {
84356
- return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
84752
+ return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
84357
84753
  }
84358
84754
  function checkDeprecatedAliasedSymbol(symbol, location) {
84359
84755
  if (!(symbol.flags & 2097152 /* Alias */))
@@ -84482,7 +84878,7 @@ var ts;
84482
84878
  }
84483
84879
  }
84484
84880
  else {
84485
- if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
84881
+ if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) {
84486
84882
  // Import equals declaration is deprecated in es6 or above
84487
84883
  grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
84488
84884
  }
@@ -84508,7 +84904,7 @@ var ts;
84508
84904
  ts.forEach(node.exportClause.elements, checkExportSpecifier);
84509
84905
  var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
84510
84906
  var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ &&
84511
- !node.moduleSpecifier && node.flags & 8388608 /* Ambient */;
84907
+ !node.moduleSpecifier && node.flags & 16777216 /* Ambient */;
84512
84908
  if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
84513
84909
  error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
84514
84910
  }
@@ -84673,10 +85069,10 @@ var ts;
84673
85069
  checkExpressionCached(node.expression);
84674
85070
  }
84675
85071
  checkExternalModuleExports(container);
84676
- if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
85072
+ if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
84677
85073
  grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
84678
85074
  }
84679
- if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) {
85075
+ if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
84680
85076
  if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
84681
85077
  // export assignment is not supported in es6 modules
84682
85078
  grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
@@ -85052,6 +85448,9 @@ var ts;
85052
85448
  case 226 /* ClassExpression */:
85053
85449
  checkClassExpressionDeferred(node);
85054
85450
  break;
85451
+ case 163 /* TypeParameter */:
85452
+ checkTypeParameterDeferred(node);
85453
+ break;
85055
85454
  case 279 /* JsxSelfClosingElement */:
85056
85455
  checkJsxSelfClosingElementDeferred(node);
85057
85456
  break;
@@ -85109,7 +85508,7 @@ var ts;
85109
85508
  // This relies on the results of other lazy diagnostics, so must be computed after them
85110
85509
  if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
85111
85510
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
85112
- if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
85511
+ if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
85113
85512
  diagnostics.add(diag);
85114
85513
  }
85115
85514
  });
@@ -85209,7 +85608,7 @@ var ts;
85209
85608
  }
85210
85609
  // Language service support
85211
85610
  function getSymbolsInScope(location, meaning) {
85212
- if (location.flags & 16777216 /* InWithStatement */) {
85611
+ if (location.flags & 33554432 /* InWithStatement */) {
85213
85612
  // We cannot answer semantic questions within a with block, do not proceed any further
85214
85613
  return [];
85215
85614
  }
@@ -85559,7 +85958,7 @@ var ts;
85559
85958
  }
85560
85959
  var parent = node.parent;
85561
85960
  var grandParent = parent.parent;
85562
- if (node.flags & 16777216 /* InWithStatement */) {
85961
+ if (node.flags & 33554432 /* InWithStatement */) {
85563
85962
  // We cannot answer semantic questions within a with block, do not proceed any further
85564
85963
  return undefined;
85565
85964
  }
@@ -85701,7 +86100,7 @@ var ts;
85701
86100
  if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
85702
86101
  return errorType;
85703
86102
  }
85704
- if (node.flags & 16777216 /* InWithStatement */) {
86103
+ if (node.flags & 33554432 /* InWithStatement */) {
85705
86104
  // We cannot answer semantic questions within a with block, do not proceed any further
85706
86105
  return errorType;
85707
86106
  }
@@ -85866,11 +86265,11 @@ var ts;
85866
86265
  var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
85867
86266
  return leftSpread ? [leftSpread, rightSpread]
85868
86267
  : syntheticOrigin ? [syntheticOrigin]
85869
- : ts.singleElementArray(tryGetAliasTarget(symbol));
86268
+ : ts.singleElementArray(tryGetTarget(symbol));
85870
86269
  }
85871
86270
  return undefined;
85872
86271
  }
85873
- function tryGetAliasTarget(symbol) {
86272
+ function tryGetTarget(symbol) {
85874
86273
  var target;
85875
86274
  var next = symbol;
85876
86275
  while (next = getSymbolLinks(next).target) {
@@ -86100,7 +86499,7 @@ var ts;
86100
86499
  if (links === null || links === void 0 ? void 0 : links.referenced) {
86101
86500
  return true;
86102
86501
  }
86103
- var target = getSymbolLinks(symbol).target; // TODO: GH#18217
86502
+ var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
86104
86503
  if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
86105
86504
  target.flags & 111551 /* Value */ &&
86106
86505
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
@@ -86148,11 +86547,6 @@ var ts;
86148
86547
  !parameter.initializer &&
86149
86548
  ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
86150
86549
  }
86151
- function isOptionalUninitializedParameter(parameter) {
86152
- return !!strictNullChecks &&
86153
- isOptionalParameter(parameter) &&
86154
- !parameter.initializer;
86155
- }
86156
86550
  function isExpandoFunctionDeclaration(node) {
86157
86551
  var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
86158
86552
  if (!declaration) {
@@ -86754,7 +87148,7 @@ var ts;
86754
87148
  function checkExternalEmitHelpers(location, helpers) {
86755
87149
  if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
86756
87150
  var sourceFile = ts.getSourceFileOfNode(location);
86757
- if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) {
87151
+ if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) {
86758
87152
  var helpersModule = resolveHelpersModule(sourceFile, location);
86759
87153
  if (helpersModule !== unknownSymbol) {
86760
87154
  var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
@@ -87007,7 +87401,7 @@ var ts;
87007
87401
  else if (node.kind === 164 /* Parameter */) {
87008
87402
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
87009
87403
  }
87010
- else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
87404
+ else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
87011
87405
  return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
87012
87406
  }
87013
87407
  else if (ts.isPrivateIdentifierClassElementDeclaration(node)) {
@@ -87053,7 +87447,7 @@ var ts;
87053
87447
  if (flags & 256 /* Async */) {
87054
87448
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
87055
87449
  }
87056
- else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) {
87450
+ else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) {
87057
87451
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
87058
87452
  }
87059
87453
  else if (node.kind === 164 /* Parameter */) {
@@ -87069,8 +87463,7 @@ var ts;
87069
87463
  case 144 /* OutKeyword */:
87070
87464
  var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
87071
87465
  var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
87072
- if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ &&
87073
- node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
87466
+ if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
87074
87467
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
87075
87468
  }
87076
87469
  if (flags & inOutFlag) {
@@ -87199,7 +87592,7 @@ var ts;
87199
87592
  if (i !== (parameterCount - 1)) {
87200
87593
  return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
87201
87594
  }
87202
- if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
87595
+ if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
87203
87596
  checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
87204
87597
  }
87205
87598
  if (parameter.questionToken) {
@@ -87410,7 +87803,7 @@ var ts;
87410
87803
  ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ ||
87411
87804
  node.kind === 213 /* FunctionExpression */ ||
87412
87805
  node.kind === 169 /* MethodDeclaration */);
87413
- if (node.flags & 8388608 /* Ambient */) {
87806
+ if (node.flags & 16777216 /* Ambient */) {
87414
87807
  return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
87415
87808
  }
87416
87809
  if (!node.body) {
@@ -87648,7 +88041,7 @@ var ts;
87648
88041
  return false;
87649
88042
  }
87650
88043
  function checkGrammarAccessor(accessor) {
87651
- if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
88044
+ if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
87652
88045
  if (languageVersion < 1 /* ES5 */) {
87653
88046
  return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
87654
88047
  }
@@ -87788,7 +88181,7 @@ var ts;
87788
88181
  // However, property declarations disallow computed names in general,
87789
88182
  // and accessors are not allowed in ambient contexts in general,
87790
88183
  // so this error only really matters for methods.
87791
- if (node.flags & 8388608 /* Ambient */) {
88184
+ if (node.flags & 16777216 /* Ambient */) {
87792
88185
  return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
87793
88186
  }
87794
88187
  else if (node.kind === 169 /* MethodDeclaration */ && !node.body) {
@@ -87904,7 +88297,7 @@ var ts;
87904
88297
  }
87905
88298
  function checkGrammarVariableDeclaration(node) {
87906
88299
  if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) {
87907
- if (node.flags & 8388608 /* Ambient */) {
88300
+ if (node.flags & 16777216 /* Ambient */) {
87908
88301
  checkAmbientInitializer(node);
87909
88302
  }
87910
88303
  else if (!node.initializer) {
@@ -87916,7 +88309,7 @@ var ts;
87916
88309
  }
87917
88310
  }
87918
88311
  }
87919
- if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
88312
+ if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) {
87920
88313
  var message = node.initializer
87921
88314
  ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
87922
88315
  : !node.type
@@ -87925,7 +88318,7 @@ var ts;
87925
88318
  return grammarErrorOnNode(node.exclamationToken, message);
87926
88319
  }
87927
88320
  if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
87928
- !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
88321
+ !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
87929
88322
  checkESModuleMarker(node.name);
87930
88323
  }
87931
88324
  var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
@@ -88102,11 +88495,11 @@ var ts;
88102
88495
  return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
88103
88496
  }
88104
88497
  }
88105
- if (node.flags & 8388608 /* Ambient */) {
88498
+ if (node.flags & 16777216 /* Ambient */) {
88106
88499
  checkAmbientInitializer(node);
88107
88500
  }
88108
88501
  if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
88109
- node.flags & 8388608 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
88502
+ node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
88110
88503
  var message = node.initializer
88111
88504
  ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
88112
88505
  : !node.type
@@ -88152,10 +88545,10 @@ var ts;
88152
88545
  return false;
88153
88546
  }
88154
88547
  function checkGrammarSourceFile(node) {
88155
- return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
88548
+ return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
88156
88549
  }
88157
88550
  function checkGrammarStatementInAmbientContext(node) {
88158
- if (node.flags & 8388608 /* Ambient */) {
88551
+ if (node.flags & 16777216 /* Ambient */) {
88159
88552
  // Find containing block which is either Block, ModuleBlock, SourceFile
88160
88553
  var links = getNodeLinks(node);
88161
88554
  if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
@@ -92273,7 +92666,7 @@ var ts;
92273
92666
  return !ts.nodeIsMissing(node.body);
92274
92667
  }
92275
92668
  function visitPropertyDeclaration(node) {
92276
- if (node.flags & 8388608 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92669
+ if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92277
92670
  return undefined;
92278
92671
  }
92279
92672
  var updated = factory.updatePropertyDeclaration(node,
@@ -92304,11 +92697,11 @@ var ts;
92304
92697
  }
92305
92698
  var statements = [];
92306
92699
  resumeLexicalEnvironment();
92307
- var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92308
- var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
92700
+ var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92701
+ var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
92309
92702
  // If there was a super call, visit existing statements up to and including it
92310
92703
  if (superStatementIndex >= 0) {
92311
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
92704
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
92312
92705
  }
92313
92706
  // Transform parameters into property assignments. Transforms this:
92314
92707
  //
@@ -92327,12 +92720,12 @@ var ts;
92327
92720
  if (superStatementIndex >= 0) {
92328
92721
  ts.addRange(statements, parameterPropertyAssignments);
92329
92722
  }
92330
- // Since there was no super() call, parameter properties are the first statements in the constructor
92723
+ // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
92331
92724
  else {
92332
- statements = ts.addRange(parameterPropertyAssignments, statements);
92725
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
92333
92726
  }
92334
- // Add remaining statements from the body, skipping the super() call if it was found
92335
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
92727
+ // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
92728
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
92336
92729
  // End the lexical environment.
92337
92730
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
92338
92731
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
@@ -99163,8 +99556,8 @@ var ts;
99163
99556
  // declarations may not be sorted by position.
99164
99557
  // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
99165
99558
  var pos = -1, end = -1;
99166
- for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
99167
- var node = declarations_9[_i];
99559
+ for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
99560
+ var node = declarations_10[_i];
99168
99561
  pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
99169
99562
  end = Math.max(end, node.end);
99170
99563
  }
@@ -108096,6 +108489,10 @@ var ts;
108096
108489
  return factory.updateModifiers(statement, modifiers);
108097
108490
  }
108098
108491
  function transformTopLevelDeclaration(input) {
108492
+ if (lateMarkedStatements) {
108493
+ while (ts.orderedRemoveItem(lateMarkedStatements, input))
108494
+ ;
108495
+ }
108099
108496
  if (shouldStripInternal(input))
108100
108497
  return;
108101
108498
  switch (input.kind) {
@@ -108207,7 +108604,7 @@ var ts;
108207
108604
  needsScopeFixMarker = false;
108208
108605
  var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
108209
108606
  var lateStatements = transformAndReplaceLatePaintedStatements(statements);
108210
- if (input.flags & 8388608 /* Ambient */) {
108607
+ if (input.flags & 16777216 /* Ambient */) {
108211
108608
  needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates"
108212
108609
  }
108213
108610
  // With the final list of statements, there are 3 possibilities:
@@ -109227,7 +109624,7 @@ var ts;
109227
109624
  addOutput(buildInfoPath);
109228
109625
  }
109229
109626
  function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
109230
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109627
+ if (ts.isDeclarationFileName(inputFileName))
109231
109628
  return;
109232
109629
  var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109233
109630
  addOutput(js);
@@ -109272,7 +109669,7 @@ var ts;
109272
109669
  /*@internal*/
109273
109670
  function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
109274
109671
  var options = _a.options, fileNames = _a.fileNames;
109275
- return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
109672
+ return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
109276
109673
  }
109277
109674
  ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
109278
109675
  /*@internal*/
@@ -109314,7 +109711,7 @@ var ts;
109314
109711
  var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
109315
109712
  for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
109316
109713
  var inputFileName = _b[_a];
109317
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109714
+ if (ts.isDeclarationFileName(inputFileName))
109318
109715
  continue;
109319
109716
  var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109320
109717
  if (jsFilePath)
@@ -109855,6 +110252,9 @@ var ts;
109855
110252
  var currentParenthesizerRule;
109856
110253
  var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
109857
110254
  var parenthesizer = ts.factory.parenthesizer;
110255
+ var typeArgumentParenthesizerRuleSelector = {
110256
+ select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
110257
+ };
109858
110258
  var emitBinaryExpression = createEmitBinaryExpression();
109859
110259
  reset();
109860
110260
  return {
@@ -111067,7 +111467,7 @@ var ts;
111067
111467
  writePunctuation("}");
111068
111468
  }
111069
111469
  function emitArrayType(node) {
111070
- emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType);
111470
+ emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
111071
111471
  writePunctuation("[");
111072
111472
  writePunctuation("]");
111073
111473
  }
@@ -111078,7 +111478,7 @@ var ts;
111078
111478
  function emitTupleType(node) {
111079
111479
  emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node);
111080
111480
  var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */;
111081
- emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */);
111481
+ emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType);
111082
111482
  emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node);
111083
111483
  }
111084
111484
  function emitNamedTupleMember(node) {
@@ -111090,21 +111490,21 @@ var ts;
111090
111490
  emit(node.type);
111091
111491
  }
111092
111492
  function emitOptionalType(node) {
111093
- emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType);
111493
+ emit(node.type, parenthesizer.parenthesizeTypeOfOptionalType);
111094
111494
  writePunctuation("?");
111095
111495
  }
111096
111496
  function emitUnionType(node) {
111097
- emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
111497
+ emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType);
111098
111498
  }
111099
111499
  function emitIntersectionType(node) {
111100
- emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
111500
+ emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType);
111101
111501
  }
111102
111502
  function emitConditionalType(node) {
111103
- emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType);
111503
+ emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType);
111104
111504
  writeSpace();
111105
111505
  writeKeyword("extends");
111106
111506
  writeSpace();
111107
- emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType);
111507
+ emit(node.extendsType, parenthesizer.parenthesizeExtendsTypeOfConditionalType);
111108
111508
  writeSpace();
111109
111509
  writePunctuation("?");
111110
111510
  writeSpace();
@@ -111130,10 +111530,13 @@ var ts;
111130
111530
  function emitTypeOperator(node) {
111131
111531
  writeTokenText(node.operator, writeKeyword);
111132
111532
  writeSpace();
111133
- emit(node.type, parenthesizer.parenthesizeMemberOfElementType);
111533
+ var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ?
111534
+ parenthesizer.parenthesizeOperandOfReadonlyTypeOperator :
111535
+ parenthesizer.parenthesizeOperandOfTypeOperator;
111536
+ emit(node.type, parenthesizerRule);
111134
111537
  }
111135
111538
  function emitIndexedAccessType(node) {
111136
- emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType);
111539
+ emit(node.objectType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
111137
111540
  writePunctuation("[");
111138
111541
  emit(node.indexType);
111139
111542
  writePunctuation("]");
@@ -112867,7 +113270,7 @@ var ts;
112867
113270
  emitList(parentNode, decorators, 2146305 /* Decorators */);
112868
113271
  }
112869
113272
  function emitTypeArguments(parentNode, typeArguments) {
112870
- emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType);
113273
+ emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector);
112871
113274
  }
112872
113275
  function emitTypeParameters(parentNode, typeParameters) {
112873
113276
  if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
@@ -112986,6 +113389,7 @@ var ts;
112986
113389
  if (format & 128 /* Indented */) {
112987
113390
  increaseIndent();
112988
113391
  }
113392
+ var emitListItem = getEmitListItem(emit, parenthesizerRule);
112989
113393
  // Emit each child.
112990
113394
  var previousSibling = void 0;
112991
113395
  var previousSourceFileTextKind = void 0;
@@ -113036,12 +113440,7 @@ var ts;
113036
113440
  shouldEmitInterveningComments = mayEmitInterveningComments;
113037
113441
  }
113038
113442
  nextListElementPos = child.pos;
113039
- if (emit.length === 1) {
113040
- emit(child);
113041
- }
113042
- else {
113043
- emit(child, parenthesizerRule);
113044
- }
113443
+ emitListItem(child, emit, parenthesizerRule, i);
113045
113444
  if (shouldDecreaseIndentAfterEmit) {
113046
113445
  decreaseIndent();
113047
113446
  shouldDecreaseIndentAfterEmit = false;
@@ -114282,6 +114681,20 @@ var ts;
114282
114681
  TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask";
114283
114682
  TempFlags[TempFlags["_i"] = 268435456] = "_i";
114284
114683
  })(TempFlags || (TempFlags = {}));
114684
+ function emitListItemNoParenthesizer(node, emit, _parenthesizerRule, _index) {
114685
+ emit(node);
114686
+ }
114687
+ function emitListItemWithParenthesizerRuleSelector(node, emit, parenthesizerRuleSelector, index) {
114688
+ emit(node, parenthesizerRuleSelector.select(index));
114689
+ }
114690
+ function emitListItemWithParenthesizerRule(node, emit, parenthesizerRule, _index) {
114691
+ emit(node, parenthesizerRule);
114692
+ }
114693
+ function getEmitListItem(emit, parenthesizerRule) {
114694
+ return emit.length === 1 ? emitListItemNoParenthesizer :
114695
+ typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
114696
+ emitListItemWithParenthesizerRule;
114697
+ }
114285
114698
  })(ts || (ts = {}));
114286
114699
  /* @internal */
114287
114700
  var ts;
@@ -114648,7 +115061,7 @@ var ts;
114648
115061
  if (ts.outFile(options) || options.outDir)
114649
115062
  return false;
114650
115063
  // File if emitted next to input needs to be ignored
114651
- if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) {
115064
+ if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
114652
115065
  // If its declaration directory: its not ignored if not excluded by config
114653
115066
  if (options.declarationDir)
114654
115067
  return false;
@@ -115821,7 +116234,7 @@ var ts;
115821
116234
  var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
115822
116235
  for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
115823
116236
  var fileName = _c[_b];
115824
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
116237
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
115825
116238
  processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
115826
116239
  }
115827
116240
  }
@@ -116012,7 +116425,7 @@ var ts;
116012
116425
  }
116013
116426
  function getRedirectReferenceForResolution(file) {
116014
116427
  var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
116015
- if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]))
116428
+ if (redirect || !ts.isDeclarationFileName(file.originalFileName))
116016
116429
  return redirect;
116017
116430
  // The originalFileName could not be actual source file name if file found was d.ts from referecned project
116018
116431
  // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
@@ -116348,7 +116761,7 @@ var ts;
116348
116761
  // moduleAugmentations has changed
116349
116762
  structureIsReused = 1 /* SafeModules */;
116350
116763
  }
116351
- if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) {
116764
+ if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
116352
116765
  // dynamicImport has changed
116353
116766
  structureIsReused = 1 /* SafeModules */;
116354
116767
  }
@@ -116512,6 +116925,9 @@ var ts;
116512
116925
  return !!sourceFilesFoundSearchingNodeModules.get(file.path);
116513
116926
  }
116514
116927
  function isSourceFileDefaultLibrary(file) {
116928
+ if (!file.isDeclarationFile) {
116929
+ return false;
116930
+ }
116515
116931
  if (file.hasNoDefaultLib) {
116516
116932
  return true;
116517
116933
  }
@@ -117023,7 +117439,7 @@ var ts;
117023
117439
  var node = _a[_i];
117024
117440
  collectModuleReferences(node, /*inAmbientModule*/ false);
117025
117441
  }
117026
- if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
117442
+ if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
117027
117443
  collectDynamicImportOrRequireCalls(file);
117028
117444
  }
117029
117445
  file.imports = imports || ts.emptyArray;
@@ -117400,7 +117816,7 @@ var ts;
117400
117816
  }
117401
117817
  function getProjectReferenceRedirectProject(fileName) {
117402
117818
  // Ignore dts or any json files
117403
- if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117819
+ if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117404
117820
  return undefined;
117405
117821
  }
117406
117822
  // If this file is produced by a referenced project, we need to rewrite it to
@@ -117449,7 +117865,7 @@ var ts;
117449
117865
  else {
117450
117866
  var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
117451
117867
  ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
117452
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117868
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117453
117869
  var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
117454
117870
  mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
117455
117871
  }
@@ -117621,7 +118037,7 @@ var ts;
117621
118037
  && index < file.imports.length
117622
118038
  && !elideImport
117623
118039
  && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile))
117624
- && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */));
118040
+ && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
117625
118041
  if (elideImport) {
117626
118042
  modulesWithElidedImports.set(file.path, true);
117627
118043
  }
@@ -118250,7 +118666,7 @@ var ts;
118250
118666
  if (options.outDir) {
118251
118667
  return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
118252
118668
  }
118253
- if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
118669
+ if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
118254
118670
  // Otherwise just check if sourceFile with the name exists
118255
118671
  var filePathWithoutExtension = ts.removeFileExtension(filePath);
118256
118672
  return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
@@ -118876,7 +119292,7 @@ var ts;
118876
119292
  /*forceDtsEmit*/ true);
118877
119293
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
118878
119294
  if (firstDts_1) {
118879
- ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
119295
+ ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
118880
119296
  latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
118881
119297
  if (exportedModulesMapCache && latestSignature !== prevSignature) {
118882
119298
  updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
@@ -119281,7 +119697,7 @@ var ts;
119281
119697
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
119282
119698
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
119283
119699
  */
119284
- function getNextAffectedFile(state, cancellationToken, computeHash) {
119700
+ function getNextAffectedFile(state, cancellationToken, computeHash, host) {
119285
119701
  while (true) {
119286
119702
  var affectedFiles = state.affectedFiles;
119287
119703
  if (affectedFiles) {
@@ -119292,7 +119708,7 @@ var ts;
119292
119708
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
119293
119709
  // Set the next affected file as seen and remove the cached semantic diagnostics
119294
119710
  state.affectedFilesIndex = affectedFilesIndex;
119295
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
119711
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
119296
119712
  return affectedFile;
119297
119713
  }
119298
119714
  affectedFilesIndex++;
@@ -119333,6 +119749,11 @@ var ts;
119333
119749
  state.seenAffectedFiles = new ts.Set();
119334
119750
  }
119335
119751
  }
119752
+ function clearAffectedFilesPendingEmit(state) {
119753
+ state.affectedFilesPendingEmit = undefined;
119754
+ state.affectedFilesPendingEmitKind = undefined;
119755
+ state.affectedFilesPendingEmitIndex = undefined;
119756
+ }
119336
119757
  /**
119337
119758
  * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
119338
119759
  */
@@ -119352,9 +119773,7 @@ var ts;
119352
119773
  }
119353
119774
  }
119354
119775
  }
119355
- state.affectedFilesPendingEmit = undefined;
119356
- state.affectedFilesPendingEmitKind = undefined;
119357
- state.affectedFilesPendingEmitIndex = undefined;
119776
+ clearAffectedFilesPendingEmit(state);
119358
119777
  }
119359
119778
  return undefined;
119360
119779
  }
@@ -119362,7 +119781,7 @@ var ts;
119362
119781
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119363
119782
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
119364
119783
  */
119365
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
119784
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
119366
119785
  var _a;
119367
119786
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119368
119787
  // If affected files is everything except default library, then nothing more to do
@@ -119387,14 +119806,14 @@ var ts;
119387
119806
  ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
119388
119807
  }
119389
119808
  if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
119390
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
119809
+ forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
119391
119810
  }
119392
119811
  }
119393
119812
  /**
119394
119813
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
119395
119814
  * Also we need to make sure signature is updated for these files
119396
119815
  */
119397
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
119816
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
119398
119817
  removeSemanticDiagnosticsOf(state, path);
119399
119818
  if (!state.changedFilesSet.has(path)) {
119400
119819
  var program = ts.Debug.checkDefined(state.program);
@@ -119405,8 +119824,7 @@ var ts;
119405
119824
  // This ensures that we dont later during incremental builds considering wrong signature.
119406
119825
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
119407
119826
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
119408
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
119409
- /* useFileVersionAsSignature */ true);
119827
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
119410
119828
  // If not dts emit, nothing more to do
119411
119829
  if (ts.getEmitDeclarations(state.compilerOptions)) {
119412
119830
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -119603,13 +120021,18 @@ var ts;
119603
120021
  var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
119604
120022
  var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
119605
120023
  return value.version === actualSignature ?
119606
- value.affectsGlobalScope ?
119607
- { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
120024
+ value.affectsGlobalScope || value.impliedFormat ?
120025
+ // If file version is same as signature, dont serialize signature
120026
+ { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120027
+ // If file info only contains version and signature and both are same we can just write string
119608
120028
  value.version :
119609
- actualSignature !== undefined ?
120029
+ actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
119610
120030
  signature === undefined ?
120031
+ // If we havent computed signature, use fileInfo as is
119611
120032
  value :
120033
+ // Serialize fileInfo with new updated signature
119612
120034
  { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120035
+ // Signature of the FileInfo is undefined, serialize it as false
119613
120036
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
119614
120037
  });
119615
120038
  var referencedMap;
@@ -119854,7 +120277,7 @@ var ts;
119854
120277
  * in that order would be used to write the files
119855
120278
  */
119856
120279
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
119857
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120280
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
119858
120281
  var emitKind = 1 /* Full */;
119859
120282
  var isPendingEmitFile = false;
119860
120283
  if (!affected) {
@@ -119899,54 +120322,48 @@ var ts;
119899
120322
  * in that order would be used to write the files
119900
120323
  */
119901
120324
  function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
119902
- var restorePendingEmitOnHandlingNoEmitSuccess = false;
119903
- var savedAffectedFilesPendingEmit;
119904
- var savedAffectedFilesPendingEmitKind;
119905
- var savedAffectedFilesPendingEmitIndex;
119906
- // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors
119907
- // This ensures pending files to emit is updated in tsbuildinfo
119908
- // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit)
119909
- if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
119910
- !targetSourceFile &&
119911
- !ts.outFile(state.compilerOptions) &&
119912
- !state.compilerOptions.noEmit &&
119913
- state.compilerOptions.noEmitOnError) {
119914
- restorePendingEmitOnHandlingNoEmitSuccess = true;
119915
- savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
119916
- savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
119917
- savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
119918
- }
120325
+ var _a;
119919
120326
  if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
119920
120327
  assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
119921
120328
  }
119922
120329
  var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
119923
120330
  if (result)
119924
120331
  return result;
119925
- if (restorePendingEmitOnHandlingNoEmitSuccess) {
119926
- state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
119927
- state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
119928
- state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
119929
- }
119930
120332
  // Emit only affected files if using builder for emit
119931
- if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
119932
- // Emit and report any errors we ran into.
119933
- var sourceMaps = [];
119934
- var emitSkipped = false;
119935
- var diagnostics = void 0;
119936
- var emittedFiles = [];
119937
- var affectedEmitResult = void 0;
119938
- while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
119939
- emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
119940
- diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
119941
- emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
119942
- sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120333
+ if (!targetSourceFile) {
120334
+ if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120335
+ // Emit and report any errors we ran into.
120336
+ var sourceMaps = [];
120337
+ var emitSkipped = false;
120338
+ var diagnostics = void 0;
120339
+ var emittedFiles = [];
120340
+ var affectedEmitResult = void 0;
120341
+ while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
120342
+ emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
120343
+ diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
120344
+ emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
120345
+ sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120346
+ }
120347
+ return {
120348
+ emitSkipped: emitSkipped,
120349
+ diagnostics: diagnostics || ts.emptyArray,
120350
+ emittedFiles: emittedFiles,
120351
+ sourceMaps: sourceMaps
120352
+ };
120353
+ }
120354
+ // In non Emit builder, clear affected files pending emit
120355
+ else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
120356
+ ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
120357
+ // State can clear affected files pending emit if
120358
+ if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
120359
+ // If every file pending emit is pending on only dts emit
120360
+ || ts.every(state.affectedFilesPendingEmit, function (path, index) {
120361
+ return index < state.affectedFilesPendingEmitIndex ||
120362
+ state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
120363
+ })) {
120364
+ clearAffectedFilesPendingEmit(state);
120365
+ }
119943
120366
  }
119944
- return {
119945
- emitSkipped: emitSkipped,
119946
- diagnostics: diagnostics || ts.emptyArray,
119947
- emittedFiles: emittedFiles,
119948
- sourceMaps: sourceMaps
119949
- };
119950
120367
  }
119951
120368
  return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
119952
120369
  }
@@ -119956,7 +120373,7 @@ var ts;
119956
120373
  */
119957
120374
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
119958
120375
  while (true) {
119959
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120376
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
119960
120377
  if (!affected) {
119961
120378
  // Done
119962
120379
  return undefined;
@@ -123076,9 +123493,6 @@ var ts;
123076
123493
  function newer(date1, date2) {
123077
123494
  return date2 > date1 ? date2 : date1;
123078
123495
  }
123079
- function isDeclarationFile(fileName) {
123080
- return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
123081
- }
123082
123496
  /*@internal*/
123083
123497
  function isCircularBuildOrder(buildOrder) {
123084
123498
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -123641,7 +124055,7 @@ var ts;
123641
124055
  outputFiles.forEach(function (_a) {
123642
124056
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
123643
124057
  var priorChangeTime;
123644
- if (!anyDtsChanged && isDeclarationFile(name)) {
124058
+ if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
123645
124059
  // Check for unchanged .d.ts files
123646
124060
  if (host.fileExists(name) && state.readFileWithCache(name) === text) {
123647
124061
  priorChangeTime = host.getModifiedTime(name);
@@ -123982,7 +124396,7 @@ var ts;
123982
124396
  // In addition to file timestamps, we also keep track of when a .d.ts file
123983
124397
  // had its file touched but not had its contents changed - this allows us
123984
124398
  // to skip a downstream typecheck
123985
- if (isDeclarationFile(output)) {
124399
+ if (ts.isDeclarationFileName(output)) {
123986
124400
  var outputModifiedTime = ts.getModifiedTime(host, output);
123987
124401
  newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
123988
124402
  }
@@ -124136,7 +124550,7 @@ var ts;
124136
124550
  reportVerbose = false;
124137
124551
  reportStatus(state, verboseMessage, proj.options.configFilePath);
124138
124552
  }
124139
- if (isDeclarationFile(file)) {
124553
+ if (ts.isDeclarationFileName(file)) {
124140
124554
  priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
124141
124555
  }
124142
124556
  host.setModifiedTime(file, now);