typescript 4.8.0-dev.20220705 → 4.8.0-dev.20220708

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/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-dev.20220705";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220708";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -2065,7 +2065,7 @@ var ts;
2065
2065
  * and 1 insertion/deletion at 3 characters)
2066
2066
  */
2067
2067
  function getSpellingSuggestion(name, candidates, getName) {
2068
- var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
2068
+ var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
2069
2069
  var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
2070
2070
  var bestCandidate;
2071
2071
  for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
@@ -2794,6 +2794,22 @@ var ts;
2794
2794
  return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true);
2795
2795
  }
2796
2796
  Debug.formatFlowFlags = formatFlowFlags;
2797
+ function formatRelationComparisonResult(result) {
2798
+ return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true);
2799
+ }
2800
+ Debug.formatRelationComparisonResult = formatRelationComparisonResult;
2801
+ function formatCheckMode(mode) {
2802
+ return formatEnum(mode, ts.CheckMode, /*isFlags*/ true);
2803
+ }
2804
+ Debug.formatCheckMode = formatCheckMode;
2805
+ function formatSignatureCheckMode(mode) {
2806
+ return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true);
2807
+ }
2808
+ Debug.formatSignatureCheckMode = formatSignatureCheckMode;
2809
+ function formatTypeFacts(facts) {
2810
+ return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true);
2811
+ }
2812
+ Debug.formatTypeFacts = formatTypeFacts;
2797
2813
  var isDebugInfoEnabled = false;
2798
2814
  var extendedDebugModule;
2799
2815
  function extendedDebug() {
@@ -4746,6 +4762,7 @@ var ts;
4746
4762
  NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
4747
4763
  NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
4748
4764
  NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
4765
+ NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
4749
4766
  // Error handling
4750
4767
  NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
4751
4768
  NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
@@ -4786,6 +4803,7 @@ var ts;
4786
4803
  TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
4787
4804
  TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
4788
4805
  TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
4806
+ TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
4789
4807
  // Error Handling
4790
4808
  TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType";
4791
4809
  // TypeFormatFlags exclusive
@@ -4797,7 +4815,7 @@ var ts;
4797
4815
  TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
4798
4816
  TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias";
4799
4817
  /** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike";
4800
- TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 814775659] = "NodeBuilderFlagsMask";
4818
+ TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask";
4801
4819
  })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
4802
4820
  var SymbolFormatFlags;
4803
4821
  (function (SymbolFormatFlags) {
@@ -9031,6 +9049,7 @@ var ts;
9031
9049
  The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
9032
9050
  _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
9033
9051
  We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
9052
+ Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
9034
9053
  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}'."),
9035
9054
  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}'."),
9036
9055
  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}'."),
@@ -19529,7 +19548,8 @@ var ts;
19529
19548
  function getDeclarationModifierFlagsFromSymbol(s, isWrite) {
19530
19549
  if (isWrite === void 0) { isWrite = false; }
19531
19550
  if (s.valueDeclaration) {
19532
- var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration;
19551
+ var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration))
19552
+ || (s.flags & 32768 /* GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration;
19533
19553
  var flags = ts.getCombinedModifierFlags(declaration);
19534
19554
  return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
19535
19555
  }
@@ -20204,7 +20224,7 @@ var ts;
20204
20224
  // Excludes declaration files - they still require an explicit `export {}` or the like
20205
20225
  // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20206
20226
  // that aren't esm-mode (meaning not in a `type: module` scope).
20207
- return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20227
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */]))) && !file.isDeclarationFile ? true : undefined;
20208
20228
  }
20209
20229
  function getSetExternalModuleIndicator(options) {
20210
20230
  // TODO: Should this callback be cached?
@@ -20227,10 +20247,7 @@ var ts;
20227
20247
  if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
20228
20248
  checks.push(isFileModuleFromUsingJSXTag);
20229
20249
  }
20230
- var moduleKind = getEmitModuleKind(options);
20231
- if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
20232
- checks.push(isFileForcedToBeModuleByFormat);
20233
- }
20250
+ checks.push(isFileForcedToBeModuleByFormat);
20234
20251
  var combined_1 = ts.or.apply(void 0, checks);
20235
20252
  var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
20236
20253
  return callback;
@@ -33950,10 +33967,10 @@ var ts;
33950
33967
  var hasJSDoc = hasPrecedingJSDocComment();
33951
33968
  var modifiers = parseModifiers();
33952
33969
  if (parseContextualModifier(136 /* GetKeyword */)) {
33953
- return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */);
33970
+ return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */, 4 /* Type */);
33954
33971
  }
33955
33972
  if (parseContextualModifier(149 /* SetKeyword */)) {
33956
- return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */);
33973
+ return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */, 4 /* Type */);
33957
33974
  }
33958
33975
  if (isIndexSignature()) {
33959
33976
  return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers);
@@ -35999,10 +36016,10 @@ var ts;
35999
36016
  var decorators = parseDecorators();
36000
36017
  var modifiers = parseModifiers();
36001
36018
  if (parseContextualModifier(136 /* GetKeyword */)) {
36002
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
36019
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
36003
36020
  }
36004
36021
  if (parseContextualModifier(149 /* SetKeyword */)) {
36005
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
36022
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
36006
36023
  }
36007
36024
  var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
36008
36025
  var tokenIsIdentifier = isIdentifier();
@@ -36694,9 +36711,15 @@ var ts;
36694
36711
  return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */);
36695
36712
  }
36696
36713
  function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
36697
- if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) {
36698
- parseSemicolon();
36699
- return;
36714
+ if (token() !== 18 /* OpenBraceToken */) {
36715
+ if (flags & 4 /* Type */) {
36716
+ parseTypeMemberSemicolon();
36717
+ return;
36718
+ }
36719
+ if (canParseSemicolon()) {
36720
+ parseSemicolon();
36721
+ return;
36722
+ }
36700
36723
  }
36701
36724
  return parseFunctionBlock(flags, diagnosticMessage);
36702
36725
  }
@@ -36900,12 +36923,12 @@ var ts;
36900
36923
  }
36901
36924
  return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
36902
36925
  }
36903
- function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
36926
+ function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) {
36904
36927
  var name = parsePropertyName();
36905
36928
  var typeParameters = parseTypeParameters();
36906
36929
  var parameters = parseParameters(0 /* None */);
36907
36930
  var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
36908
- var body = parseFunctionBlockOrSemicolon(0 /* None */);
36931
+ var body = parseFunctionBlockOrSemicolon(flags);
36909
36932
  var node = kind === 172 /* GetAccessor */
36910
36933
  ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
36911
36934
  : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
@@ -37092,10 +37115,10 @@ var ts;
37092
37115
  return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
37093
37116
  }
37094
37117
  if (parseContextualModifier(136 /* GetKeyword */)) {
37095
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
37118
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
37096
37119
  }
37097
37120
  if (parseContextualModifier(149 /* SetKeyword */)) {
37098
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
37121
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
37099
37122
  }
37100
37123
  if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) {
37101
37124
  var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
@@ -44406,6 +44429,7 @@ var ts;
44406
44429
  return toSearchResult(/*value*/ undefined);
44407
44430
  }
44408
44431
  /**
44432
+ * @internal
44409
44433
  * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44410
44434
  * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44411
44435
  */
@@ -44428,6 +44452,7 @@ var ts;
44428
44452
  return 1;
44429
44453
  return 0;
44430
44454
  }
44455
+ ts.comparePatternKeys = comparePatternKeys;
44431
44456
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44432
44457
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44433
44458
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
@@ -48499,7 +48524,7 @@ var ts;
48499
48524
  // Masks
48500
48525
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
48501
48526
  TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
48502
- })(TypeFacts || (TypeFacts = {}));
48527
+ })(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {}));
48503
48528
  var typeofNEFacts = new ts.Map(ts.getEntries({
48504
48529
  string: 256 /* TypeofNEString */,
48505
48530
  number: 512 /* TypeofNENumber */,
@@ -48534,7 +48559,7 @@ var ts;
48534
48559
  CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
48535
48560
  // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
48536
48561
  // we need to preserve generic types instead of substituting them for constraints
48537
- })(CheckMode || (CheckMode = {}));
48562
+ })(CheckMode = ts.CheckMode || (ts.CheckMode = {}));
48538
48563
  var SignatureCheckMode;
48539
48564
  (function (SignatureCheckMode) {
48540
48565
  SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback";
@@ -48542,7 +48567,7 @@ var ts;
48542
48567
  SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes";
48543
48568
  SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity";
48544
48569
  SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback";
48545
- })(SignatureCheckMode || (SignatureCheckMode = {}));
48570
+ })(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {}));
48546
48571
  var IntersectionState;
48547
48572
  (function (IntersectionState) {
48548
48573
  IntersectionState[IntersectionState["None"] = 0] = "None";
@@ -48894,7 +48919,7 @@ var ts;
48894
48919
  },
48895
48920
  getContextualTypeForObjectLiteralElement: function (nodeIn) {
48896
48921
  var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
48897
- return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
48922
+ return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined;
48898
48923
  },
48899
48924
  getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
48900
48925
  var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
@@ -48902,7 +48927,7 @@ var ts;
48902
48927
  },
48903
48928
  getContextualTypeForJsxAttribute: function (nodeIn) {
48904
48929
  var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
48905
- return node && getContextualTypeForJsxAttribute(node);
48930
+ return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined);
48906
48931
  },
48907
48932
  isContextSensitive: isContextSensitive,
48908
48933
  getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
@@ -49108,6 +49133,7 @@ var ts;
49108
49133
  var stringMappingTypes = new ts.Map();
49109
49134
  var substitutionTypes = new ts.Map();
49110
49135
  var subtypeReductionCache = new ts.Map();
49136
+ var cachedTypes = new ts.Map();
49111
49137
  var evolvingArrayTypes = [];
49112
49138
  var undefinedProperties = new ts.Map();
49113
49139
  var markerTypes = new ts.Set();
@@ -49361,6 +49387,14 @@ var ts;
49361
49387
  ];
49362
49388
  initializeTypeChecker();
49363
49389
  return checker;
