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.
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220405";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220415";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -4609,10 +4609,11 @@ var ts;
4609
4609
  NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext";
4610
4610
  NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext";
4611
4611
  NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext";
4612
- NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError";
4613
- NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile";
4614
- NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError";
4615
- NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData";
4612
+ NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 65536] = "DisallowConditionalTypesContext";
4613
+ NodeFlags[NodeFlags["ThisNodeHasError"] = 131072] = "ThisNodeHasError";
4614
+ NodeFlags[NodeFlags["JavaScriptFile"] = 262144] = "JavaScriptFile";
4615
+ NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 524288] = "ThisNodeOrAnySubNodesHasError";
4616
+ NodeFlags[NodeFlags["HasAggregatedChildData"] = 1048576] = "HasAggregatedChildData";
4616
4617
  // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
4617
4618
  // walking the tree if the flags are not set. However, these flags are just a approximation
4618
4619
  // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
@@ -4622,25 +4623,25 @@ var ts;
4622
4623
  // removal, it is likely that users will add the import anyway.
4623
4624
  // The advantage of this approach is its simplicity. For the case of batch compilation,
4624
4625
  // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
4625
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport";
4626
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta";
4627
- NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc";
4628
- /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient";
4629
- /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement";
4630
- NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile";
4631
- /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 67108864] = "TypeCached";
4632
- /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 134217728] = "Deprecated";
4626
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 2097152] = "PossiblyContainsDynamicImport";
4627
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 4194304] = "PossiblyContainsImportMeta";
4628
+ NodeFlags[NodeFlags["JSDoc"] = 8388608] = "JSDoc";
4629
+ /* @internal */ NodeFlags[NodeFlags["Ambient"] = 16777216] = "Ambient";
4630
+ /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 33554432] = "InWithStatement";
4631
+ NodeFlags[NodeFlags["JsonFile"] = 67108864] = "JsonFile";
4632
+ /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
4633
+ /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
4633
4634
  NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
4634
4635
  NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
4635
4636
  NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
4636
4637
  // Parsing context flags
4637
- NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags";
4638
+ NodeFlags[NodeFlags["ContextFlags"] = 50720768] = "ContextFlags";
4638
4639
  // Exclude these flags when parsing a Type
4639
4640
  NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags";
4640
4641
  // Represents all flags that are potentially set once and
4641
4642
  // never cleared on SourceFiles which get re-used in between incremental parses.
4642
4643
  // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
4643
- /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags";
4644
+ /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 6291456] = "PermanentlySetIncrementalFlags";
4644
4645
  })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {}));
4645
4646
  var ModifierFlags;
4646
4647
  (function (ModifierFlags) {
@@ -4853,7 +4854,6 @@ var ts;
4853
4854
  NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
4854
4855
  NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
4855
4856
  NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
4856
- NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
4857
4857
  // Error handling
4858
4858
  NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
4859
4859
  NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
@@ -8910,6 +8910,7 @@ var ts;
8910
8910
  _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
8911
8911
  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."),
8912
8912
  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."),
8913
+ 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."),
8913
8914
  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."),
8914
8915
  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."),
8915
8916
  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."),
@@ -9082,6 +9083,7 @@ var ts;
9082
9083
  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}'?"),
9083
9084
  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."),
9084
9085
  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."),
9086
+ 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."),
9085
9087
  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}'."),
9086
9088
  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}'."),
9087
9089
  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}'."),
@@ -14496,24 +14498,24 @@ var ts;
14496
14498
  // Returns true if this node contains a parse error anywhere underneath it.
14497
14499
  function containsParseError(node) {
14498
14500
  aggregateChildData(node);
14499
- return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0;
14501
+ return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0;
14500
14502
  }
14501
14503
  ts.containsParseError = containsParseError;
14502
14504
  function aggregateChildData(node) {
14503
- if (!(node.flags & 524288 /* HasAggregatedChildData */)) {
14505
+ if (!(node.flags & 1048576 /* HasAggregatedChildData */)) {
14504
14506
  // A node is considered to contain a parse error if:
14505
14507
  // a) the parser explicitly marked that it had an error
14506
14508
  // b) any of it's children reported that it had an error.
14507
- var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) ||
14509
+ var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) ||
14508
14510
  ts.forEachChild(node, containsParseError);
14509
14511
  // If so, mark ourselves accordingly.
14510
14512
  if (thisNodeOrAnySubNodesHasError) {
14511
- node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */;
14513
+ node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */;
14512
14514
  }
14513
14515
  // Also mark that we've propagated the child information to this node. This way we can
14514
14516
  // always consult the bit directly on this node without needing to check its children
14515
14517
  // again.
14516
- node.flags |= 524288 /* HasAggregatedChildData */;
14518
+ node.flags |= 1048576 /* HasAggregatedChildData */;
14517
14519
  }
14518
14520
  }
14519
14521
  function getSourceFileOfNode(node) {
@@ -15157,6 +15159,10 @@ var ts;
15157
15159
  }
15158
15160
  }
15159
15161
  ts.isAnyImportSyntax = isAnyImportSyntax;
15162
+ function isAnyImportOrBareOrAccessedRequire(node) {
15163
+ return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
15164
+ }
15165
+ ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
15160
15166
  function isLateVisibilityPaintedStatement(node) {
15161
15167
  switch (node.kind) {
15162
15168
  case 266 /* ImportDeclaration */:
@@ -16320,11 +16326,11 @@ var ts;
16320
16326
  }
16321
16327
  ts.isSourceFileNotJS = isSourceFileNotJS;
16322
16328
  function isInJSFile(node) {
16323
- return !!node && !!(node.flags & 131072 /* JavaScriptFile */);
16329
+ return !!node && !!(node.flags & 262144 /* JavaScriptFile */);
16324
16330
  }
16325
16331
  ts.isInJSFile = isInJSFile;
16326
16332
  function isInJsonFile(node) {
16327
- return !!node && !!(node.flags & 33554432 /* JsonFile */);
16333
+ return !!node && !!(node.flags & 67108864 /* JsonFile */);
16328
16334
  }
16329
16335
  ts.isInJsonFile = isInJsonFile;
16330
16336
  function isSourceFileNotJson(file) {
@@ -16332,7 +16338,7 @@ var ts;
16332
16338
  }
16333
16339
  ts.isSourceFileNotJson = isSourceFileNotJson;
16334
16340
  function isInJSDoc(node) {
16335
- return !!node && !!(node.flags & 4194304 /* JSDoc */);
16341
+ return !!node && !!(node.flags & 8388608 /* JSDoc */);
16336
16342
  }
16337
16343
  ts.isInJSDoc = isInJSDoc;
16338
16344
  function isJSDocIndexSignature(node) {
@@ -16517,17 +16523,13 @@ var ts;
16517
16523
  if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
16518
16524
  return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
16519
16525
  }
16520
- if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
16526
+ if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
16521
16527
  (initializer.expression.kind === 108 /* ThisKeyword */ ||
16522
16528
  ts.isIdentifier(initializer.expression) &&
16523
16529
  (initializer.expression.escapedText === "window" ||
16524
16530
  initializer.expression.escapedText === "self" ||
16525
16531
  initializer.expression.escapedText === "global"))) {
16526
- var nameOrArgument = getNameOrArgument(initializer);
16527
- if (ts.isPrivateIdentifier(nameOrArgument)) {
16528
- ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
16529
- }
16530
- return isSameEntityName(name, nameOrArgument);
16532
+ return isSameEntityName(name, getNameOrArgument(initializer));
16531
16533
  }
16532
16534
  if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
16533
16535
  return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
@@ -16718,7 +16720,7 @@ var ts;
16718
16720
  function setValueDeclaration(symbol, node) {
16719
16721
  var valueDeclaration = symbol.valueDeclaration;
16720
16722
  if (!valueDeclaration ||
16721
- !(node.flags & 8388608 /* Ambient */ && !(valueDeclaration.flags & 8388608 /* Ambient */)) &&
16723
+ !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) &&
16722
16724
  (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
16723
16725
  (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
16724
16726
  // other kinds of value declarations take precedence over modules and assignment declarations
@@ -16735,14 +16737,14 @@ var ts;
16735
16737
  }
16736
16738
  ts.isFunctionSymbol = isFunctionSymbol;
16737
16739
  function tryGetModuleSpecifierFromDeclaration(node) {
16738
- var _a, _b, _c;
16740
+ var _a, _b;
16739
16741
  switch (node.kind) {
16740
16742
  case 254 /* VariableDeclaration */:
16741
- return node.initializer.arguments[0].text;
16743
+ return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
16742
16744
  case 266 /* ImportDeclaration */:
16743
- return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text;
16745
+ return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
16744
16746
  case 265 /* ImportEqualsDeclaration */:
16745
- 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;
16747
+ return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
16746
16748
  default:
16747
16749
  ts.Debug.assertNever(node);
16748
16750
  }
@@ -17257,7 +17259,10 @@ var ts;
17257
17259
  return parent.propertyName === node;
17258
17260
  case 275 /* ExportSpecifier */:
17259
17261
  case 285 /* JsxAttribute */:
17260
- // Any name in an export specifier or JSX Attribute
17262
+ case 279 /* JsxSelfClosingElement */:
17263
+ case 280 /* JsxOpeningElement */:
17264
+ case 281 /* JsxClosingElement */:
17265
+ // Any name in an export specifier or JSX Attribute or Jsx Element
17261
17266
  return true;
17262
17267
  }
17263
17268
  return false;
@@ -17273,21 +17278,28 @@ var ts;
17273
17278
  // export = <EntityNameExpression>
17274
17279
  // export default <EntityNameExpression>
17275
17280
  // module.exports = <EntityNameExpression>
17276
- // {<Identifier>}
17277
- // {name: <EntityNameExpression>}
17281
+ // module.exports.x = <EntityNameExpression>
17282
+ // const x = require("...")
17283
+ // const { x } = require("...")
17284
+ // const x = require("...").y
17285
+ // const { x } = require("...").y
17278
17286
  function isAliasSymbolDeclaration(node) {
17279
- return node.kind === 265 /* ImportEqualsDeclaration */ ||
17287
+ if (node.kind === 265 /* ImportEqualsDeclaration */ ||
17280
17288
  node.kind === 264 /* NamespaceExportDeclaration */ ||
17281
17289
  node.kind === 267 /* ImportClause */ && !!node.name ||
17282
17290
  node.kind === 268 /* NamespaceImport */ ||
17283
17291
  node.kind === 274 /* NamespaceExport */ ||
17284
17292
  node.kind === 270 /* ImportSpecifier */ ||
17285
17293
  node.kind === 275 /* ExportSpecifier */ ||
17286
- node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
17287
- ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17288
- ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) ||
17289
- node.kind === 297 /* ShorthandPropertyAssignment */ ||
17290
- node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer);
17294
+ node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
17295
+ return true;
17296
+ }
17297
+ return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17298
+ ts.isPropertyAccessExpression(node)
17299
+ && ts.isBinaryExpression(node.parent)
17300
+ && node.parent.left === node
17301
+ && node.parent.operatorToken.kind === 63 /* EqualsToken */
17302
+ && isAliasableExpression(node.parent.right));
17291
17303
  }
17292
17304
  ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
17293
17305
  function getAliasDeclarationFromName(node) {
@@ -17298,6 +17310,7 @@ var ts;
17298
17310
  case 275 /* ExportSpecifier */:
17299
17311
  case 271 /* ExportAssignment */:
17300
17312
  case 265 /* ImportEqualsDeclaration */:
17313
+ case 274 /* NamespaceExport */:
17301
17314
  return node.parent;
17302
17315
  case 161 /* QualifiedName */:
17303
17316
  do {
@@ -19124,6 +19137,11 @@ var ts;
19124
19137
  (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
19125
19138
  }
19126
19139
  ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
19140
+ function isRightSideOfAccessExpression(node) {
19141
+ return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
19142
+ || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
19143
+ }
19144
+ ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression;
19127
19145
  function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
19128
19146
  return ts.isQualifiedName(node.parent) && node.parent.right === node
19129
19147
  || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
@@ -19775,6 +19793,41 @@ var ts;
19775
19793
  return expr;
19776
19794
  }
19777
19795
  ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
19796
+ function forEachNameInAccessChainWalkingLeft(name, action) {
19797
+ if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
19798
+ return walkAccessExpression(name.parent);
19799
+ }
19800
+ function walkAccessExpression(access) {
19801
+ if (access.kind === 206 /* PropertyAccessExpression */) {
19802
+ var res = action(access.name);
19803
+ if (res !== undefined) {
19804
+ return res;
19805
+ }
19806
+ }
19807
+ else if (access.kind === 207 /* ElementAccessExpression */) {
19808
+ if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) {
19809
+ var res = action(access.argumentExpression);
19810
+ if (res !== undefined) {
19811
+ return res;
19812
+ }
19813
+ }
19814
+ else {
19815
+ // Chain interrupted by non-static-name access 'x[expr()].y.z'
19816
+ return undefined;
19817
+ }
19818
+ }
19819
+ if (isAccessExpression(access.expression)) {
19820
+ return walkAccessExpression(access.expression);
19821
+ }
19822
+ if (ts.isIdentifier(access.expression)) {
19823
+ // End of chain at Identifier 'x.y.z'
19824
+ return action(access.expression);
19825
+ }
19826
+ // End of chain at non-Identifier 'x().y.z'
19827
+ return undefined;
19828
+ }
19829
+ }
19830
+ ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft;
19778
19831
  function getLeftmostExpression(node, stopAtCallExpressions) {
19779
19832
  while (true) {
19780
19833
  switch (node.kind) {
@@ -20722,6 +20775,7 @@ var ts;
20722
20775
  ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
20723
20776
  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 */]];
20724
20777
  var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
20778
+ ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
20725
20779
  function getSupportedExtensions(options, extraFileExtensions) {
20726
20780
  var needJsExtensions = options && getAllowJSCompilerOption(options);
20727
20781
  if (!extraFileExtensions || extraFileExtensions.length === 0) {
@@ -21020,7 +21074,7 @@ var ts;
21020
21074
  }
21021
21075
  ts.pseudoBigIntToString = pseudoBigIntToString;
21022
21076
  function isValidTypeOnlyAliasUseSite(useSite) {
21023
- return !!(useSite.flags & 8388608 /* Ambient */)
21077
+ return !!(useSite.flags & 16777216 /* Ambient */)
21024
21078
  || isPartOfTypeQuery(useSite)
21025
21079
  || isIdentifierInNonEmittingHeritageClause(useSite)
21026
21080
  || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
@@ -21410,6 +21464,11 @@ var ts;
21410
21464
  return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
21411
21465
  }
21412
21466
  ts.getNodeModulePathParts = getNodeModulePathParts;
21467
+ function getParameterTypeNode(parameter) {
21468
+ var _a;
21469
+ return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
21470
+ }
21471
+ ts.getParameterTypeNode = getParameterTypeNode;
21413
21472
  })(ts || (ts = {}));
21414
21473
  /* @internal */
21415
21474
  var ts;
@@ -21473,11 +21532,20 @@ var ts;
21473
21532
  parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
21474
21533
  parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
21475
21534
  parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
21476
- parenthesizeMemberOfConditionalType: parenthesizeMemberOfConditionalType,
21477
- parenthesizeMemberOfElementType: parenthesizeMemberOfElementType,
21478
- parenthesizeElementTypeOfArrayType: parenthesizeElementTypeOfArrayType,
21479
- parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType,
21535
+ parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
21536
+ parenthesizeExtendsTypeOfConditionalType: parenthesizeExtendsTypeOfConditionalType,
21537
+ parenthesizeConstituentTypesOfUnionType: parenthesizeConstituentTypesOfUnionType,
21538
+ parenthesizeConstituentTypeOfUnionType: parenthesizeConstituentTypeOfUnionType,
21539
+ parenthesizeConstituentTypesOfIntersectionType: parenthesizeConstituentTypesOfIntersectionType,
21540
+ parenthesizeConstituentTypeOfIntersectionType: parenthesizeConstituentTypeOfIntersectionType,
21541
+ parenthesizeOperandOfTypeOperator: parenthesizeOperandOfTypeOperator,
21542
+ parenthesizeOperandOfReadonlyTypeOperator: parenthesizeOperandOfReadonlyTypeOperator,
21543
+ parenthesizeNonArrayTypeOfPostfixType: parenthesizeNonArrayTypeOfPostfixType,
21544
+ parenthesizeElementTypesOfTupleType: parenthesizeElementTypesOfTupleType,
21545
+ parenthesizeElementTypeOfTupleType: parenthesizeElementTypeOfTupleType,
21546
+ parenthesizeTypeOfOptionalType: parenthesizeTypeOfOptionalType,
21480
21547
  parenthesizeTypeArguments: parenthesizeTypeArguments,
21548
+ parenthesizeLeadingTypeArgument: parenthesizeLeadingTypeArgument,
21481
21549
  };
21482
21550
  function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
21483
21551
  binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map());
@@ -21789,33 +21857,191 @@ var ts;
21789
21857
  }
21790
21858
  return body;
21791
21859
  }
