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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220705";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220708";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -2250,7 +2250,7 @@ var ts;
2250
2250
  * and 1 insertion/deletion at 3 characters)
2251
2251
  */
2252
2252
  function getSpellingSuggestion(name, candidates, getName) {
2253
- var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
2253
+ var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
2254
2254
  var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
2255
2255
  var bestCandidate;
2256
2256
  for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
@@ -2979,6 +2979,22 @@ var ts;
2979
2979
  return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true);
2980
2980
  }
2981
2981
  Debug.formatFlowFlags = formatFlowFlags;
2982
+ function formatRelationComparisonResult(result) {
2983
+ return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true);
2984
+ }
2985
+ Debug.formatRelationComparisonResult = formatRelationComparisonResult;
2986
+ function formatCheckMode(mode) {
2987
+ return formatEnum(mode, ts.CheckMode, /*isFlags*/ true);
2988
+ }
2989
+ Debug.formatCheckMode = formatCheckMode;
2990
+ function formatSignatureCheckMode(mode) {
2991
+ return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true);
2992
+ }
2993
+ Debug.formatSignatureCheckMode = formatSignatureCheckMode;
2994
+ function formatTypeFacts(facts) {
2995
+ return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true);
2996
+ }
2997
+ Debug.formatTypeFacts = formatTypeFacts;
2982
2998
  var isDebugInfoEnabled = false;
2983
2999
  var extendedDebugModule;
2984
3000
  function extendedDebug() {
@@ -4931,6 +4947,7 @@ var ts;
4931
4947
  NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
4932
4948
  NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
4933
4949
  NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
4950
+ NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
4934
4951
  // Error handling
4935
4952
  NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
4936
4953
  NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
@@ -4971,6 +4988,7 @@ var ts;
4971
4988
  TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
4972
4989
  TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
4973
4990
  TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
4991
+ TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
4974
4992
  // Error Handling
4975
4993
  TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType";
4976
4994
  // TypeFormatFlags exclusive
@@ -4982,7 +5000,7 @@ var ts;
4982
5000
  TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
4983
5001
  TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias";
4984
5002
  /** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike";
4985
- TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 814775659] = "NodeBuilderFlagsMask";
5003
+ TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask";
4986
5004
  })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
4987
5005
  var SymbolFormatFlags;
4988
5006
  (function (SymbolFormatFlags) {
@@ -9216,6 +9234,7 @@ var ts;
9216
9234
  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'."),
9217
9235
  _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?"),
9218
9236
  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."),
9237
+ 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."),
9219
9238
  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}'."),
9220
9239
  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}'."),
9221
9240
  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}'."),
@@ -19714,7 +19733,8 @@ var ts;
19714
19733
  function getDeclarationModifierFlagsFromSymbol(s, isWrite) {
19715
19734
  if (isWrite === void 0) { isWrite = false; }
19716
19735
  if (s.valueDeclaration) {
19717
- var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration;
19736
+ var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration))
19737
+ || (s.flags & 32768 /* GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration;
19718
19738
  var flags = ts.getCombinedModifierFlags(declaration);
19719
19739
  return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
19720
19740
  }
@@ -20389,7 +20409,7 @@ var ts;
20389
20409
  // Excludes declaration files - they still require an explicit `export {}` or the like
20390
20410
  // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20391
20411
  // that aren't esm-mode (meaning not in a `type: module` scope).
20392
- return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20412
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */]))) && !file.isDeclarationFile ? true : undefined;
20393
20413
  }
20394
20414
  function getSetExternalModuleIndicator(options) {
20395
20415
  // TODO: Should this callback be cached?
@@ -20412,10 +20432,7 @@ var ts;
20412
20432
  if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
20413
20433
  checks.push(isFileModuleFromUsingJSXTag);
20414
20434
  }
20415
- var moduleKind = getEmitModuleKind(options);
20416
- if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
20417
- checks.push(isFileForcedToBeModuleByFormat);
20418
- }
20435
+ checks.push(isFileForcedToBeModuleByFormat);
20419
20436
  var combined_1 = ts.or.apply(void 0, checks);
20420
20437
  var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
20421
20438
  return callback;
@@ -34135,10 +34152,10 @@ var ts;
34135
34152
  var hasJSDoc = hasPrecedingJSDocComment();
34136
34153
  var modifiers = parseModifiers();
34137
34154
  if (parseContextualModifier(136 /* GetKeyword */)) {
34138
- return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */);
34155
+ return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */, 4 /* Type */);
34139
34156
  }
34140
34157
  if (parseContextualModifier(149 /* SetKeyword */)) {
34141
- return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */);
34158
+ return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */, 4 /* Type */);
34142
34159
  }
34143
34160
  if (isIndexSignature()) {
34144
34161
  return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers);
@@ -36184,10 +36201,10 @@ var ts;
36184
36201
  var decorators = parseDecorators();
36185
36202
  var modifiers = parseModifiers();
36186
36203
  if (parseContextualModifier(136 /* GetKeyword */)) {
36187
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
36204
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
36188
36205
  }
36189
36206
  if (parseContextualModifier(149 /* SetKeyword */)) {
36190
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
36207
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
36191
36208
  }
36192
36209
  var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
36193
36210
  var tokenIsIdentifier = isIdentifier();
@@ -36879,9 +36896,15 @@ var ts;
36879
36896
  return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */);
36880
36897
  }
36881
36898
  function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
36882
- if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) {
36883
- parseSemicolon();
36884
- return;
36899
+ if (token() !== 18 /* OpenBraceToken */) {
36900
+ if (flags & 4 /* Type */) {
36901
+ parseTypeMemberSemicolon();
36902
+ return;
36903
+ }
36904
+ if (canParseSemicolon()) {
36905
+ parseSemicolon();
36906
+ return;
36907
+ }
36885
36908
  }
36886
36909
  return parseFunctionBlock(flags, diagnosticMessage);
36887
36910
  }
@@ -37085,12 +37108,12 @@ var ts;
37085
37108
  }
37086
37109
  return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
37087
37110
  }
37088
- function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
37111
+ function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) {
37089
37112
  var name = parsePropertyName();
37090
37113
  var typeParameters = parseTypeParameters();
37091
37114
  var parameters = parseParameters(0 /* None */);
37092
37115
  var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
37093
- var body = parseFunctionBlockOrSemicolon(0 /* None */);
37116
+ var body = parseFunctionBlockOrSemicolon(flags);
37094
37117
  var node = kind === 172 /* GetAccessor */
37095
37118
  ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
37096
37119
  : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
@@ -37277,10 +37300,10 @@ var ts;
37277
37300
  return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
37278
37301
  }
37279
37302
  if (parseContextualModifier(136 /* GetKeyword */)) {
37280
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
37303
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
37281
37304
  }
37282
37305
  if (parseContextualModifier(149 /* SetKeyword */)) {
37283
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
37306
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
37284
37307
  }
37285
37308
  if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) {
37286
37309
  var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
@@ -44591,6 +44614,7 @@ var ts;
44591
44614
  return toSearchResult(/*value*/ undefined);
44592
44615
  }
44593
44616
  /**
44617
+ * @internal
44594
44618
  * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44595
44619
  * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44596
44620
  */
@@ -44613,6 +44637,7 @@ var ts;
44613
44637
  return 1;
44614
44638
  return 0;
44615
44639
  }
44640
+ ts.comparePatternKeys = comparePatternKeys;
44616
44641
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44617
44642
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44618
44643
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
@@ -48684,7 +48709,7 @@ var ts;
48684
48709
  // Masks
48685
48710
  TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
48686
48711
  TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
48687
- })(TypeFacts || (TypeFacts = {}));
48712
+ })(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {}));
48688
48713
  var typeofNEFacts = new ts.Map(ts.getEntries({
48689
48714
  string: 256 /* TypeofNEString */,
48690
48715
  number: 512 /* TypeofNENumber */,
@@ -48719,7 +48744,7 @@ var ts;
48719
48744
  CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
48720
48745
  // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
48721
48746
  // we need to preserve generic types instead of substituting them for constraints
48722
- })(CheckMode || (CheckMode = {}));
48747
+ })(CheckMode = ts.CheckMode || (ts.CheckMode = {}));
48723
48748
  var SignatureCheckMode;
48724
48749
  (function (SignatureCheckMode) {
48725
48750
  SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback";
@@ -48727,7 +48752,7 @@ var ts;
48727
48752
  SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes";
48728
48753
  SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity";
48729
48754
  SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback";
48730
- })(SignatureCheckMode || (SignatureCheckMode = {}));
48755
+ })(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {}));
48731
48756
  var IntersectionState;
48732
48757
  (function (IntersectionState) {
48733
48758
  IntersectionState[IntersectionState["None"] = 0] = "None";
@@ -49079,7 +49104,7 @@ var ts;
49079
49104
  },
49080
49105
  getContextualTypeForObjectLiteralElement: function (nodeIn) {
49081
49106
  var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
49082
- return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
49107
+ return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined;
49083
49108
  },
49084
49109
  getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
49085
49110
  var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
@@ -49087,7 +49112,7 @@ var ts;
49087
49112
  },
49088
49113
  getContextualTypeForJsxAttribute: function (nodeIn) {
49089
49114
  var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
49090
- return node && getContextualTypeForJsxAttribute(node);
49115
+ return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined);
49091
49116
  },
49092
49117
  isContextSensitive: isContextSensitive,
49093
49118
  getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
@@ -49293,6 +49318,7 @@ var ts;
49293
49318
  var stringMappingTypes = new ts.Map();
49294
49319
  var substitutionTypes = new ts.Map();
49295
49320
  var subtypeReductionCache = new ts.Map();
49321
+ var cachedTypes = new ts.Map();
49296
49322
  var evolvingArrayTypes = [];
49297
49323
  var undefinedProperties = new ts.Map();
49298
49324
  var markerTypes = new ts.Set();
@@ -49546,6 +49572,14 @@ var ts;
49546
49572
  ];
49547
49573
  initializeTypeChecker();
49548
49574
  return checker;