49390
+ function getCachedType(key) {
49391
+ return key ? cachedTypes.get(key) : undefined;
49392
+ }
49393
+ function setCachedType(key, type) {
49394
+ if (key)
49395
+ cachedTypes.set(key, type);
49396
+ return type;
49397
+ }
49364
49398
  function getJsxNamespace(location) {
49365
49399
  if (location) {
49366
49400
  var file = ts.getSourceFileOfNode(location);
@@ -50225,6 +50259,7 @@ var ts;
50225
50259
  if (ctor && ctor.locals) {
50226
50260
  if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
50227
50261
  // Remember the property node, it will be used later to report appropriate error
50262
+ ts.Debug.assertNode(location, ts.isPropertyDeclaration);
50228
50263
  propertyWithInvalidInitializer = location;
50229
50264
  }
50230
50265
  }
@@ -50414,11 +50449,27 @@ var ts;
50414
50449
  }
50415
50450
  }
50416
50451
  }
50452
+ // The invalid initializer error is needed in two situation:
50453
+ // 1. When result is undefined, after checking for a missing "this."
50454
+ // 2. When result is defined
50455
+ function checkAndReportErrorForInvalidInitializer() {
50456
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50457
+ // We have a match, but the reference occurred within a property initializer and the identifier also binds
50458
+ // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50459
+ // with ESNext+useDefineForClassFields because the scope semantics are different.
50460
+ error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
50461
+ ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
50462
+ : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
50463
+ return true;
50464
+ }
50465
+ return false;
50466
+ }
50417
50467
  if (!result) {
50418
50468
  if (nameNotFoundMessage) {
50419
50469
  addLazyDiagnostic(function () {
50420
50470
  if (!errorLocation ||
50421
50471
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
50472
+ !checkAndReportErrorForInvalidInitializer() &&
50422
50473
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50423
50474
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50424
50475
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
@@ -50426,7 +50477,16 @@ var ts;
50426
50477
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50427
50478
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50428
50479
  var suggestion = void 0;
50429
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50480
+ var suggestedLib = void 0;
50481
+ // Report missing lib first
50482
+ if (nameArg) {
50483
+ suggestedLib = getSuggestedLibForNonExistentName(nameArg);
50484
+ if (suggestedLib) {
50485
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
50486
+ }
50487
+ }
50488
+ // then spelling suggestions
50489
+ if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50430
50490
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
50431
50491
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
50432
50492
  if (isGlobalScopeAugmentationDeclaration) {
@@ -50445,16 +50505,9 @@ var ts;
50445
50505
  }
50446
50506
  }
50447
50507
  }
50448
- if (!suggestion) {
50449
- if (nameArg) {
50450
- var lib = getSuggestedLibForNonExistentName(nameArg);
50451
- if (lib) {
50452
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
50453
- }
50454
- else {
50455
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50456
- }
50457
- }
50508
+ // And then fall back to unspecified "not found"
50509
+ if (!suggestion && !suggestedLib && nameArg) {
50510
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50458
50511
  }
50459
50512
  suggestionCount++;
50460
50513
  }
@@ -50462,12 +50515,7 @@ var ts;
50462
50515
  }
50463
50516
  return undefined;
50464
50517
  }
50465
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50466
- // We have a match, but the reference occurred within a property initializer and the identifier also binds
50467
- // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50468
- // with ESNext+useDefineForClassFields because the scope semantics are different.
50469
- var propertyName = propertyWithInvalidInitializer.name;
50470
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
50518
+ else if (checkAndReportErrorForInvalidInitializer()) {
50471
50519
  return undefined;
50472
50520
  }
50473
50521
  // Perform extra checks only if error reporting was requested
@@ -52616,13 +52664,25 @@ var ts;
52616
52664
  && isDeclarationVisible(declaration.parent)) {
52617
52665
  return addVisibleAlias(declaration, declaration);
52618
52666
  }
52619
- else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement
52620
- && ts.isVariableDeclaration(declaration.parent.parent)
52621
- && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
52622
- && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */)
52623
- && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
52624
- && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
52625
- return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
52667
+ else if (ts.isBindingElement(declaration)) {
52668
+ if (symbol.flags & 2097152 /* Alias */ && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement
52669
+ && ts.isVariableDeclaration(declaration.parent.parent)
52670
+ && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
52671
+ && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */)
52672
+ && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
52673
+ && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
52674
+ return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
52675
+ }
52676
+ else if (symbol.flags & 2 /* BlockScopedVariable */) {
52677
+ var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement);
52678
+ if (ts.hasSyntacticModifier(variableStatement, 1 /* Export */)) {
52679
+ return true;
52680
+ }
52681
+ if (!isDeclarationVisible(variableStatement.parent)) {
52682
+ return false;
52683
+ }
52684
+ return addVisibleAlias(declaration, variableStatement);
52685
+ }
52626
52686
  }
52627
52687
  // Declaration is not visible
52628
52688
  return false;
@@ -52755,7 +52815,7 @@ var ts;
52755
52815
  }
52756
52816
  function toNodeBuilderFlags(flags) {
52757
52817
  if (flags === void 0) { flags = 0 /* None */; }
52758
- return flags & 814775659 /* NodeBuilderFlagsMask */;
52818
+ return flags & 848330091 /* NodeBuilderFlagsMask */;
52759
52819
  }
52760
52820
  function isClassInstanceSide(type) {
52761
52821
  return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */)));
@@ -53143,6 +53203,10 @@ var ts;
53143
53203
  }
53144
53204
  return typeToTypeNodeHelper(type, context);
53145
53205
  }
53206
+ function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) {
53207
+ return isMappedTypeWithKeyofConstraintDeclaration(type)
53208
+ && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */);
53209
+ }
53146
53210
  function createMappedTypeNodeFromType(type) {
53147
53211
  ts.Debug.assert(!!(type.flags & 524288 /* Object */));
53148
53212
  var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
@@ -53152,7 +53216,7 @@ var ts;
53152
53216
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
53153
53217
  // We have a { [P in keyof T]: X }
53154
53218
  // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
53155
- if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53219
+ if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53156
53220
  var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
53157
53221
  var name = typeParameterToName(newParam, context);
53158
53222
  newTypeVariable = ts.factory.createTypeReferenceNode(name);
@@ -53168,11 +53232,12 @@ var ts;
53168
53232
  var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
53169
53233
  context.approximateLength += 10;
53170
53234
  var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
53171
- if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53235
+ if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53172
53236
  // homomorphic mapped type with a non-homomorphic naive inlining
53173
53237
  // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
53174
53238
  // type stays homomorphic
53175
- return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
53239
+ var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper);
53240
+ return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 /* Unknown */ ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
53176
53241
  }
53177
53242
  return result;
53178
53243
  }
@@ -53734,7 +53799,7 @@ var ts;
53734
53799
  var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
53735
53800
  // If the expanded parameter list had a variadic in a non-trailing position, don't expand it
53736
53801
  var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
53737
- var thisParameter = tryGetThisParameterDeclaration(signature, context);
53802
+ var thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context);
53738
53803
  if (thisParameter) {
53739
53804
  parameters.unshift(thisParameter);
53740
53805
  }
@@ -54793,12 +54858,11 @@ var ts;
54793
54858
  if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
54794
54859
  var oldContext = context;
54795
54860
  context = cloneNodeBuilderContext(context);
54796
- var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
54861
+ serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
54797
54862
  if (context.reportedDiagnostic) {
54798
54863
  oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context
54799
54864
  }
54800
54865
  context = oldContext;
54801
- return result;
54802
54866
  }
54803
54867
  }
54804
54868
  // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias
@@ -57855,7 +57919,7 @@ var ts;
57855
57919
  error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
57856
57920
  }
57857
57921
  else {
57858
- error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
57922
+ error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
57859
57923
  }
57860
57924
  }
57861
57925
  links.declaredType = type;
@@ -62318,19 +62382,22 @@ var ts;
62318
62382
  * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
62319
62383
  */
62320
62384
  function isPossiblyReducibleByInstantiation(type) {
62321
- return ts.some(type.types, function (t) {
62322
- var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
62323
- return getReducedType(uniqueFilled) !== uniqueFilled;
62324
- });
62385
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(type);
62386
+ return getReducedType(uniqueFilled) !== uniqueFilled;
62387
+ }
62388
+ function shouldDeferIndexType(type) {
62389
+ return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ ||
62390
+ isGenericTupleType(type) ||
62391
+ isGenericMappedType(type) && !hasDistributiveNameType(type) ||
62392
+ type.flags & 1048576 /* Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) ||
62393
+ type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType));
62325
62394
  }
62326
62395
  function getIndexType(type, stringsOnly, noIndexSignatures) {
62327
62396
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
62328
62397
  type = getReducedType(type);
62329
- return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
62330
- ? getIndexTypeForGenericType(type, stringsOnly)
62331
- : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62332
- type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62333
- type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62398
+ return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62399
+ type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62400
+ type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62334
62401
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
62335
62402
  type === wildcardType ? wildcardType :
62336
62403
  type.flags & 2 /* Unknown */ ? neverType :
@@ -66123,13 +66190,20 @@ var ts;
66123
66190
  return result;
66124
66191
  }
66125
66192
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
66193
+ var saveErrorInfo = captureErrorCalculationState();
66194
+ var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
66195
+ if (result) {
66196
+ resetErrorInfo(saveErrorInfo);
66197
+ }
66198
+ return result;
66199
+ }
66200
+ function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
66126
66201
  if (intersectionState & 4 /* PropertyCheck */) {
66127
66202
  return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
66128
66203
  }
66129
66204
  var result;
66130
66205
  var originalErrorInfo;
66131
66206
  var varianceCheckFailed = false;
66132
- var saveErrorInfo = captureErrorCalculationState();
66133
66207
  var sourceFlags = source.flags;
66134
66208
  var targetFlags = target.flags;
66135
66209
  if (relation === identityRelation) {
@@ -66193,7 +66267,6 @@ var ts;
66193
66267
  if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66194
66268
  // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66195
66269
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
66196
- resetErrorInfo(saveErrorInfo);
66197
66270
  return result;
66198
66271
  }
66199
66272
  }
@@ -66318,7 +66391,6 @@ var ts;
66318
66391
  result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
66319
66392
  }
66320
66393
  if (result) {
66321
- resetErrorInfo(saveErrorInfo);
66322
66394
  return result;
66323
66395
  }
66324
66396
  if (reportErrors) {
@@ -66421,7 +66493,6 @@ var ts;
66421
66493
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
66422
66494
  // conditional type and bail out with a Ternary.Maybe result.
66423
66495
  if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
66424
- resetErrorInfo(saveErrorInfo);
66425
66496
  return 3 /* Maybe */;
66426
66497
  }