21792
- function parenthesizeMemberOfConditionalType(member) {
21793
- return member.kind === 189 /* ConditionalType */ ? factory.createParenthesizedType(member) : member;
21860
+ // Type[Extends] :
21861
+ // FunctionOrConstructorType
21862
+ // ConditionalType[?Extends]
21863
+ // ConditionalType[Extends] :
21864
+ // UnionType[?Extends]
21865
+ // [~Extends] UnionType[~Extends] `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
21866
+ //
21867
+ // - The check type (the `UnionType`, above) does not allow function, constructor, or conditional types (they must be parenthesized)
21868
+ // - The extends type (the first `Type`, above) does not allow conditional types (they must be parenthesized). Function and constructor types are fine.
21869
+ // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type
21870
+ function parenthesizeCheckTypeOfConditionalType(checkType) {
21871
+ switch (checkType.kind) {
21872
+ case 179 /* FunctionType */:
21873
+ case 180 /* ConstructorType */:
21874
+ case 189 /* ConditionalType */:
21875
+ return factory.createParenthesizedType(checkType);
21876
+ }
21877
+ return checkType;
21794
21878
  }
21795
- function parenthesizeMemberOfElementType(member) {
21796
- switch (member.kind) {
21879
+ function parenthesizeExtendsTypeOfConditionalType(extendsType) {
21880
+ switch (extendsType.kind) {
21881
+ case 189 /* ConditionalType */:
21882
+ return factory.createParenthesizedType(extendsType);
21883
+ }
21884
+ return extendsType;
21885
+ }
21886
+ // UnionType[Extends] :
21887
+ // `|`? IntersectionType[?Extends]
21888
+ // UnionType[?Extends] `|` IntersectionType[?Extends]
21889
+ //
21890
+ // - A union type constituent has the same precedence as the check type of a conditional type
21891
+ function parenthesizeConstituentTypeOfUnionType(type) {
21892
+ switch (type.kind) {
21893
+ case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened
21894
+ case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
21895
+ return factory.createParenthesizedType(type);
21896
+ }
21897
+ return parenthesizeCheckTypeOfConditionalType(type);
21898
+ }
21899
+ function parenthesizeConstituentTypesOfUnionType(members) {
21900
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfUnionType));
21901
+ }
21902
+ // IntersectionType[Extends] :
21903
+ // `&`? TypeOperator[?Extends]
21904
+ // IntersectionType[?Extends] `&` TypeOperator[?Extends]
21905
+ //
21906
+ // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized)
21907
+ function parenthesizeConstituentTypeOfIntersectionType(type) {
21908
+ switch (type.kind) {
21797
21909
  case 187 /* UnionType */:
21910
+ case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened
21911
+ return factory.createParenthesizedType(type);
21912
+ }
21913
+ return parenthesizeConstituentTypeOfUnionType(type);
21914
+ }
21915
+ function parenthesizeConstituentTypesOfIntersectionType(members) {
21916
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
21917
+ }
21918
+ // TypeOperator[Extends] :
21919
+ // PostfixType
21920
+ // InferType[?Extends]
21921
+ // `keyof` TypeOperator[?Extends]
21922
+ // `unique` TypeOperator[?Extends]
21923
+ // `readonly` TypeOperator[?Extends]
21924
+ //
21925
+ function parenthesizeOperandOfTypeOperator(type) {
21926
+ switch (type.kind) {
21798
21927
  case 188 /* IntersectionType */:
21799
- case 179 /* FunctionType */:
21800
- case 180 /* ConstructorType */:
21801
- return factory.createParenthesizedType(member);
21928
+ return factory.createParenthesizedType(type);
21802
21929
  }
21803
- return parenthesizeMemberOfConditionalType(member);
21930
+ return parenthesizeConstituentTypeOfIntersectionType(type);
21804
21931
  }
21805
- function parenthesizeElementTypeOfArrayType(member) {
21806
- switch (member.kind) {
21807
- case 181 /* TypeQuery */:
21932
+ function parenthesizeOperandOfReadonlyTypeOperator(type) {
21933
+ switch (type.kind) {
21808
21934
  case 193 /* TypeOperator */:
21935
+ return factory.createParenthesizedType(type);
21936
+ }
21937
+ return parenthesizeOperandOfTypeOperator(type);
21938
+ }
21939
+ // PostfixType :
21940
+ // NonArrayType
21941
+ // NonArrayType [no LineTerminator here] `!` // JSDoc
21942
+ // NonArrayType [no LineTerminator here] `?` // JSDoc
21943
+ // IndexedAccessType
21944
+ // ArrayType
21945
+ //
21946
+ // IndexedAccessType :
21947
+ // NonArrayType `[` Type[~Extends] `]`
21948
+ //
21949
+ // ArrayType :
21950
+ // NonArrayType `[` `]`
21951
+ //
21952
+ function parenthesizeNonArrayTypeOfPostfixType(type) {
21953
+ switch (type.kind) {
21809
21954
  case 190 /* InferType */:
21810
- return factory.createParenthesizedType(member);
21955
+ case 193 /* TypeOperator */:
21956
+ case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
21957
+ return factory.createParenthesizedType(type);
21811
21958
  }
21812
- return parenthesizeMemberOfElementType(member);
21959
+ return parenthesizeOperandOfTypeOperator(type);
21813
21960
  }
21814
- function parenthesizeConstituentTypesOfUnionOrIntersectionType(members) {
21815
- return factory.createNodeArray(ts.sameMap(members, parenthesizeMemberOfElementType));
21961
+ // TupleType :
21962
+ // `[` Elision? `]`
21963
+ // `[` NamedTupleElementTypes `]`
21964
+ // `[` NamedTupleElementTypes `,` Elision? `]`
21965
+ // `[` TupleElementTypes `]`
21966
+ // `[` TupleElementTypes `,` Elision? `]`
21967
+ //
21968
+ // NamedTupleElementTypes :
21969
+ // Elision? NamedTupleMember
21970
+ // NamedTupleElementTypes `,` Elision? NamedTupleMember
21971
+ //
21972
+ // NamedTupleMember :
21973
+ // Identifier `?`? `:` Type[~Extends]
21974
+ // `...` Identifier `:` Type[~Extends]
21975
+ //
21976
+ // TupleElementTypes :
21977
+ // Elision? TupleElementType
21978
+ // TupleElementTypes `,` Elision? TupleElementType
21979
+ //
21980
+ // TupleElementType :
21981
+ // Type[~Extends] // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
21982
+ // OptionalType
21983
+ // RestType
21984
+ //
21985
+ // OptionalType :
21986
+ // Type[~Extends] `?` // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
21987
+ //
21988
+ // RestType :
21989
+ // `...` Type[~Extends]
21990
+ //
21991
+ function parenthesizeElementTypesOfTupleType(types) {
21992
+ return factory.createNodeArray(ts.sameMap(types, parenthesizeElementTypeOfTupleType));
21993
+ }
21994
+ function parenthesizeElementTypeOfTupleType(type) {
21995
+ if (hasJSDocPostfixQuestion(type))
21996
+ return factory.createParenthesizedType(type);
21997
+ return type;
21998
+ }
21999
+ function hasJSDocPostfixQuestion(type) {
22000
+ if (ts.isJSDocNullableType(type))
22001
+ return type.postfix;
22002
+ if (ts.isNamedTupleMember(type))
22003
+ return hasJSDocPostfixQuestion(type.type);
22004
+ if (ts.isFunctionTypeNode(type) || ts.isConstructorTypeNode(type) || ts.isTypeOperatorNode(type))
22005
+ return hasJSDocPostfixQuestion(type.type);
22006
+ if (ts.isConditionalTypeNode(type))
22007
+ return hasJSDocPostfixQuestion(type.falseType);
22008
+ if (ts.isUnionTypeNode(type))
22009
+ return hasJSDocPostfixQuestion(ts.last(type.types));
22010
+ if (ts.isIntersectionTypeNode(type))
22011
+ return hasJSDocPostfixQuestion(ts.last(type.types));
22012
+ if (ts.isInferTypeNode(type))
22013
+ return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
22014
+ return false;
22015
+ }
22016
+ function parenthesizeTypeOfOptionalType(type) {
22017
+ if (hasJSDocPostfixQuestion(type))
22018
+ return factory.createParenthesizedType(type);
22019
+ return parenthesizeNonArrayTypeOfPostfixType(type);
22020
+ }
22021
+ // function parenthesizeMemberOfElementType(member: TypeNode): TypeNode {
22022
+ // switch (member.kind) {
22023
+ // case SyntaxKind.UnionType:
22024
+ // case SyntaxKind.IntersectionType:
22025
+ // case SyntaxKind.FunctionType:
22026
+ // case SyntaxKind.ConstructorType:
22027
+ // return factory.createParenthesizedType(member);
22028
+ // }
22029
+ // return parenthesizeMemberOfConditionalType(member);
22030
+ // }
22031
+ // function parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode {
22032
+ // switch (member.kind) {
22033
+ // case SyntaxKind.TypeQuery:
22034
+ // case SyntaxKind.TypeOperator:
22035
+ // case SyntaxKind.InferType:
22036
+ // return factory.createParenthesizedType(member);
22037
+ // }
22038
+ // return parenthesizeMemberOfElementType(member);
22039
+ // }
22040
+ function parenthesizeLeadingTypeArgument(node) {
22041
+ return ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
21816
22042
  }
21817
22043
  function parenthesizeOrdinalTypeArgument(node, i) {
21818
- return i === 0 && ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
22044
+ return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
21819
22045
  }
21820
22046
  function parenthesizeTypeArguments(typeArguments) {
21821
22047
  if (ts.some(typeArguments)) {
@@ -21841,11 +22067,20 @@ var ts;
21841
22067
  parenthesizeExpressionForDisallowedComma: ts.identity,
21842
22068
  parenthesizeExpressionOfExpressionStatement: ts.identity,
21843
22069
  parenthesizeConciseBodyOfArrowFunction: ts.identity,
21844
- parenthesizeMemberOfConditionalType: ts.identity,
21845
- parenthesizeMemberOfElementType: ts.identity,
21846
- parenthesizeElementTypeOfArrayType: ts.identity,
21847
- parenthesizeConstituentTypesOfUnionOrIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
22070
+ parenthesizeCheckTypeOfConditionalType: ts.identity,
22071
+ parenthesizeExtendsTypeOfConditionalType: ts.identity,
22072
+ parenthesizeConstituentTypesOfUnionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
22073
+ parenthesizeConstituentTypeOfUnionType: ts.identity,
22074
+ parenthesizeConstituentTypesOfIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
22075
+ parenthesizeConstituentTypeOfIntersectionType: ts.identity,
22076
+ parenthesizeOperandOfTypeOperator: ts.identity,
22077
+ parenthesizeOperandOfReadonlyTypeOperator: ts.identity,
22078
+ parenthesizeNonArrayTypeOfPostfixType: ts.identity,
22079
+ parenthesizeElementTypesOfTupleType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
22080
+ parenthesizeElementTypeOfTupleType: ts.identity,
22081
+ parenthesizeTypeOfOptionalType: ts.identity,
21848
22082
  parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
22083
+ parenthesizeLeadingTypeArgument: ts.identity,
21849
22084
  };
21850
22085
  })(ts || (ts = {}));
21851
22086
  /* @internal */
@@ -21985,6 +22220,8 @@ var ts;
21985
22220
  var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
21986
22221
  var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
21987
22222
  var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
22223
+ var getJSDocPrePostfixUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type, postfix) { return createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix); }; });
22224
+ var getJSDocPrePostfixUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocPrePostfixUnaryTypeWorker(kind, node, type); }; });
21988
22225
  var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
21989
22226
  var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
21990
22227
  var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
@@ -21992,6 +22229,8 @@ var ts;
21992
22229
  var factory = {
21993
22230
  get parenthesizer() { return parenthesizerRules(); },
21994
22231
  get converters() { return converters(); },
22232
+ baseFactory: baseFactory,
22233
+ flags: flags,
21995
22234
  createNodeArray: createNodeArray,
21996
22235
  createNumericLiteral: createNumericLiteral,
21997
22236
  createBigIntLiteral: createBigIntLiteral,
@@ -22267,10 +22506,10 @@ var ts;
22267
22506
  // lazily load factory members for JSDoc types with similar structure
22268
22507
  get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); },
22269
22508
  get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); },
22270
- get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
22271
- get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
22272
- get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
22273
- get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
22509
+ get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
22510
+ get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
22511
+ get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
22512
+ get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
22274
22513
  get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); },
22275
22514
  get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); },
22276
22515
  get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); },
@@ -23386,7 +23625,7 @@ var ts;
23386
23625
  // @api
23387
23626
  function createArrayTypeNode(elementType) {
23388
23627
  var node = createBaseNode(183 /* ArrayType */);
23389
- node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType);
23628
+ node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
23390
23629
  node.transformFlags = 1 /* ContainsTypeScript */;
23391
23630
  return node;
23392
23631
  }
@@ -23399,7 +23638,7 @@ var ts;
23399
23638
  // @api
23400
23639
  function createTupleTypeNode(elements) {
23401
23640
  var node = createBaseNode(184 /* TupleType */);
23402
- node.elements = createNodeArray(elements);
23641
+ node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
23403
23642
  node.transformFlags = 1 /* ContainsTypeScript */;
23404
23643
  return node;
23405
23644
  }
@@ -23431,7 +23670,7 @@ var ts;
23431
23670
  // @api
23432
23671
  function createOptionalTypeNode(type) {
23433
23672
  var node = createBaseNode(185 /* OptionalType */);
23434
- node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type);
23673
+ node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
23435
23674
  node.transformFlags = 1 /* ContainsTypeScript */;
23436
23675
  return node;
23437
23676
  }
@@ -23454,38 +23693,38 @@ var ts;
23454
23693
  ? update(createRestTypeNode(type), node)
23455
23694
  : node;
23456
23695
  }
23457
- function createUnionOrIntersectionTypeNode(kind, types) {
23696
+ function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
23458
23697
  var node = createBaseNode(kind);
23459
- node.types = parenthesizerRules().parenthesizeConstituentTypesOfUnionOrIntersectionType(types);
23698
+ node.types = factory.createNodeArray(parenthesize(types));
23460
23699
  node.transformFlags = 1 /* ContainsTypeScript */;
23461
23700
  return node;
23462
23701
  }
23463
- function updateUnionOrIntersectionTypeNode(node, types) {
23702
+ function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
23464
23703
  return node.types !== types
23465
- ? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
23704
+ ? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node)
23466
23705
  : node;
23467
23706
  }
23468
23707
  // @api
23469
23708
  function createUnionTypeNode(types) {
23470
- return createUnionOrIntersectionTypeNode(187 /* UnionType */, types);
23709
+ return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
23471
23710
  }
23472
23711
  // @api
23473
23712
  function updateUnionTypeNode(node, types) {
23474
- return updateUnionOrIntersectionTypeNode(node, types);
23713
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
23475
23714
  }
23476
23715
  // @api
23477
23716
  function createIntersectionTypeNode(types) {
23478
- return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types);
23717
+ return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
23479
23718
  }
23480
23719
  // @api
23481
23720
  function updateIntersectionTypeNode(node, types) {
23482
- return updateUnionOrIntersectionTypeNode(node, types);
23721
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
23483
23722
  }
23484
23723
  // @api
23485
23724
  function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
23486
23725
  var node = createBaseNode(189 /* ConditionalType */);
23487
- node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType);
23488
- node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType);
23726
+ node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
23727
+ node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
23489
23728
  node.trueType = trueType;
23490
23729
  node.falseType = falseType;
23491
23730
  node.transformFlags = 1 /* ContainsTypeScript */;
@@ -23580,7 +23819,9 @@ var ts;
23580
23819
  function createTypeOperatorNode(operator, type) {
23581
23820
  var node = createBaseNode(193 /* TypeOperator */);
23582
23821
  node.operator = operator;
23583
- node.type = parenthesizerRules().parenthesizeMemberOfElementType(type);
23822
+ node.type = operator === 145 /* ReadonlyKeyword */ ?
23823
+ parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) :
23824
+ parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
23584
23825
  node.transformFlags = 1 /* ContainsTypeScript */;
23585
23826
  return node;
23586
23827
  }
@@ -23593,7 +23834,7 @@ var ts;
23593
23834
  // @api
23594
23835
  function createIndexedAccessTypeNode(objectType, indexType) {
23595
23836
  var node = createBaseNode(194 /* IndexedAccessType */);
23596
- node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType);
23837
+ node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
23597
23838
  node.indexType = indexType;
23598
23839
  node.transformFlags = 1 /* ContainsTypeScript */;
23599
23840
  return node;
@@ -25329,8 +25570,15 @@ var ts;
25329
25570
  return createBaseNode(kind);
25330
25571
  }
25331
25572
  // @api
25332
- // createJSDocNonNullableType
25333
25573
  // createJSDocNullableType
25574
+ // createJSDocNonNullableType
25575
+ function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix) {
25576
+ if (postfix === void 0) { postfix = false; }
25577
+ var node = createJSDocUnaryTypeWorker(kind, postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type);
25578
+ node.postfix = postfix;
25579
+ return node;
25580
+ }
25581
+ // @api
25334
25582
  // createJSDocOptionalType
25335
25583
  // createJSDocVariadicType
25336
25584
  // createJSDocNamepathType
@@ -25342,6 +25590,12 @@ var ts;
25342
25590
  // @api
25343
25591
  // updateJSDocNonNullableType
25344
25592
  // updateJSDocNullableType
25593
+ function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
25594
+ return node.type !== type
25595
+ ? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node)
25596
+ : node;
25597
+ }
25598
+ // @api
25345
25599
  // updateJSDocOptionalType
25346
25600
  // updateJSDocVariadicType
25347
25601
  // updateJSDocNamepathType
@@ -30422,7 +30676,7 @@ var ts;
30422
30676
  || ts.isExportDeclaration(node) ? node : undefined;
30423
30677
  }
30424
30678
  function getImportMetaIfNecessary(sourceFile) {
30425
- return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
30679
+ return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ?
30426
30680
  walkTreeForImportMeta(sourceFile) :
30427
30681
  undefined;
30428
30682
  }
@@ -31077,7 +31331,7 @@ var ts;
31077
31331
  var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
31078
31332
  // 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.
31079
31333
  // We will manually port the flag to the new source file.
31080
- newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */);
31334
+ newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */);
31081
31335
  return newSourceFile;
31082
31336
  }
31083
31337
  ts.updateSourceFile = updateSourceFile;
@@ -31361,10 +31615,10 @@ var ts;
31361
31615
  switch (scriptKind) {
31362
31616
  case 1 /* JS */:
31363
31617
  case 2 /* JSX */:
31364
- contextFlags = 131072 /* JavaScriptFile */;
31618
+ contextFlags = 262144 /* JavaScriptFile */;
31365
31619
  break;
31366
31620
  case 6 /* JSON */:
31367
- contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */;
31621
+ contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */;
31368
31622
  break;
31369
31623
  default:
31370
31624
  contextFlags = 0 /* None */;
@@ -31399,7 +31653,7 @@ var ts;
31399
31653
  function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
31400
31654
  var isDeclarationFile = isDeclarationFileName(fileName);
31401
31655
  if (isDeclarationFile) {
31402
- contextFlags |= 8388608 /* Ambient */;
31656
+ contextFlags |= 16777216 /* Ambient */;
31403
31657
  }
31404
31658
  sourceFlags = contextFlags;
31405
31659
  // Prime the scanner.
@@ -31438,7 +31692,7 @@ var ts;
31438
31692
  node.jsDoc = jsDoc;
31439
31693
  if (hasDeprecatedTag) {
31440
31694
  hasDeprecatedTag = false;
31441
- node.flags |= 134217728 /* Deprecated */;
31695
+ node.flags |= 268435456 /* Deprecated */;
31442
31696
  }
31443
31697
  return node;
31444
31698
  }
@@ -31633,6 +31887,12 @@ var ts;
31633
31887
  function disallowInAnd(func) {
31634
31888
  return doInsideOfContext(4096 /* DisallowInContext */, func);
31635
31889
  }
31890
+ function allowConditionalTypesAnd(func) {
31891
+ return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
31892
+ }
31893
+ function disallowConditionalTypesAnd(func) {
31894
+ return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
31895
+ }
31636
31896
  function doInYieldContext(func) {
31637
31897
  return doInsideOfContext(8192 /* YieldContext */, func);
31638
31898
  }
@@ -31660,6 +31920,9 @@ var ts;
31660
31920
  function inDisallowInContext() {
31661
31921
  return inContext(4096 /* DisallowInContext */);
31662
31922
  }
31923
+ function inDisallowConditionalTypesContext() {
31924
+ return inContext(65536 /* DisallowConditionalTypesContext */);
31925
+ }
31663
31926
  function inDecoratorContext() {
31664
31927
  return inContext(16384 /* DecoratorContext */);
31665
31928
  }
@@ -32044,7 +32307,7 @@ var ts;
32044
32307
  // flag so that we don't mark any subsequent nodes.
32045
32308
  if (parseErrorBeforeNextFinishedNode) {
32046
32309
  parseErrorBeforeNextFinishedNode = false;
32047
- node.flags |= 65536 /* ThisNodeHasError */;
32310
+ node.flags |= 131072 /* ThisNodeHasError */;
32048
32311
  }
32049
32312
  return node;
32050
32313
  }
@@ -32502,7 +32765,7 @@ var ts;
32502
32765
  // differently depending on what mode it is in.
32503
32766
  //
32504
32767
  // This also applies to all our other context flags as well.
32505
- var nodeContextFlags = node.flags & 25358336 /* ContextFlags */;
32768
+ var nodeContextFlags = node.flags & 50720768 /* ContextFlags */;
32506
32769
  if (nodeContextFlags !== contextFlags) {
32507
32770
  return undefined;
32508
32771
  }
@@ -33027,7 +33290,7 @@ var ts;
33027
33290
  function parseJSDocNonNullableType() {
33028
33291
  var pos = getNodePos();
33029
33292
  nextToken();
33030
- return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
33293
+ return finishNode(factory.createJSDocNonNullableType(parseNonArrayType(), /*postfix*/ false), pos);
33031
33294
  }
33032
33295
  function parseJSDocUnknownOrNullableType() {
33033
33296
  var pos = getNodePos();
@@ -33051,7 +33314,7 @@ var ts;
33051
33314
  return finishNode(factory.createJSDocUnknownType(), pos);
33052
33315
  }
33053
33316
  else {
33054
- return finishNode(factory.createJSDocNullableType(parseType()), pos);
33317
+ return finishNode(factory.createJSDocNullableType(parseType(), /*postfix*/ false), pos);
33055
33318
  }
33056
33319
  }
33057
33320
  function parseJSDocFunctionType() {
@@ -33223,7 +33486,7 @@ var ts;
33223
33486
  }
33224
33487
  function parseReturnType(returnToken, isType) {
33225
33488
  if (shouldParseReturnType(returnToken, isType)) {
33226
- return parseTypeOrTypePredicate();
33489
+ return allowConditionalTypesAnd(parseTypeOrTypePredicate);
33227
33490
  }
33228
33491
  }
33229
33492
  function shouldParseReturnType(returnToken, isType) {
@@ -33638,7 +33901,7 @@ var ts;
33638
33901
  return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
33639
33902
  }
33640
33903
  function parseImportType() {
33641
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
33904
+ sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
33642
33905
  var pos = getNodePos();
33643
33906
  var isTypeOf = parseOptional(112 /* TypeOfKeyword */);
33644
33907
  parseExpected(100 /* ImportKeyword */);
@@ -33788,7 +34051,7 @@ var ts;
33788
34051
  switch (token()) {
33789
34052
  case 53 /* ExclamationToken */:
33790
34053
  nextToken();
33791
- type = finishNode(factory.createJSDocNonNullableType(type), pos);
34054
+ type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos);
33792
34055
  break;
33793
34056
  case 57 /* QuestionToken */:
33794
34057
  // If next token is start of a type we have a conditional type
@@ -33796,7 +34059,7 @@ var ts;
33796
34059
  return type;
33797
34060
  }
33798
34061
  nextToken();
33799
- type = finishNode(factory.createJSDocNullableType(type), pos);
34062
+ type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos);
33800
34063
  break;
33801
34064
  case 22 /* OpenBracketToken */:
33802
34065
  parseExpected(22 /* OpenBracketToken */);
@@ -33821,12 +34084,20 @@ var ts;
33821
34084
  parseExpected(operator);
33822
34085
  return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
33823
34086
  }
34087
+ function tryParseConstraintOfInferType() {
34088
+ if (parseOptional(94 /* ExtendsKeyword */)) {
34089
+ var constraint = disallowConditionalTypesAnd(parseType);
34090
+ if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) {
34091
+ return constraint;
34092
+ }
34093
+ }
34094
+ }
33824
34095
  function parseTypeParameterOfInferType() {
33825
34096
  var pos = getNodePos();
33826
- return finishNode(factory.createTypeParameterDeclaration(
33827
- /*modifiers*/ undefined, parseIdentifier(),
33828
- /*constraint*/ undefined,
33829
- /*defaultType*/ undefined), pos);
34097
+ var name = parseIdentifier();
34098
+ var constraint = tryParse(tryParseConstraintOfInferType);
34099
+ var node = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint);
34100
+ return finishNode(node, pos);
33830
34101
  }
33831
34102
  function parseInferType() {
33832
34103
  var pos = getNodePos();
@@ -33843,7 +34114,7 @@ var ts;
33843
34114
  case 137 /* InferKeyword */:
33844
34115
  return parseInferType();
33845
34116
  }
33846
- return parsePostfixTypeOrHigher();
34117
+ return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
33847
34118
  }