49575
+ function getCachedType(key) {
49576
+ return key ? cachedTypes.get(key) : undefined;
49577
+ }
49578
+ function setCachedType(key, type) {
49579
+ if (key)
49580
+ cachedTypes.set(key, type);
49581
+ return type;
49582
+ }
49549
49583
  function getJsxNamespace(location) {
49550
49584
  if (location) {
49551
49585
  var file = ts.getSourceFileOfNode(location);
@@ -50410,6 +50444,7 @@ var ts;
50410
50444
  if (ctor && ctor.locals) {
50411
50445
  if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
50412
50446
  // Remember the property node, it will be used later to report appropriate error
50447
+ ts.Debug.assertNode(location, ts.isPropertyDeclaration);
50413
50448
  propertyWithInvalidInitializer = location;
50414
50449
  }
50415
50450
  }
@@ -50599,11 +50634,27 @@ var ts;
50599
50634
  }
50600
50635
  }
50601
50636
  }
50637
+ // The invalid initializer error is needed in two situation:
50638
+ // 1. When result is undefined, after checking for a missing "this."
50639
+ // 2. When result is defined
50640
+ function checkAndReportErrorForInvalidInitializer() {
50641
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50642
+ // We have a match, but the reference occurred within a property initializer and the identifier also binds
50643
+ // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50644
+ // with ESNext+useDefineForClassFields because the scope semantics are different.
50645
+ error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
50646
+ ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
50647
+ : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
50648
+ return true;
50649
+ }
50650
+ return false;
50651
+ }
50602
50652
  if (!result) {
50603
50653
  if (nameNotFoundMessage) {
50604
50654
  addLazyDiagnostic(function () {
50605
50655
  if (!errorLocation ||
50606
50656
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
50657
+ !checkAndReportErrorForInvalidInitializer() &&
50607
50658
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50608
50659
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50609
50660
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
@@ -50611,7 +50662,16 @@ var ts;
50611
50662
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50612
50663
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50613
50664
  var suggestion = void 0;
50614
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50665
+ var suggestedLib = void 0;
50666
+ // Report missing lib first
50667
+ if (nameArg) {
50668
+ suggestedLib = getSuggestedLibForNonExistentName(nameArg);
50669
+ if (suggestedLib) {
50670
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
50671
+ }
50672
+ }
50673
+ // then spelling suggestions
50674
+ if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50615
50675
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
50616
50676
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
50617
50677
  if (isGlobalScopeAugmentationDeclaration) {
@@ -50630,16 +50690,9 @@ var ts;
50630
50690
  }
50631
50691
  }
50632
50692
  }
50633
- if (!suggestion) {
50634
- if (nameArg) {
50635
- var lib = getSuggestedLibForNonExistentName(nameArg);
50636
- if (lib) {
50637
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
50638
- }
50639
- else {
50640
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50641
- }
50642
- }
50693
+ // And then fall back to unspecified "not found"
50694
+ if (!suggestion && !suggestedLib && nameArg) {
50695
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50643
50696
  }
50644
50697
  suggestionCount++;
50645
50698
  }
@@ -50647,12 +50700,7 @@ var ts;
50647
50700
  }
50648
50701
  return undefined;
50649
50702
  }
50650
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50651
- // We have a match, but the reference occurred within a property initializer and the identifier also binds
50652
- // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50653
- // with ESNext+useDefineForClassFields because the scope semantics are different.
50654
- var propertyName = propertyWithInvalidInitializer.name;
50655
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
50703
+ else if (checkAndReportErrorForInvalidInitializer()) {
50656
50704
  return undefined;
50657
50705
  }
50658
50706
  // Perform extra checks only if error reporting was requested
@@ -52801,13 +52849,25 @@ var ts;
52801
52849
  && isDeclarationVisible(declaration.parent)) {
52802
52850
  return addVisibleAlias(declaration, declaration);
52803
52851
  }
52804
- 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
52805
- && ts.isVariableDeclaration(declaration.parent.parent)
52806
- && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
52807
- && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */)
52808
- && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
52809
- && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
52810
- return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
52852
+ else if (ts.isBindingElement(declaration)) {
52853
+ 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
52854
+ && ts.isVariableDeclaration(declaration.parent.parent)
52855
+ && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
52856
+ && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */)
52857
+ && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
52858
+ && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
52859
+ return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
52860
+ }
52861
+ else if (symbol.flags & 2 /* BlockScopedVariable */) {
52862
+ var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement);
52863
+ if (ts.hasSyntacticModifier(variableStatement, 1 /* Export */)) {
52864
+ return true;
52865
+ }
52866
+ if (!isDeclarationVisible(variableStatement.parent)) {
52867
+ return false;
52868
+ }
52869
+ return addVisibleAlias(declaration, variableStatement);
52870
+ }
52811
52871
  }
52812
52872
  // Declaration is not visible
52813
52873
  return false;
@@ -52940,7 +53000,7 @@ var ts;
52940
53000
  }
52941
53001
  function toNodeBuilderFlags(flags) {
52942
53002
  if (flags === void 0) { flags = 0 /* None */; }
52943
- return flags & 814775659 /* NodeBuilderFlagsMask */;
53003
+ return flags & 848330091 /* NodeBuilderFlagsMask */;
52944
53004
  }
52945
53005
  function isClassInstanceSide(type) {
52946
53006
  return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */)));
@@ -53328,6 +53388,10 @@ var ts;
53328
53388
  }
53329
53389
  return typeToTypeNodeHelper(type, context);
53330
53390
  }
53391
+ function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) {
53392
+ return isMappedTypeWithKeyofConstraintDeclaration(type)
53393
+ && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */);
53394
+ }
53331
53395
  function createMappedTypeNodeFromType(type) {
53332
53396
  ts.Debug.assert(!!(type.flags & 524288 /* Object */));
53333
53397
  var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
@@ -53337,7 +53401,7 @@ var ts;
53337
53401
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
53338
53402
  // We have a { [P in keyof T]: X }
53339
53403
  // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
53340
- if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53404
+ if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53341
53405
  var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
53342
53406
  var name = typeParameterToName(newParam, context);
53343
53407
  newTypeVariable = ts.factory.createTypeReferenceNode(name);
@@ -53353,11 +53417,12 @@ var ts;
53353
53417
  var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
53354
53418
  context.approximateLength += 10;
53355
53419
  var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
53356
- if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53420
+ if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53357
53421
  // homomorphic mapped type with a non-homomorphic naive inlining
53358
53422
  // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
53359
53423
  // type stays homomorphic
53360
- 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 */));
53424
+ var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper);
53425
+ 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 */));
53361
53426
  }
53362
53427
  return result;
53363
53428
  }
@@ -53919,7 +53984,7 @@ var ts;
53919
53984
  var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
53920
53985
  // If the expanded parameter list had a variadic in a non-trailing position, don't expand it
53921
53986
  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); });
53922
- var thisParameter = tryGetThisParameterDeclaration(signature, context);
53987
+ var thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context);
53923
53988
  if (thisParameter) {
53924
53989
  parameters.unshift(thisParameter);
53925
53990
  }
@@ -54978,12 +55043,11 @@ var ts;
54978
55043
  if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
54979
55044
  var oldContext = context;
54980
55045
  context = cloneNodeBuilderContext(context);
54981
- var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
55046
+ serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
54982
55047
  if (context.reportedDiagnostic) {
54983
55048
  oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context
54984
55049
  }
54985
55050
  context = oldContext;
54986
- return result;
54987
55051
  }
54988
55052
  }
54989
55053
  // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias
@@ -58040,7 +58104,7 @@ var ts;
58040
58104
  error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
58041
58105
  }
58042
58106
  else {
58043
- error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
58107
+ error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
58044
58108
  }
58045
58109
  }
58046
58110
  links.declaredType = type;
@@ -62503,19 +62567,22 @@ var ts;
62503
62567
  * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
62504
62568
  */
62505
62569
  function isPossiblyReducibleByInstantiation(type) {
62506
- return ts.some(type.types, function (t) {
62507
- var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
62508
- return getReducedType(uniqueFilled) !== uniqueFilled;
62509
- });
62570
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(type);
62571
+ return getReducedType(uniqueFilled) !== uniqueFilled;
62572
+ }
62573
+ function shouldDeferIndexType(type) {
62574
+ return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ ||
62575
+ isGenericTupleType(type) ||
62576
+ isGenericMappedType(type) && !hasDistributiveNameType(type) ||
62577
+ type.flags & 1048576 /* Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) ||
62578
+ type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType));
62510
62579
  }
62511
62580
  function getIndexType(type, stringsOnly, noIndexSignatures) {
62512
62581
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
62513
62582
  type = getReducedType(type);
62514
- return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
62515
- ? getIndexTypeForGenericType(type, stringsOnly)
62516
- : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62517
- type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62518
- type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62583
+ return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62584
+ type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62585
+ type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62519
62586
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
62520
62587
  type === wildcardType ? wildcardType :
62521
62588
  type.flags & 2 /* Unknown */ ? neverType :
@@ -66308,13 +66375,20 @@ var ts;
66308
66375
  return result;
66309
66376
  }
66310
66377
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
66378
+ var saveErrorInfo = captureErrorCalculationState();
66379
+ var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
66380
+ if (result) {
66381
+ resetErrorInfo(saveErrorInfo);
66382
+ }
66383
+ return result;
66384
+ }
66385
+ function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
66311
66386
  if (intersectionState & 4 /* PropertyCheck */) {
66312
66387
  return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
66313
66388
  }
66314
66389
  var result;
66315
66390
  var originalErrorInfo;
66316
66391
  var varianceCheckFailed = false;
66317
- var saveErrorInfo = captureErrorCalculationState();
66318
66392
  var sourceFlags = source.flags;
66319
66393
  var targetFlags = target.flags;
66320
66394
  if (relation === identityRelation) {
@@ -66378,7 +66452,6 @@ var ts;
66378
66452
  if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
66379
66453
  // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
66380
66454
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
66381
- resetErrorInfo(saveErrorInfo);
66382
66455
  return result;
66383
66456
  }
66384
66457
  }
@@ -66503,7 +66576,6 @@ var ts;
66503
66576
  result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
66504
66577
  }
66505
66578
  if (result) {
66506
- resetErrorInfo(saveErrorInfo);
66507
66579
  return result;
66508
66580
  }
66509
66581
  if (reportErrors) {
@@ -66606,7 +66678,6 @@ var ts;
66606
66678
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
66607
66679
  // conditional type and bail out with a Ternary.Maybe result.
66608
66680
  if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
66609
- resetErrorInfo(saveErrorInfo);
66610
66681
  return 3 /* Maybe */;
66611
66682
  }
66612
66683
  var c = target;