66427
66498
  var c = target;
@@ -66436,7 +66507,6 @@ var ts;
66436
66507
  if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
66437
66508
  result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
66438
66509
  if (result) {
66439
- resetErrorInfo(saveErrorInfo);
66440
66510
  return result;
66441
66511
  }
66442
66512
  }
@@ -66468,12 +66538,10 @@ var ts;
66468
66538
  var constraint = getConstraintOfType(source) || unknownType;
66469
66539
  // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
66470
66540
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
66471
- resetErrorInfo(saveErrorInfo);
66472
66541
  return result;
66473
66542
  }
66474
66543
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
66475
66544
  else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
66476
- resetErrorInfo(saveErrorInfo);
66477
66545
  return result;
66478
66546
  }
66479
66547
  if (isMappedTypeGenericIndexedAccess(source)) {
@@ -66482,7 +66550,6 @@ var ts;
66482
66550
  var indexConstraint = getConstraintOfType(source.indexType);
66483
66551
  if (indexConstraint) {
66484
66552
  if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
66485
- resetErrorInfo(saveErrorInfo);
66486
66553
  return result;
66487
66554
  }
66488
66555
  }
@@ -66491,7 +66558,6 @@ var ts;
66491
66558
  }
66492
66559
  else if (sourceFlags & 4194304 /* Index */) {
66493
66560
  if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
66494
- resetErrorInfo(saveErrorInfo);
66495
66561
  return result;
66496
66562
  }
66497
66563
  }
@@ -66499,7 +66565,6 @@ var ts;
66499
66565
  if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
66500
66566
  var constraint = getBaseConstraintOfType(source);
66501
66567
  if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
66502
- resetErrorInfo(saveErrorInfo);
66503
66568
  return result;
66504
66569
  }
66505
66570
  }
@@ -66510,14 +66575,12 @@ var ts;
66510
66575
  return 0 /* False */;
66511
66576
  }
66512
66577
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66513
- resetErrorInfo(saveErrorInfo);
66514
66578
  return result;
66515
66579
  }
66516
66580
  }
66517
66581
  else {
66518
66582
  var constraint = getBaseConstraintOfType(source);
66519
66583
  if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
66520
- resetErrorInfo(saveErrorInfo);
66521
66584
  return result;
66522
66585
  }
66523
66586
  }
@@ -66526,7 +66589,6 @@ var ts;
66526
66589
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
66527
66590
  // conditional type and bail out with a Ternary.Maybe result.
66528
66591
  if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
66529
- resetErrorInfo(saveErrorInfo);
66530
66592
  return 3 /* Maybe */;
66531
66593
  }
66532
66594
  if (targetFlags & 16777216 /* Conditional */) {
@@ -66549,7 +66611,6 @@ var ts;
66549
66611
  result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
66550
66612
  }
66551
66613
  if (result) {
66552
- resetErrorInfo(saveErrorInfo);
66553
66614
  return result;
66554
66615
  }
66555
66616
  }
@@ -66560,7 +66621,6 @@ var ts;
66560
66621
  var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
66561
66622
  if (distributiveConstraint) {
66562
66623
  if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
66563
- resetErrorInfo(saveErrorInfo);
66564
66624
  return result;
66565
66625
  }
66566
66626
  }
@@ -66570,7 +66630,6 @@ var ts;
66570
66630
  var defaultConstraint = getDefaultConstraintOfConditionalType(source);
66571
66631
  if (defaultConstraint) {
66572
66632
  if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
66573
- resetErrorInfo(saveErrorInfo);
66574
66633
  return result;
66575
66634
  }
66576
66635
  }
@@ -66583,7 +66642,6 @@ var ts;
66583
66642
  if (isGenericMappedType(target)) {
66584
66643
  if (isGenericMappedType(source)) {
66585
66644
  if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
66586
- resetErrorInfo(saveErrorInfo);
66587
66645
  return result;
66588
66646
  }
66589
66647
  }
@@ -68038,9 +68096,14 @@ var ts;
68038
68096
  type.flags & 256 /* NumberLiteral */ ? numberType :
68039
68097
  type.flags & 2048 /* BigIntLiteral */ ? bigintType :
68040
68098
  type.flags & 512 /* BooleanLiteral */ ? booleanType :
68041
- type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) :
68099
+ type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) :
68042
68100
  type;
68043
68101
  }
68102
+ function getBaseTypeOfLiteralTypeUnion(type) {
68103
+ var _a;
68104
+ var key = "B" + getTypeId(type);
68105
+ return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
68106
+ }
68044
68107
  function getWidenedLiteralType(type) {
68045
68108
  return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
68046
68109
  type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType :
@@ -69924,6 +69987,15 @@ var ts;
69924
69987
  var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
69925
69988
  return key && key + "." + propName;
69926
69989
  }
69990
+ break;
69991
+ case 201 /* ObjectBindingPattern */:
69992
+ case 202 /* ArrayBindingPattern */:
69993
+ case 256 /* FunctionDeclaration */:
69994
+ case 213 /* FunctionExpression */:
69995
+ case 214 /* ArrowFunction */:
69996
+ case 169 /* MethodDeclaration */:
69997
+ // Handle pseudo-references originating in getNarrowedTypeOfSymbol.
69998
+ return getNodeId(node) + "#" + getTypeId(declaredType);
69927
69999
  }
69928
70000
  return undefined;
69929
70001
  }
@@ -70183,23 +70255,25 @@ var ts;
70183
70255
  // For example, when a variable of type number | string | boolean is assigned a value of type number | boolean,
70184
70256
  // we remove type string.
70185
70257
  function getAssignmentReducedType(declaredType, assignedType) {
70186
- if (declaredType !== assignedType) {
70187
- if (assignedType.flags & 131072 /* Never */) {
70188
- return assignedType;
70189
- }
70190
- var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
70191
- if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) {
70192
- reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types
70193
- }
70194
- // Our crude heuristic produces an invalid result in some cases: see GH#26130.
70195
- // For now, when that happens, we give up and don't narrow at all. (This also
70196
- // means we'll never narrow for erroneous assignments where the assigned type
70197
- // is not assignable to the declared type.)
70198
- if (isTypeAssignableTo(assignedType, reducedType)) {
70199
- return reducedType;
70200
- }
70258
+ var _a;
70259
+ if (declaredType === assignedType) {
70260
+ return declaredType;
70201
70261
  }
70202
- return declaredType;
70262
+ if (assignedType.flags & 131072 /* Never */) {
70263
+ return assignedType;
70264
+ }
70265
+ var key = "A" + getTypeId(declaredType) + "," + getTypeId(assignedType);
70266
+ return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType));
70267
+ }
70268
+ function getAssignmentReducedTypeWorker(declaredType, assignedType) {
70269
+ var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
70270
+ // Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type.
70271
+ var reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
70272
+ // Our crude heuristic produces an invalid result in some cases: see GH#26130.
70273
+ // For now, when that happens, we give up and don't narrow at all. (This also
70274
+ // means we'll never narrow for erroneous assignments where the assigned type
70275
+ // is not assignable to the declared type.)
70276
+ return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
70203
70277
  }
70204
70278
  function isFunctionObjectType(type) {
70205
70279
  // We do a quick check for a "bind" property before performing the more expensive subtype
@@ -71605,7 +71679,7 @@ var ts;
71605
71679
  var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
71606
71680
  ? getTypeOfSymbol(classSymbol)
71607
71681
  : getDeclaredTypeOfSymbol(classSymbol);
71608
- return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
71682
+ return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
71609
71683
  }
71610
71684
  function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
71611
71685
  // We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
@@ -71856,9 +71930,15 @@ var ts;
71856
71930
  if (!nonConstructorTypeInUnion)
71857
71931
  return type;
71858
71932
  }
71859
- return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
71933
+ return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
71934
+ }
71935
+ function getNarrowedType(type, candidate, assumeTrue, checkDerived) {
71936
+ var _a;
71937
+ var key = type.flags & 1048576 /* Union */ ? "N" + getTypeId(type) + "," + getTypeId(candidate) + "," + ((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined;
71938
+ return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived));
71860
71939
  }
71861
- function getNarrowedType(type, candidate, assumeTrue, isRelated) {
71940
+ function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
71941
+ var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
71862
71942
  if (!assumeTrue) {
71863
71943
  return filterType(type, function (t) { return !isRelated(t, candidate); });
71864
71944
  }
@@ -71906,7 +71986,7 @@ var ts;
71906
71986
  var predicateArgument = getTypePredicateArgument(predicate, callExpression);
71907
71987
  if (predicateArgument) {
71908
71988
  if (isMatchingReference(reference, predicateArgument)) {
71909
- return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
71989
+ return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false);
71910
71990
  }
71911
71991
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
71912
71992
  !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
@@ -71914,7 +71994,7 @@ var ts;
71914
71994
  }
71915
71995
  var access = getDiscriminantPropertyAccess(predicateArgument, type);
71916
71996
  if (access) {
71917
- return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
71997
+ return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); });
71918
71998
  }
71919
71999
  }
71920
72000
  }
@@ -72091,7 +72171,7 @@ var ts;
72091
72171
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
72092
72172
  (checkMode && checkMode & 64 /* RestBindingElement */ ?
72093
72173
  getContextualType(node, 8 /* SkipBindingPatterns */)
72094
- : getContextualType(node));
72174
+ : getContextualType(node, /*contextFlags*/ undefined));
72095
72175
  return contextualType && !isGenericType(contextualType);
72096
72176
  }
72097
72177
  function getNarrowableTypeForReference(type, reference, checkMode) {
@@ -72253,9 +72333,7 @@ var ts;
72253
72333
  getNodeLinks(container).flags |= 8192 /* CaptureArguments */;
72254
72334
  return getTypeOfSymbol(symbol);
72255
72335
  }
72256
- // We should only mark aliases as referenced if there isn't a local value declaration
72257
- // for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that
72258
- if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
72336
+ if (shouldMarkIdentifierAliasReferenced(node)) {
72259
72337
  markAliasReferenced(symbol, node);
72260
72338
  }
72261
72339
  var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
@@ -72389,6 +72467,25 @@ var ts;
72389
72467
  }
72390
72468
  return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
72391
72469
  }