33848
34119
  function parseFunctionOrConstructorTypeToError(isInUnionType) {
33849
34120
  // the function type and constructor type shorthand notation
@@ -33973,23 +34244,21 @@ var ts;
33973
34244
  return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
33974
34245
  }
33975
34246
  function parseType() {
33976
- // The rules about 'yield' only apply to actual code/expression contexts. They don't
33977
- // apply to 'type' contexts. So we disable these parameters here before moving on.
33978
- return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker);
33979
- }
33980
- function parseTypeWorker(noConditionalTypes) {
34247
+ if (contextFlags & 40960 /* TypeExcludesFlags */) {
34248
+ return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType);
34249
+ }
33981
34250
  if (isStartOfFunctionTypeOrConstructorType()) {
33982
34251
  return parseFunctionOrConstructorType();
33983
34252
  }
33984
34253
  var pos = getNodePos();
33985
34254
  var type = parseUnionTypeOrHigher();
33986
- if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
34255
+ if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
33987
34256
  // The type following 'extends' is not permitted to be another conditional type
33988
- var extendsType = parseTypeWorker(/*noConditionalTypes*/ true);
34257
+ var extendsType = disallowConditionalTypesAnd(parseType);
33989
34258
  parseExpected(57 /* QuestionToken */);
33990
- var trueType = parseTypeWorker();
34259
+ var trueType = allowConditionalTypesAnd(parseType);
33991
34260
  parseExpected(58 /* ColonToken */);
33992
- var falseType = parseTypeWorker();
34261
+ var falseType = allowConditionalTypesAnd(parseType);
33993
34262
  return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
33994
34263
  }
33995
34264
  return type;
@@ -34826,7 +35095,7 @@ var ts;
34826
35095
  // var foo3 = require("subfolder
34827
35096
  // import * as foo1 from "module-from-node
34828
35097
  // We want this import to be a statement rather than import call expression
34829
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
35098
+ sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
34830
35099
  expression = parseTokenNode();
34831
35100
  }
34832
35101
  else if (lookAhead(nextTokenIsDot)) {
@@ -34834,7 +35103,7 @@ var ts;
34834
35103
  nextToken(); // advance past the 'import'
34835
35104
  nextToken(); // advance past the dot
34836
35105
  expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos);
34837
- sourceFlags |= 2097152 /* PossiblyContainsImportMeta */;
35106
+ sourceFlags |= 4194304 /* PossiblyContainsImportMeta */;
34838
35107
  }
34839
35108
  else {
34840
35109
  expression = parseMemberExpressionOrHigher();
@@ -35050,7 +35319,7 @@ var ts;
35050
35319
  return finishNode(factory.createJsxOpeningFragment(), pos);
35051
35320
  }
35052
35321
  var tagName = parseJsxElementName();
35053
- var typeArguments = (contextFlags & 131072 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
35322
+ var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
35054
35323
  var attributes = parseJsxAttributes();
35055
35324
  var node;
35056
35325
  if (token() === 31 /* GreaterThanToken */) {
@@ -35328,7 +35597,7 @@ var ts;
35328
35597
  return result;
35329
35598
  }
35330
35599
  function parseTypeArgumentsInExpression() {
35331
- if ((contextFlags & 131072 /* JavaScriptFile */) !== 0) {
35600
+ if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) {
35332
35601
  // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators.
35333
35602
  return undefined;
35334
35603
  }
@@ -35353,34 +35622,10 @@ var ts;
35353
35622
  case 20 /* OpenParenToken */: // foo<x>(
35354
35623
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35355
35624
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35356
- // These tokens can't follow in a call expression, nor can they start an
35357
- // expression. So, consider the type argument list part of an instantiation
35358
- // expression.
35359
- // falls through
35360
- case 27 /* CommaToken */: // foo<x>,
35361
- case 24 /* DotToken */: // foo<x>.
35362
- case 28 /* QuestionDotToken */: // foo<x>?.
35363
- case 21 /* CloseParenToken */: // foo<x>)
35364
- case 23 /* CloseBracketToken */: // foo<x>]
35365
- case 58 /* ColonToken */: // foo<x>:
35366
- case 26 /* SemicolonToken */: // foo<x>;
35367
- case 57 /* QuestionToken */: // foo<x>?
35368
- case 34 /* EqualsEqualsToken */: // foo<x> ==
35369
- case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
35370
- case 35 /* ExclamationEqualsToken */: // foo<x> !=
35371
- case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
35372
- case 55 /* AmpersandAmpersandToken */: // foo<x> &&
35373
- case 56 /* BarBarToken */: // foo<x> ||
35374
- case 60 /* QuestionQuestionToken */: // foo<x> ??
35375
- case 52 /* CaretToken */: // foo<x> ^
35376
- case 50 /* AmpersandToken */: // foo<x> &
35377
- case 51 /* BarToken */: // foo<x> |
35378
- case 19 /* CloseBraceToken */: // foo<x> }
35379
- case 1 /* EndOfFileToken */: // foo<x>
35380
35625
  return true;
35381
35626
  }
35382
- // Treat anything else as an expression.
35383
- return false;
35627
+ // Consider something a type argument list only if the following token can't start an expression.
35628
+ return !isStartOfExpression();
35384
35629
  }
35385
35630
  function parsePrimaryExpression() {
35386
35631
  switch (token()) {
@@ -35724,7 +35969,7 @@ var ts;
35724
35969
  var openParenParsed = parseExpected(20 /* OpenParenToken */);
35725
35970
  var expression = allowInAnd(parseExpression);
35726
35971
  parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35727
- var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
35972
+ var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement);
35728
35973
  return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
35729
35974
  }
35730
35975
  function parseCaseClause() {
@@ -36099,16 +36344,16 @@ var ts;
36099
36344
  if (isAmbient) {
36100
36345
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36101
36346
  var m = _a[_i];
36102
- m.flags |= 8388608 /* Ambient */;
36347
+ m.flags |= 16777216 /* Ambient */;
36103
36348
  }
36104
- return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
36349
+ return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
36105
36350
  }
36106
36351
  else {
36107
36352
  return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
36108
36353
  }
36109
36354
  }
36110
36355
  function tryReuseAmbientDeclaration() {
36111
- return doInsideOfContext(8388608 /* Ambient */, function () {
36356
+ return doInsideOfContext(16777216 /* Ambient */, function () {
36112
36357
  var node = currentNode(parsingContext);
36113
36358
  if (node) {
36114
36359
  return consumeNode(node);
@@ -36575,9 +36820,9 @@ var ts;
36575
36820
  if (isAmbient) {
36576
36821
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36577
36822
  var m = _a[_i];
36578
- m.flags |= 8388608 /* Ambient */;
36823
+ m.flags |= 16777216 /* Ambient */;
36579
36824
  }
36580
- return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
36825
+ return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
36581
36826
  }
36582
36827
  else {
36583
36828
  return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
@@ -37142,7 +37387,7 @@ var ts;
37142
37387
  function parseJSDocTypeExpression(mayOmitBraces) {
37143
37388
  var pos = getNodePos();
37144
37389
  var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */);
37145
- var type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
37390
+ var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
37146
37391
  if (!mayOmitBraces || hasBrace) {
37147
37392
  parseExpectedJSDoc(19 /* CloseBraceToken */);
37148
37393
  }
@@ -37171,7 +37416,7 @@ var ts;
37171
37416
  JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
37172
37417
  function parseIsolatedJSDocComment(content, start, length) {
37173
37418
  initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
37174
- var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37419
+ var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37175
37420
  var sourceFile = { languageVariant: 0 /* Standard */, text: content };
37176
37421
  var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
37177
37422
  clearState();
@@ -37182,9 +37427,9 @@ var ts;
37182
37427
  var saveToken = currentToken;
37183
37428
  var saveParseDiagnosticsLength = parseDiagnostics.length;
37184
37429
  var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
37185
- var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37430
+ var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37186
37431
  ts.setParent(comment, parent);
37187
- if (contextFlags & 131072 /* JavaScriptFile */) {
37432
+ if (contextFlags & 262144 /* JavaScriptFile */) {
37188
37433
  if (!jsDocDiagnostics) {
37189
37434
  jsDocDiagnostics = [];
37190
37435
  }
@@ -38000,7 +38245,7 @@ var ts;
38000
38245
  if (isBracketed) {
38001
38246
  skipWhitespace();
38002
38247
  parseExpected(63 /* EqualsToken */);
38003
- defaultType = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
38248
+ defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
38004
38249
  parseExpected(23 /* CloseBracketToken */);
38005
38250
  }
38006
38251
  if (ts.nodeIsMissing(name)) {
@@ -38598,7 +38843,7 @@ var ts;
38598
38843
  })(IncrementalParser || (IncrementalParser = {}));
38599
38844
  /** @internal */
38600
38845
  function isDeclarationFileName(fileName) {
38601
- return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
38846
+ return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
38602
38847
  }
38603
38848
  ts.isDeclarationFileName = isDeclarationFileName;
38604
38849
  function parseResolutionMode(mode, pos, end, reportDiagnostic) {
@@ -42106,7 +42351,8 @@ var ts;
42106
42351
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
42107
42352
  Extensions[Extensions["Json"] = 2] = "Json";
42108
42353
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
42109
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
42354
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
42355
+ Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
42110
42356
  })(Extensions || (Extensions = {}));
42111
42357
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
42112
42358
  function resolvedTypeScriptOnly(resolved) {
@@ -43051,7 +43297,21 @@ var ts;
43051
43297
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43052
43298
  }
43053
43299
  function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
43054
- return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
43300
+ var extensions;
43301
+ if (lookupConfig) {
43302
+ extensions = tsconfigExtensions;
43303
+ }
43304
+ else if (compilerOptions.noDtsResolution) {
43305
+ extensions = [Extensions.TsOnly];
43306
+ if (compilerOptions.allowJs)
43307
+ extensions.push(Extensions.JavaScript);
43308
+ if (compilerOptions.resolveJsonModule)
43309
+ extensions.push(Extensions.Json);
43310
+ }
43311
+ else {
43312
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
43313
+ }
43314
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
43055
43315
  }
43056
43316
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
43057
43317
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -43060,6 +43320,10 @@ var ts;
43060
43320
  var failedLookupLocations = [];
43061
43321
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
43062
43322
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43323
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
43324
+ if (compilerOptions.noDtsResolution) {
43325
+ conditions.pop();
43326
+ }
43063
43327
  var state = {
43064
43328
  compilerOptions: compilerOptions,
43065
43329
  host: host,
@@ -43067,7 +43331,7 @@ var ts;
43067
43331
  failedLookupLocations: failedLookupLocations,
43068
43332
  packageJsonInfoCache: cache,
43069
43333
  features: features,
43070
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
43334
+ conditions: conditions,
43071
43335
  };
43072
43336
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43073
43337
  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);
@@ -43243,9 +43507,9 @@ var ts;
43243
43507
  }
43244
43508
  }
43245
43509
  function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
43246
- if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) {
43510
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
43247
43511
  var result = tryFile(candidate, onlyRecordFailures, state);
43248
- 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;
43512
+ return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43249
43513
  }
43250
43514
  return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
43251
43515
  }
@@ -43275,20 +43539,22 @@ var ts;
43275
43539
  default: return tryExtension(".d.ts" /* Dts */);
43276
43540
  }
43277
43541
  case Extensions.TypeScript:
43542
+ case Extensions.TsOnly:
43543
+ var useDts = extensions === Extensions.TypeScript;
43278
43544
  switch (originalExtension) {
43279
43545
  case ".mjs" /* Mjs */:
43280
43546
  case ".mts" /* Mts */:
43281
43547
  case ".d.mts" /* Dmts */:
43282
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43548
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
43283
43549
  case ".cjs" /* Cjs */:
43284
43550
  case ".cts" /* Cts */:
43285
43551
  case ".d.cts" /* Dcts */:
43286
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43552
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
43287
43553
  case ".json" /* Json */:
43288
43554
  candidate += ".json" /* Json */;
43289
- return tryExtension(".d.ts" /* Dts */);
43555
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
43290
43556
  default:
43291
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
43557
+ return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
43292
43558
  }
43293
43559
  case Extensions.JavaScript:
43294
43560
  switch (originalExtension) {
@@ -43515,6 +43781,7 @@ var ts;
43515
43781
  switch (extensions) {
43516
43782
  case Extensions.JavaScript:
43517
43783
  case Extensions.Json:
43784
+ case Extensions.TsOnly:
43518
43785
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43519
43786
  break;
43520
43787
  case Extensions.TypeScript:
@@ -43587,14 +43854,16 @@ var ts;
43587
43854
  function extensionIsOk(extensions, extension) {
43588
43855
  switch (extensions) {
43589
43856
  case Extensions.JavaScript:
43590
- return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
43857
+ return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
43591
43858
  case Extensions.TSConfig:
43592
43859
  case Extensions.Json:
43593
43860
  return extension === ".json" /* Json */;
43594
43861
  case Extensions.TypeScript:
43595
- return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43862
+ 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 */;
43863
+ case Extensions.TsOnly:
43864
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
43596
43865
  case Extensions.DtsOnly:
43597
- return extension === ".d.ts" /* Dts */;
43866
+ return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
43598
43867
  }
43599
43868
  }
43600
43869
  /* @internal */
@@ -45754,6 +46023,7 @@ var ts;
45754
46023
  case 261 /* ModuleDeclaration */:
45755
46024
  case 259 /* TypeAliasDeclaration */:
45756
46025
  case 195 /* MappedType */:
46026
+ case 176 /* IndexSignature */:
45757
46027
  return 1 /* IsContainer */ | 32 /* HasLocals */;
45758
46028
  case 305 /* SourceFile */:
45759
46029
  return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
@@ -45772,7 +46042,6 @@ var ts;
45772
46042
  case 317 /* JSDocFunctionType */:
45773
46043
  case 179 /* FunctionType */:
45774
46044
  case 175 /* ConstructSignature */:
45775
- case 176 /* IndexSignature */:
45776
46045
  case 180 /* ConstructorType */:
45777
46046
  case 170 /* ClassStaticBlockDeclaration */:
45778
46047
  return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
@@ -45888,7 +46157,7 @@ var ts;
45888
46157
  function setExportContextFlag(node) {
45889
46158
  // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
45890
46159
  // declarations with export modifiers) is an export context in which declarations are implicitly exported.
45891
- if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) {
46160
+ if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) {
45892
46161
  node.flags |= 64 /* ExportContext */;
45893
46162
  }
45894
46163
  else {
@@ -46091,8 +46360,8 @@ var ts;
46091
46360
  function checkContextualIdentifier(node) {
46092
46361
  // Report error only if there are no parse errors in file
46093
46362
  if (!file.parseDiagnostics.length &&
46094
- !(node.flags & 8388608 /* Ambient */) &&
46095
- !(node.flags & 4194304 /* JSDoc */) &&
46363
+ !(node.flags & 16777216 /* Ambient */) &&
46364
+ !(node.flags & 8388608 /* JSDoc */) &&
46096
46365
  !ts.isIdentifierName(node)) {
46097
46366
  // strict mode identifiers
46098
46367
  if (inStrictMode &&
@@ -47121,7 +47390,7 @@ var ts;
47121
47390
  if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) {
47122
47391
  return;
47123
47392
  }
47124
- if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) {
47393
+ if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) {
47125
47394
  // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
47126
47395
  // strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
47127
47396
  checkStrictModeEvalOrArguments(node, node.name);
@@ -47140,7 +47409,7 @@ var ts;
47140
47409
  }
47141
47410
  }
47142
47411
  function bindFunctionDeclaration(node) {
47143
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
47412
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
47144
47413
  if (ts.isAsyncFunction(node)) {
47145
47414
  emitFlags |= 2048 /* HasAsyncFunctions */;
47146
47415
  }
@@ -47155,7 +47424,7 @@ var ts;
47155
47424
  }
47156
47425
  }
47157
47426
  function bindFunctionExpression(node) {
47158
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
47427
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
47159
47428
  if (ts.isAsyncFunction(node)) {
47160
47429
  emitFlags |= 2048 /* HasAsyncFunctions */;
47161
47430
  }
@@ -47168,7 +47437,7 @@ var ts;
47168
47437
  return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
47169
47438
  }
47170
47439
  function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
47171
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) {
47440
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) {
47172
47441
  emitFlags |= 2048 /* HasAsyncFunctions */;
47173
47442
  }
47174
47443
  if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
@@ -47241,7 +47510,7 @@ var ts;
47241
47510
  // Rationale: we don't want to report errors on non-initialized var's since they are hoisted
47242
47511
  // On the other side we do want to report errors on non-initialized 'lets' because of TDZ
47243
47512
  var isError_1 = ts.unreachableCodeIsError(options) &&
47244
- !(node.flags & 8388608 /* Ambient */) &&
47513
+ !(node.flags & 16777216 /* Ambient */) &&
47245
47514
  (!ts.isVariableStatement(node) ||
47246
47515
  !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) ||
47247
47516
  node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
@@ -48141,7 +48410,7 @@ var ts;
48141
48410
  ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
48142
48411
  diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
48143
48412
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
48144
- if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
48413
+ if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
48145
48414
  (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
48146
48415
  }
48147
48416
  });
@@ -48592,7 +48861,7 @@ var ts;
48592
48861
  return diagnostic;
48593
48862
  }
48594
48863
  function isDeprecatedSymbol(symbol) {
48595
- return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
48864
+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
48596
48865
  }
48597
48866
  function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
48598
48867
  var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
@@ -48820,7 +49089,7 @@ var ts;
48820
49089
  else {
48821
49090
  // find a module that about to be augmented
48822
49091
  // do not validate names of augmentations that are defined in ambient context
48823
- var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */)
49092
+ var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */)
48824
49093
  ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
48825
49094
  : undefined;
48826
49095
  var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
@@ -48934,7 +49203,7 @@ var ts;
48934
49203
  if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
48935
49204
  (!ts.outFile(compilerOptions)) ||
48936
49205
  isInTypeQuery(usage) ||
48937
- declaration.flags & 8388608 /* Ambient */) {
49206
+ declaration.flags & 16777216 /* Ambient */) {
48938
49207
  // nodes are in different files and order cannot be determined
48939
49208
  return true;
48940
49209
  }
@@ -48996,7 +49265,7 @@ var ts;
48996
49265
  if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) {
48997
49266
  return true;
48998
49267
  }
48999
- if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
49268
+ if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
49000
49269
  return true;
49001
49270
  }
49002
49271
  if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
@@ -49261,7 +49530,7 @@ var ts;
49261
49530
  // falls through
49262
49531
  case 261 /* ModuleDeclaration */:
49263
49532
  var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
49264
- if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
49533
+ if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
49265
49534
  // It's an external module. First see if the module has an export default and if the local
49266
49535
  // name of that export default matches.
49267
49536
  if (result = moduleExports.get("default" /* Default */)) {
@@ -49584,7 +49853,7 @@ var ts;
49584
49853
  }
49585
49854
  }
49586
49855
  // If we're in an external module, we can't reference value symbols created from UMD export declarations
49587
- if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
49856
+ if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) {
49588
49857
  var merged = getMergedSymbol(result);
49589
49858
  if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
49590
49859
  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));
@@ -49839,7 +50108,7 @@ var ts;
49839
50108
  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 */); });
49840
50109
  if (declaration === undefined)
49841
50110
  return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
49842
- if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
50111
+ if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
49843
50112
  var diagnosticMessage = void 0;
49844
50113
  var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