@@ -66621,7 +66692,6 @@ var ts;
66621
66692
  if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
66622
66693
  result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
66623
66694
  if (result) {
66624
- resetErrorInfo(saveErrorInfo);
66625
66695
  return result;
66626
66696
  }
66627
66697
  }
@@ -66653,12 +66723,10 @@ var ts;
66653
66723
  var constraint = getConstraintOfType(source) || unknownType;
66654
66724
  // 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
66655
66725
  if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
66656
- resetErrorInfo(saveErrorInfo);
66657
66726
  return result;
66658
66727
  }
66659
66728
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
66660
66729
  else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
66661
- resetErrorInfo(saveErrorInfo);
66662
66730
  return result;
66663
66731
  }
66664
66732
  if (isMappedTypeGenericIndexedAccess(source)) {
@@ -66667,7 +66735,6 @@ var ts;
66667
66735
  var indexConstraint = getConstraintOfType(source.indexType);
66668
66736
  if (indexConstraint) {
66669
66737
  if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
66670
- resetErrorInfo(saveErrorInfo);
66671
66738
  return result;
66672
66739
  }
66673
66740
  }
@@ -66676,7 +66743,6 @@ var ts;
66676
66743
  }
66677
66744
  else if (sourceFlags & 4194304 /* Index */) {
66678
66745
  if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
66679
- resetErrorInfo(saveErrorInfo);
66680
66746
  return result;
66681
66747
  }
66682
66748
  }
@@ -66684,7 +66750,6 @@ var ts;
66684
66750
  if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
66685
66751
  var constraint = getBaseConstraintOfType(source);
66686
66752
  if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
66687
- resetErrorInfo(saveErrorInfo);
66688
66753
  return result;
66689
66754
  }
66690
66755
  }
@@ -66695,14 +66760,12 @@ var ts;
66695
66760
  return 0 /* False */;
66696
66761
  }
66697
66762
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66698
- resetErrorInfo(saveErrorInfo);
66699
66763
  return result;
66700
66764
  }
66701
66765
  }
66702
66766
  else {
66703
66767
  var constraint = getBaseConstraintOfType(source);
66704
66768
  if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
66705
- resetErrorInfo(saveErrorInfo);
66706
66769
  return result;
66707
66770
  }
66708
66771
  }
@@ -66711,7 +66774,6 @@ var ts;
66711
66774
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
66712
66775
  // conditional type and bail out with a Ternary.Maybe result.
66713
66776
  if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
66714
- resetErrorInfo(saveErrorInfo);
66715
66777
  return 3 /* Maybe */;
66716
66778
  }
66717
66779
  if (targetFlags & 16777216 /* Conditional */) {
@@ -66734,7 +66796,6 @@ var ts;
66734
66796
  result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
66735
66797
  }
66736
66798
  if (result) {
66737
- resetErrorInfo(saveErrorInfo);
66738
66799
  return result;
66739
66800
  }
66740
66801
  }
@@ -66745,7 +66806,6 @@ var ts;
66745
66806
  var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
66746
66807
  if (distributiveConstraint) {
66747
66808
  if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
66748
- resetErrorInfo(saveErrorInfo);
66749
66809
  return result;
66750
66810
  }
66751
66811
  }
@@ -66755,7 +66815,6 @@ var ts;
66755
66815
  var defaultConstraint = getDefaultConstraintOfConditionalType(source);
66756
66816
  if (defaultConstraint) {
66757
66817
  if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
66758
- resetErrorInfo(saveErrorInfo);
66759
66818
  return result;
66760
66819
  }
66761
66820
  }
@@ -66768,7 +66827,6 @@ var ts;
66768
66827
  if (isGenericMappedType(target)) {
66769
66828
  if (isGenericMappedType(source)) {
66770
66829
  if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
66771
- resetErrorInfo(saveErrorInfo);
66772
66830
  return result;
66773
66831
  }
66774
66832
  }
@@ -68223,9 +68281,14 @@ var ts;
68223
68281
  type.flags & 256 /* NumberLiteral */ ? numberType :
68224
68282
  type.flags & 2048 /* BigIntLiteral */ ? bigintType :
68225
68283
  type.flags & 512 /* BooleanLiteral */ ? booleanType :
68226
- type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) :
68284
+ type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) :
68227
68285
  type;
68228
68286
  }
68287
+ function getBaseTypeOfLiteralTypeUnion(type) {
68288
+ var _a;
68289
+ var key = "B" + getTypeId(type);
68290
+ return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
68291
+ }
68229
68292
  function getWidenedLiteralType(type) {
68230
68293
  return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
68231
68294
  type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType :
@@ -70109,6 +70172,15 @@ var ts;
70109
70172
  var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
70110
70173
  return key && key + "." + propName;
70111
70174
  }
70175
+ break;
70176
+ case 201 /* ObjectBindingPattern */:
70177
+ case 202 /* ArrayBindingPattern */:
70178
+ case 256 /* FunctionDeclaration */:
70179
+ case 213 /* FunctionExpression */:
70180
+ case 214 /* ArrowFunction */:
70181
+ case 169 /* MethodDeclaration */:
70182
+ // Handle pseudo-references originating in getNarrowedTypeOfSymbol.
70183
+ return getNodeId(node) + "#" + getTypeId(declaredType);
70112
70184
  }
70113
70185
  return undefined;
70114
70186
  }
@@ -70368,23 +70440,25 @@ var ts;
70368
70440
  // For example, when a variable of type number | string | boolean is assigned a value of type number | boolean,
70369
70441
  // we remove type string.
70370
70442
  function getAssignmentReducedType(declaredType, assignedType) {
70371
- if (declaredType !== assignedType) {
70372
- if (assignedType.flags & 131072 /* Never */) {
70373
- return assignedType;
70374
- }
70375
- var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
70376
- if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) {
70377
- reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types
70378
- }
70379
- // Our crude heuristic produces an invalid result in some cases: see GH#26130.
70380
- // For now, when that happens, we give up and don't narrow at all. (This also
70381
- // means we'll never narrow for erroneous assignments where the assigned type
70382
- // is not assignable to the declared type.)
70383
- if (isTypeAssignableTo(assignedType, reducedType)) {
70384
- return reducedType;
70385
- }
70443
+ var _a;
70444
+ if (declaredType === assignedType) {
70445
+ return declaredType;
70386
70446
  }
70387
- return declaredType;
70447
+ if (assignedType.flags & 131072 /* Never */) {
70448
+ return assignedType;
70449
+ }
70450
+ var key = "A" + getTypeId(declaredType) + "," + getTypeId(assignedType);
70451
+ return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType));
70452
+ }
70453
+ function getAssignmentReducedTypeWorker(declaredType, assignedType) {
70454
+ var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
70455
+ // Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type.
70456
+ var reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
70457
+ // Our crude heuristic produces an invalid result in some cases: see GH#26130.
70458
+ // For now, when that happens, we give up and don't narrow at all. (This also
70459
+ // means we'll never narrow for erroneous assignments where the assigned type
70460
+ // is not assignable to the declared type.)
70461
+ return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
70388
70462
  }
70389
70463
  function isFunctionObjectType(type) {
70390
70464
  // We do a quick check for a "bind" property before performing the more expensive subtype
@@ -71790,7 +71864,7 @@ var ts;
71790
71864
  var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
71791
71865
  ? getTypeOfSymbol(classSymbol)
71792
71866
  : getDeclaredTypeOfSymbol(classSymbol);
71793
- return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
71867
+ return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
71794
71868
  }
71795
71869
  function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
71796
71870
  // We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
@@ -72041,9 +72115,15 @@ var ts;
72041
72115
  if (!nonConstructorTypeInUnion)
72042
72116
  return type;
72043
72117
  }
72044
- return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
72118
+ return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
72045
72119
  }
72046
- function getNarrowedType(type, candidate, assumeTrue, isRelated) {
72120
+ function getNarrowedType(type, candidate, assumeTrue, checkDerived) {
72121
+ var _a;
72122
+ var key = type.flags & 1048576 /* Union */ ? "N" + getTypeId(type) + "," + getTypeId(candidate) + "," + ((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined;
72123
+ return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived));
72124
+ }
72125
+ function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
72126
+ var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
72047
72127
  if (!assumeTrue) {
72048
72128
  return filterType(type, function (t) { return !isRelated(t, candidate); });
72049
72129
  }
@@ -72091,7 +72171,7 @@ var ts;
72091
72171
  var predicateArgument = getTypePredicateArgument(predicate, callExpression);
72092
72172
  if (predicateArgument) {
72093
72173
  if (isMatchingReference(reference, predicateArgument)) {
72094
- return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
72174
+ return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false);
72095
72175
  }
72096
72176
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
72097
72177
  !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
@@ -72099,7 +72179,7 @@ var ts;
72099
72179
  }
72100
72180
  var access = getDiscriminantPropertyAccess(predicateArgument, type);
72101
72181
  if (access) {
72102
- return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
72182
+ return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); });
72103
72183
  }
72104
72184
  }
72105
72185
  }
@@ -72276,7 +72356,7 @@ var ts;
72276
72356
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
72277
72357
  (checkMode && checkMode & 64 /* RestBindingElement */ ?
72278
72358
  getContextualType(node, 8 /* SkipBindingPatterns */)
72279
- : getContextualType(node));
72359
+ : getContextualType(node, /*contextFlags*/ undefined));
72280
72360
  return contextualType && !isGenericType(contextualType);
72281
72361
  }
72282
72362
  function getNarrowableTypeForReference(type, reference, checkMode) {
@@ -72438,9 +72518,7 @@ var ts;
72438
72518
  getNodeLinks(container).flags |= 8192 /* CaptureArguments */;
72439
72519
  return getTypeOfSymbol(symbol);
72440
72520
  }
72441
- // We should only mark aliases as referenced if there isn't a local value declaration
72442
- // for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that
72443
- if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
72521
+ if (shouldMarkIdentifierAliasReferenced(node)) {
72444
72522
  markAliasReferenced(symbol, node);
72445
72523
  }
72446
72524
  var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
@@ -72574,6 +72652,25 @@ var ts;
72574
72652
  }
72575
72653
  return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
72576
72654
  }