72470
+ function shouldMarkIdentifierAliasReferenced(node) {
72471
+ var _a;
72472
+ var parent = node.parent;
72473
+ if (parent) {
72474
+ // A property access expression LHS? checkPropertyAccessExpression will handle that.
72475
+ if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
72476
+ return false;
72477
+ }
72478
+ // Next two check for an identifier inside a type only export.
72479
+ if (ts.isExportSpecifier(parent) && parent.isTypeOnly) {
72480
+ return false;
72481
+ }
72482
+ var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent;
72483
+ if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) {
72484
+ return false;
72485
+ }
72486
+ }
72487
+ return true;
72488
+ }
72392
72489
  function isInsideFunctionOrInstancePropertyInitializer(node, threshold) {
72393
72490
  return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); });
72394
72491
  }
@@ -72938,7 +73035,7 @@ var ts;
72938
73035
  // We have an object literal method. Check if the containing object literal has a contextual type
72939
73036
  // that includes a ThisType<T>. If so, T is the contextual type for 'this'. We continue looking in
72940
73037
  // any directly enclosing object literals.
72941
- var contextualType = getApparentTypeOfContextualType(containingLiteral);
73038
+ var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined);
72942
73039
  var literal = containingLiteral;
72943
73040
  var type = contextualType;
72944
73041
  while (type) {
@@ -72950,7 +73047,7 @@ var ts;
72950
73047
  break;
72951
73048
  }
72952
73049
  literal = literal.parent.parent;
72953
- type = getApparentTypeOfContextualType(literal);
73050
+ type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined);
72954
73051
  }
72955
73052
  // There was no contextual ThisType<T> for the containing object literal, so the contextual type
72956
73053
  // for 'this' is the non-null form of the contextual type for the containing object literal or
@@ -73007,7 +73104,7 @@ var ts;
73007
73104
  tryGetTypeAtPosition(contextualSignature, index);
73008
73105
  }
73009
73106
  }
73010
- function getContextualTypeForVariableLikeDeclaration(declaration) {
73107
+ function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) {
73011
73108
  var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
73012
73109
  if (typeNode) {
73013
73110
  return getTypeFromTypeNode(typeNode);
@@ -73016,18 +73113,18 @@ var ts;
73016
73113
  case 164 /* Parameter */:
73017
73114
  return getContextuallyTypedParameterType(declaration);
73018
73115
  case 203 /* BindingElement */:
73019
- return getContextualTypeForBindingElement(declaration);
73116
+ return getContextualTypeForBindingElement(declaration, contextFlags);
73020
73117
  case 167 /* PropertyDeclaration */:
73021
73118
  if (ts.isStatic(declaration)) {
73022
- return getContextualTypeForStaticPropertyDeclaration(declaration);
73119
+ return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags);
73023
73120
  }
73024
73121
  // By default, do nothing and return undefined - only the above cases have context implied by a parent
73025
73122
  }
73026
73123
  }
73027
- function getContextualTypeForBindingElement(declaration) {
73124
+ function getContextualTypeForBindingElement(declaration, contextFlags) {
73028
73125
  var parent = declaration.parent.parent;
73029
73126
  var name = declaration.propertyName || declaration.name;
73030
- var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
73127
+ var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) ||
73031
73128
  parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
73032
73129
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
73033
73130
  return undefined;
@@ -73043,8 +73140,8 @@ var ts;
73043
73140
  return getTypeOfPropertyOfType(parentType, text);
73044
73141
  }
73045
73142
  }
73046
- function getContextualTypeForStaticPropertyDeclaration(declaration) {
73047
- var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
73143
+ function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) {
73144
+ var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags);
73048
73145
  if (!parentType)
73049
73146
  return undefined;
73050
73147
  return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
@@ -73060,7 +73157,7 @@ var ts;
73060
73157
  function getContextualTypeForInitializerExpression(node, contextFlags) {
73061
73158
  var declaration = node.parent;
73062
73159
  if (ts.hasInitializer(declaration) && node === declaration.initializer) {
73063
- var result = getContextualTypeForVariableLikeDeclaration(declaration);
73160
+ var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags);
73064
73161
  if (result) {
73065
73162
  return result;
73066
73163
  }
@@ -73070,10 +73167,10 @@ var ts;
73070
73167
  }
73071
73168
  return undefined;
73072
73169
  }
73073
- function getContextualTypeForReturnExpression(node) {
73170
+ function getContextualTypeForReturnExpression(node, contextFlags) {
73074
73171
  var func = ts.getContainingFunction(node);
73075
73172
  if (func) {
73076
- var contextualReturnType = getContextualReturnType(func);
73173
+ var contextualReturnType = getContextualReturnType(func, contextFlags);
73077
73174
  if (contextualReturnType) {
73078
73175
  var functionFlags = ts.getFunctionFlags(func);
73079
73176
  if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
@@ -73103,11 +73200,11 @@ var ts;
73103
73200
  }
73104
73201
  return undefined;
73105
73202
  }
73106
- function getContextualTypeForYieldOperand(node) {
73203
+ function getContextualTypeForYieldOperand(node, contextFlags) {
73107
73204
  var func = ts.getContainingFunction(node);
73108
73205
  if (func) {
73109
73206
  var functionFlags = ts.getFunctionFlags(func);
73110
- var contextualReturnType = getContextualReturnType(func);
73207
+ var contextualReturnType = getContextualReturnType(func, contextFlags);
73111
73208
  if (contextualReturnType) {
73112
73209
  return node.asteriskToken
73113
73210
  ? contextualReturnType
@@ -73131,14 +73228,14 @@ var ts;
73131
73228
  }
73132
73229
  function getContextualIterationType(kind, functionDecl) {
73133
73230
  var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */);
73134
- var contextualReturnType = getContextualReturnType(functionDecl);
73231
+ var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined);
73135
73232
  if (contextualReturnType) {
73136
73233
  return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
73137
73234
  || undefined;
73138
73235
  }
73139
73236
  return undefined;
73140
73237
  }
73141
- function getContextualReturnType(functionDecl) {
73238
+ function getContextualReturnType(functionDecl, contextFlags) {
73142
73239
  // If the containing function has a return type annotation, is a constructor, or is a get accessor whose
73143
73240
  // corresponding set accessor has a type annotation, return statements in the function are contextually typed
73144
73241
  var returnType = getReturnTypeFromAnnotation(functionDecl);
@@ -73153,7 +73250,7 @@ var ts;
73153
73250
  }
73154
73251
  var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl);
73155
73252
  if (iife) {
73156
- return getContextualType(iife);
73253
+ return getContextualType(iife, contextFlags);
73157
73254
  }
73158
73255
  return undefined;
73159
73256
  }
@@ -73406,7 +73503,7 @@ var ts;
73406
73503
  }
73407
73504
  function getContextualTypeForObjectLiteralElement(element, contextFlags) {
73408
73505
  var objectLiteral = element.parent;
73409
- var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
73506
+ var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags);
73410
73507
  if (propertyAssignmentType) {
73411
73508
  return propertyAssignmentType;
73412
73509
  }
@@ -73601,9 +73698,9 @@ var ts;
73601
73698
  return getContextualTypeForInitializerExpression(node, contextFlags);
73602
73699
  case 214 /* ArrowFunction */:
73603
73700
  case 247 /* ReturnStatement */:
73604
- return getContextualTypeForReturnExpression(node);
73701
+ return getContextualTypeForReturnExpression(node, contextFlags);
73605
73702
  case 224 /* YieldExpression */:
73606
- return getContextualTypeForYieldOperand(parent);
73703
+ return getContextualTypeForYieldOperand(parent, contextFlags);
73607
73704
  case 218 /* AwaitExpression */:
73608
73705
  return getContextualTypeForAwaitOperand(parent, contextFlags);
73609
73706
  case 208 /* CallExpression */:
@@ -73651,7 +73748,7 @@ var ts;
73651
73748
  }
73652
73749
  return undefined;
73653
73750
  function tryFindWhenConstTypeReference(node) {
73654
- return getContextualType(node);
73751
+ return getContextualType(node, contextFlags);
73655
73752
  }
73656
73753
  }
73657
73754
  function getInferenceContext(node) {
@@ -73953,7 +74050,7 @@ var ts;
73953
74050
  var elementCount = elements.length;
73954
74051
  var elementTypes = [];
73955
74052
  var elementFlags = [];
73956
- var contextualType = getApparentTypeOfContextualType(node);
74053
+ var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
73957
74054
  var inDestructuringPattern = ts.isAssignmentTarget(node);
73958
74055
  var inConstContext = isConstContext(node);
73959
74056
  var hasOmittedExpression = false;
@@ -74124,7 +74221,7 @@ var ts;
74124
74221
  var propertiesTable = ts.createSymbolTable();
74125
74222
  var propertiesArray = [];
74126
74223
  var spread = emptyObjectType;
74127
- var contextualType = getApparentTypeOfContextualType(node);
74224
+ var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
74128
74225
  var contextualTypeHasPattern = contextualType && contextualType.pattern &&
74129
74226
  (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */);
74130
74227
  var inConstContext = isConstContext(node);
@@ -74463,7 +74560,7 @@ var ts;
74463
74560
  if (explicitlySpecifyChildrenAttribute) {
74464
74561
  error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
74465
74562
  }
74466
- var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
74563
+ var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined);
74467
74564
  var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
74468
74565
  // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process
74469
74566
  var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
@@ -76926,7 +77023,7 @@ var ts;
76926
77023
  argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
76927
77024
  if (inferenceContext) {
76928
77025
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
76929
- checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
77026
+ checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
76930
77027
  // If the original signature has a generic rest type, instantiation may produce a
76931
77028
  // signature with different arity and we need to perform another arity check.
76932
77029
  if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
@@ -78303,17 +78400,6 @@ var ts;
78303
78400
  }
78304
78401
  }
78305
78402
  }
78306
- var restType = getEffectiveRestType(context);
78307
- if (restType && restType.flags & 262144 /* TypeParameter */) {
78308
- // The contextual signature has a generic rest parameter. We first instantiate the contextual
78309
- // signature (without fixing type parameters) and assign types to contextually typed parameters.
78310
- var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
78311
- assignContextualParameterTypes(signature, instantiatedContext);
78312
- // We then infer from a tuple type representing the parameters that correspond to the contextual
78313
- // rest parameter.
78314
- var restPos = getParameterCount(context) - 1;
78315
- inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
78316
- }
78317
78403
  }