49845
50114
  if (result.flags & 2 /* BlockScopedVariable */) {
@@ -50350,27 +50619,27 @@ var ts;
50350
50619
  function resolveAlias(symbol) {
50351
50620
  ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
50352
50621
  var links = getSymbolLinks(symbol);
50353
- if (!links.target) {
50354
- links.target = resolvingSymbol;
50622
+ if (!links.aliasTarget) {
50623
+ links.aliasTarget = resolvingSymbol;
50355
50624
  var node = getDeclarationOfAliasSymbol(symbol);
50356
50625
  if (!node)
50357
50626
  return ts.Debug.fail();
50358
50627
  var target = getTargetOfAliasDeclaration(node);
50359
- if (links.target === resolvingSymbol) {
50360
- links.target = target || unknownSymbol;
50628
+ if (links.aliasTarget === resolvingSymbol) {
50629
+ links.aliasTarget = target || unknownSymbol;
50361
50630
  }
50362
50631
  else {
50363
50632
  error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
50364
50633
  }
50365
50634
  }
50366
- else if (links.target === resolvingSymbol) {
50367
- links.target = unknownSymbol;
50635
+ else if (links.aliasTarget === resolvingSymbol) {
50636
+ links.aliasTarget = unknownSymbol;
50368
50637
  }
50369
- return links.target;
50638
+ return links.aliasTarget;
50370
50639
  }
50371
50640
  function tryResolveAlias(symbol) {
50372
50641
  var links = getSymbolLinks(symbol);
50373
- if (links.target !== resolvingSymbol) {
50642
+ if (links.aliasTarget !== resolvingSymbol) {
50374
50643
  return resolveAlias(symbol);
50375
50644
  }
50376
50645
  return undefined;
@@ -50612,7 +50881,7 @@ var ts;
50612
50881
  }
50613
50882
  }
50614
50883
  function getAssignmentDeclarationLocation(node) {
50615
- var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
50884
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
50616
50885
  if (typeAlias) {
50617
50886
  return;
50618
50887
  }
@@ -52080,7 +52349,20 @@ var ts;
52080
52349
  if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
52081
52350
  if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
52082
52351
  context.approximateLength += (ts.symbolName(type.symbol).length + 6);
52083
- return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined));
52352
+ var constraintNode = void 0;
52353
+ var constraint = getConstraintOfTypeParameter(type);
52354
+ if (constraint) {
52355
+ // If the infer type has a constraint that is not the same as the constraint
52356
+ // we would have normally inferred based on context, we emit the constraint
52357
+ // using `infer T extends ?`. We omit inferred constraints from type references
52358
+ // as they may be elided.
52359
+ var inferredConstraint = getInferredTypeParameterConstraint(type, /*omitTypeReferences*/ true);
52360
+ if (!(inferredConstraint && isTypeIdenticalTo(constraint, inferredConstraint))) {
52361
+ context.approximateLength += 9;
52362
+ constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
52363
+ }
52364
+ }
52365
+ return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
52084
52366
  }
52085
52367
  if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
52086
52368
  type.flags & 262144 /* TypeParameter */ &&
@@ -52154,13 +52436,37 @@ var ts;
52154
52436
  return ts.Debug.fail("Should be unreachable.");
52155
52437
  function conditionalTypeToTypeNode(type) {
52156
52438
  var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
52439
+ context.approximateLength += 15;
52440
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) {
52441
+ var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
52442
+ var name = typeParameterToName(newParam, context);
52443
+ var newTypeVariable = ts.factory.createTypeReferenceNode(name);
52444
+ context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
52445
+ var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
52446
+ var saveInferTypeParameters_1 = context.inferTypeParameters;
52447
+ context.inferTypeParameters = type.root.inferTypeParameters;
52448
+ var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
52449
+ context.inferTypeParameters = saveInferTypeParameters_1;
52450
+ var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
52451
+ var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
52452
+ // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
52453
+ // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
52454
+ // inner conditional runs the check the user provided on the check type (distributively) and returns the result
52455
+ // checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
52456
+ // this is potentially simplifiable to
52457
+ // checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
52458
+ // but that may confuse users who read the output more.
52459
+ // On the other hand,
52460
+ // checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
52461
+ // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
52462
+ 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 */));
52463
+ }
52157
52464
  var saveInferTypeParameters = context.inferTypeParameters;
52158
52465
  context.inferTypeParameters = type.root.inferTypeParameters;
52159
52466
  var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
52160
52467
  context.inferTypeParameters = saveInferTypeParameters;
52161
52468
  var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
52162
52469
  var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
52163
- context.approximateLength += 15;
52164
52470
  return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
52165
52471
  }
52166
52472
  function typeToTypeNodeOrCircularityElision(type) {
@@ -52859,9 +53165,6 @@ var ts;
52859
53165
  if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
52860
53166
  parameterType = getOptionalType(parameterType);
52861
53167
  }
52862
- if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
52863
- parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
52864
- }
52865
53168
  var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
52866
53169
  var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
52867
53170
  var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
@@ -53420,7 +53723,7 @@ var ts;
53420
53723
  if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
53421
53724
  // try to reuse the existing annotation
53422
53725
  var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
53423
- if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53726
+ if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53424
53727
  var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
53425
53728
  if (result_6) {
53426
53729
  return result_6;
@@ -53437,6 +53740,16 @@ var ts;
53437
53740
  context.flags = oldFlags;
53438
53741
  return result;
53439
53742
  }
53743
+ function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
53744
+ var typeFromTypeNode = getTypeFromTypeNode(typeNode);
53745
+ if (typeFromTypeNode === type) {
53746
+ return true;
53747
+ }
53748
+ if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
53749
+ return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
53750
+ }
53751
+ return false;
53752
+ }
53440
53753
  function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
53441
53754
  if (!isErrorType(type) && context.enclosingDeclaration) {
53442
53755
  var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
@@ -54036,7 +54349,7 @@ var ts;
54036
54349
  newModifierFlags |= 1 /* Export */;
54037
54350
  }
54038
54351
  if (addingDeclare && !(newModifierFlags & 1 /* Export */) &&
54039
- (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* Ambient */)) &&
54352
+ (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) &&
54040
54353
  (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
54041
54354
  // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
54042
54355
  newModifierFlags |= 2 /* Ambient */;
@@ -55006,7 +55319,7 @@ var ts;
55006
55319
  var parent = getDeclarationContainer(node);
55007
55320
  // If the node is not exported or it is not ambient module element (except import declaration)
55008
55321
  if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) &&
55009
- !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) {
55322
+ !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) {
55010
55323
  return isGlobalSourceFile(parent);
55011
55324
  }
55012
55325
  // Exported members/ambient module elements (exception import declaration) are visible if parent is visible
@@ -55346,7 +55659,7 @@ var ts;
55346
55659
  }
55347
55660
  var pattern = declaration.parent;
55348
55661
  // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
55349
- if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
55662
+ if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
55350
55663
  parentType = getNonNullableType(parentType);
55351
55664
  }
55352
55665
  // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
@@ -55462,7 +55775,7 @@ var ts;
55462
55775
  }
55463
55776
  if ((noImplicitAny || ts.isInJSFile(declaration)) &&
55464
55777
  ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
55465
- !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) {
55778
+ !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) {
55466
55779
  // If --noImplicitAny is on or the declaration is in a Javascript file,
55467
55780
  // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
55468
55781
  // initializer or a 'null' or 'undefined' initializer.
@@ -55708,7 +56021,7 @@ var ts;
55708
56021
  }
55709
56022
  }
55710
56023
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55711
- type = getUnionType(sourceTypes, 2 /* Subtype */);
56024
+ type = getUnionType(sourceTypes);
55712
56025
  }
55713
56026
  }
55714
56027
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -56918,7 +57231,7 @@ var ts;
56918
57231
  function isLiteralEnumMember(member) {
56919
57232
  var expr = member.initializer;
56920
57233
  if (!expr) {
56921
- return !(member.flags & 8388608 /* Ambient */);
57234
+ return !(member.flags & 16777216 /* Ambient */);
56922
57235
  }
56923
57236
  switch (expr.kind) {
56924
57237
  case 10 /* StringLiteral */:
@@ -58457,8 +58770,9 @@ var ts;
58457
58770
  // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
58458
58771
  // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
58459
58772
  // nesting, so it is effectively just a safety stop.
58460
- if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) {
58461
- stack.push(t);
58773
+ var identity_1 = getRecursionIdentity(t);
58774
+ if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
58775
+ stack.push(identity_1);
58462
58776
  result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
58463
58777
  stack.pop();
58464
58778
  }
@@ -59551,7 +59865,7 @@ var ts;
59551
59865
  function getConstraintDeclaration(type) {
59552
59866
  return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
59553
59867
  }
59554
- function getInferredTypeParameterConstraint(typeParameter) {
59868
+ function getInferredTypeParameterConstraint(typeParameter, omitTypeReferences) {
59555
59869
  var _a;
59556
59870
  var inferences;
59557
59871
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
@@ -59563,7 +59877,7 @@ var ts;
59563
59877
  // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are
59564
59878
  // present, we form an intersection of the inferred constraint types.
59565
59879
  var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
59566
- if (grandParent.kind === 178 /* TypeReference */) {
59880
+ if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
59567
59881
  var typeReference = grandParent;
59568
59882
  var typeParameters = getTypeParametersForTypeReference(typeReference);
59569
59883
  if (typeParameters) {
@@ -59985,7 +60299,7 @@ var ts;
59985
60299
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
59986
60300
  }
59987
60301
  function isJSDocTypeReference(node) {
59988
- return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
60302
+ return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
59989
60303
  }
59990
60304
  function checkNoTypeArguments(node, symbol) {
59991
60305
  if (node.typeArguments) {
@@ -61544,7 +61858,7 @@ var ts;
61544
61858
  if (ts.isCallLikeExpression(parent)) {
61545
61859
  return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
61546
61860
  }
61547
- return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
61861
+ return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
61548
61862
  }
61549
61863
  return true;
61550
61864
  }
@@ -62237,7 +62551,7 @@ var ts;
62237
62551
  links.resolvedSymbol = unknownSymbol;
62238
62552
  return links.resolvedType = errorType;
62239
62553
  }
62240
- var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
62554
+ var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
62241
62555
  // TODO: Future work: support unions/generics/whatever via a deferred import-type
62242
62556
  var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
62243
62557
  if (!innerModuleSymbol) {
@@ -62573,7 +62887,7 @@ var ts;
62573
62887
  }
62574
62888
  // /** @return {this} */
62575
62889
  // x.prototype.m = function() { ... }
62576
- var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
62890
+ var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
62577
62891
  if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) {
62578
62892
  return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
62579
62893
  }
@@ -62648,7 +62962,7 @@ var ts;
62648
62962
  case 143 /* NeverKeyword */:
62649
62963
  return neverType;
62650
62964
  case 148 /* ObjectKeyword */:
62651
- return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
62965
+ return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
62652
62966
  case 138 /* IntrinsicKeyword */:
62653
62967
  return intrinsicMarkerType;
62654
62968
  case 192 /* ThisType */:
@@ -66656,12 +66970,12 @@ var ts;
66656
66970
  function isDeeplyNestedType(type, stack, depth, maxDepth) {
66657
66971
  if (maxDepth === void 0) { maxDepth = 3; }
66658
66972
  if (depth >= maxDepth) {
66659
- var identity_1 = getRecursionIdentity(type);
66973
+ var identity_2 = getRecursionIdentity(type);
66660
66974
  var count = 0;
66661
66975
  var lastTypeId = 0;
66662
66976
  for (var i = 0; i < depth; i++) {
66663
66977
  var t = stack[i];
66664
- if (getRecursionIdentity(t) === identity_1) {
66978
+ if (getRecursionIdentity(t) === identity_2) {
66665
66979
  // We only count occurrences with a higher type id than the previous occurrence, since higher
66666
66980
  // type ids are an indicator of newer instantiations caused by recursion.
66667
66981
  if (t.id >= lastTypeId) {
@@ -67525,6 +67839,9 @@ var ts;
67525
67839
  var inference = inferences[i];
67526
67840
  if (t === inference.typeParameter) {
67527
67841
  if (fix && !inference.isFixed) {
67842
+ // Before we commit to a particular inference (and thus lock out any further inferences),
67843
+ // we infer from any intra-expression inference sites we have collected.
67844
+ inferFromIntraExpressionSites(context);
67528
67845
  clearCachedInferences(inferences);
67529
67846
  inference.isFixed = true;
67530
67847
  }
@@ -67541,6 +67858,37 @@ var ts;
67541
67858
  }
67542
67859
  }
67543
67860
  }
67861
+ function addIntraExpressionInferenceSite(context, node, type) {
67862
+ var _a;
67863
+ ((_a = context.intraExpressionInferenceSites) !== null && _a !== void 0 ? _a : (context.intraExpressionInferenceSites = [])).push({ node: node, type: type });
67864
+ }
67865
+ // We collect intra-expression inference sites within object and array literals to handle cases where
67866
+ // inferred types flow between context sensitive element expressions. For example:
67867
+ //
67868
+ // declare function foo<T>(arg: [(n: number) => T, (x: T) => void]): void;
67869
+ // foo([_a => 0, n => n.toFixed()]);
67870
+ //
67871
+ // Above, both arrow functions in the tuple argument are context sensitive, thus both are omitted from the
67872
+ // pass that collects inferences from the non-context sensitive parts of the arguments. In the subsequent
67873
+ // pass where nothing is omitted, we need to commit to an inference for T in order to contextually type the
67874
+ // parameter in the second arrow function, but we want to first infer from the return type of the first
67875
+ // arrow function. This happens automatically when the arrow functions are discrete arguments (because we
67876
+ // infer from each argument before processing the next), but when the arrow functions are elements of an
67877
+ // object or array literal, we need to perform intra-expression inferences early.
67878
+ function inferFromIntraExpressionSites(context) {
67879
+ if (context.intraExpressionInferenceSites) {
67880
+ for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) {
67881
+ var _b = _a[_i], node = _b.node, type = _b.type;
67882
+ var contextualType = node.kind === 169 /* MethodDeclaration */ ?
67883
+ getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) :
67884
+ getContextualType(node, 2 /* NoConstraints */);
67885
+ if (contextualType) {
67886
+ inferTypes(context.inferences, type, contextualType);
67887
+ }
67888
+ }
67889
+ context.intraExpressionInferenceSites = undefined;
67890
+ }
67891
+ }
67544
67892
  function createInferenceInfo(typeParameter) {
67545
67893
  return {
67546
67894
  typeParameter: typeParameter,
@@ -69523,7 +69871,7 @@ var ts;
69523
69871
  // parameter symbols with declarations that have explicit type annotations. Such references are
69524
69872
  // resolvable with no possibility of triggering circularities in control flow analysis.
69525
69873
  function getTypeOfDottedName(node, diagnostic) {
69526
- if (!(node.flags & 16777216 /* InWithStatement */)) {
69874
+ if (!(node.flags & 33554432 /* InWithStatement */)) {
69527
69875
  switch (node.kind) {
69528
69876
  case 79 /* Identifier */:
69529
69877
  var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
@@ -70927,6 +71275,7 @@ var ts;
70927
71275
  // a generic type without a nullable constraint and x is a generic type. This is because when both obj
70928
71276
  // and x are of generic types T and K, we want the resulting type to be T[K].
70929
71277
  return parent.kind === 206 /* PropertyAccessExpression */ ||
71278
+ parent.kind === 161 /* QualifiedName */ ||
70930
71279
  parent.kind === 208 /* CallExpression */ && parent.expression === node ||
70931
71280
  parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node &&
70932
71281
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
@@ -71220,7 +71569,7 @@ var ts;
71220
71569
  isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) ||
71221
71570
  node.parent.kind === 230 /* NonNullExpression */ ||
71222
71571
  declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken ||
71223
- declaration.flags & 8388608 /* Ambient */;
71572
+ declaration.flags & 16777216 /* Ambient */;
71224
71573
  var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
71225
71574
  type === autoType || type === autoArrayType ? undefinedType :
71226
71575
  getOptionalType(type);
@@ -72228,7 +72577,7 @@ var ts;
72228
72577
  // exists. Otherwise, it is the type of the string index signature in T, if one exists.
72229
72578
  function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
72230
72579
  ts.Debug.assert(ts.isObjectLiteralMethod(node));
72231
- if (node.flags & 16777216 /* InWithStatement */) {
72580
+ if (node.flags & 33554432 /* InWithStatement */) {
72232
72581
  // We cannot answer semantic questions within a with block, do not proceed any further
72233
72582
  return undefined;
72234
72583
  }
@@ -72416,7 +72765,7 @@ var ts;
72416
72765
  * @returns the contextual type of an expression.
72417
72766
  */
72418
72767
  function getContextualType(node, contextFlags) {
72419
- if (node.flags & 16777216 /* InWithStatement */) {
72768
+ if (node.flags & 33554432 /* InWithStatement */) {
72420
72769
  // We cannot answer semantic questions within a with block, do not proceed any further
72421
72770
  return undefined;
72422
72771
  }
@@ -72834,6 +73183,11 @@ var ts;
72834
73183
  var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
72835
73184
  elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression));
72836
73185
  elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
73186
+ if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
73187
+ var inferenceContext = getInferenceContext(node);
73188
+ ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
73189
+ addIntraExpressionInferenceSite(inferenceContext, e, type);
73190
+ }
72837
73191
  }
72838
73192
  }
72839
73193
  if (inDestructuringPattern) {
@@ -73035,6 +73389,13 @@ var ts;
73035
73389
  prop.target = member;
73036
73390
  member = prop;
73037
73391
  allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
73392
+ if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) &&
73393
+ (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
73394
+ var inferenceContext = getInferenceContext(node);
73395
+ ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
73396
+ var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
73397
+ addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
73398
+ }
73038
73399
  }
73039
73400
  else if (memberDecl.kind === 298 /* SpreadAssignment */) {
73040
73401
  if (languageVersion < 2 /* ES2015 */) {
@@ -74127,7 +74488,7 @@ var ts;
74127
74488
  if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
74128
74489
  error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
74129
74490
  }
74130
- if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
74491
+ if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) {
74131
74492
  addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
74132
74493
  }
74133
74494
  }
@@ -74195,7 +74556,7 @@ var ts;
74195
74556
  if (declaration && isPropertyWithoutInitializer(declaration)) {
74196
74557
  if (!ts.isStatic(declaration)) {
74197
74558
  var flowContainer = getControlFlowContainer(node);
74198
- if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) {
74559
+ if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) {
74199
74560
  assumeUninitialized = true;
74200
74561
  }
74201
74562
  }
@@ -74232,7 +74593,7 @@ var ts;
74232
74593
  }
74233
74594
  else if (valueDeclaration.kind === 257 /* ClassDeclaration */ &&
74234
74595
  node.parent.kind !== 178 /* TypeReference */ &&
74235
- !(valueDeclaration.flags & 8388608 /* Ambient */) &&
74596
+ !(valueDeclaration.flags & 16777216 /* Ambient */) &&
74236
74597
  !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
74237
74598
  diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
74238
74599
  }
@@ -74897,34 +75258,36 @@ var ts;
74897
75258
  if (node.kind !== 165 /* Decorator */) {
74898
75259
  var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
74899
75260
  if (contextualType) {
74900
- // We clone the inference context to avoid disturbing a resolution in progress for an
74901
- // outer call expression. Effectively we just want a snapshot of whatever has been
74902
- // inferred for any outer call expression so far.
74903
- var outerContext = getInferenceContext(node);
74904
- var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
74905
- var instantiatedType = instantiateType(contextualType, outerMapper);
74906
- // If the contextual type is a generic function type with a single call signature, we
74907
- // instantiate the type with its own type parameters and type arguments. This ensures that
74908
- // the type parameters are not erased to type any during type inference such that they can
74909
- // be inferred as actual types from the contextual type. For example:
74910
- // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
74911
- // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
74912
- // Above, the type of the 'value' parameter is inferred to be 'A'.
74913
- var contextualSignature = getSingleCallSignature(instantiatedType);
74914
- var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
74915
- getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
74916
- instantiatedType;
74917
75261
  var inferenceTargetType = getReturnTypeOfSignature(signature);
74918
- // Inferences made from return types have lower priority than all other inferences.
74919
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
74920
- // Create a type mapper for instantiating generic contextual types using the inferences made
74921
- // from the return type. We need a separate inference pass here because (a) instantiation of
74922
- // the source type uses the outer context's return mapper (which excludes inferences made from
74923
- // outer arguments), and (b) we don't want any further inferences going into this context.
74924
- var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
74925
- var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
74926
- inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
74927
- context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
75262
+ if (couldContainTypeVariables(inferenceTargetType)) {
75263
+ // We clone the inference context to avoid disturbing a resolution in progress for an
75264
+ // outer call expression. Effectively we just want a snapshot of whatever has been
75265
+ // inferred for any outer call expression so far.
75266
+ var outerContext = getInferenceContext(node);
75267
+ var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
75268
+ var instantiatedType = instantiateType(contextualType, outerMapper);
75269
+ // If the contextual type is a generic function type with a single call signature, we
75270
+ // instantiate the type with its own type parameters and type arguments. This ensures that
75271
+ // the type parameters are not erased to type any during type inference such that they can
75272
+ // be inferred as actual types from the contextual type. For example:
75273
+ // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
75274
+ // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
75275
+ // Above, the type of the 'value' parameter is inferred to be 'A'.
75276
+ var contextualSignature = getSingleCallSignature(instantiatedType);
75277
+ var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
75278
+ getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
75279
+ instantiatedType;
75280
+ // Inferences made from return types have lower priority than all other inferences.
75281
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
75282
+ // Create a type mapper for instantiating generic contextual types using the inferences made
75283
+ // from the return type. We need a separate inference pass here because (a) instantiation of
75284
+ // the source type uses the outer context's return mapper (which excludes inferences made from
75285
+ // outer arguments), and (b) we don't want any further inferences going into this context.
75286
+ var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
75287
+ var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
75288
+ inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
75289
+ context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
75290
+ }
74928
75291
  }
74929
75292
  }
74930
75293
  var restType = getNonArrayRestType(signature);
@@ -74936,7 +75299,7 @@ var ts;
74936
75299
  }
74937
75300
  }
74938
75301
  var thisType = getThisTypeOfSignature(signature);
74939
- if (thisType) {
75302
+ if (thisType && couldContainTypeVariables(thisType)) {
74940
75303
  var thisArgumentNode = getThisArgumentOfCall(node);
74941
75304
  inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
74942
75305
  }
@@ -74944,11 +75307,13 @@ var ts;
74944
75307
  var arg = args[i];
74945
75308
  if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
74946
75309
  var paramType = getTypeAtPosition(signature, i);
74947
- var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
74948
- inferTypes(context.inferences, argType, paramType);
75310
+ if (couldContainTypeVariables(paramType)) {
75311
+ var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
75312
+ inferTypes(context.inferences, argType, paramType);
75313
+ }
74949
75314
  }
74950
75315
  }
74951
- if (restType) {
75316
+ if (restType && couldContainTypeVariables(restType)) {
74952
75317
  var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
74953
75318
  inferTypes(context.inferences, spreadType, restType);
74954
75319
  }
@@ -76528,7 +76893,7 @@ var ts;
76528
76893
  return returnType;
76529
76894
  }
76530
76895
  function checkDeprecatedSignature(signature, node) {
76531
- if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) {
76896
+ if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) {
76532
76897
  var suggestionNode = getDeprecatedSuggestionNode(node);
76533
76898
  var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
76534
76899
  addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
@@ -76612,7 +76977,7 @@ var ts;
76612
76977
  var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
76613
76978
  newSymbol.parent = originalSymbol;
76614
76979
  newSymbol.nameType = getStringLiteralType("default");
76615
- newSymbol.target = resolveSymbol(symbol);
76980
+ newSymbol.aliasTarget = resolveSymbol(symbol);
76616
76981
  memberTable.set("default" /* Default */, newSymbol);
76617
76982
  return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
76618
76983
  }
@@ -76672,7 +77037,7 @@ var ts;
76672
77037
  if (targetDeclarationKind !== 0 /* Unknown */) {
76673
77038
  var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
76674
77039
  // function/variable declaration should be ambient
76675
- return !!decl && !!(decl.flags & 8388608 /* Ambient */);
77040
+ return !!decl && !!(decl.flags & 16777216 /* Ambient */);
76676
77041
  }
76677
77042
  return false;
76678
77043
  }