72655
+ function shouldMarkIdentifierAliasReferenced(node) {
72656
+ var _a;
72657
+ var parent = node.parent;
72658
+ if (parent) {
72659
+ // A property access expression LHS? checkPropertyAccessExpression will handle that.
72660
+ if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
72661
+ return false;
72662
+ }
72663
+ // Next two check for an identifier inside a type only export.
72664
+ if (ts.isExportSpecifier(parent) && parent.isTypeOnly) {
72665
+ return false;
72666
+ }
72667
+ var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent;
72668
+ if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) {
72669
+ return false;
72670
+ }
72671
+ }
72672
+ return true;
72673
+ }
72577
72674
  function isInsideFunctionOrInstancePropertyInitializer(node, threshold) {
72578
72675
  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); });
72579
72676
  }
@@ -73123,7 +73220,7 @@ var ts;
73123
73220
  // We have an object literal method. Check if the containing object literal has a contextual type
73124
73221
  // that includes a ThisType<T>. If so, T is the contextual type for 'this'. We continue looking in
73125
73222
  // any directly enclosing object literals.
73126
- var contextualType = getApparentTypeOfContextualType(containingLiteral);
73223
+ var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined);
73127
73224
  var literal = containingLiteral;
73128
73225
  var type = contextualType;
73129
73226
  while (type) {
@@ -73135,7 +73232,7 @@ var ts;
73135
73232
  break;
73136
73233
  }
73137
73234
  literal = literal.parent.parent;
73138
- type = getApparentTypeOfContextualType(literal);
73235
+ type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined);
73139
73236
  }
73140
73237
  // There was no contextual ThisType<T> for the containing object literal, so the contextual type
73141
73238
  // for 'this' is the non-null form of the contextual type for the containing object literal or
@@ -73192,7 +73289,7 @@ var ts;
73192
73289
  tryGetTypeAtPosition(contextualSignature, index);
73193
73290
  }
73194
73291
  }
73195
- function getContextualTypeForVariableLikeDeclaration(declaration) {
73292
+ function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) {
73196
73293
  var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
73197
73294
  if (typeNode) {
73198
73295
  return getTypeFromTypeNode(typeNode);
@@ -73201,18 +73298,18 @@ var ts;
73201
73298
  case 164 /* Parameter */:
73202
73299
  return getContextuallyTypedParameterType(declaration);
73203
73300
  case 203 /* BindingElement */:
73204
- return getContextualTypeForBindingElement(declaration);
73301
+ return getContextualTypeForBindingElement(declaration, contextFlags);
73205
73302
  case 167 /* PropertyDeclaration */:
73206
73303
  if (ts.isStatic(declaration)) {
73207
- return getContextualTypeForStaticPropertyDeclaration(declaration);
73304
+ return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags);
73208
73305
  }
73209
73306
  // By default, do nothing and return undefined - only the above cases have context implied by a parent
73210
73307
  }
73211
73308
  }
73212
- function getContextualTypeForBindingElement(declaration) {
73309
+ function getContextualTypeForBindingElement(declaration, contextFlags) {
73213
73310
  var parent = declaration.parent.parent;
73214
73311
  var name = declaration.propertyName || declaration.name;
73215
- var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
73312
+ var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) ||
73216
73313
  parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
73217
73314
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
73218
73315
  return undefined;
@@ -73228,8 +73325,8 @@ var ts;
73228
73325
  return getTypeOfPropertyOfType(parentType, text);
73229
73326
  }
73230
73327
  }
73231
- function getContextualTypeForStaticPropertyDeclaration(declaration) {
73232
- var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
73328
+ function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) {
73329
+ var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags);
73233
73330
  if (!parentType)
73234
73331
  return undefined;
73235
73332
  return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
@@ -73245,7 +73342,7 @@ var ts;
73245
73342
  function getContextualTypeForInitializerExpression(node, contextFlags) {
73246
73343
  var declaration = node.parent;
73247
73344
  if (ts.hasInitializer(declaration) && node === declaration.initializer) {
73248
- var result = getContextualTypeForVariableLikeDeclaration(declaration);
73345
+ var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags);
73249
73346
  if (result) {
73250
73347
  return result;
73251
73348
  }
@@ -73255,10 +73352,10 @@ var ts;
73255
73352
  }
73256
73353
  return undefined;
73257
73354
  }
73258
- function getContextualTypeForReturnExpression(node) {
73355
+ function getContextualTypeForReturnExpression(node, contextFlags) {
73259
73356
  var func = ts.getContainingFunction(node);
73260
73357
  if (func) {
73261
- var contextualReturnType = getContextualReturnType(func);
73358
+ var contextualReturnType = getContextualReturnType(func, contextFlags);
73262
73359
  if (contextualReturnType) {
73263
73360
  var functionFlags = ts.getFunctionFlags(func);
73264
73361
  if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
@@ -73288,11 +73385,11 @@ var ts;
73288
73385
  }
73289
73386
  return undefined;
73290
73387
  }
73291
- function getContextualTypeForYieldOperand(node) {
73388
+ function getContextualTypeForYieldOperand(node, contextFlags) {
73292
73389
  var func = ts.getContainingFunction(node);
73293
73390
  if (func) {
73294
73391
  var functionFlags = ts.getFunctionFlags(func);
73295
- var contextualReturnType = getContextualReturnType(func);
73392
+ var contextualReturnType = getContextualReturnType(func, contextFlags);
73296
73393
  if (contextualReturnType) {
73297
73394
  return node.asteriskToken
73298
73395
  ? contextualReturnType
@@ -73316,14 +73413,14 @@ var ts;
73316
73413
  }
73317
73414
  function getContextualIterationType(kind, functionDecl) {
73318
73415
  var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */);
73319
- var contextualReturnType = getContextualReturnType(functionDecl);
73416
+ var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined);
73320
73417
  if (contextualReturnType) {
73321
73418
  return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
73322
73419
  || undefined;
73323
73420
  }
73324
73421
  return undefined;
73325
73422
  }
73326
- function getContextualReturnType(functionDecl) {
73423
+ function getContextualReturnType(functionDecl, contextFlags) {
73327
73424
  // If the containing function has a return type annotation, is a constructor, or is a get accessor whose
73328
73425
  // corresponding set accessor has a type annotation, return statements in the function are contextually typed
73329
73426
  var returnType = getReturnTypeFromAnnotation(functionDecl);
@@ -73338,7 +73435,7 @@ var ts;
73338
73435
  }
73339
73436
  var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl);
73340
73437
  if (iife) {
73341
- return getContextualType(iife);
73438
+ return getContextualType(iife, contextFlags);
73342
73439
  }
73343
73440
  return undefined;
73344
73441
  }
@@ -73591,7 +73688,7 @@ var ts;
73591
73688
  }
73592
73689
  function getContextualTypeForObjectLiteralElement(element, contextFlags) {
73593
73690
  var objectLiteral = element.parent;
73594
- var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
73691
+ var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags);
73595
73692
  if (propertyAssignmentType) {
73596
73693
  return propertyAssignmentType;
73597
73694
  }
@@ -73786,9 +73883,9 @@ var ts;
73786
73883
  return getContextualTypeForInitializerExpression(node, contextFlags);
73787
73884
  case 214 /* ArrowFunction */:
73788
73885
  case 247 /* ReturnStatement */:
73789
- return getContextualTypeForReturnExpression(node);
73886
+ return getContextualTypeForReturnExpression(node, contextFlags);
73790
73887
  case 224 /* YieldExpression */:
73791
- return getContextualTypeForYieldOperand(parent);
73888
+ return getContextualTypeForYieldOperand(parent, contextFlags);
73792
73889
  case 218 /* AwaitExpression */:
73793
73890
  return getContextualTypeForAwaitOperand(parent, contextFlags);
73794
73891
  case 208 /* CallExpression */:
@@ -73836,7 +73933,7 @@ var ts;
73836
73933
  }
73837
73934
  return undefined;
73838
73935
  function tryFindWhenConstTypeReference(node) {
73839
- return getContextualType(node);
73936
+ return getContextualType(node, contextFlags);
73840
73937
  }
73841
73938
  }
73842
73939
  function getInferenceContext(node) {
@@ -74138,7 +74235,7 @@ var ts;
74138
74235
  var elementCount = elements.length;
74139
74236
  var elementTypes = [];
74140
74237
  var elementFlags = [];
74141
- var contextualType = getApparentTypeOfContextualType(node);
74238
+ var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
74142
74239
  var inDestructuringPattern = ts.isAssignmentTarget(node);
74143
74240
  var inConstContext = isConstContext(node);
74144
74241
  var hasOmittedExpression = false;
@@ -74309,7 +74406,7 @@ var ts;
74309
74406
  var propertiesTable = ts.createSymbolTable();
74310
74407
  var propertiesArray = [];
74311
74408
  var spread = emptyObjectType;
74312
- var contextualType = getApparentTypeOfContextualType(node);
74409
+ var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
74313
74410
  var contextualTypeHasPattern = contextualType && contextualType.pattern &&
74314
74411
  (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */);
74315
74412
  var inConstContext = isConstContext(node);
@@ -74648,7 +74745,7 @@ var ts;
74648
74745
  if (explicitlySpecifyChildrenAttribute) {
74649
74746
  error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
74650
74747
  }
74651
- var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
74748
+ var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined);
74652
74749
  var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
74653
74750
  // 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
74654
74751
  var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
@@ -77111,7 +77208,7 @@ var ts;
77111
77208
  argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
77112
77209
  if (inferenceContext) {
77113
77210
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
77114
- checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
77211
+ checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
77115
77212
  // If the original signature has a generic rest type, instantiation may produce a
77116
77213
  // signature with different arity and we need to perform another arity check.
77117
77214
  if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
@@ -78488,17 +78585,6 @@ var ts;
78488
78585
  }
78489
78586
  }
78490
78587
  }
78491
- var restType = getEffectiveRestType(context);
78492
- if (restType && restType.flags & 262144 /* TypeParameter */) {
78493
- // The contextual signature has a generic rest parameter. We first instantiate the contextual
78494
- // signature (without fixing type parameters) and assign types to contextually typed parameters.
78495
- var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
78496
- assignContextualParameterTypes(signature, instantiatedContext);
78497
- // We then infer from a tuple type representing the parameters that correspond to the contextual
78498
- // rest parameter.
78499
- var restPos = getParameterCount(context) - 1;
78500
- inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
78501
- }
78502
78588
  }