78318
78404
  function assignContextualParameterTypes(signature, context) {
78319
78405
  if (context.typeParameters) {
@@ -78506,7 +78592,7 @@ var ts;
78506
78592
  var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
78507
78593
  var contextualType = !contextualSignature ? undefined :
78508
78594
  contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
78509
- instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
78595
+ instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined);
78510
78596
  if (isGenerator) {
78511
78597
  yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync);
78512
78598
  returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync);
@@ -78577,7 +78663,7 @@ var ts;
78577
78663
  nextType = iterationTypes && iterationTypes.nextType;
78578
78664
  }
78579
78665
  else {
78580
- nextType = getContextualType(yieldExpression);
78666
+ nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined);
78581
78667
  }
78582
78668
  if (nextType)
78583
78669
  ts.pushIfUnique(nextTypes, nextType);
@@ -78786,11 +78872,16 @@ var ts;
78786
78872
  if (isContextSensitive(node)) {
78787
78873
  if (contextualSignature) {
78788
78874
  var inferenceContext = getInferenceContext(node);
78875
+ var instantiatedContextualSignature = void 0;
78789
78876
  if (checkMode && checkMode & 2 /* Inferential */) {
78790
78877
  inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
78878
+ var restType = getEffectiveRestType(contextualSignature);
78879
+ if (restType && restType.flags & 262144 /* TypeParameter */) {
78880
+ instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
78881
+ }
78791
78882
  }
78792
- var instantiatedContextualSignature = inferenceContext ?
78793
- instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
78883
+ instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ?
78884
+ instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
78794
78885
  assignContextualParameterTypes(signature, instantiatedContextualSignature);
78795
78886
  }
78796
78887
  else {
@@ -80032,7 +80123,7 @@ var ts;
80032
80123
  type = anyType;
80033
80124
  addLazyDiagnostic(function () {
80034
80125
  if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
80035
- var contextualType = getContextualType(node);
80126
+ var contextualType = getContextualType(node, /*contextFlags*/ undefined);
80036
80127
  if (!contextualType || isTypeAny(contextualType)) {
80037
80128
  error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
80038
80129
  }
@@ -80073,7 +80164,7 @@ var ts;
80073
80164
  texts.push(span.literal.text);
80074
80165
  types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
80075
80166
  }
80076
- return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
80167
+ return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
80077
80168
  }
80078
80169
  function isTemplateLiteralContextualType(type) {
80079
80170
  return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) ||
@@ -80101,7 +80192,7 @@ var ts;
80101
80192
  // We strip literal freshness when an appropriate contextual type is present such that contextually typed
80102
80193
  // literals always preserve their literal types (otherwise they might widen during type inference). An alternative
80103
80194
  // here would be to not mark contextually typed literals as fresh in the first place.
80104
- var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
80195
+ var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ?
80105
80196
  getRegularTypeOfLiteralType(type) : type;
80106
80197
  return result;
80107
80198
  }
@@ -80216,7 +80307,7 @@ var ts;
80216
80307
  var type = checkExpression(node, checkMode, forceTuple);
80217
80308
  return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
80218
80309
  isTypeAssertion(node) ? type :
80219
- getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
80310
+ getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined));
80220
80311
  }
80221
80312
  function checkPropertyAssignment(node, checkMode) {
80222
80313
  // Do not use hasDynamicName here, because that returns false for well known symbols.
@@ -86198,7 +86289,9 @@ var ts;
86198
86289
  error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
86199
86290
  }
86200
86291
  else {
86201
- markExportAsReferenced(node);
86292
+ if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
86293
+ markExportAsReferenced(node);
86294
+ }
86202
86295
  var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
86203
86296
  if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) {
86204
86297
  checkExpressionCached(node.propertyName || node.name);
@@ -89559,9 +89652,6 @@ var ts;
89559
89652
  else {
89560
89653
  return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
89561
89654
  }
89562
- if (!isConstOrReadonly || isInvalidInitializer) {
89563
- return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
89564
- }
89565
89655
  }
89566
89656
  }
89567
89657
  function checkGrammarVariableDeclaration(node) {
@@ -111346,7 +111436,7 @@ var ts;
111346
111436
  return;
111347
111437
  }
111348
111438
  // Make sure not to write js file and source map file if any of them cannot be written
111349
- if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
111439
+ if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
111350
111440
  emitSkipped = true;
111351
111441
  return;
111352
111442
  }
@@ -124608,7 +124698,6 @@ var ts;
124608
124698
  var parsedConfigs; // Parsed commandline and watching cached for referenced projects
124609
124699
  var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
124610
124700
  var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
124611
- var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
124612
124701
  var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
124613
124702
  var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
124614
124703
  var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files
@@ -124761,12 +124850,12 @@ var ts;
124761
124850
  var program = getCurrentBuilderProgram();
124762
124851
  if (hasChangedCompilerOptions) {
124763
124852
  newLine = updateNewLine();
124764
- if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) {
124853
+ if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
124765
124854
  resolutionCache.clear();
124766
124855
  }
124767
124856
  }
124768
124857
  // All resolutions are invalid if user provided resolutions
124769
- var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
124858
+ var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
124770
124859
  if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
124771
124860
  if (hasChangedConfigFileParsingErrors) {
124772
124861
  if (reportFileChangeDetectedOnCreateProgram) {
@@ -124782,7 +124871,6 @@ var ts;
124782
124871
  }
124783
124872
  createNewProgram(hasInvalidatedResolution);
124784
124873
  }
124785
- changesAffectResolution = false; // reset for next sync
124786
124874
  reportFileChangeDetectedOnCreateProgram = false;
124787
124875
  if (host.afterProgramCreate && program !== builderProgram) {
124788
124876
  host.afterProgramCreate(builderProgram);
@@ -126163,7 +126251,7 @@ var ts;
126163
126251
  }
126164
126252
  function afterProgramDone(state, program, config) {
126165
126253
  if (program) {
126166
- if (program && state.write)
126254
+ if (state.write)
126167
126255
  ts.listFiles(program, state.write);
126168
126256
  if (state.host.afterProgramEmitAndDiagnostics) {
126169
126257
  state.host.afterProgramEmitAndDiagnostics(program);
@@ -132321,6 +132409,26 @@ var ts;
132321
132409
  (function (Completions) {
132322
132410
  var StringCompletions;
132323
132411
  (function (StringCompletions) {
132412
+ var _a;
132413
+ var kindPrecedence = (_a = {},
132414
+ _a["directory" /* directory */] = 0,
132415
+ _a["script" /* scriptElement */] = 1,
132416
+ _a["external module name" /* externalModuleName */] = 2,
132417
+ _a);
132418
+ function createNameAndKindSet() {
132419
+ var map = new ts.Map();
132420
+ function add(value) {
132421
+ var existing = map.get(value.name);
132422
+ if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) {
132423
+ map.set(value.name, value);
132424
+ }
132425
+ }
132426
+ return {
132427
+ add: add,
132428
+ has: map.has.bind(map),
132429
+ values: map.values.bind(map),
132430
+ };
132431
+ }
132324
132432
  function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
132325
132433
  if (ts.isInReferenceComment(sourceFile, position)) {
132326
132434
  var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
@@ -132602,11 +132710,12 @@ var ts;
132602
132710
  }
132603
132711
  function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) {
132604
132712
  var literalValue = ts.normalizeSlashes(node.text);
132713
+ var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
132605
132714
  var scriptPath = sourceFile.path;
132606
132715
  var scriptDirectory = ts.getDirectoryPath(scriptPath);
132607
132716
  return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue))
132608
132717
  ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
132609
- : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
132718
+ : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker);
132610
132719
  function getIncludeExtensionOption() {
132611
132720
  var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
132612
132721
  return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
@@ -132622,7 +132731,7 @@ var ts;
132622
132731
  return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath);
132623
132732
  }
132624
132733
  else {
132625
- return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
132734
+ return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values());
132626
132735
  }
132627
132736
  }
132628
132737
  function isEmitResolutionKindUsingNodeModules(compilerOptions) {
@@ -132658,7 +132767,7 @@ var ts;
132658
132767
  var basePath = compilerOptions.project || host.getCurrentDirectory();
132659
132768
  var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
132660
132769
  var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
132661
- return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); });
132770
+ return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); });
132662
132771
  }
132663
132772
  var IncludeExtensionsOption;
132664
132773
  (function (IncludeExtensionsOption) {
@@ -132669,10 +132778,9 @@ var ts;
132669
132778
  /**
132670
132779
  * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
132671
132780
  */
132672
- function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) {
132673
- var _b;
132674
- var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption;
132675
- if (result === void 0) { result = []; }
132781
+ function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) {
132782
+ var _a;
132783
+ if (result === void 0) { result = createNameAndKindSet(); }
132676
132784
  if (fragment === undefined) {
132677
132785
  fragment = "";
132678
132786
  }
@@ -132696,11 +132804,11 @@ var ts;
132696
132804
  var packageJson = ts.readJson(packageJsonPath, host);
132697
132805
  var typesVersions = packageJson.typesVersions;
132698
132806
  if (typeof typesVersions === "object") {
132699
- var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths;
132807
+ var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths;
132700
132808
  if (versionPaths) {
132701
132809
  var packageDirectory = ts.getDirectoryPath(packageJsonPath);
132702
132810
  var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length);
132703
- if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) {
132811
+ if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
132704
132812
  // A true result means one of the `versionPaths` was matched, which will block relative resolution
132705
132813
  // to files and folders from here. All reachable paths given the pattern match are already added.
132706
132814
  return result;
@@ -132712,39 +132820,17 @@ var ts;
132712
132820
  if (!ts.tryDirectoryExists(host, baseDirectory))
132713
132821
  return result;
132714
132822
  // Enumerate the available files if possible
132715
- var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
132823
+ var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
132716
132824
  if (files) {
132717
- /**
132718
- * Multiple file entries might map to the same truncated name once we remove extensions
132719
- * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg:
132720
- *
132721
- * both foo.ts and foo.tsx become foo
132722
- */
132723
- var foundFiles = new ts.Map(); // maps file to its extension
132724
132825
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
132725
132826
  var filePath = files_1[_i];
132726
132827
  filePath = ts.normalizePath(filePath);
132727
132828
  if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) {
132728
132829
  continue;
132729
132830
  }
132730
- var foundFileName = void 0;
132731
- var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings());
132732
- if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
132733
- foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath));
132734
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
132735
- }
132736
- else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
132737
- foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension);
132738
- foundFiles.set(foundFileName, outputExtension);
132739
- }
132740
- else {
132741
- foundFileName = ts.getBaseFileName(filePath);
132742
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
132743
- }
132831
+ var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension;
132832
+ result.add(nameAndKind(name, "script" /* scriptElement */, extension));
132744
132833
  }