@@ -76867,7 +77232,7 @@ var ts;
76867
77232
  error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
76868
77233
  }
76869
77234
  var file = ts.getSourceFileOfNode(node);
76870
- ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
77235
+ ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
76871
77236
  return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
76872
77237
  }
76873
77238
  function getTypeOfParameter(symbol) {
@@ -78881,6 +79246,11 @@ var ts;
78881
79246
  context.contextualType = contextualType;
78882
79247
  context.inferenceContext = inferenceContext;
78883
79248
  var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0));
79249
+ // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type
79250
+ // parameters. This information is no longer needed after the call to checkExpression.
79251
+ if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
79252
+ inferenceContext.intraExpressionInferenceSites = undefined;
79253
+ }
78884
79254
  // We strip literal freshness when an appropriate contextual type is present such that contextually typed
78885
79255
  // literals always preserve their literal types (otherwise they might widen during type inference). An alternative
78886
79256
  // here would be to not mark contextually typed literals as fresh in the first place.
@@ -79172,7 +79542,7 @@ var ts;
79172
79542
  return quickType;
79173
79543
  }
79174
79544
  // If a type has been cached for the node, return it.
79175
- if (node.flags & 67108864 /* TypeCached */ && flowTypeCache) {
79545
+ if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) {
79176
79546
  var cachedType = flowTypeCache[getNodeId(node)];
79177
79547
  if (cachedType) {
79178
79548
  return cachedType;
@@ -79184,7 +79554,7 @@ var ts;
79184
79554
  if (flowInvocationCount !== startInvocationCount) {
79185
79555
  var cache = flowTypeCache || (flowTypeCache = []);
79186
79556
  cache[getNodeId(node)] = type;
79187
- ts.setNodeFlags(node, node.flags | 67108864 /* TypeCached */);
79557
+ ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */);
79188
79558
  }
79189
79559
  return type;
79190
79560
  }
@@ -79270,7 +79640,7 @@ var ts;
79270
79640
  if (compilerOptions.isolatedModules) {
79271
79641
  ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
79272
79642
  var constEnumDeclaration = type.symbol.valueDeclaration;
79273
- if (constEnumDeclaration.flags & 8388608 /* Ambient */) {
79643
+ if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
79274
79644
  error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
79275
79645
  }
79276
79646
  }
@@ -79419,19 +79789,28 @@ var ts;
79419
79789
  if (constraintType && defaultType) {
79420
79790
  checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
79421
79791
  }
79422
- if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) {
79792
+ checkNodeDeferred(node);
79793
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79794
+ }
79795
+ function checkTypeParameterDeferred(node) {
79796
+ if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
79797
+ var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
79423
79798
  var modifiers = getVarianceModifiers(typeParameter);
79424
- if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
79799
+ if (modifiers) {
79425
79800
  var symbol = getSymbolOfNode(node.parent);
79426
- var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
79427
- var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
79428
- var saveVarianceTypeParameter = typeParameter;
79429
- varianceTypeParameter = typeParameter;
79430
- checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
79431
- varianceTypeParameter = saveVarianceTypeParameter;
79801
+ if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
79802
+ error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
79803
+ }
79804
+ else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
79805
+ var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
79806
+ var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
79807
+ var saveVarianceTypeParameter = typeParameter;
79808
+ varianceTypeParameter = typeParameter;
79809
+ checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
79810
+ varianceTypeParameter = saveVarianceTypeParameter;
79811
+ }
79432
79812
  }
79433
79813
  }
79434
- addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79435
79814
  }
79436
79815
  function checkParameter(node) {
79437
79816
  // Grammar checking
@@ -79921,7 +80300,7 @@ var ts;
79921
80300
  superCallStatement = statement;
79922
80301
  break;
79923
80302
  }
79924
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
80303
+ if (nodeImmediatelyReferencesSuperOrThis(statement)) {
79925
80304
  break;
79926
80305
  }
79927
80306
  }
@@ -79963,7 +80342,7 @@ var ts;
79963
80342
  checkDecorators(node);
79964
80343
  checkSignatureDeclaration(node);
79965
80344
  if (node.kind === 172 /* GetAccessor */) {
79966
- if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
80345
+ if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
79967
80346
  if (!(node.flags & 512 /* HasExplicitReturn */)) {
79968
80347
  error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
79969
80348
  }
@@ -80058,7 +80437,7 @@ var ts;
80058
80437
  }
80059
80438
  var symbol = getNodeLinks(node).resolvedSymbol;
80060
80439
  if (symbol) {
80061
- if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) {
80440
+ if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) {
80062
80441
  addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
80063
80442
  }
80064
80443
  if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
@@ -80218,6 +80597,23 @@ var ts;
80218
80597
  grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
80219
80598
  }
80220
80599
  checkSourceElement(node.typeParameter);
80600
+ var symbol = getSymbolOfNode(node.typeParameter);
80601
+ if (symbol.declarations && symbol.declarations.length > 1) {
80602
+ var links = getSymbolLinks(symbol);
80603
+ if (!links.typeParametersChecked) {
80604
+ links.typeParametersChecked = true;
80605
+ var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
80606
+ var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */);
80607
+ if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
80608
+ // Report an error on every conflicting declaration.
80609
+ var name = symbolToString(symbol);
80610
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
80611
+ var declaration = declarations_4[_i];
80612
+ error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
80613
+ }
80614
+ }
80615
+ }
80616
+ }
80221
80617
  registerForUnusedIdentifiersCheck(node);
80222
80618
  }
80223
80619
  function checkTemplateLiteralType(node) {
@@ -80255,7 +80651,7 @@ var ts;
80255
80651
  getTypeFromTypeNode(node);
80256
80652
  }
80257
80653
  function isPrivateWithinAmbient(node) {
80258
- return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
80654
+ return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */);
80259
80655
  }
80260
80656
  function getEffectiveDeclarationFlags(n, flagsToCheck) {
80261
80657
  var flags = ts.getCombinedModifierFlags(n);
@@ -80264,7 +80660,7 @@ var ts;
80264
80660
  if (n.parent.kind !== 258 /* InterfaceDeclaration */ &&
80265
80661
  n.parent.kind !== 257 /* ClassDeclaration */ &&
80266
80662
  n.parent.kind !== 226 /* ClassExpression */ &&
80267
- n.flags & 8388608 /* Ambient */) {
80663
+ n.flags & 16777216 /* Ambient */) {
80268
80664
  if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
80269
80665
  // It is nested in an ambient context, which means it is automatically exported
80270
80666
  flags |= 1 /* Export */;
@@ -80397,10 +80793,10 @@ var ts;
80397
80793
  var hasNonAmbientClass = false;
80398
80794
  var functionDeclarations = [];
80399
80795
  if (declarations) {
80400
- for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
80401
- var current = declarations_4[_i];
80796
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
80797
+ var current = declarations_5[_i];
80402
80798
  var node = current;
80403
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
80799
+ var inAmbientContext = node.flags & 16777216 /* Ambient */;
80404
80800
  var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext;
80405
80801
  if (inAmbientContextOrInterface) {
80406
80802
  // check if declarations are consecutive only if they are non-ambient
@@ -81252,7 +81648,7 @@ var ts;
81252
81648
  // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
81253
81649
  var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(
81254
81650
  // Get first non javascript function declaration
81255
- function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); });
81651
+ function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); });
81256
81652
  // Only type check the symbol once
81257
81653
  if (node === firstDeclaration) {
81258
81654
  checkFunctionOrConstructorSymbol(localSymbol);
@@ -81374,7 +81770,7 @@ var ts;
81374
81770
  var symbol = getSymbolOfNode(member);
81375
81771
  if (!symbol.isReferenced
81376
81772
  && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
81377
- && !(member.flags & 8388608 /* Ambient */)) {
81773
+ && !(member.flags & 16777216 /* Ambient */)) {
81378
81774
  addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
81379
81775
  }
81380
81776
  break;
@@ -81564,8 +81960,8 @@ var ts;
81564
81960
  : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
81565
81961
  }
81566
81962
  else {
81567
- for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
81568
- var decl = declarations_5[_i];
81963
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
81964
+ var decl = declarations_6[_i];
81569
81965
  addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
81570
81966
  }
81571
81967
  }
@@ -81607,7 +82003,7 @@ var ts;
81607
82003
  }
81608
82004
  function checkCollisionWithArgumentsInGeneratedCode(node) {
81609
82005
  // no rest parameters \ declaration context \ overload - no codegen impact
81610
- if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) {
82006
+ if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) {
81611
82007
  return;
81612
82008
  }
81613
82009
  ts.forEach(node.parameters, function (p) {
@@ -81635,7 +82031,7 @@ var ts;
81635
82031
  // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified
81636
82032
  return false;
81637
82033
  }
81638
- if (node.flags & 8388608 /* Ambient */) {
82034
+ if (node.flags & 16777216 /* Ambient */) {
81639
82035
  // ambient context - no codegen impact
81640
82036
  return false;
81641
82037
  }
@@ -81774,7 +82170,7 @@ var ts;
81774
82170
  recordPotentialCollisionWithReflectInGeneratedCode(node, name);
81775
82171
  if (ts.isClassLike(node)) {
81776
82172
  checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0);
81777
- if (!(node.flags & 8388608 /* Ambient */)) {
82173
+ if (!(node.flags & 16777216 /* Ambient */)) {
81778
82174
  checkClassNameCollisionWithObject(name);
81779
82175
  }
81780
82176
  }
@@ -83368,23 +83764,23 @@ var ts;
83368
83764
  return;
83369
83765
  }
83370
83766
  var type = getDeclaredTypeOfSymbol(symbol);
83371
- if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
83767
+ if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
83372
83768
  // Report an error on every conflicting declaration.
83373
83769
  var name = symbolToString(symbol);
83374
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
83375
- var declaration = declarations_6[_i];
83770
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
83771
+ var declaration = declarations_7[_i];
83376
83772
  error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
83377
83773
  }
83378
83774
  }
83379
83775
  }
83380
83776
  }
83381
- function areTypeParametersIdentical(declarations, targetParameters) {
83777
+ function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
83382
83778
  var maxTypeArgumentCount = ts.length(targetParameters);
83383
83779
  var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
83384
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
83385
- var declaration = declarations_7[_i];
83780
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
83781
+ var declaration = declarations_8[_i];
83386
83782
  // If this declaration has too few or too many type parameters, we report an error
83387
- var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
83783
+ var sourceParameters = getTypeParameterDeclarations(declaration);
83388
83784
  var numTypeParameters = sourceParameters.length;
83389
83785
  if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
83390
83786
  return false;
@@ -83452,7 +83848,7 @@ var ts;
83452
83848
  checkFunctionOrConstructorSymbol(symbol);
83453
83849
  checkClassForDuplicateDeclarations(node);
83454
83850
  // Only check for reserved static identifiers on non-ambient context.
83455
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
83851
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
83456
83852
  if (!nodeInAmbientContext) {
83457
83853
  checkClassForStaticPropertyNameConflicts(node);
83458
83854
  }
@@ -83602,7 +83998,7 @@ var ts;
83602
83998
  */
83603
83999
  function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
83604
84000
  var isJs = ts.isInJSFile(node);
83605
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
84001
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
83606
84002
  if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
83607
84003
  var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
83608
84004
  var thisType = memberIsStatic ? staticType : typeWithThis;
@@ -83830,7 +84226,7 @@ var ts;
83830
84226
  && !(derived.flags & 33554432 /* Transient */)
83831
84227
  && !(baseDeclarationFlags & 128 /* Abstract */)
83832
84228
  && !(derivedDeclarationFlags & 128 /* Abstract */)
83833
- && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) {
84229
+ && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
83834
84230
  var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
83835
84231
  var propName = uninitialized.name;
83836
84232
  if (uninitialized.exclamationToken
@@ -83922,7 +84318,7 @@ var ts;
83922
84318
  return ok;
83923
84319
  }
83924
84320
  function checkPropertyInitialization(node) {
83925
- if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) {
84321
+ if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) {
83926
84322
  return;
83927
84323
  }
83928
84324
  var constructor = findConstructorDeclaration(node);
@@ -84059,7 +84455,7 @@ var ts;
84059
84455
  }
84060
84456
  // In ambient non-const numeric enum declarations, enum members without initializers are
84061
84457
  // considered computed members (as opposed to having auto-incremented values).
84062
- if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
84458
+ if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
84063
84459
  return undefined;
84064
84460
  }
84065
84461
  // If the member declaration specifies no value, the member is considered a constant enum member.
@@ -84091,7 +84487,7 @@ var ts;
84091
84487
  else if (isConstEnum) {
84092
84488
  error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
84093
84489
  }
84094
- else if (member.parent.flags & 8388608 /* Ambient */) {
84490
+ else if (member.parent.flags & 16777216 /* Ambient */) {
84095
84491
  error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
84096
84492
  }
84097
84493
  else {
@@ -84259,11 +84655,11 @@ var ts;
84259
84655
  function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
84260
84656
  var declarations = symbol.declarations;
84261
84657
  if (declarations) {
84262
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
84263
- var declaration = declarations_8[_i];
84658
+ for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
84659
+ var declaration = declarations_9[_i];
84264
84660
  if ((declaration.kind === 257 /* ClassDeclaration */ ||
84265
84661
  (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
84266
- !(declaration.flags & 8388608 /* Ambient */)) {
84662
+ !(declaration.flags & 16777216 /* Ambient */)) {
84267
84663
  return declaration;
84268
84664
  }
84269
84665
  }
@@ -84294,7 +84690,7 @@ var ts;
84294
84690
  function checkModuleDeclarationDiagnostics() {
84295
84691
  // Grammar checking
84296
84692
  var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
84297
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
84693
+ var inAmbientContext = node.flags & 16777216 /* Ambient */;
84298
84694
  if (isGlobalAugmentation && !inAmbientContext) {
84299
84695
  error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
84300
84696
  }
@@ -84512,7 +84908,7 @@ var ts;
84512
84908
  }
84513
84909
  if (compilerOptions.isolatedModules
84514
84910
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
84515
- && !(node.flags & 8388608 /* Ambient */)) {
84911
+ && !(node.flags & 16777216 /* Ambient */)) {
84516
84912
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
84517
84913
  var isType = !(target.flags & 111551 /* Value */);
84518
84914
  if (isType || typeOnlyAlias) {
@@ -84558,7 +84954,7 @@ var ts;
84558
84954
  }
84559
84955
  }
84560
84956
  function isDeprecatedAliasedSymbol(symbol) {
84561
- return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
84957
+ return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
84562
84958
  }
84563
84959
  function checkDeprecatedAliasedSymbol(symbol, location) {
84564
84960
  if (!(symbol.flags & 2097152 /* Alias */))
@@ -84687,7 +85083,7 @@ var ts;
84687
85083
  }
84688
85084
  }
84689
85085
  else {
84690
- if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
85086
+ if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) {
84691
85087
  // Import equals declaration is deprecated in es6 or above
84692
85088
  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);
84693
85089
  }
@@ -84713,7 +85109,7 @@ var ts;
84713
85109
  ts.forEach(node.exportClause.elements, checkExportSpecifier);
84714
85110
  var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
84715
85111
  var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ &&
84716
- !node.moduleSpecifier && node.flags & 8388608 /* Ambient */;
85112
+ !node.moduleSpecifier && node.flags & 16777216 /* Ambient */;
84717
85113
  if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
84718
85114
  error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
84719
85115
  }
@@ -84878,10 +85274,10 @@ var ts;
84878
85274
  checkExpressionCached(node.expression);
84879
85275
  }
84880
85276
  checkExternalModuleExports(container);
84881
- if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
85277
+ if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
84882
85278
  grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
84883
85279
  }
84884
- if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) {
85280
+ if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
84885
85281
  if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
84886
85282
  // export assignment is not supported in es6 modules
84887
85283
  grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
@@ -85257,6 +85653,9 @@ var ts;
85257
85653
  case 226 /* ClassExpression */:
85258
85654
  checkClassExpressionDeferred(node);
85259
85655
  break;
85656
+ case 163 /* TypeParameter */:
85657
+ checkTypeParameterDeferred(node);
85658
+ break;
85260
85659
  case 279 /* JsxSelfClosingElement */:
85261
85660
  checkJsxSelfClosingElementDeferred(node);
85262
85661
  break;
@@ -85314,7 +85713,7 @@ var ts;
85314
85713
  // This relies on the results of other lazy diagnostics, so must be computed after them
85315
85714
  if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
85316
85715
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
85317
- if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
85716
+ if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
85318
85717
  diagnostics.add(diag);
85319
85718
  }
85320
85719
  });
@@ -85414,7 +85813,7 @@ var ts;
85414
85813
  }
85415
85814
  // Language service support
85416
85815
  function getSymbolsInScope(location, meaning) {
85417
- if (location.flags & 16777216 /* InWithStatement */) {
85816
+ if (location.flags & 33554432 /* InWithStatement */) {
85418
85817
  // We cannot answer semantic questions within a with block, do not proceed any further
85419
85818
  return [];
85420
85819
  }
@@ -85764,7 +86163,7 @@ var ts;
85764
86163
  }
85765
86164
  var parent = node.parent;
85766
86165
  var grandParent = parent.parent;
85767
- if (node.flags & 16777216 /* InWithStatement */) {
86166
+ if (node.flags & 33554432 /* InWithStatement */) {
85768
86167
  // We cannot answer semantic questions within a with block, do not proceed any further
85769
86168
  return undefined;
85770
86169
  }
@@ -85906,7 +86305,7 @@ var ts;
85906
86305
  if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
85907
86306
  return errorType;
85908
86307
  }
85909
- if (node.flags & 16777216 /* InWithStatement */) {
86308
+ if (node.flags & 33554432 /* InWithStatement */) {
85910
86309
  // We cannot answer semantic questions within a with block, do not proceed any further
85911
86310
  return errorType;
85912
86311
  }
@@ -86071,11 +86470,11 @@ var ts;
86071
86470
  var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
86072
86471
  return leftSpread ? [leftSpread, rightSpread]
86073
86472
  : syntheticOrigin ? [syntheticOrigin]
86074
- : ts.singleElementArray(tryGetAliasTarget(symbol));
86473
+ : ts.singleElementArray(tryGetTarget(symbol));
86075
86474
  }
86076
86475
  return undefined;
86077
86476
  }