78503
78589
  function assignContextualParameterTypes(signature, context) {
78504
78590
  if (context.typeParameters) {
@@ -78691,7 +78777,7 @@ var ts;
78691
78777
  var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
78692
78778
  var contextualType = !contextualSignature ? undefined :
78693
78779
  contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
78694
- instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
78780
+ instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined);
78695
78781
  if (isGenerator) {
78696
78782
  yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync);
78697
78783
  returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync);
@@ -78762,7 +78848,7 @@ var ts;
78762
78848
  nextType = iterationTypes && iterationTypes.nextType;
78763
78849
  }
78764
78850
  else {
78765
- nextType = getContextualType(yieldExpression);
78851
+ nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined);
78766
78852
  }
78767
78853
  if (nextType)
78768
78854
  ts.pushIfUnique(nextTypes, nextType);
@@ -78971,11 +79057,16 @@ var ts;
78971
79057
  if (isContextSensitive(node)) {
78972
79058
  if (contextualSignature) {
78973
79059
  var inferenceContext = getInferenceContext(node);
79060
+ var instantiatedContextualSignature = void 0;
78974
79061
  if (checkMode && checkMode & 2 /* Inferential */) {
78975
79062
  inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
79063
+ var restType = getEffectiveRestType(contextualSignature);
79064
+ if (restType && restType.flags & 262144 /* TypeParameter */) {
79065
+ instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
79066
+ }
78976
79067
  }
78977
- var instantiatedContextualSignature = inferenceContext ?
78978
- instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
79068
+ instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ?
79069
+ instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
78979
79070
  assignContextualParameterTypes(signature, instantiatedContextualSignature);
78980
79071
  }
78981
79072
  else {
@@ -80217,7 +80308,7 @@ var ts;
80217
80308
  type = anyType;
80218
80309
  addLazyDiagnostic(function () {
80219
80310
  if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
80220
- var contextualType = getContextualType(node);
80311
+ var contextualType = getContextualType(node, /*contextFlags*/ undefined);
80221
80312
  if (!contextualType || isTypeAny(contextualType)) {
80222
80313
  error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
80223
80314
  }
@@ -80258,7 +80349,7 @@ var ts;
80258
80349
  texts.push(span.literal.text);
80259
80350
  types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
80260
80351
  }
80261
- return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
80352
+ return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
80262
80353
  }
80263
80354
  function isTemplateLiteralContextualType(type) {
80264
80355
  return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) ||
@@ -80286,7 +80377,7 @@ var ts;
80286
80377
  // We strip literal freshness when an appropriate contextual type is present such that contextually typed
80287
80378
  // literals always preserve their literal types (otherwise they might widen during type inference). An alternative
80288
80379
  // here would be to not mark contextually typed literals as fresh in the first place.
80289
- var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
80380
+ var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ?
80290
80381
  getRegularTypeOfLiteralType(type) : type;
80291
80382
  return result;
80292
80383
  }
@@ -80401,7 +80492,7 @@ var ts;
80401
80492
  var type = checkExpression(node, checkMode, forceTuple);
80402
80493
  return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
80403
80494
  isTypeAssertion(node) ? type :
80404
- getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
80495
+ getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined));
80405
80496
  }
80406
80497
  function checkPropertyAssignment(node, checkMode) {
80407
80498
  // Do not use hasDynamicName here, because that returns false for well known symbols.
@@ -86383,7 +86474,9 @@ var ts;
86383
86474
  error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
86384
86475
  }
86385
86476
  else {
86386
- markExportAsReferenced(node);
86477
+ if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
86478
+ markExportAsReferenced(node);
86479
+ }
86387
86480
  var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
86388
86481
  if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) {
86389
86482
  checkExpressionCached(node.propertyName || node.name);
@@ -89744,9 +89837,6 @@ var ts;
89744
89837
  else {
89745
89838
  return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
89746
89839
  }
89747
- if (!isConstOrReadonly || isInvalidInitializer) {
89748
- return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
89749
- }
89750
89840
  }
89751
89841
  }
89752
89842
  function checkGrammarVariableDeclaration(node) {
@@ -111531,7 +111621,7 @@ var ts;
111531
111621
  return;
111532
111622
  }
111533
111623
  // Make sure not to write js file and source map file if any of them cannot be written
111534
- if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
111624
+ if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
111535
111625
  emitSkipped = true;
111536
111626
  return;
111537
111627
  }
@@ -124793,7 +124883,6 @@ var ts;
124793
124883
  var parsedConfigs; // Parsed commandline and watching cached for referenced projects
124794
124884
  var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
124795
124885
  var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
124796
- var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
124797
124886
  var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
124798
124887
  var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
124799
124888
  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
@@ -124946,12 +125035,12 @@ var ts;
124946
125035
  var program = getCurrentBuilderProgram();
124947
125036
  if (hasChangedCompilerOptions) {
124948
125037
  newLine = updateNewLine();
124949
- if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) {
125038
+ if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
124950
125039
  resolutionCache.clear();
124951
125040
  }
124952
125041
  }
124953
125042
  // All resolutions are invalid if user provided resolutions
124954
- var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
125043
+ var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
124955
125044
  if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
124956
125045
  if (hasChangedConfigFileParsingErrors) {
124957
125046
  if (reportFileChangeDetectedOnCreateProgram) {
@@ -124967,7 +125056,6 @@ var ts;
124967
125056
  }
124968
125057
  createNewProgram(hasInvalidatedResolution);
124969
125058
  }
124970
- changesAffectResolution = false; // reset for next sync
124971
125059
  reportFileChangeDetectedOnCreateProgram = false;
124972
125060
  if (host.afterProgramCreate && program !== builderProgram) {
124973
125061
  host.afterProgramCreate(builderProgram);
@@ -126348,7 +126436,7 @@ var ts;
126348
126436
  }
126349
126437
  function afterProgramDone(state, program, config) {
126350
126438
  if (program) {
126351
- if (program && state.write)
126439
+ if (state.write)
126352
126440
  ts.listFiles(program, state.write);
126353
126441
  if (state.host.afterProgramEmitAndDiagnostics) {
126354
126442
  state.host.afterProgramEmitAndDiagnostics(program);
@@ -132925,6 +133013,26 @@ var ts;
132925
133013
  (function (Completions) {
132926
133014
  var StringCompletions;
132927
133015
  (function (StringCompletions) {
133016
+ var _a;
133017
+ var kindPrecedence = (_a = {},
133018
+ _a["directory" /* directory */] = 0,
133019
+ _a["script" /* scriptElement */] = 1,
133020
+ _a["external module name" /* externalModuleName */] = 2,
133021
+ _a);
133022
+ function createNameAndKindSet() {
133023
+ var map = new ts.Map();
133024
+ function add(value) {
133025
+ var existing = map.get(value.name);
133026
+ if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) {
133027
+ map.set(value.name, value);
133028
+ }
133029
+ }
133030
+ return {
133031
+ add: add,
133032
+ has: map.has.bind(map),
133033
+ values: map.values.bind(map),
133034
+ };
133035
+ }
132928
133036
  function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
132929
133037
  if (ts.isInReferenceComment(sourceFile, position)) {
132930
133038
  var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
@@ -133206,11 +133314,12 @@ var ts;
133206
133314
  }
133207
133315
  function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) {
133208
133316
  var literalValue = ts.normalizeSlashes(node.text);
133317
+ var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
133209
133318
  var scriptPath = sourceFile.path;
133210
133319
  var scriptDirectory = ts.getDirectoryPath(scriptPath);
133211
133320
  return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue))
133212
133321
  ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
133213
- : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
133322
+ : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker);
133214
133323
  function getIncludeExtensionOption() {
133215
133324
  var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
133216
133325
  return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
@@ -133226,7 +133335,7 @@ var ts;
133226
133335
  return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath);
133227
133336
  }
133228
133337
  else {
133229
- return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
133338
+ return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values());
133230
133339
  }
133231
133340
  }
133232
133341
  function isEmitResolutionKindUsingNodeModules(compilerOptions) {
@@ -133262,7 +133371,7 @@ var ts;
133262
133371
  var basePath = compilerOptions.project || host.getCurrentDirectory();
133263
133372
  var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
133264
133373
  var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
133265
- return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); });
133374
+ return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); });
133266
133375
  }
133267
133376
  var IncludeExtensionsOption;
133268
133377
  (function (IncludeExtensionsOption) {
@@ -133273,10 +133382,9 @@ var ts;
133273
133382
  /**
133274
133383
  * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
133275
133384
  */
133276
- function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) {
133277
- var _b;
133278
- var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption;
133279
- if (result === void 0) { result = []; }
133385
+ function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) {
133386
+ var _a;
133387
+ if (result === void 0) { result = createNameAndKindSet(); }
133280
133388
  if (fragment === undefined) {
133281
133389
  fragment = "";
133282
133390
  }
@@ -133300,11 +133408,11 @@ var ts;
133300
133408
  var packageJson = ts.readJson(packageJsonPath, host);
133301
133409
  var typesVersions = packageJson.typesVersions;
133302
133410
  if (typeof typesVersions === "object") {
133303
- var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths;
133411
+ var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths;
133304
133412
  if (versionPaths) {
133305
133413
  var packageDirectory = ts.getDirectoryPath(packageJsonPath);
133306
133414
  var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length);
133307
- if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) {
133415
+ if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
133308
133416
  // A true result means one of the `versionPaths` was matched, which will block relative resolution
133309
133417
  // to files and folders from here. All reachable paths given the pattern match are already added.
133310
133418
  return result;
@@ -133316,39 +133424,17 @@ var ts;
133316
133424
  if (!ts.tryDirectoryExists(host, baseDirectory))
133317
133425
  return result;
133318
133426
  // Enumerate the available files if possible
133319
- var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
133427
+ var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
133320
133428
  if (files) {
133321
- /**
133322
- * Multiple file entries might map to the same truncated name once we remove extensions
133323
- * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg:
133324
- *
133325
- * both foo.ts and foo.tsx become foo
133326
- */
133327
- var foundFiles = new ts.Map(); // maps file to its extension
133328
133429
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
133329
133430
  var filePath = files_1[_i];
133330
133431
  filePath = ts.normalizePath(filePath);
133331
133432
  if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) {
133332
133433
  continue;
133333
133434
  }
133334
- var foundFileName = void 0;
133335
- var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings());
133336
- if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
133337
- foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath));
133338
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
133339
- }
133340
- else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
133341
- foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension);
133342
- foundFiles.set(foundFileName, outputExtension);
133343
- }
133344
- else {
133345
- foundFileName = ts.getBaseFileName(filePath);
133346
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
133347
- }
133435
+ var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension;
133436
+ result.add(nameAndKind(name, "script" /* scriptElement */, extension));
133348
133437
  }