132745
- foundFiles.forEach(function (ext, foundFile) {
132746
- result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext));
132747
- });
132748
132834
  }
132749
132835
  // If possible, get folder completion as well
132750
132836
  var directories = ts.tryGetDirectories(host, baseDirectory);
@@ -132753,27 +132839,52 @@ var ts;
132753
132839
  var directory = directories_1[_c];
132754
132840
  var directoryName = ts.getBaseFileName(ts.normalizePath(directory));
132755
132841
  if (directoryName !== "@types") {
132756
- result.push(directoryResult(directoryName));
132842
+ result.add(directoryResult(directoryName));
132757
132843
  }
132758
132844
  }
132759
132845
  }
132760
132846
  return result;
132761
132847
  }
132848
+ function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) {
132849
+ var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions);
132850
+ if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
132851
+ return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) };
132852
+ }
132853
+ else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
132854
+ return { name: ts.changeExtension(name, outputExtension), extension: outputExtension };
132855
+ }
132856
+ else {
132857
+ return { name: name, extension: ts.tryGetExtensionFromPath(name) };
132858
+ }
132859
+ }
132762
132860
  /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
132763
- function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) {
132764
- var _a;
132861
+ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) {
132862
+ var getPatternsForKey = function (key) { return paths[key]; };
132863
+ var comparePaths = function (a, b) {
132864
+ var patternA = ts.tryParsePattern(a);
132865
+ var patternB = ts.tryParsePattern(b);
132866
+ var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length;
132867
+ var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length;
132868
+ return ts.compareValues(lengthB, lengthA);
132869
+ };
132870
+ return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths);
132871
+ }
132872
+ /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
132873
+ function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) {
132765
132874
  var pathResults = [];
132766
- var matchedPathPrefixLength = -1;
132767
- for (var path in paths) {
132768
- if (!ts.hasProperty(paths, path))
132875
+ var matchedPath;
132876
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
132877
+ var key = keys_1[_i];
132878
+ if (key === ".")
132769
132879
  continue;
132770
- var patterns = paths[path];
132880
+ var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./"
132881
+ var patterns = getPatternsForKey(key);
132771
132882
  if (patterns) {
132772
- var pathPattern = ts.tryParsePattern(path);
132883
+ var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash);
132773
132884
  if (!pathPattern)
132774
132885
  continue;
132775
132886
  var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment);
132776
- var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength);
132887
+ var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* LessThan */);
132777
132888
  if (isLongestMatch) {
132778
132889
  // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
132779
132890
  // for `import {} from "some-package/|"` with a typesVersions:
@@ -132786,13 +132897,13 @@ var ts;
132786
132897
  // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
132787
132898
  // ./dist/foo and ./foo, when only the latter will actually be resolvable.
132788
132899
  // See pathCompletionsTypesVersionsWildcard6.ts.
132789
- matchedPathPrefixLength = pathPattern.prefix.length;
132900
+ matchedPath = key;
132790
132901
  pathResults = pathResults.filter(function (r) { return !r.matchedPattern; });
132791
132902
  }
132792
- if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) {
132903
+ if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* GreaterThan */) {
132793
132904
  pathResults.push({
132794
132905
  matchedPattern: isMatch,
132795
- results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host)
132906
+ results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host)
132796
132907
  .map(function (_a) {
132797
132908
  var name = _a.name, kind = _a.kind, extension = _a.extension;
132798
132909
  return nameAndKind(name, kind, extension);
@@ -132801,10 +132912,8 @@ var ts;
132801
132912
  }
132802
132913
  }
132803
132914
  }
132804
- var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
132805
- var equateResults = function (a, b) { return equatePaths(a.name, b.name); };
132806
- pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); });
132807
- return matchedPathPrefixLength > -1;
132915
+ pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); });
132916
+ return matchedPath !== undefined;
132808
132917
  }
132809
132918
  /**
132810
132919
  * Check all of the declared modules and those in node modules. Possible sources of modules:
@@ -132813,22 +132922,22 @@ var ts;
132813
132922
  * Modules from node_modules (i.e. those listed in package.json)
132814
132923
  * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions
132815
132924
  */
132816
- function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) {
132925
+ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) {
132817
132926
  var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths;
132818
- var result = [];
132819
- var extensionOptions = getExtensionOptions(compilerOptions);
132927
+ var result = createNameAndKindSet();
132928
+ var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption);
132820
132929
  if (baseUrl) {
132821
132930
  var projectDir = compilerOptions.project || host.getCurrentDirectory();
132822
132931
  var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl));
132823
132932
  getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result);
132824
132933
  if (paths) {
132825
- addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host);
132934
+ addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
132826
132935
  }
132827
132936
  }
132828
132937
  var fragmentDirectory = getFragmentDirectory(fragment);
132829
132938
  for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) {
132830
132939
  var ambientName = _a[_i];
132831
- result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
132940
+ result.add(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
132832
132941
  }
132833
132942
  getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
132834
132943
  if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
@@ -132836,15 +132945,13 @@ var ts;
132836
132945
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
132837
132946
  var foundGlobal = false;
132838
132947
  if (fragmentDirectory === undefined) {
132839
- var _loop_3 = function (moduleName) {
132840
- if (!result.some(function (entry) { return entry.name === moduleName; })) {
132841
- foundGlobal = true;
132842
- result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
132843
- }
132844
- };
132845
132948
  for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
132846
132949
  var moduleName = _c[_b];
132847
- _loop_3(moduleName);
132950
+ var moduleResult = nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined);
132951
+ if (!result.has(moduleResult.name)) {
132952
+ foundGlobal = true;
132953
+ result.add(moduleResult);
132954
+ }
132848
132955
  }
132849
132956
  }
132850
132957
  if (!foundGlobal) {
@@ -132870,39 +132977,19 @@ var ts;
132870
132977
  }
132871
132978
  packagePath = ts.combinePaths(packagePath, subName);
132872
132979
  }
132873
- var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
132980
+ var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath);
132981
+ var packageFile = ts.combinePaths(packageDirectory, "package.json");
132874
132982
  if (ts.tryFileExists(host, packageFile)) {
132875
132983
  var packageJson = ts.readJson(packageFile, host);
132876
- var exports = packageJson.exports;
132877
- if (exports) {
132878
- if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
132984
+ var exports_1 = packageJson.exports;
132985
+ if (exports_1) {
132986
+ if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null
132879
132987
  return; // null exports or entrypoint only, no sub-modules available
132880
132988
  }
132881
- var keys = ts.getOwnKeys(exports);
132882
- var fragmentSubpath_1 = components.join("/");
132883
- var processedKeys = ts.mapDefined(keys, function (k) {
132884
- if (k === ".")
132885
- return undefined;
132886
- if (!ts.startsWith(k, "./"))
132887
- return undefined;
132888
- var subpath = k.substring(2);
132889
- if (!ts.startsWith(subpath, fragmentSubpath_1))
132890
- return undefined;
132891
- // subpath is a valid export (barring conditions, which we don't currently check here)
132892
- if (!ts.stringContains(subpath, "*")) {
132893
- return subpath;
132894
- }
132895
- // pattern export - only return everything up to the `*`, so the user can autocomplete, then
132896
- // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
132897
- // but conditions will make that somewhat awkward, as each condition may have a different set of possible
132898
- // options for the `*`.
132899
- return subpath.slice(0, subpath.indexOf("*"));
132900
- });
132901
- ts.forEach(processedKeys, function (k) {
132902
- if (k) {
132903
- result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
132904
- }
132905
- });
132989
+ var keys = ts.getOwnKeys(exports_1);
132990
+ var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : "");
132991
+ var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"];
132992
+ addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys);
132906
132993
  return;
132907
132994
  }
132908
132995
  }
@@ -132912,31 +132999,44 @@ var ts;
132912
132999
  ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
132913
133000
  }
132914
133001
  }
132915
- return result;
133002
+ return ts.arrayFrom(result.values());
133003
+ }
133004
+ function getPatternFromFirstMatchingCondition(target, conditions) {
133005
+ if (typeof target === "string") {
133006
+ return target;
133007
+ }
133008
+ if (target && typeof target === "object" && !ts.isArray(target)) {
133009
+ for (var condition in target) {
133010
+ if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) {
133011
+ var pattern = target[condition];
133012
+ return getPatternFromFirstMatchingCondition(pattern, conditions);
133013
+ }
133014
+ }
133015
+ }
132916
133016
  }
132917
133017
  function getFragmentDirectory(fragment) {
132918
133018
  return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined;
132919
133019
  }
132920
- function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) {
133020
+ function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) {
132921
133021
  if (!ts.endsWith(path, "*")) {
132922
133022
  // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion.
132923
- return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray;
133023
+ return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* scriptElement */) : ts.emptyArray;
132924
133024
  }
132925
133025
  var pathPrefix = path.slice(0, path.length - 1);
132926
133026
  var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix);
132927
133027
  if (remainingFragment === undefined) {
132928
133028
  var starIsFullPathComponent = path[path.length - 2] === "/";
132929
- return starIsFullPathComponent ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", baseUrl, pattern, fileExtensions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) {
133029
+ return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* directory */) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) {
132930
133030
  var name = _a.name, rest = __rest(_a, ["name"]);
132931
133031
  return (__assign({ name: pathPrefix + name }, rest));
132932
133032
  }); });
132933
133033
  }
132934
- return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); });
132935
- function justPathMappingName(name) {
132936
- return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray;
133034
+ return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); });
133035
+ function justPathMappingName(name, kind) {
133036
+ return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray;
132937
133037
  }
132938
133038
  }
132939
- function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) {
133039
+ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) {
132940
133040
  if (!host.readDirectory) {
132941
133041
  return undefined;
132942
133042
  }
@@ -132955,21 +133055,33 @@ var ts;
132955
133055
  var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory;
132956
133056
  var normalizedSuffix = ts.normalizePath(parsed.suffix);
132957
133057
  // Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b".
132958
- var baseDirectory = ts.normalizePath(ts.combinePaths(baseUrl, expandedPrefixDirectory));
133058
+ var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory));
132959
133059
  var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase;