86078
- function tryGetAliasTarget(symbol) {
86477
+ function tryGetTarget(symbol) {
86079
86478
  var target;
86080
86479
  var next = symbol;
86081
86480
  while (next = getSymbolLinks(next).target) {
@@ -86305,7 +86704,7 @@ var ts;
86305
86704
  if (links === null || links === void 0 ? void 0 : links.referenced) {
86306
86705
  return true;
86307
86706
  }
86308
- var target = getSymbolLinks(symbol).target; // TODO: GH#18217
86707
+ var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
86309
86708
  if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
86310
86709
  target.flags & 111551 /* Value */ &&
86311
86710
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
@@ -86353,11 +86752,6 @@ var ts;
86353
86752
  !parameter.initializer &&
86354
86753
  ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
86355
86754
  }
86356
- function isOptionalUninitializedParameter(parameter) {
86357
- return !!strictNullChecks &&
86358
- isOptionalParameter(parameter) &&
86359
- !parameter.initializer;
86360
- }
86361
86755
  function isExpandoFunctionDeclaration(node) {
86362
86756
  var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
86363
86757
  if (!declaration) {
@@ -86959,7 +87353,7 @@ var ts;
86959
87353
  function checkExternalEmitHelpers(location, helpers) {
86960
87354
  if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
86961
87355
  var sourceFile = ts.getSourceFileOfNode(location);
86962
- if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) {
87356
+ if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) {
86963
87357
  var helpersModule = resolveHelpersModule(sourceFile, location);
86964
87358
  if (helpersModule !== unknownSymbol) {
86965
87359
  var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
@@ -87212,7 +87606,7 @@ var ts;
87212
87606
  else if (node.kind === 164 /* Parameter */) {
87213
87607
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
87214
87608
  }
87215
- else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
87609
+ else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
87216
87610
  return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
87217
87611
  }
87218
87612
  else if (ts.isPrivateIdentifierClassElementDeclaration(node)) {
@@ -87258,7 +87652,7 @@ var ts;
87258
87652
  if (flags & 256 /* Async */) {
87259
87653
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
87260
87654
  }
87261
- else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) {
87655
+ else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) {
87262
87656
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
87263
87657
  }
87264
87658
  else if (node.kind === 164 /* Parameter */) {
@@ -87274,8 +87668,7 @@ var ts;
87274
87668
  case 144 /* OutKeyword */:
87275
87669
  var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
87276
87670
  var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
87277
- if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ &&
87278
- node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
87671
+ if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
87279
87672
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
87280
87673
  }
87281
87674
  if (flags & inOutFlag) {
@@ -87404,7 +87797,7 @@ var ts;
87404
87797
  if (i !== (parameterCount - 1)) {
87405
87798
  return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
87406
87799
  }
87407
- if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
87800
+ if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
87408
87801
  checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
87409
87802
  }
87410
87803
  if (parameter.questionToken) {
@@ -87615,7 +88008,7 @@ var ts;
87615
88008
  ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ ||
87616
88009
  node.kind === 213 /* FunctionExpression */ ||
87617
88010
  node.kind === 169 /* MethodDeclaration */);
87618
- if (node.flags & 8388608 /* Ambient */) {
88011
+ if (node.flags & 16777216 /* Ambient */) {
87619
88012
  return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
87620
88013
  }
87621
88014
  if (!node.body) {
@@ -87853,7 +88246,7 @@ var ts;
87853
88246
  return false;
87854
88247
  }
87855
88248
  function checkGrammarAccessor(accessor) {
87856
- if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
88249
+ if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
87857
88250
  if (languageVersion < 1 /* ES5 */) {
87858
88251
  return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
87859
88252
  }
@@ -87993,7 +88386,7 @@ var ts;
87993
88386
  // However, property declarations disallow computed names in general,
87994
88387
  // and accessors are not allowed in ambient contexts in general,
87995
88388
  // so this error only really matters for methods.
87996
- if (node.flags & 8388608 /* Ambient */) {
88389
+ if (node.flags & 16777216 /* Ambient */) {
87997
88390
  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);
87998
88391
  }
87999
88392
  else if (node.kind === 169 /* MethodDeclaration */ && !node.body) {
@@ -88109,7 +88502,7 @@ var ts;
88109
88502
  }
88110
88503
  function checkGrammarVariableDeclaration(node) {
88111
88504
  if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) {
88112
- if (node.flags & 8388608 /* Ambient */) {
88505
+ if (node.flags & 16777216 /* Ambient */) {
88113
88506
  checkAmbientInitializer(node);
88114
88507
  }
88115
88508
  else if (!node.initializer) {
@@ -88121,7 +88514,7 @@ var ts;
88121
88514
  }
88122
88515
  }
88123
88516
  }
88124
- if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
88517
+ if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) {
88125
88518
  var message = node.initializer
88126
88519
  ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
88127
88520
  : !node.type
@@ -88130,7 +88523,7 @@ var ts;
88130
88523
  return grammarErrorOnNode(node.exclamationToken, message);
88131
88524
  }
88132
88525
  if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
88133
- !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
88526
+ !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
88134
88527
  checkESModuleMarker(node.name);
88135
88528
  }
88136
88529
  var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
@@ -88307,11 +88700,11 @@ var ts;
88307
88700
  return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
88308
88701
  }
88309
88702
  }
88310
- if (node.flags & 8388608 /* Ambient */) {
88703
+ if (node.flags & 16777216 /* Ambient */) {
88311
88704
  checkAmbientInitializer(node);
88312
88705
  }
88313
88706
  if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
88314
- node.flags & 8388608 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
88707
+ node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
88315
88708
  var message = node.initializer
88316
88709
  ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
88317
88710
  : !node.type
@@ -88357,10 +88750,10 @@ var ts;
88357
88750
  return false;
88358
88751
  }
88359
88752
  function checkGrammarSourceFile(node) {
88360
- return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
88753
+ return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
88361
88754
  }
88362
88755
  function checkGrammarStatementInAmbientContext(node) {
88363
- if (node.flags & 8388608 /* Ambient */) {
88756
+ if (node.flags & 16777216 /* Ambient */) {
88364
88757
  // Find containing block which is either Block, ModuleBlock, SourceFile
88365
88758
  var links = getNodeLinks(node);
88366
88759
  if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
@@ -92478,7 +92871,7 @@ var ts;
92478
92871
  return !ts.nodeIsMissing(node.body);
92479
92872
  }
92480
92873
  function visitPropertyDeclaration(node) {
92481
- if (node.flags & 8388608 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92874
+ if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92482
92875
  return undefined;
92483
92876
  }
92484
92877
  var updated = factory.updatePropertyDeclaration(node,
@@ -92509,11 +92902,11 @@ var ts;
92509
92902
  }
92510
92903
  var statements = [];
92511
92904
  resumeLexicalEnvironment();
92512
- var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92513
- var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
92905
+ var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92906
+ var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
92514
92907
  // If there was a super call, visit existing statements up to and including it
92515
92908
  if (superStatementIndex >= 0) {
92516
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
92909
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
92517
92910
  }
92518
92911
  // Transform parameters into property assignments. Transforms this:
92519
92912
  //
@@ -92532,12 +92925,12 @@ var ts;
92532
92925
  if (superStatementIndex >= 0) {
92533
92926
  ts.addRange(statements, parameterPropertyAssignments);
92534
92927
  }
92535
- // Since there was no super() call, parameter properties are the first statements in the constructor
92928
+ // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
92536
92929
  else {
92537
- statements = ts.addRange(parameterPropertyAssignments, statements);
92930
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
92538
92931
  }
92539
- // Add remaining statements from the body, skipping the super() call if it was found
92540
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
92932
+ // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
92933
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
92541
92934
  // End the lexical environment.
92542
92935
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
92543
92936
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
@@ -99368,8 +99761,8 @@ var ts;
99368
99761
  // declarations may not be sorted by position.
99369
99762
  // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
99370
99763
  var pos = -1, end = -1;
99371
- for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
99372
- var node = declarations_9[_i];
99764
+ for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
99765
+ var node = declarations_10[_i];
99373
99766
  pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
99374
99767
  end = Math.max(end, node.end);
99375
99768
  }
@@ -108301,6 +108694,10 @@ var ts;
108301
108694
  return factory.updateModifiers(statement, modifiers);
108302
108695
  }
108303
108696
  function transformTopLevelDeclaration(input) {
108697
+ if (lateMarkedStatements) {
108698
+ while (ts.orderedRemoveItem(lateMarkedStatements, input))
108699
+ ;
108700
+ }
108304
108701
  if (shouldStripInternal(input))
108305
108702
  return;
108306
108703
  switch (input.kind) {
@@ -108412,7 +108809,7 @@ var ts;
108412
108809
  needsScopeFixMarker = false;
108413
108810
  var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
108414
108811
  var lateStatements = transformAndReplaceLatePaintedStatements(statements);
108415
- if (input.flags & 8388608 /* Ambient */) {
108812
+ if (input.flags & 16777216 /* Ambient */) {
108416
108813
  needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates"
108417
108814
  }
108418
108815
  // With the final list of statements, there are 3 possibilities:
@@ -109432,7 +109829,7 @@ var ts;
109432
109829
  addOutput(buildInfoPath);
109433
109830
  }
109434
109831
  function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
109435
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109832
+ if (ts.isDeclarationFileName(inputFileName))
109436
109833
  return;
109437
109834
  var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109438
109835
  addOutput(js);
@@ -109477,7 +109874,7 @@ var ts;
109477
109874
  /*@internal*/
109478
109875
  function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
109479
109876
  var options = _a.options, fileNames = _a.fileNames;
109480
- 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));
109877
+ 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));
109481
109878
  }
109482
109879
  ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
109483
109880
  /*@internal*/
@@ -109519,7 +109916,7 @@ var ts;
109519
109916
  var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
109520
109917
  for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
109521
109918
  var inputFileName = _b[_a];
109522
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109919
+ if (ts.isDeclarationFileName(inputFileName))
109523
109920
  continue;
109524
109921
  var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109525
109922
  if (jsFilePath)
@@ -110060,6 +110457,9 @@ var ts;
110060
110457
  var currentParenthesizerRule;
110061
110458
  var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
110062
110459
  var parenthesizer = ts.factory.parenthesizer;
110460
+ var typeArgumentParenthesizerRuleSelector = {
110461
+ select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
110462
+ };
110063
110463
  var emitBinaryExpression = createEmitBinaryExpression();
110064
110464
  reset();
110065
110465
  return {
@@ -111272,7 +111672,7 @@ var ts;
111272
111672
  writePunctuation("}");
111273
111673
  }
111274
111674
  function emitArrayType(node) {
111275
- emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType);
111675
+ emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
111276
111676
  writePunctuation("[");
111277
111677
  writePunctuation("]");
111278
111678
  }
@@ -111283,7 +111683,7 @@ var ts;
111283
111683
  function emitTupleType(node) {
111284
111684
  emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node);
111285
111685
  var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */;
111286
- emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */);
111686
+ emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType);
111287
111687
  emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node);
111288
111688
  }
111289
111689
  function emitNamedTupleMember(node) {
@@ -111295,21 +111695,21 @@ var ts;
111295
111695
  emit(node.type);
111296
111696
  }
111297
111697
  function emitOptionalType(node) {
111298
- emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType);
111698
+ emit(node.type, parenthesizer.parenthesizeTypeOfOptionalType);
111299
111699
  writePunctuation("?");
111300
111700
  }
111301
111701
  function emitUnionType(node) {
111302
- emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
111702
+ emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType);
111303
111703
  }
111304
111704
  function emitIntersectionType(node) {
111305
- emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
111705
+ emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType);
111306
111706
  }
111307
111707
  function emitConditionalType(node) {
111308
- emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType);
111708
+ emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType);
111309
111709
  writeSpace();
111310
111710
  writeKeyword("extends");
111311
111711
  writeSpace();
111312
- emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType);
111712
+ emit(node.extendsType, parenthesizer.parenthesizeExtendsTypeOfConditionalType);
111313
111713
  writeSpace();
111314
111714
  writePunctuation("?");
111315
111715
  writeSpace();
@@ -111335,10 +111735,13 @@ var ts;
111335
111735
  function emitTypeOperator(node) {
111336
111736
  writeTokenText(node.operator, writeKeyword);
111337
111737
  writeSpace();
111338
- emit(node.type, parenthesizer.parenthesizeMemberOfElementType);
111738
+ var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ?
111739
+ parenthesizer.parenthesizeOperandOfReadonlyTypeOperator :
111740
+ parenthesizer.parenthesizeOperandOfTypeOperator;
111741
+ emit(node.type, parenthesizerRule);
111339
111742
  }
111340
111743
  function emitIndexedAccessType(node) {
111341
- emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType);
111744
+ emit(node.objectType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
111342
111745
  writePunctuation("[");
111343
111746
  emit(node.indexType);
111344
111747
  writePunctuation("]");
@@ -113072,7 +113475,7 @@ var ts;
113072
113475
  emitList(parentNode, decorators, 2146305 /* Decorators */);
113073
113476
  }
113074
113477
  function emitTypeArguments(parentNode, typeArguments) {
113075
- emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType);
113478
+ emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector);
113076
113479
  }
113077
113480
  function emitTypeParameters(parentNode, typeParameters) {
113078
113481
  if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
@@ -113191,6 +113594,7 @@ var ts;
113191
113594
  if (format & 128 /* Indented */) {
113192
113595
  increaseIndent();
113193
113596
  }
113597
+ var emitListItem = getEmitListItem(emit, parenthesizerRule);
113194
113598
  // Emit each child.
113195
113599
  var previousSibling = void 0;
113196
113600
  var previousSourceFileTextKind = void 0;
@@ -113241,12 +113645,7 @@ var ts;
113241
113645
  shouldEmitInterveningComments = mayEmitInterveningComments;
113242
113646
  }
113243
113647
  nextListElementPos = child.pos;
113244
- if (emit.length === 1) {
113245
- emit(child);
113246
- }
113247
- else {
113248
- emit(child, parenthesizerRule);
113249
- }
113648
+ emitListItem(child, emit, parenthesizerRule, i);
113250
113649
  if (shouldDecreaseIndentAfterEmit) {
113251
113650
  decreaseIndent();
113252
113651
  shouldDecreaseIndentAfterEmit = false;
@@ -114487,6 +114886,20 @@ var ts;
114487
114886
  TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask";
114488
114887
  TempFlags[TempFlags["_i"] = 268435456] = "_i";
114489
114888
  })(TempFlags || (TempFlags = {}));
114889
+ function emitListItemNoParenthesizer(node, emit, _parenthesizerRule, _index) {
114890
+ emit(node);
114891
+ }
114892
+ function emitListItemWithParenthesizerRuleSelector(node, emit, parenthesizerRuleSelector, index) {
114893
+ emit(node, parenthesizerRuleSelector.select(index));
114894
+ }
114895
+ function emitListItemWithParenthesizerRule(node, emit, parenthesizerRule, _index) {
114896
+ emit(node, parenthesizerRule);
114897
+ }
114898
+ function getEmitListItem(emit, parenthesizerRule) {
114899
+ return emit.length === 1 ? emitListItemNoParenthesizer :
114900
+ typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
114901
+ emitListItemWithParenthesizerRule;
114902
+ }
114490
114903
  })(ts || (ts = {}));
114491
114904
  /* @internal */
114492
114905
  var ts;
@@ -114853,7 +115266,7 @@ var ts;
114853
115266
  if (ts.outFile(options) || options.outDir)
114854
115267
  return false;
114855
115268
  // File if emitted next to input needs to be ignored
114856
- if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) {
115269
+ if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
114857
115270
  // If its declaration directory: its not ignored if not excluded by config
114858
115271
  if (options.declarationDir)
114859
115272
  return false;
@@ -116026,7 +116439,7 @@ var ts;
116026
116439
  var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
116027
116440
  for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
116028
116441
  var fileName = _c[_b];
116029
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
116442
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
116030
116443
  processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
116031
116444
  }
116032
116445
  }
@@ -116217,7 +116630,7 @@ var ts;
116217
116630
  }
116218
116631
  function getRedirectReferenceForResolution(file) {
116219
116632
  var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
116220
- if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]))
116633
+ if (redirect || !ts.isDeclarationFileName(file.originalFileName))
116221
116634
  return redirect;
116222
116635
  // The originalFileName could not be actual source file name if file found was d.ts from referecned project
116223
116636
  // 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
@@ -116553,7 +116966,7 @@ var ts;
116553
116966
  // moduleAugmentations has changed
116554
116967
  structureIsReused = 1 /* SafeModules */;
116555
116968
  }
116556
- if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) {
116969
+ if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
116557
116970
  // dynamicImport has changed
116558
116971
  structureIsReused = 1 /* SafeModules */;
116559
116972
  }
@@ -116717,6 +117130,9 @@ var ts;
116717
117130
  return !!sourceFilesFoundSearchingNodeModules.get(file.path);
116718
117131
  }
116719
117132
  function isSourceFileDefaultLibrary(file) {
117133
+ if (!file.isDeclarationFile) {
117134
+ return false;
117135
+ }
116720
117136
  if (file.hasNoDefaultLib) {
116721
117137
  return true;
116722
117138
  }
@@ -117228,7 +117644,7 @@ var ts;
117228
117644
  var node = _a[_i];
117229
117645
  collectModuleReferences(node, /*inAmbientModule*/ false);
117230
117646
  }
117231
- if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
117647
+ if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
117232
117648
  collectDynamicImportOrRequireCalls(file);
117233
117649
  }
117234
117650
  file.imports = imports || ts.emptyArray;
@@ -117605,7 +118021,7 @@ var ts;
117605
118021
  }
117606
118022
  function getProjectReferenceRedirectProject(fileName) {
117607
118023
  // Ignore dts or any json files
117608
- if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
118024
+ if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117609
118025
  return undefined;
117610
118026
  }
117611
118027
  // If this file is produced by a referenced project, we need to rewrite it to
@@ -117654,7 +118070,7 @@ var ts;
117654
118070
  else {
117655
118071
  var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
117656
118072
  ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
117657
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
118073
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117658
118074
  var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
117659
118075
  mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
117660
118076
  }
@@ -117826,7 +118242,7 @@ var ts;
117826
118242
  && index < file.imports.length
117827
118243
  && !elideImport
117828
118244
  && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile))
117829
- && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */));
118245
+ && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
117830
118246
  if (elideImport) {
117831
118247
  modulesWithElidedImports.set(file.path, true);
117832
118248
  }
@@ -118455,7 +118871,7 @@ var ts;
118455
118871
  if (options.outDir) {
118456
118872
  return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
118457
118873
  }
118458
- if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
118874
+ if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
118459
118875
  // Otherwise just check if sourceFile with the name exists
118460
118876
  var filePathWithoutExtension = ts.removeFileExtension(filePath);
118461
118877
  return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
@@ -119081,7 +119497,7 @@ var ts;
119081
119497
  /*forceDtsEmit*/ true);
119082
119498
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
119083
119499
  if (firstDts_1) {
119084
- 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; })); });
119500
+ 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; })); });
119085
119501
  latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
119086
119502
  if (exportedModulesMapCache && latestSignature !== prevSignature) {
119087
119503
  updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
@@ -119486,7 +119902,7 @@ var ts;
119486
119902
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
119487
119903
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
119488
119904
  */
119489
- function getNextAffectedFile(state, cancellationToken, computeHash) {
119905
+ function getNextAffectedFile(state, cancellationToken, computeHash, host) {
119490
119906
  while (true) {
119491
119907
  var affectedFiles = state.affectedFiles;
119492
119908
  if (affectedFiles) {
@@ -119497,7 +119913,7 @@ var ts;
119497
119913
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
119498
119914
  // Set the next affected file as seen and remove the cached semantic diagnostics
119499
119915
  state.affectedFilesIndex = affectedFilesIndex;
119500
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
119916
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
119501
119917
  return affectedFile;
119502
119918
  }
119503
119919
  affectedFilesIndex++;
@@ -119538,6 +119954,11 @@ var ts;
119538
119954
  state.seenAffectedFiles = new ts.Set();
119539
119955
  }
119540
119956
  }
119957
+ function clearAffectedFilesPendingEmit(state) {
119958
+ state.affectedFilesPendingEmit = undefined;
119959
+ state.affectedFilesPendingEmitKind = undefined;
119960
+ state.affectedFilesPendingEmitIndex = undefined;
119961
+ }
119541
119962
  /**
119542
119963
  * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
119543
119964
  */
@@ -119557,9 +119978,7 @@ var ts;
119557
119978
  }
119558
119979
  }
119559
119980
  }
119560
- state.affectedFilesPendingEmit = undefined;
119561
- state.affectedFilesPendingEmitKind = undefined;
119562
- state.affectedFilesPendingEmitIndex = undefined;
119981
+ clearAffectedFilesPendingEmit(state);
119563
119982
  }
119564
119983
  return undefined;
119565
119984
  }
@@ -119567,7 +119986,7 @@ var ts;
119567
119986
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119568
119987
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
119569
119988
  */
119570
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
119989
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
119571
119990
  var _a;
119572
119991
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119573
119992
  // If affected files is everything except default library, then nothing more to do
@@ -119592,14 +120011,14 @@ var ts;
119592
120011
  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);
119593
120012
  }
119594
120013
  if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
119595
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
120014
+ forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
119596
120015
  }
119597
120016
  }
119598
120017
  /**
119599
120018
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
119600
120019
  * Also we need to make sure signature is updated for these files
119601
120020
  */
119602
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
120021
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
119603
120022
  removeSemanticDiagnosticsOf(state, path);
119604
120023
  if (!state.changedFilesSet.has(path)) {
119605
120024
  var program = ts.Debug.checkDefined(state.program);
@@ -119610,8 +120029,7 @@ var ts;
119610
120029
  // This ensures that we dont later during incremental builds considering wrong signature.
119611
120030
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
119612
120031
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
119613
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
119614
- /* useFileVersionAsSignature */ true);
120032
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
119615
120033
  // If not dts emit, nothing more to do