133349
- foundFiles.forEach(function (ext, foundFile) {
133350
- result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext));
133351
- });
133352
133438
  }
133353
133439
  // If possible, get folder completion as well
133354
133440
  var directories = ts.tryGetDirectories(host, baseDirectory);
@@ -133357,27 +133443,52 @@ var ts;
133357
133443
  var directory = directories_1[_c];
133358
133444
  var directoryName = ts.getBaseFileName(ts.normalizePath(directory));
133359
133445
  if (directoryName !== "@types") {
133360
- result.push(directoryResult(directoryName));
133446
+ result.add(directoryResult(directoryName));
133361
133447
  }
133362
133448
  }
133363
133449
  }
133364
133450
  return result;
133365
133451
  }
133452
+ function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) {
133453
+ var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions);
133454
+ if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
133455
+ return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) };
133456
+ }
133457
+ else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
133458
+ return { name: ts.changeExtension(name, outputExtension), extension: outputExtension };
133459
+ }
133460
+ else {
133461
+ return { name: name, extension: ts.tryGetExtensionFromPath(name) };
133462
+ }
133463
+ }
133366
133464
  /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
133367
- function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) {
133368
- var _a;
133465
+ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) {
133466
+ var getPatternsForKey = function (key) { return paths[key]; };
133467
+ var comparePaths = function (a, b) {
133468
+ var patternA = ts.tryParsePattern(a);
133469
+ var patternB = ts.tryParsePattern(b);
133470
+ var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length;
133471
+ var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length;
133472
+ return ts.compareValues(lengthB, lengthA);
133473
+ };
133474
+ return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths);
133475
+ }
133476
+ /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
133477
+ function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) {
133369
133478
  var pathResults = [];
133370
- var matchedPathPrefixLength = -1;
133371
- for (var path in paths) {
133372
- if (!ts.hasProperty(paths, path))
133479
+ var matchedPath;
133480
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
133481
+ var key = keys_1[_i];
133482
+ if (key === ".")
133373
133483
  continue;
133374
- var patterns = paths[path];
133484
+ var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./"
133485
+ var patterns = getPatternsForKey(key);
133375
133486
  if (patterns) {
133376
- var pathPattern = ts.tryParsePattern(path);
133487
+ var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash);
133377
133488
  if (!pathPattern)
133378
133489
  continue;
133379
133490
  var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment);
133380
- var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength);
133491
+ var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* LessThan */);
133381
133492
  if (isLongestMatch) {
133382
133493
  // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
133383
133494
  // for `import {} from "some-package/|"` with a typesVersions:
@@ -133390,13 +133501,13 @@ var ts;
133390
133501
  // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
133391
133502
  // ./dist/foo and ./foo, when only the latter will actually be resolvable.
133392
133503
  // See pathCompletionsTypesVersionsWildcard6.ts.
133393
- matchedPathPrefixLength = pathPattern.prefix.length;
133504
+ matchedPath = key;
133394
133505
  pathResults = pathResults.filter(function (r) { return !r.matchedPattern; });
133395
133506
  }
133396
- if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) {
133507
+ if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* GreaterThan */) {
133397
133508
  pathResults.push({
133398
133509
  matchedPattern: isMatch,
133399
- results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host)
133510
+ results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host)
133400
133511
  .map(function (_a) {
133401
133512
  var name = _a.name, kind = _a.kind, extension = _a.extension;
133402
133513
  return nameAndKind(name, kind, extension);
@@ -133405,10 +133516,8 @@ var ts;
133405
133516
  }
133406
133517
  }
133407
133518
  }
133408
- var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
133409
- var equateResults = function (a, b) { return equatePaths(a.name, b.name); };
133410
- pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); });
133411
- return matchedPathPrefixLength > -1;
133519
+ pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); });
133520
+ return matchedPath !== undefined;
133412
133521
  }
133413
133522
  /**
133414
133523
  * Check all of the declared modules and those in node modules. Possible sources of modules:
@@ -133417,22 +133526,22 @@ var ts;
133417
133526
  * Modules from node_modules (i.e. those listed in package.json)
133418
133527
  * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions
133419
133528
  */
133420
- function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) {
133529
+ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) {
133421
133530
  var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths;
133422
- var result = [];
133423
- var extensionOptions = getExtensionOptions(compilerOptions);
133531
+ var result = createNameAndKindSet();
133532
+ var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption);
133424
133533
  if (baseUrl) {
133425
133534
  var projectDir = compilerOptions.project || host.getCurrentDirectory();
133426
133535
  var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl));
133427
133536
  getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result);
133428
133537
  if (paths) {
133429
- addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host);
133538
+ addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
133430
133539
  }
133431
133540
  }
133432
133541
  var fragmentDirectory = getFragmentDirectory(fragment);
133433
133542
  for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) {
133434
133543
  var ambientName = _a[_i];
133435
- result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133544
+ result.add(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133436
133545
  }
133437
133546
  getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
133438
133547
  if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
@@ -133440,15 +133549,13 @@ var ts;
133440
133549
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
133441
133550
  var foundGlobal = false;
133442
133551
  if (fragmentDirectory === undefined) {
133443
- var _loop_3 = function (moduleName) {
133444
- if (!result.some(function (entry) { return entry.name === moduleName; })) {
133445
- foundGlobal = true;
133446
- result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133447
- }
133448
- };
133449
133552
  for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
133450
133553
  var moduleName = _c[_b];
133451
- _loop_3(moduleName);
133554
+ var moduleResult = nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined);
133555
+ if (!result.has(moduleResult.name)) {
133556
+ foundGlobal = true;
133557
+ result.add(moduleResult);
133558
+ }
133452
133559
  }
133453
133560
  }
133454
133561
  if (!foundGlobal) {
@@ -133474,39 +133581,19 @@ var ts;
133474
133581
  }
133475
133582
  packagePath = ts.combinePaths(packagePath, subName);
133476
133583
  }
133477
- var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
133584
+ var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath);
133585
+ var packageFile = ts.combinePaths(packageDirectory, "package.json");
133478
133586
  if (ts.tryFileExists(host, packageFile)) {
133479
133587
  var packageJson = ts.readJson(packageFile, host);
133480
- var exports = packageJson.exports;
133481
- if (exports) {
133482
- if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
133588
+ var exports_1 = packageJson.exports;
133589
+ if (exports_1) {
133590
+ if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null
133483
133591
  return; // null exports or entrypoint only, no sub-modules available
133484
133592
  }
133485
- var keys = ts.getOwnKeys(exports);
133486
- var fragmentSubpath_1 = components.join("/");
133487
- var processedKeys = ts.mapDefined(keys, function (k) {
133488
- if (k === ".")
133489
- return undefined;
133490
- if (!ts.startsWith(k, "./"))
133491
- return undefined;
133492
- var subpath = k.substring(2);
133493
- if (!ts.startsWith(subpath, fragmentSubpath_1))
133494
- return undefined;
133495
- // subpath is a valid export (barring conditions, which we don't currently check here)
133496
- if (!ts.stringContains(subpath, "*")) {
133497
- return subpath;
133498
- }
133499
- // pattern export - only return everything up to the `*`, so the user can autocomplete, then
133500
- // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
133501
- // but conditions will make that somewhat awkward, as each condition may have a different set of possible
133502
- // options for the `*`.
133503
- return subpath.slice(0, subpath.indexOf("*"));
133504
- });
133505
- ts.forEach(processedKeys, function (k) {
133506
- if (k) {
133507
- result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
133508
- }
133509
- });
133593
+ var keys = ts.getOwnKeys(exports_1);
133594
+ var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : "");
133595
+ var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"];
133596
+ addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys);
133510
133597
  return;
133511
133598
  }
133512
133599
  }
@@ -133516,31 +133603,44 @@ var ts;
133516
133603
  ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
133517
133604
  }
133518
133605
  }
133519
- return result;
133606
+ return ts.arrayFrom(result.values());
133607
+ }
133608
+ function getPatternFromFirstMatchingCondition(target, conditions) {
133609
+ if (typeof target === "string") {
133610
+ return target;
133611
+ }
133612
+ if (target && typeof target === "object" && !ts.isArray(target)) {
133613
+ for (var condition in target) {
133614
+ if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) {
133615
+ var pattern = target[condition];
133616
+ return getPatternFromFirstMatchingCondition(pattern, conditions);
133617
+ }
133618
+ }
133619
+ }
133520
133620
  }
133521
133621
  function getFragmentDirectory(fragment) {
133522
133622
  return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined;
133523
133623
  }
133524
- function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) {
133624
+ function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) {
133525
133625
  if (!ts.endsWith(path, "*")) {
133526
133626
  // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion.
133527
- return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray;
133627
+ return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* scriptElement */) : ts.emptyArray;
133528
133628
  }
133529
133629
  var pathPrefix = path.slice(0, path.length - 1);
133530
133630
  var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix);
133531
133631
  if (remainingFragment === undefined) {
133532
133632
  var starIsFullPathComponent = path[path.length - 2] === "/";
133533
- 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) {
133633
+ 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) {
133534
133634
  var name = _a.name, rest = __rest(_a, ["name"]);
133535
133635
  return (__assign({ name: pathPrefix + name }, rest));
133536
133636
  }); });
133537
133637
  }
133538
- return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); });
133539
- function justPathMappingName(name) {
133540
- return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray;
133638
+ return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); });
133639
+ function justPathMappingName(name, kind) {
133640
+ return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray;
133541
133641
  }
133542
133642
  }
133543
- function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) {
133643
+ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) {
133544
133644
  if (!host.readDirectory) {
133545
133645
  return undefined;
133546
133646
  }
@@ -133559,21 +133659,33 @@ var ts;
133559
133659
  var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory;
133560
133660
  var normalizedSuffix = ts.normalizePath(parsed.suffix);
133561
133661
  // Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b".
133562
- var baseDirectory = ts.normalizePath(ts.combinePaths(baseUrl, expandedPrefixDirectory));
133662
+ var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory));
133563
133663
  var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase;