132960
- // If we have a suffix, then we need to read the directory all the way down. We could create a glob
132961
- // that encodes the suffix, but we would have to escape the character "?" which readDirectory
132962
- // doesn't support. For now, this is safer but slower
132963
- var includeGlob = normalizedSuffix ? "**/*" : "./*";
132964
- var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) {
132965
- var extension = ts.tryGetExtensionFromPath(match);
132966
- var name = trimPrefixAndSuffix(match);
132967
- return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension);
132968
- });
132969
- var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) {
132970
- var name = trimPrefixAndSuffix(dir);
132971
- return name === undefined ? undefined : directoryResult(name);
133060
+ // If we have a suffix, then we read the directory all the way down to avoid returning completions for
133061
+ // directories that don't contain files that would match the suffix. A previous comment here was concerned
133062
+ // about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally,
133063
+ // but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not
133064
+ // a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?`
133065
+ // interpreted as "any character" can only return *too many* results as compared to the literal
133066
+ // interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always
133067
+ // done.
133068
+ var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*";
133069
+ var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) {
133070
+ var trimmedWithPattern = trimPrefixAndSuffix(match);
133071
+ if (trimmedWithPattern) {
133072
+ if (containsSlash(trimmedWithPattern)) {
133073
+ return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
133074
+ }
133075
+ var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension;
133076
+ return nameAndKind(name, "script" /* scriptElement */, extension);
133077
+ }
132972
133078
  });
133079
+ // If we had a suffix, we already recursively searched for all possible files that could match
133080
+ // it and returned the directories leading to those files. Otherwise, assume any directory could
133081
+ // have something valid to import.
133082
+ var directories = normalizedSuffix
133083
+ ? ts.emptyArray
133084
+ : ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); });
132973
133085
  return __spreadArray(__spreadArray([], matches, true), directories, true);
132974
133086
  function trimPrefixAndSuffix(path) {
132975
133087
  var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix);
@@ -133012,10 +133124,10 @@ var ts;
133012
133124
  var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path)
133013
133125
  : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions))
133014
133126
  : ts.Debug.fail();
133015
- return addReplacementSpans(toComplete, range.pos + prefix.length, names);
133127
+ return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values()));
133016
133128
  }
133017
133129
  function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) {
133018
- if (result === void 0) { result = []; }
133130
+ if (result === void 0) { result = createNameAndKindSet(); }
133019
133131
  // Check for typings specified in compiler options
133020
133132
  var seen = new ts.Map();
133021
133133
  var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray;
@@ -133040,7 +133152,7 @@ var ts;
133040
133152
  continue;
133041
133153
  if (fragmentDirectory === undefined) {
133042
133154
  if (!seen.has(packageName)) {
133043
- result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133155
+ result.add(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133044
133156
  seen.set(packageName, true);
133045
133157
  }
133046
133158
  }
@@ -133932,7 +134044,7 @@ var ts;
133932
134044
  var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
133933
134045
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
133934
134046
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
133935
- var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
134047
+ var builderFlags = 33554432 /* OmitThisParameter */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
133936
134048
  switch (declaration.kind) {
133937
134049
  case 166 /* PropertySignature */:
133938
134050
  case 167 /* PropertyDeclaration */:
@@ -138641,7 +138753,7 @@ var ts;
138641
138753
  result = references;
138642
138754
  continue;
138643
138755
  }
138644
- var _loop_4 = function (entry) {
138756
+ var _loop_3 = function (entry) {
138645
138757
  if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
138646
138758
  result.push(entry);
138647
138759
  return "continue";
@@ -138673,7 +138785,7 @@ var ts;
138673
138785
  };
138674
138786
  for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
138675
138787
  var entry = references_2[_b];
138676
- _loop_4(entry);
138788
+ _loop_3(entry);
138677
138789
  }
138678
138790
  }
138679
138791
  return result;
@@ -140254,8 +140366,8 @@ var ts;
140254
140366
  var declarations;
140255
140367
  if (symbol && symbol.declarations) {
140256
140368
  var indices = ts.indicesOf(symbol.declarations);
140257
- var keys_1 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140258
- indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_1[a].file, keys_1[b].file) || keys_1[a].pos - keys_1[b].pos; });
140369
+ var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140370
+ indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; });
140259
140371
  var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; });
140260
140372
  var lastDecl = void 0;
140261
140373
  for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) {
@@ -140703,7 +140815,7 @@ var ts;
140703
140815
  }
140704
140816
  function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
140705
140817
  var allFiles = program.getSourceFiles();
140706
- var _loop_5 = function (sourceFile) {
140818
+ var _loop_4 = function (sourceFile) {
140707
140819
  var newFromOld = oldToNew(sourceFile.fileName);
140708
140820
  var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
140709
140821
  var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
@@ -140735,7 +140847,7 @@ var ts;
140735
140847
  };
140736
140848
  for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
140737
140849
  var sourceFile = allFiles_1[_i];
140738
- _loop_5(sourceFile);
140850
+ _loop_4(sourceFile);
140739
140851
  }
140740
140852
  }
140741
140853
  function combineNormal(pathA, pathB) {
@@ -141759,7 +141871,7 @@ var ts;
141759
141871
  if (!patternMatcher)
141760
141872
  return ts.emptyArray;
141761
141873
  var rawItems = [];
141762
- var _loop_6 = function (sourceFile) {
141874
+ var _loop_5 = function (sourceFile) {
141763
141875
  cancellationToken.throwIfCancellationRequested();
141764
141876
  if (excludeDtsFiles && sourceFile.isDeclarationFile) {
141765
141877
  return "continue";
@@ -141771,7 +141883,7 @@ var ts;
141771
141883
  // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
141772
141884
  for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
141773
141885
  var sourceFile = sourceFiles_4[_i];
141774
- _loop_6(sourceFile);
141886
+ _loop_5(sourceFile);
141775
141887
  }
141776
141888
  rawItems.sort(compareNavigateToItems);
141777
141889
  return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
@@ -143834,13 +143946,13 @@ var ts;
143834
143946
  // Assumes 'value' is already lowercase.
143835
143947
  function indexOfIgnoringCase(str, value) {
143836
143948
  var n = str.length - value.length;
143837
- var _loop_7 = function (start) {
143949
+ var _loop_6 = function (start) {
143838
143950
  if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
143839
143951
  return { value: start };
143840
143952
  }
143841
143953
  };
143842
143954
  for (var start = 0; start <= n; start++) {
143843
- var state_3 = _loop_7(start);
143955
+ var state_3 = _loop_6(start);
143844
143956
  if (typeof state_3 === "object")
143845
143957
  return state_3.value;
143846
143958
  }
@@ -145307,7 +145419,7 @@ var ts;
145307
145419
  return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
145308
145420
  }
145309
145421
  function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
145310
- var _loop_8 = function (n) {
145422
+ var _loop_7 = function (n) {
145311
145423
  // If the node is not a subspan of its parent, this is a big problem.
145312
145424
  // There have been crashes that might be caused by this violation.
145313
145425
  ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); });
@@ -145317,7 +145429,7 @@ var ts;
145317
145429
  }
145318
145430
  };
145319
145431
  for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
145320
- var state_4 = _loop_8(n);
145432
+ var state_4 = _loop_7(n);
145321
145433
  if (typeof state_4 === "object")
145322
145434
  return state_4.value;
145323
145435
  }
@@ -146930,7 +147042,7 @@ var ts;
146930
147042
  commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
146931
147043
  ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
146932
147044
  options = ts.cloneCompilerOptions(options);
146933
- var _loop_9 = function (opt) {
147045
+ var _loop_8 = function (opt) {
146934
147046
  if (!ts.hasProperty(options, opt.name)) {
146935
147047
  return "continue";
146936
147048
  }
@@ -146949,7 +147061,7 @@ var ts;
146949
147061
  };
146950
147062
  for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
146951
147063
  var opt = commandLineOptionsStringToEnum_1[_i];
146952
- _loop_9(opt);
147064
+ _loop_8(opt);
146953
147065
  }
146954
147066
  return options;
146955
147067
  }