119616
120034
  if (ts.getEmitDeclarations(state.compilerOptions)) {
119617
120035
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -119808,13 +120226,18 @@ var ts;
119808
120226
  var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
119809
120227
  var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
119810
120228
  return value.version === actualSignature ?
119811
- value.affectsGlobalScope ?
119812
- { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
120229
+ value.affectsGlobalScope || value.impliedFormat ?
120230
+ // If file version is same as signature, dont serialize signature
120231
+ { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120232
+ // If file info only contains version and signature and both are same we can just write string
119813
120233
  value.version :
119814
- actualSignature !== undefined ?
120234
+ actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
119815
120235
  signature === undefined ?
120236
+ // If we havent computed signature, use fileInfo as is
119816
120237
  value :
120238
+ // Serialize fileInfo with new updated signature
119817
120239
  { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120240
+ // Signature of the FileInfo is undefined, serialize it as false
119818
120241
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
119819
120242
  });
119820
120243
  var referencedMap;
@@ -120059,7 +120482,7 @@ var ts;
120059
120482
  * in that order would be used to write the files
120060
120483
  */
120061
120484
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
120062
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120485
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
120063
120486
  var emitKind = 1 /* Full */;
120064
120487
  var isPendingEmitFile = false;
120065
120488
  if (!affected) {
@@ -120104,54 +120527,48 @@ var ts;
120104
120527
  * in that order would be used to write the files
120105
120528
  */
120106
120529
  function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
120107
- var restorePendingEmitOnHandlingNoEmitSuccess = false;
120108
- var savedAffectedFilesPendingEmit;
120109
- var savedAffectedFilesPendingEmitKind;
120110
- var savedAffectedFilesPendingEmitIndex;
120111
- // 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
120112
- // This ensures pending files to emit is updated in tsbuildinfo
120113
- // 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)
120114
- if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
120115
- !targetSourceFile &&
120116
- !ts.outFile(state.compilerOptions) &&
120117
- !state.compilerOptions.noEmit &&
120118
- state.compilerOptions.noEmitOnError) {
120119
- restorePendingEmitOnHandlingNoEmitSuccess = true;
120120
- savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120121
- savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120122
- savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120123
- }
120530
+ var _a;
120124
120531
  if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120125
120532
  assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
120126
120533
  }
120127
120534
  var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
120128
120535
  if (result)
120129
120536
  return result;
120130
- if (restorePendingEmitOnHandlingNoEmitSuccess) {
120131
- state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
120132
- state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
120133
- state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
120134
- }
120135
120537
  // Emit only affected files if using builder for emit
120136
- if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120137
- // Emit and report any errors we ran into.
120138
- var sourceMaps = [];
120139
- var emitSkipped = false;
120140
- var diagnostics = void 0;
120141
- var emittedFiles = [];
120142
- var affectedEmitResult = void 0;
120143
- while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
120144
- emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
120145
- diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
120146
- emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
120147
- sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120538
+ if (!targetSourceFile) {
120539
+ if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120540
+ // Emit and report any errors we ran into.
120541
+ var sourceMaps = [];
120542
+ var emitSkipped = false;
120543
+ var diagnostics = void 0;
120544
+ var emittedFiles = [];
120545
+ var affectedEmitResult = void 0;
120546
+ while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
120547
+ emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
120548
+ diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
120549
+ emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
120550
+ sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120551
+ }
120552
+ return {
120553
+ emitSkipped: emitSkipped,
120554
+ diagnostics: diagnostics || ts.emptyArray,
120555
+ emittedFiles: emittedFiles,
120556
+ sourceMaps: sourceMaps
120557
+ };
120558
+ }
120559
+ // In non Emit builder, clear affected files pending emit
120560
+ else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
120561
+ ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
120562
+ // State can clear affected files pending emit if
120563
+ if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
120564
+ // If every file pending emit is pending on only dts emit
120565
+ || ts.every(state.affectedFilesPendingEmit, function (path, index) {
120566
+ return index < state.affectedFilesPendingEmitIndex ||
120567
+ state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
120568
+ })) {
120569
+ clearAffectedFilesPendingEmit(state);
120570
+ }
120148
120571
  }
120149
- return {
120150
- emitSkipped: emitSkipped,
120151
- diagnostics: diagnostics || ts.emptyArray,
120152
- emittedFiles: emittedFiles,
120153
- sourceMaps: sourceMaps
120154
- };
120155
120572
  }
120156
120573
  return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120157
120574
  }
@@ -120161,7 +120578,7 @@ var ts;
120161
120578
  */
120162
120579
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
120163
120580
  while (true) {
120164
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120581
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
120165
120582
  if (!affected) {
120166
120583
  // Done
120167
120584
  return undefined;
@@ -123281,9 +123698,6 @@ var ts;
123281
123698
  function newer(date1, date2) {
123282
123699
  return date2 > date1 ? date2 : date1;
123283
123700
  }
123284
- function isDeclarationFile(fileName) {
123285
- return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
123286
- }
123287
123701
  /*@internal*/
123288
123702
  function isCircularBuildOrder(buildOrder) {
123289
123703
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -123846,7 +124260,7 @@ var ts;
123846
124260
  outputFiles.forEach(function (_a) {
123847
124261
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
123848
124262
  var priorChangeTime;
123849
- if (!anyDtsChanged && isDeclarationFile(name)) {
124263
+ if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
123850
124264
  // Check for unchanged .d.ts files
123851
124265
  if (host.fileExists(name) && state.readFileWithCache(name) === text) {
123852
124266
  priorChangeTime = host.getModifiedTime(name);
@@ -124187,7 +124601,7 @@ var ts;
124187
124601
  // In addition to file timestamps, we also keep track of when a .d.ts file
124188
124602
  // had its file touched but not had its contents changed - this allows us
124189
124603
  // to skip a downstream typecheck
124190
- if (isDeclarationFile(output)) {
124604
+ if (ts.isDeclarationFileName(output)) {
124191
124605
  var outputModifiedTime = ts.getModifiedTime(host, output);
124192
124606
  newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
124193
124607
  }
@@ -124341,7 +124755,7 @@ var ts;
124341
124755
  reportVerbose = false;
124342
124756
  reportStatus(state, verboseMessage, proj.options.configFilePath);
124343
124757
  }
124344
- if (isDeclarationFile(file)) {
124758
+ if (ts.isDeclarationFileName(file)) {
124345
124759
  priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
124346
124760
  }
124347
124761
  host.setModifiedTime(file, now);
@@ -127110,7 +127524,7 @@ var ts;
127110
127524
  result.push("export" /* exportedModifier */);
127111
127525
  if (flags & 8192 /* Deprecated */)
127112
127526
  result.push("deprecated" /* deprecatedModifier */);
127113
- if (node.flags & 8388608 /* Ambient */)
127527
+ if (node.flags & 16777216 /* Ambient */)
127114
127528
  result.push("declare" /* ambientModifier */);
127115
127529
  if (node.kind === 271 /* ExportAssignment */)
127116
127530
  result.push("export" /* exportedModifier */);
@@ -131653,17 +132067,13 @@ var ts;
131653
132067
  }
131654
132068
  }
131655
132069
  if (origin && originIsObjectLiteralMethod(origin)) {
131656
- var importAdder = void 0;
131657
- (insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
132070
+ (insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails);
131658
132071
  if (!preferences.useLabelDetailsInCompletionEntries) {
131659
132072
  name = name + labelDetails.detail;
131660
132073
  labelDetails = undefined;
131661
132074
  }
131662
132075
  source = CompletionSource.ObjectLiteralMethodSnippet;
131663
132076
  sortText = Completions.SortText.SortBelow(sortText);
131664
- if (importAdder.hasFixes()) {
131665
- hasAction = true;
131666
- }
131667
132077
  }
131668
132078
  if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
131669
132079
  var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
@@ -131886,8 +132296,7 @@ var ts;
131886
132296
  var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
131887
132297
  var insertText = name;
131888
132298
  var sourceFile = enclosingDeclaration.getSourceFile();
131889
- var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
131890
- var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
132299
+ var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences);
131891
132300
  if (!method) {
131892
132301
  return undefined;
131893
132302
  }
@@ -131916,16 +132325,15 @@ var ts;
131916
132325
  /*modifiers*/ undefined,
131917
132326
  /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
131918
132327
  var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
131919
- return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, labelDetails: labelDetails };
132328
+ return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
131920
132329
  }
131921
132330
  ;
131922
- function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) {
132331
+ function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
131923
132332
  var declarations = symbol.getDeclarations();
131924
132333
  if (!(declarations && declarations.length)) {
131925
132334
  return undefined;
131926
132335
  }
131927
132336
  var checker = program.getTypeChecker();
131928
- var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
131929
132337
  var declaration = declarations[0];
131930
132338
  var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
131931
132339
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
@@ -131958,11 +132366,6 @@ var ts;
131958
132366
  if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
131959
132367
  return undefined;
131960
132368
  }
131961
- var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
131962
- if (importableReference) {
131963
- typeNode = importableReference.typeNode;
131964
- ts.codefix.importSymbols(importAdder, importableReference.symbols);
131965
- }
131966
132369
  var body = void 0;
131967
132370
  if (preferences.includeCompletionsWithSnippetText) {
131968
132371
  var emptyStmt = ts.factory.createEmptyStatement();
@@ -131972,11 +132375,19 @@ var ts;
131972
132375
  else {
131973
132376
  body = ts.factory.createBlock([], /* multiline */ true);
131974
132377
  }
132378
+ var parameters = typeNode.parameters.map(function (typedParam) {
132379
+ return ts.factory.createParameterDeclaration(
132380
+ /*decorators*/ undefined,
132381
+ /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
132382
+ /*type*/ undefined, typedParam.initializer);
132383
+ });
131975
132384
  return ts.factory.createMethodDeclaration(
131976
132385
  /*decorators*/ undefined,
131977
132386
  /*modifiers*/ undefined,
131978
132387
  /*asteriskToken*/ undefined, name,
131979
- /*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
132388
+ /*questionToken*/ undefined,
132389
+ /*typeParameters*/ undefined, parameters,
132390
+ /*type*/ undefined, body);
131980
132391
  }
131981
132392
  default:
131982
132393
  return undefined;
@@ -132339,20 +132750,6 @@ var ts;
132339
132750
  };
132340
132751
  }
132341
132752
  }
132342
- if (source === CompletionSource.ObjectLiteralMethodSnippet) {
132343
- var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
132344
- var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
132345
- if (importAdder.hasFixes()) {
132346
- var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
132347
- return {
132348
- sourceDisplay: undefined,
132349
- codeActions: [{
132350
- changes: changes,
132351
- description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
132352
- }],
132353
- };
132354
- }
132355
- }
132356
132753
  if (originIsTypeOnlyAlias(origin)) {
132357
132754
  var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
132358
132755
  ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
@@ -133426,7 +133823,7 @@ var ts;
133426
133823
  var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker);
133427
133824
  // Check completions for Object property value shorthand
133428
133825
  if (instantiatedType === undefined) {
133429
- if (objectLikeContainer.flags & 16777216 /* InWithStatement */) {
133826
+ if (objectLikeContainer.flags & 33554432 /* InWithStatement */) {
133430
133827
  return 2 /* Fail */;
133431
133828
  }
133432
133829
  isNonContextualObjectLiteral = true;
@@ -135173,7 +135570,7 @@ var ts;
135173
135570
  // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
135174
135571
  // If this occurs unexpectedly, the fix is likely to synchronize the project settings.
135175
135572
  // Skip .d.ts files to reduce noise (should also cover most of node_modules).
135176
- var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
135573
+ var otherBucketKey = !ts.isDeclarationFileName(path) &&
135177
135574
  ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
135178
135575
  if (otherBucketKey) {
135179
135576
  ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
@@ -136089,17 +136486,25 @@ var ts;
136089
136486
  var options = { use: 1 /* References */ };
136090
136487
  var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options);
136091
136488
  var checker = program.getTypeChecker();
136092
- var symbol = checker.getSymbolAtLocation(ts.getAdjustedReferenceLocation(Core.getAdjustedNode(node, options)));
136489
+ // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition
136490
+ var adjustedNode = Core.getAdjustedNode(node, options);
136491
+ var symbol = isDefinitionForReference(adjustedNode) ? checker.getSymbolAtLocation(adjustedNode) : undefined;
136093
136492
  return !referencedSymbols || !referencedSymbols.length ? undefined : ts.mapDefined(referencedSymbols, function (_a) {
136094
136493
  var definition = _a.definition, references = _a.references;
136095
136494
  // Only include referenced symbols that have a valid definition.
136096
136495
  return definition && {
136097
136496
  definition: checker.runWithCancellationToken(cancellationToken, function (checker) { return definitionToReferencedSymbolDefinitionInfo(definition, checker, node); }),
136098
- references: references.map(function (r) { return toReferenceEntry(r, symbol); })
136497
+ references: references.map(function (r) { return toReferencedSymbolEntry(r, symbol); })
136099
136498
  };
136100
136499
  });
136101
136500
  }
136102
136501
  FindAllReferences.findReferencedSymbols = findReferencedSymbols;
136502
+ function isDefinitionForReference(node) {
136503
+ return node.kind === 88 /* DefaultKeyword */
136504
+ || !!ts.getDeclarationFromName(node)
136505
+ || ts.isLiteralComputedPropertyDeclarationName(node)
136506
+ || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
136507
+ }
136103
136508
  function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
136104
136509
  var node = ts.getTouchingPropertyName(sourceFile, position);
136105
136510
  var referenceEntries;
@@ -136228,13 +136633,19 @@ var ts;
136228
136633
  return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker)));
136229
136634
  }
136230
136635
  FindAllReferences.toRenameLocation = toRenameLocation;
136231
- function toReferenceEntry(entry, symbol) {
136636
+ function toReferencedSymbolEntry(entry, symbol) {
136637
+ var referenceEntry = toReferenceEntry(entry);
136638
+ if (!symbol)
136639
+ return referenceEntry;
136640
+ return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) });
136641
+ }
136642
+ function toReferenceEntry(entry) {
136232
136643
  var documentSpan = entryToDocumentSpan(entry);
136233
136644
  if (entry.kind === 0 /* Span */) {
136234
- return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false });
136645
+ return __assign(__assign({}, documentSpan), { isWriteAccess: false });
136235
136646
  }
136236
136647
  var kind = entry.kind, node = entry.node;
136237
- return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: isDeclarationOfSymbol(node, symbol), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
136648
+ return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
136238
136649
  }
136239
136650
  FindAllReferences.toReferenceEntry = toReferenceEntry;
136240
136651
  function entryToDocumentSpan(entry) {
@@ -136377,7 +136788,7 @@ var ts;
136377
136788
  */
136378
136789
  function declarationIsWriteAccess(decl) {
136379
136790
  // Consider anything in an ambient declaration to be a write access since it may be coming from JS.
136380
- if (!!(decl.flags & 8388608 /* Ambient */))
136791
+ if (!!(decl.flags & 16777216 /* Ambient */))
136381
136792
  return true;
136382
136793
  switch (decl.kind) {
136383
136794
  case 221 /* BinaryExpression */:
@@ -136942,15 +137353,21 @@ var ts;
136942
137353
  }
136943
137354
  function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) {
136944
137355
  var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken);
136945
- var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers;
137356
+ var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences;
136946
137357
  for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) {
136947
137358
  var importLocation = importSearches_2[_i][0];
136948
137359
  cb(importLocation);
136949
137360
  }
136950
- for (var _b = 0, indirectUsers_2 = indirectUsers; _b < indirectUsers_2.length; _b++) {
136951
- var indirectUser = indirectUsers_2[_b];
136952
- for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) {
136953
- var node = _d[_c];
137361
+ for (var _b = 0, singleReferences_2 = singleReferences; _b < singleReferences_2.length; _b++) {
137362
+ var singleReference = singleReferences_2[_b];
137363
+ if (ts.isIdentifier(singleReference) && ts.isImportTypeNode(singleReference.parent)) {
137364
+ cb(singleReference);
137365
+ }
137366
+ }
137367
+ for (var _c = 0, indirectUsers_2 = indirectUsers; _c < indirectUsers_2.length; _c++) {
137368
+ var indirectUser = indirectUsers_2[_c];
137369
+ for (var _d = 0, _e = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _d < _e.length; _d++) {
137370
+ var node = _e[_d];
136954
137371
  // Import specifiers should be handled by importSearches
136955
137372
  var symbol = checker.getSymbolAtLocation(node);
136956
137373
  var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; });
@@ -137093,6 +137510,30 @@ var ts;
137093
137510
  }
137094
137511
  }
137095
137512
  Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
137513
+ function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
137514
+ var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
137515
+ return candidates.reduce(function (topMost, decl) {
137516
+ var depth = getDepth(decl);
137517
+ if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
137518
+ topMost.declarationNames.push(decl);
137519
+ topMost.depth = depth;
137520
+ }
137521
+ else if (depth < topMost.depth) {
137522
+ topMost.declarationNames = [decl];
137523
+ topMost.depth = depth;
137524
+ }
137525
+ return topMost;
137526
+ }, { depth: Infinity, declarationNames: [] }).declarationNames;
137527
+ function getDepth(declaration) {
137528
+ var depth = 0;
137529
+ while (declaration) {
137530
+ declaration = ts.getContainerNode(declaration);
137531
+ depth++;
137532
+ }
137533
+ return depth;
137534
+ }
137535
+ }
137536
+ Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
137096
137537
  function someSignatureUsage(signature, sourceFiles, checker, cb) {
137097
137538
  if (!signature.name || !ts.isIdentifier(signature.name))
137098
137539
  return false;
@@ -137952,7 +138393,7 @@ var ts;
137952
138393
  }
137953
138394
  Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations;
137954
138395
  function isImplementation(node) {
137955
- return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
138396
+ return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
137956
138397
  (ts.isVariableLike(node) ? ts.hasInitializer(node) :
137957
138398
  ts.isFunctionLikeDeclaration(node) ? !!node.body :
137958
138399
  ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node));
@@ -138330,7 +138771,7 @@ var ts;
138330
138771
  function collect(node) {
138331
138772
  if (!node)
138332
138773
  return;
138333
- if (node.flags & 8388608 /* Ambient */) {
138774
+ if (node.flags & 16777216 /* Ambient */) {
138334
138775
  // do not descend into ambient nodes.
138335
138776
  return;
138336
138777
  }
@@ -138489,7 +138930,7 @@ var ts;
138489
138930
  }
138490
138931
  /** Gets the call sites that call out of the provided call hierarchy declaration. */
138491
138932
  function getOutgoingCalls(program, declaration) {
138492
- if (declaration.flags & 8388608 /* Ambient */ || ts.isMethodSignature(declaration)) {
138933
+ if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) {
138493
138934
  return [];
138494
138935
  }
138495
138936
  return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); });
@@ -138729,7 +139170,9 @@ var ts;
138729
139170
  (function (ts) {
138730
139171
  var GoToDefinition;
138731
139172
  (function (GoToDefinition) {
138732
- function getDefinitionAtPosition(program, sourceFile, position) {
139173
+ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly) {
139174
+ var _a;
139175
+ var _b;
138733
139176
  var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
138734
139177
  var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
138735
139178
  if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
@@ -138752,33 +139195,63 @@ var ts;
138752
139195
  }
138753
139196
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
138754
139197
  var classDecl = node.parent.parent;
138755
- var symbol_1 = getSymbol(classDecl, typeChecker);
139198
+ var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
138756
139199
  var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
138757
139200
  var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
138758
139201
  var sourceFile_1 = node.getSourceFile();
138759
139202
  return ts.map(staticBlocks, function (staticBlock) {
138760
139203
  var pos = ts.moveRangePastModifiers(staticBlock).pos;
138761
139204
  pos = ts.skipTrivia(sourceFile_1.text, pos);
138762
- return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
139205
+ return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
138763
139206
  });
138764
139207
  }
138765
- var symbol = getSymbol(node, typeChecker);
139208
+ var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
139209
+ var fallbackNode = node;
139210
+ if (searchOtherFilesOnly && failedAliasResolution) {
139211
+ // We couldn't resolve the specific import, try on the module specifier.
139212
+ var importDeclaration = ts.forEach(__spreadArray([node], (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, true), function (n) { return ts.findAncestor(n, ts.isAnyImportOrBareOrAccessedRequire); });
139213
+ var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
139214
+ if (moduleSpecifier) {
139215
+ (_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
139216
+ fallbackNode = moduleSpecifier;
139217
+ }
139218
+ }
139219
+ if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
139220
+ // We couldn't resolve the module specifier as an external module, but it could
139221
+ // be that module resolution succeeded but the target was not a module.
139222
+ var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
139223
+ if (ref) {
139224
+ return [{
139225
+ name: fallbackNode.text,
139226
+ fileName: ref.resolvedFileName,
139227
+ containerName: undefined,
139228
+ containerKind: undefined,
139229
+ kind: "script" /* scriptElement */,
139230
+ textSpan: ts.createTextSpan(0, 0),
139231
+ failedAliasResolution: failedAliasResolution,
139232
+ isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
139233
+ unverified: fallbackNode !== node,
139234
+ }];
139235
+ }
139236
+ }
138766
139237
  // Could not find a symbol e.g. node is string or number keyword,
138767
139238
  // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
138768
139239
  if (!symbol) {
138769
139240
  return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
138770
139241
  }
139242
+ if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
139243
+ return undefined;
138771
139244
  var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
138772
139245
  // Don't go to the component constructor definition for a JSX element, just go to the component definition.
138773
139246
  if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
138774
- var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
139247
+ var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
138775
139248
  // For a function, if this is the original function definition, return just sigInfo.
138776
139249
  // If this is the original constructor definition, parent is the class.
138777
139250
  if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
138778
139251
  return [sigInfo];
138779
139252
  }
138780
139253
  else {
138781
- var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
139254
+ var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
138782
139255
  // For a 'super()' call, put the signature first, else put the variable first.
138783
139256
  return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
138784
139257
  }
@@ -138790,7 +139263,7 @@ var ts;
138790
139263
  // assignment. This case and others are handled by the following code.
138791
139264
  if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) {
138792
139265
  var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
138793
- var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray;
139266
+ var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray;
138794
139267
  return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
138795
139268
  }
138796
139269
  // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
@@ -138813,7 +139286,7 @@ var ts;
138813
139286
  return prop && getDefinitionFromSymbol(typeChecker, prop, node);
138814
139287
  });
138815
139288
  }
138816
- return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
139289
+ return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
138817
139290
  }
138818
139291
  GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