133564
- // If we have a suffix, then we need to read the directory all the way down. We could create a glob
133565
- // that encodes the suffix, but we would have to escape the character "?" which readDirectory
133566
- // doesn't support. For now, this is safer but slower
133567
- var includeGlob = normalizedSuffix ? "**/*" : "./*";
133568
- var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) {
133569
- var extension = ts.tryGetExtensionFromPath(match);
133570
- var name = trimPrefixAndSuffix(match);
133571
- return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension);
133572
- });
133573
- var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) {
133574
- var name = trimPrefixAndSuffix(dir);
133575
- return name === undefined ? undefined : directoryResult(name);
133664
+ // If we have a suffix, then we read the directory all the way down to avoid returning completions for
133665
+ // directories that don't contain files that would match the suffix. A previous comment here was concerned
133666
+ // about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally,
133667
+ // but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not
133668
+ // a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?`
133669
+ // interpreted as "any character" can only return *too many* results as compared to the literal
133670
+ // interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always
133671
+ // done.
133672
+ var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*";
133673
+ var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) {
133674
+ var trimmedWithPattern = trimPrefixAndSuffix(match);
133675
+ if (trimmedWithPattern) {
133676
+ if (containsSlash(trimmedWithPattern)) {
133677
+ return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
133678
+ }
133679
+ var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension;
133680
+ return nameAndKind(name, "script" /* scriptElement */, extension);
133681
+ }
133576
133682
  });
133683
+ // If we had a suffix, we already recursively searched for all possible files that could match
133684
+ // it and returned the directories leading to those files. Otherwise, assume any directory could
133685
+ // have something valid to import.
133686
+ var directories = normalizedSuffix
133687
+ ? ts.emptyArray
133688
+ : ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); });
133577
133689
  return __spreadArray(__spreadArray([], matches, true), directories, true);
133578
133690
  function trimPrefixAndSuffix(path) {
133579
133691
  var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix);
@@ -133616,10 +133728,10 @@ var ts;
133616
133728
  var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path)
133617
133729
  : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions))
133618
133730
  : ts.Debug.fail();
133619
- return addReplacementSpans(toComplete, range.pos + prefix.length, names);
133731
+ return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values()));
133620
133732
  }
133621
133733
  function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) {
133622
- if (result === void 0) { result = []; }
133734
+ if (result === void 0) { result = createNameAndKindSet(); }
133623
133735
  // Check for typings specified in compiler options
133624
133736
  var seen = new ts.Map();
133625
133737
  var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray;
@@ -133644,7 +133756,7 @@ var ts;
133644
133756
  continue;
133645
133757
  if (fragmentDirectory === undefined) {
133646
133758
  if (!seen.has(packageName)) {
133647
- result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133759
+ result.add(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133648
133760
  seen.set(packageName, true);
133649
133761
  }
133650
133762
  }
@@ -134536,7 +134648,7 @@ var ts;
134536
134648
  var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
134537
134649
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
134538
134650
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
134539
- var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
134651
+ var builderFlags = 33554432 /* OmitThisParameter */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
134540
134652
  switch (declaration.kind) {
134541
134653
  case 166 /* PropertySignature */:
134542
134654
  case 167 /* PropertyDeclaration */:
@@ -139245,7 +139357,7 @@ var ts;
139245
139357
  result = references;
139246
139358
  continue;
139247
139359
  }
139248
- var _loop_4 = function (entry) {
139360
+ var _loop_3 = function (entry) {
139249
139361
  if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
139250
139362
  result.push(entry);
139251
139363
  return "continue";
@@ -139277,7 +139389,7 @@ var ts;
139277
139389
  };
139278
139390
  for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
139279
139391
  var entry = references_2[_b];
139280
- _loop_4(entry);
139392
+ _loop_3(entry);
139281
139393
  }
139282
139394
  }
139283
139395
  return result;
@@ -140858,8 +140970,8 @@ var ts;
140858
140970
  var declarations;
140859
140971
  if (symbol && symbol.declarations) {
140860
140972
  var indices = ts.indicesOf(symbol.declarations);
140861
- var keys_1 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140862
- indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_1[a].file, keys_1[b].file) || keys_1[a].pos - keys_1[b].pos; });
140973
+ var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140974
+ indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; });
140863
140975
  var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; });
140864
140976
  var lastDecl = void 0;
140865
140977
  for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) {
@@ -141307,7 +141419,7 @@ var ts;
141307
141419
  }
141308
141420
  function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
141309
141421
  var allFiles = program.getSourceFiles();
141310
- var _loop_5 = function (sourceFile) {
141422
+ var _loop_4 = function (sourceFile) {
141311
141423
  var newFromOld = oldToNew(sourceFile.fileName);
141312
141424
  var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
141313
141425
  var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
@@ -141339,7 +141451,7 @@ var ts;
141339
141451
  };
141340
141452
  for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
141341
141453
  var sourceFile = allFiles_1[_i];
141342
- _loop_5(sourceFile);
141454
+ _loop_4(sourceFile);
141343
141455
  }
141344
141456
  }
141345
141457
  function combineNormal(pathA, pathB) {
@@ -142363,7 +142475,7 @@ var ts;
142363
142475
  if (!patternMatcher)
142364
142476
  return ts.emptyArray;
142365
142477
  var rawItems = [];
142366
- var _loop_6 = function (sourceFile) {
142478
+ var _loop_5 = function (sourceFile) {
142367
142479
  cancellationToken.throwIfCancellationRequested();
142368
142480
  if (excludeDtsFiles && sourceFile.isDeclarationFile) {
142369
142481
  return "continue";
@@ -142375,7 +142487,7 @@ var ts;
142375
142487
  // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
142376
142488
  for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
142377
142489
  var sourceFile = sourceFiles_4[_i];
142378
- _loop_6(sourceFile);
142490
+ _loop_5(sourceFile);
142379
142491
  }
142380
142492
  rawItems.sort(compareNavigateToItems);
142381
142493
  return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
@@ -144438,13 +144550,13 @@ var ts;
144438
144550
  // Assumes 'value' is already lowercase.
144439
144551
  function indexOfIgnoringCase(str, value) {
144440
144552
  var n = str.length - value.length;
144441
- var _loop_7 = function (start) {
144553
+ var _loop_6 = function (start) {
144442
144554
  if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
144443
144555
  return { value: start };
144444
144556
  }
144445
144557
  };
144446
144558
  for (var start = 0; start <= n; start++) {
144447
- var state_3 = _loop_7(start);
144559
+ var state_3 = _loop_6(start);
144448
144560
  if (typeof state_3 === "object")
144449
144561
  return state_3.value;
144450
144562
  }
@@ -145911,7 +146023,7 @@ var ts;
145911
146023
  return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
145912
146024
  }
145913
146025
  function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
145914
- var _loop_8 = function (n) {
146026
+ var _loop_7 = function (n) {
145915
146027
  // If the node is not a subspan of its parent, this is a big problem.
145916
146028
  // There have been crashes that might be caused by this violation.
145917
146029
  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); });
@@ -145921,7 +146033,7 @@ var ts;
145921
146033
  }
145922
146034
  };
145923
146035
  for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
145924
- var state_4 = _loop_8(n);
146036
+ var state_4 = _loop_7(n);
145925
146037
  if (typeof state_4 === "object")
145926
146038
  return state_4.value;
145927
146039
  }
@@ -147534,7 +147646,7 @@ var ts;
147534
147646
  commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
147535
147647
  ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
147536
147648
  options = ts.cloneCompilerOptions(options);
147537
- var _loop_9 = function (opt) {
147649
+ var _loop_8 = function (opt) {
147538
147650
  if (!ts.hasProperty(options, opt.name)) {
147539
147651
  return "continue";
147540
147652
  }
@@ -147553,7 +147665,7 @@ var ts;
147553
147665
  };
147554
147666
  for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
147555
147667
  var opt = commandLineOptionsStringToEnum_1[_i];
147556
- _loop_9(opt);
147668
+ _loop_8(opt);
147557
147669
  }
147558
147670
  return options;
147559
147671
  }