@@ -150714,7 +150826,7 @@ var ts;
150714
150826
  ChangeTracker.prototype.finishDeleteDeclarations = function () {
150715
150827
  var _this = this;
150716
150828
  var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
150717
- var _loop_10 = function (sourceFile, node) {
150829
+ var _loop_9 = function (sourceFile, node) {
150718
150830
  if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
150719
150831
  if (ts.isArray(node)) {
150720
150832
  this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
@@ -150727,7 +150839,7 @@ var ts;
150727
150839
  var this_1 = this;
150728
150840
  for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
150729
150841
  var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
150730
- _loop_10(sourceFile, node);
150842
+ _loop_9(sourceFile, node);
150731
150843
  }
150732
150844
  deletedNodesInLists.forEach(function (node) {
150733
150845
  var sourceFile = node.getSourceFile();
@@ -150815,14 +150927,14 @@ var ts;
150815
150927
  // order changes by start position
150816
150928
  // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa.
150817
150929
  var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
150818
- var _loop_11 = function (i) {
150930
+ var _loop_10 = function (i) {
150819
150931
  ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
150820
150932
  return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
150821
150933
  });
150822
150934
  };
150823
150935
  // verify that change intervals do not overlap, except possibly at end points.
150824
150936
  for (var i = 0; i < normalized.length - 1; i++) {
150825
- _loop_11(i);
150937
+ _loop_10(i);
150826
150938
  }
150827
150939
  var textChanges = ts.mapDefined(normalized, function (c) {
150828
150940
  var span = ts.createTextSpanFromRange(c.range);
@@ -151730,7 +151842,7 @@ var ts;
151730
151842
  }
151731
151843
  var isCompleteFix = identifiers.isCompleteFix;
151732
151844
  var initializers;
151733
- var _loop_12 = function (identifier) {
151845
+ var _loop_11 = function (identifier) {
151734
151846
  var symbol = checker.getSymbolAtLocation(identifier);
151735
151847
  if (!symbol) {
151736
151848
  return "continue";
@@ -151763,7 +151875,7 @@ var ts;
151763
151875
  };
151764
151876
  for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
151765
151877
  var identifier = _a[_i];
151766
- _loop_12(identifier);
151878
+ _loop_11(identifier);
151767
151879
  }
151768
151880
  return initializers && {
151769
151881
  initializers: initializers,
@@ -152648,7 +152760,7 @@ var ts;
152648
152760
  }
152649
152761
  var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos);
152650
152762
  changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " });
152651
- var _loop_13 = function (returnStatement) {
152763
+ var _loop_12 = function (returnStatement) {
152652
152764
  ts.forEachChild(returnStatement, function visit(node) {
152653
152765
  if (ts.isCallExpression(node)) {
152654
152766
  var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
@@ -152670,7 +152782,7 @@ var ts;
152670
152782
  };
152671
152783
  for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
152672
152784
  var returnStatement = returnStatements_1[_i];
152673
- var state_5 = _loop_13(returnStatement);
152785
+ var state_5 = _loop_12(returnStatement);
152674
152786
  if (typeof state_5 === "object")
152675
152787
  return state_5.value;
152676
152788
  }
@@ -156005,7 +156117,7 @@ var ts;
156005
156117
  });
156006
156118
  typeDeclToMembers.forEach(function (infos, declaration) {
156007
156119
  var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
156008
- var _loop_14 = function (info) {
156120
+ var _loop_13 = function (info) {
156009
156121
  // If some superclass added this property, don't add it again.
156010
156122
  if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
156011
156123
  var superInfos = typeDeclToMembers.get(superClassOrInterface);
@@ -156032,7 +156144,7 @@ var ts;
156032
156144
  };
156033
156145
  for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
156034
156146
  var info = infos_1[_i];
156035
- _loop_14(info);
156147
+ _loop_13(info);
156036
156148
  }
156037
156149
  });
156038
156150
  }));
@@ -158806,7 +158918,7 @@ var ts;
158806
158918
  function getSignatureFromCalls(calls) {
158807
158919
  var parameters = [];
158808
158920
  var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
158809
- var _loop_15 = function (i) {
158921
+ var _loop_14 = function (i) {
158810
158922
  var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
158811
158923
  symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
158812
158924
  if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
@@ -158815,7 +158927,7 @@ var ts;
158815
158927
  parameters.push(symbol);
158816
158928
  };
158817
158929
  for (var i = 0; i < length; i++) {
158818
- _loop_15(i);
158930
+ _loop_14(i);
158819
158931
  }
158820
158932
  var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
158821
158933
  return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
@@ -160791,7 +160903,7 @@ var ts;
160791
160903
  // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
160792
160904
  // More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`.
160793
160905
  var neededNamedImports = new ts.Set();
160794
- var _loop_16 = function (element) {
160906
+ var _loop_15 = function (element) {
160795
160907
  var propertyName = (element.propertyName || element.name).text;
160796
160908
  ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
160797
160909
  var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
@@ -160808,7 +160920,7 @@ var ts;
160808
160920
  };
160809
160921
  for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
160810
160922
  var element = _a[_i];
160811
- _loop_16(element);
160923
+ _loop_15(element);
160812
160924
  }
160813
160925
  changes.replaceNode(sourceFile, toConvert, shouldUseDefault
160814
160926
  ? ts.factory.createIdentifier(namespaceImportName)
@@ -162699,7 +162811,7 @@ var ts;
162699
162811
  : ts.getEnclosingBlockScopeContainer(scopes[0]);
162700
162812
  ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
162701
162813
  }
162702
- var _loop_17 = function (i) {
162814
+ var _loop_16 = function (i) {
162703
162815
  var scopeUsages = usagesPerScope[i];
162704
162816
  // Special case: in the innermost scope, all usages are available.
162705
162817
  // (The computed value reflects the value at the top-level of the scope, but the
@@ -162742,7 +162854,7 @@ var ts;
162742
162854
  }
162743
162855
  };
162744
162856
  for (var i = 0; i < scopes.length; i++) {
162745
- _loop_17(i);
162857
+ _loop_16(i);
162746
162858
  }
162747
162859
  return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
162748
162860
  function isInGenericContext(node) {
@@ -163443,10 +163555,10 @@ var ts;
163443
163555
  }
163444
163556
  function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
163445
163557
  var checker = program.getTypeChecker();
163446
- var _loop_18 = function (sourceFile) {
163558
+ var _loop_17 = function (sourceFile) {
163447
163559
  if (sourceFile === oldFile)
163448
163560
  return "continue";
163449
- var _loop_19 = function (statement) {
163561
+ var _loop_18 = function (statement) {
163450
163562
  forEachImportInStatement(statement, function (importNode) {
163451
163563
  if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
163452
163564
  return;
@@ -163468,12 +163580,12 @@ var ts;
163468
163580
  };
163469
163581
  for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
163470
163582
  var statement = _c[_b];
163471
- _loop_19(statement);
163583
+ _loop_18(statement);
163472
163584
  }
163473
163585
  };
163474
163586
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
163475
163587
  var sourceFile = _a[_i];
163476
- _loop_18(sourceFile);
163588
+ _loop_17(sourceFile);
163477
163589
  }
163478
163590
  }
163479
163591
  function getNamespaceLikeImport(node) {
@@ -164836,7 +164948,7 @@ var ts;
164836
164948
  var templateSpans = [];
164837
164949
  var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
164838
164950
  copyCommentFromStringLiterals(headIndexes, templateHead);
164839
- var _loop_20 = function (i) {
164951
+ var _loop_19 = function (i) {
164840
164952
  var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
164841
164953
  copyOperatorComments(i, currentNode);
164842
164954
  var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
@@ -164865,7 +164977,7 @@ var ts;
164865
164977
  };
164866
164978
  var out_i_1;
164867
164979
  for (var i = begin; i < nodes.length; i++) {
164868
- _loop_20(i);
164980
+ _loop_19(i);
164869
164981
  i = out_i_1;
164870
164982
  }
164871
164983
  return ts.factory.createTemplateExpression(templateHead, templateSpans);
@@ -165477,20 +165589,25 @@ var ts;
165477
165589
  return this.documentationComment;
165478
165590
  };
165479
165591
  SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) {
165480
- switch (context === null || context === void 0 ? void 0 : context.kind) {
165481
- case 172 /* GetAccessor */:
165592
+ if (context) {
165593
+ if (ts.isGetAccessor(context)) {
165482
165594
  if (!this.contextualGetAccessorDocumentationComment) {
165483
165595
  this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
165484
165596
  }
165485
- return this.contextualGetAccessorDocumentationComment;
165486
- case 173 /* SetAccessor */:
165597
+ if (ts.length(this.contextualGetAccessorDocumentationComment)) {
165598
+ return this.contextualGetAccessorDocumentationComment;
165599
+ }
165600
+ }
165601
+ if (ts.isSetAccessor(context)) {
165487
165602
  if (!this.contextualSetAccessorDocumentationComment) {
165488
165603
  this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
165489
165604
  }
165490
- return this.contextualSetAccessorDocumentationComment;
165491
- default:
165492
- return this.getDocumentationComment(checker);
165605
+ if (ts.length(this.contextualSetAccessorDocumentationComment)) {
165606
+ return this.contextualSetAccessorDocumentationComment;
165607
+ }
165608
+ }
165493
165609
  }
165610
+ return this.getDocumentationComment(checker);
165494
165611
  };
165495
165612
  SymbolObject.prototype.getJsDocTags = function (checker) {
165496
165613
  if (this.tags === undefined) {
@@ -165499,20 +165616,25 @@ var ts;
165499
165616
  return this.tags;
165500
165617
  };
165501
165618
  SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
165502
- switch (context === null || context === void 0 ? void 0 : context.kind) {
165503
- case 172 /* GetAccessor */:
165619
+ if (context) {
165620
+ if (ts.isGetAccessor(context)) {
165504
165621
  if (!this.contextualGetAccessorTags) {
165505
165622
  this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
165506
165623
  }
165507
- return this.contextualGetAccessorTags;
165508
- case 173 /* SetAccessor */:
165624
+ if (ts.length(this.contextualGetAccessorTags)) {
165625
+ return this.contextualGetAccessorTags;
165626
+ }
165627
+ }
165628
+ if (ts.isSetAccessor(context)) {
165509
165629
  if (!this.contextualSetAccessorTags) {
165510
165630
  this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
165511
165631
  }
165512
- return this.contextualSetAccessorTags;
165513
- default:
165514
- return this.getJsDocTags(checker);
165632
+ if (ts.length(this.contextualSetAccessorTags)) {
165633
+ return this.contextualSetAccessorTags;
165634
+ }
165635
+ }
165515
165636
  }
165637
+ return this.getJsDocTags(checker);
165516
165638
  };
165517
165639
  return SymbolObject;
165518
165640
  }());
@@ -165701,7 +165823,7 @@ var ts;
165701
165823
  var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
165702
165824
  if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
165703
165825
  var seenSymbols_1 = new ts.Set();
165704
- var _loop_21 = function (declaration) {
165826
+ var _loop_20 = function (declaration) {
165705
165827
  var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
165706
165828
  var _a;
165707
165829
  if (!seenSymbols_1.has(symbol)) {
@@ -165718,7 +165840,7 @@ var ts;
165718
165840
  };
165719
165841
  for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165720
165842
  var declaration = declarations_7[_i];
165721
- _loop_21(declaration);
165843
+ _loop_20(declaration);
165722
165844
  }
165723
165845
  }
165724
165846
  return tags;
@@ -165729,7 +165851,7 @@ var ts;
165729
165851
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
165730
165852
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
165731
165853
  var seenSymbols_2 = new ts.Set();
165732
- var _loop_22 = function (declaration) {
165854
+ var _loop_21 = function (declaration) {
165733
165855
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
165734
165856
  if (!seenSymbols_2.has(symbol)) {
165735
165857
  seenSymbols_2.add(symbol);
@@ -165745,7 +165867,7 @@ var ts;
165745
165867
  };
165746
165868
  for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
165747
165869
  var declaration = declarations_8[_i];
165748
- _loop_22(declaration);
165870
+ _loop_21(declaration);
165749
165871
  }
165750
165872
  }
165751
165873
  return doc;
@@ -166263,7 +166385,10 @@ var ts;
166263
166385
  program = undefined; // TODO: GH#18217
166264
166386
  lastTypesRootVersion = typeRootsVersion;
166265
166387
  }
166266
- var rootFileNames = host.getScriptFileNames();
166388
+ // This array is retained by the program and will be used to determine if the program is up to date,
166389
+ // so we need to make a copy in case the host mutates the underlying array - otherwise it would look
166390
+ // like every program always has the host's current list of root files.
166391
+ var rootFileNames = host.getScriptFileNames().slice();
166267
166392
  // Get a fresh cache of the host information
166268
166393
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
166269
166394
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;