138819
139292
  /**
@@ -138911,24 +139384,24 @@ var ts;
138911
139384
  return undefined;
138912
139385
  }
138913
139386
  if (ts.isImportMeta(node.parent) && node.parent.name === node) {
138914
- return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
139387
+ return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
138915
139388
  }
138916
- var symbol = getSymbol(node, typeChecker);
139389
+ var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
138917
139390
  if (!symbol)
138918
139391
  return undefined;
138919
139392
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
138920
139393
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
138921
- var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
139394
+ var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
138922
139395
  // If a function returns 'void' or some other type with no definition, just return the function definition.
138923
- var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
139396
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
138924
139397
  return typeDefinitions.length ? typeDefinitions
138925
- : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
139398
+ : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
138926
139399
  : undefined;
138927
139400
  }
138928
139401
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
138929
- function definitionFromType(type, checker, node) {
139402
+ function definitionFromType(type, checker, node, failedAliasResolution) {
138930
139403
  return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
138931
- return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
139404
+ return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
138932
139405
  });
138933
139406
  }
138934
139407
  function tryGetReturnTypeOfFunction(symbol, type, checker) {
@@ -138970,13 +139443,17 @@ var ts;
138970
139443
  // get the aliased symbol instead. This allows for goto def on an import e.g.
138971
139444
  // import {A, B} from "mod";
138972
139445
  // to jump to the implementation directly.
139446
+ var failedAliasResolution = false;
138973
139447
  if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
138974
139448
  var aliased = checker.getAliasedSymbol(symbol);
138975
139449
  if (aliased.declarations) {
138976
- return aliased;
139450
+ return { symbol: aliased };
139451
+ }
139452
+ else {
139453
+ failedAliasResolution = true;
138977
139454
  }
138978
139455
  }
138979
- return symbol;
139456
+ return { symbol: symbol, failedAliasResolution: failedAliasResolution };
138980
139457
  }
138981
139458
  // Go to the original declaration for cases:
138982
139459
  //
@@ -138990,26 +139467,45 @@ var ts;
138990
139467
  if (node.parent === declaration) {
138991
139468
  return true;
138992
139469
  }
138993
- switch (declaration.kind) {
138994
- case 267 /* ImportClause */:
138995
- case 265 /* ImportEqualsDeclaration */:
138996
- return true;
138997
- case 270 /* ImportSpecifier */:
138998
- return declaration.parent.kind === 269 /* NamedImports */;
138999
- case 203 /* BindingElement */:
139000
- case 254 /* VariableDeclaration */:
139001
- return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
139002
- default:
139003
- return false;
139470
+ if (declaration.kind === 268 /* NamespaceImport */) {
139471
+ return false;
139004
139472
  }
139473
+ return true;
139474
+ }
139475
+ /**
139476
+ * ```ts
139477
+ * function f() {}
139478
+ * f.foo = 0;
139479
+ * ```
139480
+ *
139481
+ * Here, `f` has two declarations: the function declaration, and the identifier in the next line.
139482
+ * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
139483
+ * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
139484
+ * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
139485
+ * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
139486
+ * declaration looks like an assignment, that declaration is in no sense a definition for `f`.
139487
+ * But that information is totally lost during binding and/or symbol merging, so we need to do
139488
+ * our best to reconstruct it or use other heuristics. This function (and the logic around its
139489
+ * calling) covers our tests but feels like a hack, and it would be great if someone could come
139490
+ * up with a more precise definition of what counts as a definition.
139491
+ */
139492
+ function isExpandoDeclaration(node) {
139493
+ if (!ts.isAssignmentDeclaration(node))
139494
+ return false;
139495
+ var containingAssignment = ts.findAncestor(node, function (p) {
139496
+ if (ts.isAssignmentExpression(p))
139497
+ return true;
139498
+ if (!ts.isAssignmentDeclaration(p))
139499
+ return "quit";
139500
+ return false;
139501
+ });
139502
+ return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
139005
139503
  }
139006
- function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) {
139007
- // There are cases when you extend a function by adding properties to it afterwards,
139008
- // we want to strip those extra properties.
139009
- // For deduping purposes, we also want to exclude any declarationNodes if provided.
139010
- var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); })
139011
- || undefined;
139012
- return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
139504
+ function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
139505
+ var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
139506
+ var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
139507
+ var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
139508
+ return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); });
139013
139509
  function getConstructSignatureDefinition() {
139014
139510
  // Applicable only if we are in a new expression, or we are on a constructor declaration
139015
139511
  // and in either case the symbol has a construct signature definition, i.e. class
@@ -139033,26 +139529,27 @@ var ts;
139033
139529
  return declarations.length
139034
139530
  ? declarationsWithBody.length !== 0
139035
139531
  ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
139036
- : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
139532
+ : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)]
139037
139533
  : undefined;
139038
139534
  }
139039
139535
  }
139040
139536
  /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
139041
- function createDefinitionInfo(declaration, checker, symbol, node) {
139537
+ function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) {
139042
139538
  var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
139043
139539
  var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
139044
139540
  var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
139045
- return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
139541
+ return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution);
139046
139542
  }
139543
+ GoToDefinition.createDefinitionInfo = createDefinitionInfo;
139047
139544
  /** Creates a DefinitionInfo directly from the name of a declaration. */
139048
- function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
139545
+ function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) {
139049
139546
  var sourceFile = declaration.getSourceFile();
139050
139547
  if (!textSpan) {
139051
139548
  var name = ts.getNameOfDeclaration(declaration) || declaration;
139052
139549
  textSpan = ts.createTextSpanFromNode(name, sourceFile);
139053
139550
  }
139054
139551
  return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
139055
- containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
139552
+ containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution });
139056
139553
  }
139057
139554
  function isDefinitionVisible(checker, declaration) {
139058
139555
  if (checker.isDeclarationVisible(declaration))
@@ -139085,8 +139582,8 @@ var ts;
139085
139582
  return false;
139086
139583
  }
139087
139584
  }
139088
- function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
139089
- return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
139585
+ function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
139586
+ return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
139090
139587
  }
139091
139588
  function findReferenceInPosition(refs, pos) {
139092
139589
  return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
@@ -140623,8 +141120,8 @@ var ts;
140623
141120
  var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
140624
141121
  var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
140625
141122
  // All of the old ImportDeclarations in the file, in syntactic order.
140626
- var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration);
140627
- organizeImportsWorker(topLevelImportDecls, coalesceAndOrganizeImports);
141123
+ var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
141124
+ topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
140628
141125
  // All of the old ExportDeclarations in the file, in syntactic order.
140629
141126
  var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
140630
141127
  organizeImportsWorker(topLevelExportDecls, coalesceExports);
@@ -140632,8 +141129,8 @@ var ts;
140632
141129
  var ambientModule = _a[_i];
140633
141130
  if (!ambientModule.body)
140634
141131
  continue;
140635
- var ambientModuleImportDecls = ambientModule.body.statements.filter(ts.isImportDeclaration);
140636
- organizeImportsWorker(ambientModuleImportDecls, coalesceAndOrganizeImports);
141132
+ var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
141133
+ ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
140637
141134
  var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
140638
141135
  organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
140639
141136
  }
@@ -140679,6 +141176,40 @@ var ts;
140679
141176
  }
140680
141177
  }
140681
141178
  OrganizeImports.organizeImports = organizeImports;
141179
+ function groupImportsByNewlineContiguous(sourceFile, importDecls) {
141180
+ var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, sourceFile.languageVariant);
141181
+ var groupImports = [];
141182
+ var groupIndex = 0;
141183
+ for (var _i = 0, importDecls_1 = importDecls; _i < importDecls_1.length; _i++) {
141184
+ var topLevelImportDecl = importDecls_1[_i];
141185
+ if (isNewGroup(sourceFile, topLevelImportDecl, scanner)) {
141186
+ groupIndex++;
141187
+ }
141188
+ if (!groupImports[groupIndex]) {
141189
+ groupImports[groupIndex] = [];
141190
+ }
141191
+ groupImports[groupIndex].push(topLevelImportDecl);
141192
+ }
141193
+ return groupImports;
141194
+ }
141195
+ // a new group is created if an import includes at least two new line
141196
+ // new line from multi-line comment doesn't count
141197
+ function isNewGroup(sourceFile, topLevelImportDecl, scanner) {
141198
+ var startPos = topLevelImportDecl.getFullStart();
141199
+ var endPos = topLevelImportDecl.getStart();
141200
+ scanner.setText(sourceFile.text, startPos, endPos - startPos);
141201
+ var numberOfNewLines = 0;
141202
+ while (scanner.getTokenPos() < endPos) {
141203
+ var tokenKind = scanner.scan();
141204
+ if (tokenKind === 4 /* NewLineTrivia */) {
141205
+ numberOfNewLines++;
141206
+ if (numberOfNewLines >= 2) {
141207
+ return true;
141208
+ }
141209
+ }
141210
+ }
141211
+ return false;
141212
+ }
140682
141213
  function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
140683
141214
  // As a precaution, consider unused import detection to be destructive (GH #43051)
140684
141215
  if (skipDestructiveCodeActions) {
@@ -148639,8 +149170,11 @@ var ts;
148639
149170
  function isTrivia(s) {
148640
149171
  return ts.skipTrivia(s, 0) === s.length;
148641
149172
  }
149173
+ // A transformation context that won't perform parenthesization, as some parenthesization rules
149174
+ // are more aggressive than is strictly necessary.
149175
+ var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) });
148642
149176
  function assignPositionsToNode(node) {
148643
- var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
149177
+ var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
148644
149178
  // create proxy node for non synthesized nodes
148645
149179
  var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited);
148646
149180
  ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
@@ -152164,9 +152698,10 @@ var ts;
152164
152698
  // 2. add "member3" to the second import statement's import list
152165
152699
  // and it is up to the user to decide which one fits best.
152166
152700
  return ts.firstDefined(existingImports, function (_a) {
152701
+ var _b;
152167
152702
  var declaration = _a.declaration;
152168
152703
  var namespacePrefix = getNamespaceLikeImportText(declaration);
152169
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
152704
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
152170
152705
  if (namespacePrefix && moduleSpecifier) {
152171
152706
  var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
152172
152707
  if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
@@ -152342,8 +152877,9 @@ var ts;
152342
152877
  return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
152343
152878
  }
152344
152879
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
152880
+ var _b;
152345
152881
  var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
152346
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
152882
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
152347
152883
  if (moduleSpecifier) {
152348
152884
  var addAsTypeOnly = useRequire
152349
152885
  ? 4 /* NotAllowed */
@@ -156605,7 +157141,7 @@ var ts;
156605
157141
  var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
156606
157142
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
156607
157143
  var optional = !!(symbol.flags & 16777216 /* Optional */);
156608
- var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient;
157144
+ var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient;
156609
157145
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
156610
157146
  switch (declaration.kind) {
156611
157147
  case 166 /* PropertySignature */:
@@ -156701,7 +157237,6 @@ var ts;
156701
157237
  var checker = program.getTypeChecker();
156702
157238
  var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
156703
157239
  var flags = 1 /* NoTruncation */
156704
- | 1073741824 /* NoUndefinedOptionalParameterType */
156705
157240
  | 256 /* SuppressAnyReturnType */
156706
157241
  | 524288 /* AllowEmptyTuple */
156707
157242
  | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
@@ -158182,6 +158717,10 @@ var ts;
158182
158717
  }
158183
158718
  break;
158184
158719
  }
158720
+ case 200 /* ImportType */:
158721
+ var importTypeNode = parent;
158722
+ changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf));
158723
+ break;
158185
158724
  default:
158186
158725
  ts.Debug.failBadSyntaxKind(parent);
158187
158726
  }
@@ -159076,6 +159615,7 @@ var ts;
159076
159615
  Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
159077
159616
  Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
159078
159617
  Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block");
159618
+ Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method");
159079
159619
  })(Messages = extractSymbol.Messages || (extractSymbol.Messages = {}));
159080
159620
  var RangeFacts;
159081
159621
  (function (RangeFacts) {
@@ -159084,10 +159624,11 @@ var ts;
159084
159624
  RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator";
159085
159625
  RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction";
159086
159626
  RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis";
159627
+ RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction";
159087
159628
  /**
159088
159629
  * The range is in a function which needs the 'static' modifier in a class
159089
159630
  */
159090
- RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion";
159631
+ RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion";
159091
159632
  })(RangeFacts || (RangeFacts = {}));
159092
159633
  /**
159093
159634
  * getRangeToExtract takes a span inside a text file and returns either an expression or an array
@@ -159118,11 +159659,12 @@ var ts;
159118
159659
  // We'll modify these flags as we walk the tree to collect data
159119
159660
  // about what things need to be done as part of the extraction.
159120
159661
  var rangeFacts = RangeFacts.None;
159662
+ var thisNode;
159121
159663
  if (!start || !end) {
159122
159664
  // cannot find either start or end node
159123
159665
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
159124
159666
  }
159125
- if (start.flags & 4194304 /* JSDoc */) {
159667
+ if (start.flags & 8388608 /* JSDoc */) {
159126
159668
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
159127
159669
  }
159128
159670
  if (start.parent !== end.parent) {
@@ -159156,7 +159698,7 @@ var ts;
159156
159698
  // the expression.
159157
159699
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
159158
159700
  }
159159
- return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } };
159701
+ return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
159160
159702
  }
159161
159703
  if (ts.isReturnStatement(start) && !start.expression) {
159162
159704
  // Makes no sense to extract an expression-less return statement.
@@ -159168,7 +159710,7 @@ var ts;
159168
159710
  if (errors) {
159169
159711
  return { errors: errors };
159170
159712
  }
159171
- return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217
159713
+ return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
159172
159714
  /**
159173
159715
  * Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
159174
159716
  * @param node The unrefined extraction node.
@@ -159248,7 +159790,7 @@ var ts;
159248
159790
  if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
159249
159791
  return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
159250
159792
  }
159251
- if (nodeToCheck.flags & 8388608 /* Ambient */) {
159793
+ if (nodeToCheck.flags & 16777216 /* Ambient */) {
159252
159794
  return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)];
159253
159795
  }
159254
159796
  // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default)
@@ -159260,6 +159802,14 @@ var ts;
159260
159802
  var permittedJumps = 4 /* Return */;
159261
159803
  var seenLabels;
159262
159804
  visit(nodeToCheck);
159805
+ if (rangeFacts & RangeFacts.UsesThis) {
159806
+ var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
159807
+ if (container.kind === 256 /* FunctionDeclaration */ ||
159808
+ (container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) ||
159809
+ container.kind === 213 /* FunctionExpression */) {
159810
+ rangeFacts |= RangeFacts.UsesThisInFunction;
159811
+ }
159812
+ }
159263
159813
  return errors;
159264
159814
  function visit(node) {
159265
159815
  if (errors) {
@@ -159298,6 +159848,7 @@ var ts;
159298
159848
  }
159299
159849
  else {
159300
159850
  rangeFacts |= RangeFacts.UsesThis;
159851
+ thisNode = node;
159301
159852
  }
159302
159853
  break;
159303
159854
  case 214 /* ArrowFunction */:
@@ -159305,6 +159856,7 @@ var ts;
159305
159856
  ts.forEachChild(node, function check(n) {
159306
159857
  if (ts.isThis(n)) {
159307
159858
  rangeFacts |= RangeFacts.UsesThis;
159859
+ thisNode = node;
159308
159860
  }
159309
159861
  else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) {
159310
159862
  return false;
@@ -159361,6 +159913,7 @@ var ts;
159361
159913
  case 192 /* ThisType */:
159362
159914
  case 108 /* ThisKeyword */:
159363
159915
  rangeFacts |= RangeFacts.UsesThis;
159916
+ thisNode = node;
159364
159917
  break;
159365
159918
  case 250 /* LabeledStatement */: {
159366
159919
  var label = node.label;
@@ -159448,7 +160001,7 @@ var ts;
159448
160001
  */
159449
160002
  function collectEnclosingScopes(range) {
159450
160003
  var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range;
159451
- if (range.facts & RangeFacts.UsesThis) {
160004
+ if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) {
159452
160005
  // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class
159453
160006
  var containingClass = ts.getContainingClass(current);
159454
160007
  if (containingClass) {
@@ -159654,6 +160207,7 @@ var ts;
159654
160207
  var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty;
159655
160208
  ts.suppressLeadingAndTrailingTrivia(body);
159656
160209
  var newFunction;
160210
+ var callThis = !!(range.facts & RangeFacts.UsesThisInFunction);
159657
160211
  if (ts.isClassLike(scope)) {
159658
160212
  // always create private method in TypeScript files
159659
160213
  var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)];
@@ -159668,6 +160222,15 @@ var ts;
159668
160222
  /*questionToken*/ undefined, typeParameters, parameters, returnType, body);
159669
160223
  }
159670
160224
  else {
160225
+ if (callThis) {
160226
+ parameters.unshift(ts.factory.createParameterDeclaration(
160227
+ /*decorators*/ undefined,
160228
+ /*modifiers*/ undefined,
160229
+ /*dotDotDotToken*/ undefined,
160230
+ /*name*/ "this",
160231
+ /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */),
160232
+ /*initializer*/ undefined));
160233
+ }
159671
160234
  newFunction = ts.factory.createFunctionDeclaration(
159672
160235
  /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body);
159673
160236
  }
@@ -159684,7 +160247,10 @@ var ts;
159684
160247
  var newNodes = [];
159685
160248
  // replace range with function call
159686
160249
  var called = getCalledExpression(scope, range, functionNameText);
159687
- var call = ts.factory.createCallExpression(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference
160250
+ if (callThis) {
160251
+ callArguments.unshift(ts.factory.createIdentifier("this"));
160252
+ }
160253
+ var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference
159688
160254
  callArguments);
159689
160255
  if (range.facts & RangeFacts.IsGenerator) {
159690
160256
  call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call);
@@ -160295,6 +160861,9 @@ var ts;
160295
160861
  var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range;
160296
160862
  constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes));
160297
160863
  }
160864
+ if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) {
160865
+ functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod));
160866
+ }
160298
160867
  var hasWrite = false;
160299
160868
  var readonlyClassPropertyWrite;
160300
160869
  usagesPerScope[i].usages.forEach(function (value) {
@@ -160780,6 +161349,7 @@ var ts;
160780
161349
  }
160781
161350
  function doTypedefChange(changes, file, name, info) {
160782
161351
  var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters;
161352
+ ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
160783
161353
  var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name));
160784
161354
  var templates = [];
160785
161355
  ts.forEach(typeParameters, function (typeParameter) {
@@ -162810,7 +163380,7 @@ var ts;
162810
163380
  kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) :
162811
163381
  new TokenObject(kind, pos, end);
162812
163382
  node.parent = parent;
162813
- node.flags = parent.flags & 25358336 /* ContextFlags */;
163383
+ node.flags = parent.flags & 50720768 /* ContextFlags */;
162814
163384
  return node;
162815
163385
  }
162816
163386
  var NodeObject = /** @class */ (function () {
@@ -164247,9 +164817,9 @@ var ts;
164247
164817
  }
164248
164818
  }
164249
164819
  /// Goto definition
164250
- function getDefinitionAtPosition(fileName, position) {
164820
+ function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly) {
164251
164821
  synchronizeHostData();
164252
- return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
164822
+ return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly);
164253
164823
  }
164254
164824
  function getDefinitionAndBoundSpan(fileName, position) {
164255
164825
  synchronizeHostData();
@@ -164266,7 +164836,7 @@ var ts;
164266
164836
  }
164267
164837
  /// References and Occurrences
164268
164838
  function getOccurrencesAtPosition(fileName, position) {
164269
- return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); });
164839
+ return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); });
164270
164840
  }
164271
164841
  function getDocumentHighlights(fileName, position, filesToSearch) {
164272
164842
  var normalizedFileName = ts.normalizePath(fileName);
@@ -164295,7 +164865,7 @@ var ts;
164295
164865
  }
164296
164866
  function getReferencesAtPosition(fileName, position) {
164297
164867
  synchronizeHostData();
164298
- return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, function (entry, node, checker) { return ts.FindAllReferences.toReferenceEntry(entry, checker.getSymbolAtLocation(node)); });
164868
+ return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry);
164299
164869
  }
164300
164870
  function getReferencesWorker(node, position, options, cb) {
164301
164871
  synchronizeHostData();
@@ -164310,10 +164880,8 @@ var ts;
164310
164880
  return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
164311
164881
  }
164312
164882
  function getFileReferences(fileName) {
164313
- var _a;
164314
164883
  synchronizeHostData();
164315
- var moduleSymbol = (_a = program.getSourceFile(fileName)) === null || _a === void 0 ? void 0 : _a.symbol;
164316
- return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(function (r) { return ts.FindAllReferences.toReferenceEntry(r, moduleSymbol); });
164884
+ return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(ts.FindAllReferences.toReferenceEntry);
164317
164885
  }
164318
164886
  function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) {
164319
164887
  if (excludeDtsFiles === void 0) { excludeDtsFiles = false; }
@@ -164786,7 +165354,7 @@ var ts;
164786
165354
  }
164787
165355
  function isUnclosedFragment(_a) {
164788
165356
  var closingFragment = _a.closingFragment, parent = _a.parent;
164789
- return !!(closingFragment.flags & 65536 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
165357
+ return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
164790
165358
  }
164791
165359
  function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
164792
165360
  var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
@@ -165234,7 +165802,7 @@ var ts;
165234
165802
  tokenAtLocation = preceding;
165235
165803
  }
165236
165804
  // Cannot set breakpoint in ambient declarations
165237
- if (tokenAtLocation.flags & 8388608 /* Ambient */) {
165805
+ if (tokenAtLocation.flags & 16777216 /* Ambient */) {
165238
165806
  return undefined;
165239
165807
  }
165240
165808
  // Get the span in the node based on its syntax