@@ -151318,7 +151430,7 @@ var ts;
151318
151430
  ChangeTracker.prototype.finishDeleteDeclarations = function () {
151319
151431
  var _this = this;
151320
151432
  var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
151321
- var _loop_10 = function (sourceFile, node) {
151433
+ var _loop_9 = function (sourceFile, node) {
151322
151434
  if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
151323
151435
  if (ts.isArray(node)) {
151324
151436
  this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
@@ -151331,7 +151443,7 @@ var ts;
151331
151443
  var this_1 = this;
151332
151444
  for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
151333
151445
  var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
151334
- _loop_10(sourceFile, node);
151446
+ _loop_9(sourceFile, node);
151335
151447
  }
151336
151448
  deletedNodesInLists.forEach(function (node) {
151337
151449
  var sourceFile = node.getSourceFile();
@@ -151419,14 +151531,14 @@ var ts;
151419
151531
  // order changes by start position
151420
151532
  // 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.
151421
151533
  var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
151422
- var _loop_11 = function (i) {
151534
+ var _loop_10 = function (i) {
151423
151535
  ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
151424
151536
  return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
151425
151537
  });
151426
151538
  };
151427
151539
  // verify that change intervals do not overlap, except possibly at end points.
151428
151540
  for (var i = 0; i < normalized.length - 1; i++) {
151429
- _loop_11(i);
151541
+ _loop_10(i);
151430
151542
  }
151431
151543
  var textChanges = ts.mapDefined(normalized, function (c) {
151432
151544
  var span = ts.createTextSpanFromRange(c.range);
@@ -152334,7 +152446,7 @@ var ts;
152334
152446
  }
152335
152447
  var isCompleteFix = identifiers.isCompleteFix;
152336
152448
  var initializers;
152337
- var _loop_12 = function (identifier) {
152449
+ var _loop_11 = function (identifier) {
152338
152450
  var symbol = checker.getSymbolAtLocation(identifier);
152339
152451
  if (!symbol) {
152340
152452
  return "continue";
@@ -152367,7 +152479,7 @@ var ts;
152367
152479
  };
152368
152480
  for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
152369
152481
  var identifier = _a[_i];
152370
- _loop_12(identifier);
152482
+ _loop_11(identifier);
152371
152483
  }
152372
152484
  return initializers && {
152373
152485
  initializers: initializers,
@@ -153252,7 +153364,7 @@ var ts;
153252
153364
  }
153253
153365
  var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos);
153254
153366
  changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " });
153255
- var _loop_13 = function (returnStatement) {
153367
+ var _loop_12 = function (returnStatement) {
153256
153368
  ts.forEachChild(returnStatement, function visit(node) {
153257
153369
  if (ts.isCallExpression(node)) {
153258
153370
  var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
@@ -153274,7 +153386,7 @@ var ts;
153274
153386
  };
153275
153387
  for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
153276
153388
  var returnStatement = returnStatements_1[_i];
153277
- var state_5 = _loop_13(returnStatement);
153389
+ var state_5 = _loop_12(returnStatement);
153278
153390
  if (typeof state_5 === "object")
153279
153391
  return state_5.value;
153280
153392
  }
@@ -156609,7 +156721,7 @@ var ts;
156609
156721
  });
156610
156722
  typeDeclToMembers.forEach(function (infos, declaration) {
156611
156723
  var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
156612
- var _loop_14 = function (info) {
156724
+ var _loop_13 = function (info) {
156613
156725
  // If some superclass added this property, don't add it again.
156614
156726
  if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
156615
156727
  var superInfos = typeDeclToMembers.get(superClassOrInterface);
@@ -156636,7 +156748,7 @@ var ts;
156636
156748
  };
156637
156749
  for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
156638
156750
  var info = infos_1[_i];
156639
- _loop_14(info);
156751
+ _loop_13(info);
156640
156752
  }
156641
156753
  });
156642
156754
  }));
@@ -159410,7 +159522,7 @@ var ts;
159410
159522
  function getSignatureFromCalls(calls) {
159411
159523
  var parameters = [];
159412
159524
  var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
159413
- var _loop_15 = function (i) {
159525
+ var _loop_14 = function (i) {
159414
159526
  var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
159415
159527
  symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
159416
159528
  if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
@@ -159419,7 +159531,7 @@ var ts;
159419
159531
  parameters.push(symbol);
159420
159532
  };
159421
159533
  for (var i = 0; i < length; i++) {
159422
- _loop_15(i);
159534
+ _loop_14(i);
159423
159535
  }
159424
159536
  var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
159425
159537
  return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
@@ -161395,7 +161507,7 @@ var ts;
161395
161507
  // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
161396
161508
  // 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 }`.
161397
161509
  var neededNamedImports = new ts.Set();
161398
- var _loop_16 = function (element) {
161510
+ var _loop_15 = function (element) {
161399
161511
  var propertyName = (element.propertyName || element.name).text;
161400
161512
  ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
161401
161513
  var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
@@ -161412,7 +161524,7 @@ var ts;
161412
161524
  };
161413
161525
  for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
161414
161526
  var element = _a[_i];
161415
- _loop_16(element);
161527
+ _loop_15(element);
161416
161528
  }
161417
161529
  changes.replaceNode(sourceFile, toConvert, shouldUseDefault
161418
161530
  ? ts.factory.createIdentifier(namespaceImportName)
@@ -163303,7 +163415,7 @@ var ts;
163303
163415
  : ts.getEnclosingBlockScopeContainer(scopes[0]);
163304
163416
  ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
163305
163417
  }
163306
- var _loop_17 = function (i) {
163418
+ var _loop_16 = function (i) {
163307
163419
  var scopeUsages = usagesPerScope[i];
163308
163420
  // Special case: in the innermost scope, all usages are available.
163309
163421
  // (The computed value reflects the value at the top-level of the scope, but the
@@ -163346,7 +163458,7 @@ var ts;
163346
163458
  }
163347
163459
  };
163348
163460
  for (var i = 0; i < scopes.length; i++) {
163349
- _loop_17(i);
163461
+ _loop_16(i);
163350
163462
  }
163351
163463
  return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
163352
163464
  function isInGenericContext(node) {
@@ -164047,10 +164159,10 @@ var ts;
164047
164159
  }
164048
164160
  function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
164049
164161
  var checker = program.getTypeChecker();
164050
- var _loop_18 = function (sourceFile) {
164162
+ var _loop_17 = function (sourceFile) {
164051
164163
  if (sourceFile === oldFile)
164052
164164
  return "continue";
164053
- var _loop_19 = function (statement) {
164165
+ var _loop_18 = function (statement) {
164054
164166
  forEachImportInStatement(statement, function (importNode) {
164055
164167
  if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
164056
164168
  return;
@@ -164072,12 +164184,12 @@ var ts;
164072
164184
  };
164073
164185
  for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
164074
164186
  var statement = _c[_b];
164075
- _loop_19(statement);
164187
+ _loop_18(statement);
164076
164188
  }
164077
164189
  };
164078
164190
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
164079
164191
  var sourceFile = _a[_i];
164080
- _loop_18(sourceFile);
164192
+ _loop_17(sourceFile);
164081
164193
  }
164082
164194
  }
164083
164195
  function getNamespaceLikeImport(node) {
@@ -165440,7 +165552,7 @@ var ts;
165440
165552
  var templateSpans = [];
165441
165553
  var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
165442
165554
  copyCommentFromStringLiterals(headIndexes, templateHead);
165443
- var _loop_20 = function (i) {
165555
+ var _loop_19 = function (i) {
165444
165556
  var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
165445
165557
  copyOperatorComments(i, currentNode);
165446
165558
  var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
@@ -165469,7 +165581,7 @@ var ts;
165469
165581
  };
165470
165582
  var out_i_1;
165471
165583
  for (var i = begin; i < nodes.length; i++) {
165472
- _loop_20(i);
165584
+ _loop_19(i);
165473
165585
  i = out_i_1;
165474
165586
  }
165475
165587
  return ts.factory.createTemplateExpression(templateHead, templateSpans);
@@ -166081,20 +166193,25 @@ var ts;
166081
166193
  return this.documentationComment;
166082
166194
  };
166083
166195
  SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) {
166084
- switch (context === null || context === void 0 ? void 0 : context.kind) {
166085
- case 172 /* GetAccessor */:
166196
+ if (context) {
166197
+ if (ts.isGetAccessor(context)) {
166086
166198
  if (!this.contextualGetAccessorDocumentationComment) {
166087
166199
  this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
166088
166200
  }
166089
- return this.contextualGetAccessorDocumentationComment;
166090
- case 173 /* SetAccessor */:
166201
+ if (ts.length(this.contextualGetAccessorDocumentationComment)) {
166202
+ return this.contextualGetAccessorDocumentationComment;
166203
+ }
166204
+ }
166205
+ if (ts.isSetAccessor(context)) {
166091
166206
  if (!this.contextualSetAccessorDocumentationComment) {
166092
166207
  this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
166093
166208
  }
166094
- return this.contextualSetAccessorDocumentationComment;
166095
- default:
166096
- return this.getDocumentationComment(checker);
166209
+ if (ts.length(this.contextualSetAccessorDocumentationComment)) {
166210
+ return this.contextualSetAccessorDocumentationComment;
166211
+ }
166212
+ }
166097
166213
  }
166214
+ return this.getDocumentationComment(checker);
166098
166215
  };
166099
166216
  SymbolObject.prototype.getJsDocTags = function (checker) {
166100
166217
  if (this.tags === undefined) {
@@ -166103,20 +166220,25 @@ var ts;
166103
166220
  return this.tags;
166104
166221
  };
166105
166222
  SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
166106
- switch (context === null || context === void 0 ? void 0 : context.kind) {
166107
- case 172 /* GetAccessor */:
166223
+ if (context) {
166224
+ if (ts.isGetAccessor(context)) {
166108
166225
  if (!this.contextualGetAccessorTags) {
166109
166226
  this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
166110
166227
  }
166111
- return this.contextualGetAccessorTags;
166112
- case 173 /* SetAccessor */:
166228
+ if (ts.length(this.contextualGetAccessorTags)) {
166229
+ return this.contextualGetAccessorTags;
166230
+ }
166231
+ }
166232
+ if (ts.isSetAccessor(context)) {
166113
166233
  if (!this.contextualSetAccessorTags) {
166114
166234
  this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
166115
166235
  }
166116
- return this.contextualSetAccessorTags;
166117
- default:
166118
- return this.getJsDocTags(checker);
166236
+ if (ts.length(this.contextualSetAccessorTags)) {
166237
+ return this.contextualSetAccessorTags;
166238
+ }
166239
+ }
166119
166240
  }
166241
+ return this.getJsDocTags(checker);
166120
166242
  };
166121
166243
  return SymbolObject;
166122
166244
  }());
@@ -166305,7 +166427,7 @@ var ts;
166305
166427
  var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
166306
166428
  if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
166307
166429
  var seenSymbols_1 = new ts.Set();
166308
- var _loop_21 = function (declaration) {
166430
+ var _loop_20 = function (declaration) {
166309
166431
  var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
166310
166432
  var _a;
166311
166433
  if (!seenSymbols_1.has(symbol)) {
@@ -166322,7 +166444,7 @@ var ts;
166322
166444
  };
166323
166445
  for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
166324
166446
  var declaration = declarations_7[_i];
166325
- _loop_21(declaration);
166447
+ _loop_20(declaration);
166326
166448
  }
166327
166449
  }
166328
166450
  return tags;
@@ -166333,7 +166455,7 @@ var ts;
166333
166455
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
166334
166456
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
166335
166457
  var seenSymbols_2 = new ts.Set();
166336
- var _loop_22 = function (declaration) {
166458
+ var _loop_21 = function (declaration) {
166337
166459
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
166338
166460
  if (!seenSymbols_2.has(symbol)) {
166339
166461
  seenSymbols_2.add(symbol);
@@ -166349,7 +166471,7 @@ var ts;
166349
166471
  };
166350
166472
  for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
166351
166473
  var declaration = declarations_8[_i];
166352
- _loop_22(declaration);
166474
+ _loop_21(declaration);
166353
166475
  }
166354
166476
  }
166355
166477
  return doc;
@@ -166867,7 +166989,10 @@ var ts;
166867
166989
  program = undefined; // TODO: GH#18217
166868
166990
  lastTypesRootVersion = typeRootsVersion;
166869
166991
  }
166870
- var rootFileNames = host.getScriptFileNames();
166992
+ // This array is retained by the program and will be used to determine if the program is up to date,
166993
+ // so we need to make a copy in case the host mutates the underlying array - otherwise it would look
166994
+ // like every program always has the host's current list of root files.
166995
+ var rootFileNames = host.getScriptFileNames().slice();
166871
166996
  // Get a fresh cache of the host information
166872
166997
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
166873
166998
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;