typescript 4.9.0-dev.20220920 → 4.9.0-dev.20220922

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.
@@ -99,7 +99,7 @@ var ts;
99
99
  // The following is baselined as a literal template type without intervention
100
100
  /** The version of the TypeScript compiler release */
101
101
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
102
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220920");
102
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220922");
103
103
  /* @internal */
104
104
  var Comparison;
105
105
  (function (Comparison) {
@@ -3008,7 +3008,7 @@ var ts;
3008
3008
  ];
3009
3009
  for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
3010
3010
  var ctor = nodeConstructors_1[_i];
3011
- if (!ts.hasProperty(ctor, "__debugKind")) {
3011
+ if (!ts.hasProperty(ctor.prototype, "__debugKind")) {
3012
3012
  Object.defineProperties(ctor.prototype, {
3013
3013
  // for use with vscode-js-debug's new customDescriptionGenerator in launch.json
3014
3014
  __tsDebuggerDisplay: {
@@ -9123,6 +9123,7 @@ var ts;
9123
9123
  _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?"),
9124
9124
  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."),
9125
9125
  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."),
9126
+ This_condition_will_always_return_0: diag(2845, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
9126
9127
  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}'."),
9127
9128
  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}'."),
9128
9129
  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}'."),
@@ -10065,6 +10066,8 @@ var ts;
10065
10066
  Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
10066
10067
  Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
10067
10068
  Rename_param_tag_name_0_to_1: diag(95173, ts.DiagnosticCategory.Message, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
10069
+ Use_0: diag(95174, ts.DiagnosticCategory.Message, "Use_0_95174", "Use `{0}`."),
10070
+ Use_Number_isNaN_in_all_conditions: diag(95175, ts.DiagnosticCategory.Message, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
10068
10071
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
10069
10072
  Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
10070
10073
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -11887,12 +11890,36 @@ var ts;
11887
11890
  pos++;
11888
11891
  return token = 0 /* SyntaxKind.Unknown */;
11889
11892
  }
11890
- if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) {
11893
+ var charAfterHash = codePointAt(text, pos + 1);
11894
+ if (charAfterHash === 92 /* CharacterCodes.backslash */) {
11891
11895
  pos++;
11892
- scanIdentifier(codePointAt(text, pos), languageVersion);
11896
+ var extendedCookedChar_1 = peekExtendedUnicodeEscape();
11897
+ if (extendedCookedChar_1 >= 0 && isIdentifierStart(extendedCookedChar_1, languageVersion)) {
11898
+ pos += 3;
11899
+ tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */;
11900
+ tokenValue = "#" + scanExtendedUnicodeEscape() + scanIdentifierParts();
11901
+ return token = 80 /* SyntaxKind.PrivateIdentifier */;
11902
+ }
11903
+ var cookedChar_1 = peekUnicodeEscape();
11904
+ if (cookedChar_1 >= 0 && isIdentifierStart(cookedChar_1, languageVersion)) {
11905
+ pos += 6;
11906
+ tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */;
11907
+ tokenValue = "#" + String.fromCharCode(cookedChar_1) + scanIdentifierParts();
11908
+ return token = 80 /* SyntaxKind.PrivateIdentifier */;
11909
+ }
11910
+ pos--;
11911
+ }
11912
+ if (isIdentifierStart(charAfterHash, languageVersion)) {
11913
+ pos++;
11914
+ // We're relying on scanIdentifier's behavior and adjusting the token kind after the fact.
11915
+ // Notably absent from this block is the fact that calling a function named "scanIdentifier",
11916
+ // but identifiers don't include '#', and that function doesn't deal with it at all.
11917
+ // This works because 'scanIdentifier' tries to reuse source characters and builds up substrings;
11918
+ // however, it starts at the 'tokenPos' which includes the '#', and will "accidentally" prepend the '#' for us.
11919
+ scanIdentifier(charAfterHash, languageVersion);
11893
11920
  }
11894
11921
  else {
11895
- tokenValue = String.fromCharCode(codePointAt(text, pos));
11922
+ tokenValue = "#";
11896
11923
  error(ts.Diagnostics.Invalid_character, pos++, charSize(ch));
11897
11924
  }
11898
11925
  return token = 80 /* SyntaxKind.PrivateIdentifier */;
@@ -33130,7 +33157,7 @@ var ts;
33130
33157
  }
33131
33158
  function parsePrivateIdentifier() {
33132
33159
  var pos = getNodePos();
33133
- var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenText()));
33160
+ var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenValue()));
33134
33161
  nextToken();
33135
33162
  return finishNode(node, pos);
33136
33163
  }
@@ -45216,6 +45243,7 @@ var ts;
45216
45243
  }
45217
45244
  }
45218
45245
  function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
45246
+ var _a;
45219
45247
  var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
45220
45248
  // First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
45221
45249
  var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
@@ -45230,13 +45258,7 @@ var ts;
45230
45258
  return withPackageId(packageInfo, fromDirectory);
45231
45259
  }
45232
45260
  }
45233
- var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
45234
45261
  var loader = function (extensions, candidate, onlyRecordFailures, state) {
45235
- var _a;
45236
- // package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
45237
- if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45238
- return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45239
- }
45240
45262
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
45241
45263
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.contents.packageJsonContent, packageInfo && packageInfo.contents.versionPaths);
45242
45264
  if (!pathAndExtension && packageInfo
@@ -45249,19 +45271,24 @@ var ts;
45249
45271
  }
45250
45272
  return withPackageId(packageInfo, pathAndExtension);
45251
45273
  };
45252
- if (rest !== "") { // If "rest" is empty, we just did this search above.
45253
- var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45254
- // Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings.
45274
+ var _b = parsePackageName(moduleName), packageName = _b.packageName, rest = _b.rest;
45275
+ var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
45276
+ if (rest !== "") {
45277
+ // Previous `packageInfo` may have been from a nested package.json; ensure we have the one from the package root now.
45255
45278
  packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
45256
- if (packageInfo && packageInfo.contents.versionPaths) {
45257
- if (state.traceEnabled) {
45258
- trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.contents.versionPaths.version, ts.version, rest);
45259
- }
45260
- var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45261
- var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45262
- if (fromPaths) {
45263
- return fromPaths.value;
45264
- }
45279
+ }
45280
+ // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present, blocks them)
45281
+ if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
45282
+ return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
45283
+ }
45284
+ if (rest !== "" && packageInfo && packageInfo.contents.versionPaths) {
45285
+ if (state.traceEnabled) {
45286
+ trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.contents.versionPaths.version, ts.version, rest);
45287
+ }
45288
+ var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
45289
+ var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state);
45290
+ if (fromPaths) {
45291
+ return fromPaths.value;
45265
45292
  }
45266
45293
  }
45267
45294
  return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
@@ -49763,6 +49790,7 @@ var ts;
49763
49790
  var deferredGlobalOmitSymbol;
49764
49791
  var deferredGlobalAwaitedSymbol;
49765
49792
  var deferredGlobalBigIntType;
49793
+ var deferredGlobalNaNSymbol;
49766
49794
  var deferredGlobalRecordSymbol;
49767
49795
  var allPotentiallyUnusedIdentifiers = new ts.Map(); // key is file name
49768
49796
  var flowLoopStart = 0;
@@ -55441,6 +55469,7 @@ var ts;
55441
55469
  && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */
55442
55470
  && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */)
55443
55471
  && !(symbol.flags & 32 /* SymbolFlags.Class */)
55472
+ && !(symbol.flags & 8192 /* SymbolFlags.Method */)
55444
55473
  && !isConstMergedWithNSPrintableAsSignatureMerge) {
55445
55474
  if (propertyAsAlias) {
55446
55475
  var createdExport = serializeMaybeAliasAssignment(symbol);
@@ -60251,7 +60280,7 @@ var ts;
60251
60280
  var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp);
60252
60281
  // If the symbols are instances of one another with identical types - consider the symbols
60253
60282
  // equivalent and just use the first one, which thus allows us to avoid eliding private
60254
- // members when intersecting a (this-)instantiations of a class with it's raw base or another instance
60283
+ // members when intersecting a (this-)instantiations of a class with its raw base or another instance
60255
60284
  if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) {
60256
60285
  // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used
60257
60286
  // to do when we recorded multiple distinct symbols so that we still get, eg, `Array<T>.length` printed
@@ -60299,7 +60328,11 @@ var ts;
60299
60328
  }
60300
60329
  }
60301
60330
  }
60302
- if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) {
60331
+ if (!singleProp ||
60332
+ isUnion &&
60333
+ (propSet || checkFlags & 48 /* CheckFlags.Partial */) &&
60334
+ checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */) &&
60335
+ !(propSet && getCommonDeclarationsOfSymbols(ts.arrayFrom(propSet.values())))) {
60303
60336
  // No property was found, or, in a union, a property has a private or protected declaration in one
60304
60337
  // constituent, but is missing or has a different declaration in another constituent.
60305
60338
  return undefined;
@@ -60401,6 +60434,33 @@ var ts;
60401
60434
  }
60402
60435
  return property;
60403
60436
  }
60437
+ function getCommonDeclarationsOfSymbols(symbols) {
60438
+ var commonDeclarations;
60439
+ var _loop_14 = function (symbol) {
60440
+ if (!symbol.declarations) {
60441
+ return { value: undefined };
60442
+ }
60443
+ if (!commonDeclarations) {
60444
+ commonDeclarations = new ts.Set(symbol.declarations);
60445
+ return "continue";
60446
+ }
60447
+ commonDeclarations.forEach(function (declaration) {
60448
+ if (!ts.contains(symbol.declarations, declaration)) {
60449
+ commonDeclarations.delete(declaration);
60450
+ }
60451
+ });
60452
+ if (commonDeclarations.size === 0) {
60453
+ return { value: undefined };
60454
+ }
60455
+ };
60456
+ for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) {
60457
+ var symbol = symbols_3[_i];
60458
+ var state_4 = _loop_14(symbol);
60459
+ if (typeof state_4 === "object")
60460
+ return state_4.value;
60461
+ }
60462
+ return commonDeclarations;
60463
+ }
60404
60464
  function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) {
60405
60465
  var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
60406
60466
  // We need to filter out partial properties in union types
@@ -61115,7 +61175,7 @@ var ts;
61115
61175
  function getIndexInfosOfIndexSymbol(indexSymbol) {
61116
61176
  if (indexSymbol.declarations) {
61117
61177
  var indexInfos_4 = [];
61118
- var _loop_14 = function (declaration) {
61178
+ var _loop_15 = function (declaration) {
61119
61179
  if (declaration.parameters.length === 1) {
61120
61180
  var parameter = declaration.parameters[0];
61121
61181
  if (parameter.type) {
@@ -61129,7 +61189,7 @@ var ts;
61129
61189
  };
61130
61190
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
61131
61191
  var declaration = _a[_i];
61132
- _loop_14(declaration);
61192
+ _loop_15(declaration);
61133
61193
  }
61134
61194
  return indexInfos_4;
61135
61195
  }
@@ -61146,7 +61206,7 @@ var ts;
61146
61206
  var _a;
61147
61207
  var inferences;
61148
61208
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
61149
- var _loop_15 = function (declaration) {
61209
+ var _loop_16 = function (declaration) {
61150
61210
  if (declaration.parent.kind === 192 /* SyntaxKind.InferType */) {
61151
61211
  // When an 'infer T' declaration is immediately contained in a type reference node
61152
61212
  // (such as 'Foo<infer T>'), T's constraint is inferred from the constraint of the
@@ -61210,7 +61270,7 @@ var ts;
61210
61270
  };
61211
61271
  for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
61212
61272
  var declaration = _b[_i];
61213
- _loop_15(declaration);
61273
+ _loop_16(declaration);
61214
61274
  }
61215
61275
  }
61216
61276
  return inferences && getIntersectionType(inferences);
@@ -61867,6 +61927,9 @@ var ts;
61867
61927
  function getGlobalBigIntType() {
61868
61928
  return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
61869
61929
  }
61930
+ function getGlobalNaNSymbol() {
61931
+ return (deferredGlobalNaNSymbol || (deferredGlobalNaNSymbol = getGlobalValueSymbol("NaN", /*reportErrors*/ false)));
61932
+ }
61870
61933
  function getGlobalRecordSymbol() {
61871
61934
  deferredGlobalRecordSymbol || (deferredGlobalRecordSymbol = getGlobalTypeAliasSymbol("Record", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol);
61872
61935
  return deferredGlobalRecordSymbol === unknownSymbol ? undefined : deferredGlobalRecordSymbol;
@@ -62107,7 +62170,7 @@ var ts;
62107
62170
  var lastRequiredIndex = -1;
62108
62171
  var firstRestIndex = -1;
62109
62172
  var lastOptionalOrRestIndex = -1;
62110
- var _loop_16 = function (i) {
62173
+ var _loop_17 = function (i) {
62111
62174
  var type = elementTypes[i];
62112
62175
  var flags = target.elementFlags[i];
62113
62176
  if (flags & 8 /* ElementFlags.Variadic */) {
@@ -62137,9 +62200,9 @@ var ts;
62137
62200
  }
62138
62201
  };
62139
62202
  for (var i = 0; i < elementTypes.length; i++) {
62140
- var state_4 = _loop_16(i);
62141
- if (typeof state_4 === "object")
62142
- return state_4.value;
62203
+ var state_5 = _loop_17(i);
62204
+ if (typeof state_5 === "object")
62205
+ return state_5.value;
62143
62206
  }
62144
62207
  // Turn optional elements preceding the last required element into required elements
62145
62208
  for (var i = 0; i < lastRequiredIndex; i++) {
@@ -62167,7 +62230,7 @@ var ts;
62167
62230
  if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) {
62168
62231
  lastOptionalOrRestIndex = expandedFlags.length;
62169
62232
  }
62170
- expandedTypes.push(type);
62233
+ expandedTypes.push(flags & 2 /* ElementFlags.Optional */ ? addOptionality(type, /*isProperty*/ true) : type);
62171
62234
  expandedFlags.push(flags);
62172
62235
  if (expandedDeclarations && declaration) {
62173
62236
  expandedDeclarations.push(declaration);
@@ -62333,7 +62396,7 @@ var ts;
62333
62396
  var templates = ts.filter(types, isPatternLiteralType);
62334
62397
  if (templates.length) {
62335
62398
  var i = types.length;
62336
- var _loop_17 = function () {
62399
+ var _loop_18 = function () {
62337
62400
  i--;
62338
62401
  var t = types[i];
62339
62402
  if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
@@ -62341,7 +62404,7 @@ var ts;
62341
62404
  }
62342
62405
  };
62343
62406
  while (i > 0) {
62344
- _loop_17();
62407
+ _loop_18();
62345
62408
  }
62346
62409
  }
62347
62410
  }
@@ -62418,14 +62481,14 @@ var ts;
62418
62481
  var namedUnions = [];
62419
62482
  addNamedUnions(namedUnions, types);
62420
62483
  var reducedTypes = [];
62421
- var _loop_18 = function (t) {
62484
+ var _loop_19 = function (t) {
62422
62485
  if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) {
62423
62486
  reducedTypes.push(t);
62424
62487
  }
62425
62488
  };
62426
62489
  for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) {
62427
62490
  var t = typeSet_1[_i];
62428
- _loop_18(t);
62491
+ _loop_19(t);
62429
62492
  }
62430
62493
  if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) {
62431
62494
  return namedUnions[0];
@@ -63655,7 +63718,7 @@ var ts;
63655
63718
  var result;
63656
63719
  var extraTypes;
63657
63720
  var tailCount = 0;
63658
- var _loop_19 = function () {
63721
+ var _loop_20 = function () {
63659
63722
  if (tailCount === 1000) {
63660
63723
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
63661
63724
  result = errorType;
@@ -63776,10 +63839,10 @@ var ts;
63776
63839
  // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63777
63840
  // cases we increment the tail recursion counter and stop after 1000 iterations.
63778
63841
  while (true) {
63779
- var state_5 = _loop_19();
63780
- if (typeof state_5 === "object")
63781
- return state_5.value;
63782
- if (state_5 === "break")
63842
+ var state_6 = _loop_20();
63843
+ if (typeof state_6 === "object")
63844
+ return state_6.value;
63845
+ if (state_6 === "break")
63783
63846
  break;
63784
63847
  }
63785
63848
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
@@ -66394,7 +66457,7 @@ var ts;
66394
66457
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
66395
66458
  checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
66396
66459
  }
66397
- var _loop_20 = function (prop) {
66460
+ var _loop_21 = function (prop) {
66398
66461
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
66399
66462
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
66400
66463
  if (reportErrors) {
@@ -66457,9 +66520,9 @@ var ts;
66457
66520
  };
66458
66521
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
66459
66522
  var prop = _b[_i];
66460
- var state_6 = _loop_20(prop);
66461
- if (typeof state_6 === "object")
66462
- return state_6.value;
66523
+ var state_7 = _loop_21(prop);
66524
+ if (typeof state_7 === "object")
66525
+ return state_7.value;
66463
66526
  }
66464
66527
  return false;
66465
66528
  }
@@ -67450,11 +67513,11 @@ var ts;
67450
67513
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
67451
67514
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
67452
67515
  var matchingTypes = [];
67453
- var _loop_21 = function (combination) {
67516
+ var _loop_22 = function (combination) {
67454
67517
  var hasMatch = false;
67455
67518
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
67456
67519
  var type = _d[_c];
67457
- var _loop_22 = function (i) {
67520
+ var _loop_23 = function (i) {
67458
67521
  var sourceProperty = sourcePropertiesFiltered[i];
67459
67522
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
67460
67523
  if (!targetProperty)
@@ -67470,8 +67533,8 @@ var ts;
67470
67533
  }
67471
67534
  };
67472
67535
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
67473
- var state_8 = _loop_22(i);
67474
- switch (state_8) {
67536
+ var state_9 = _loop_23(i);
67537
+ switch (state_9) {
67475
67538
  case "continue-outer": continue outer;
67476
67539
  }
67477
67540
  }
@@ -67484,9 +67547,9 @@ var ts;
67484
67547
  };
67485
67548
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
67486
67549
  var combination = discriminantCombinations_1[_a];
67487
- var state_7 = _loop_21(combination);
67488
- if (typeof state_7 === "object")
67489
- return state_7.value;
67550
+ var state_8 = _loop_22(combination);
67551
+ if (typeof state_8 === "object")
67552
+ return state_8.value;
67490
67553
  }
67491
67554
  // Compare the remaining non-discriminant properties of each match.
67492
67555
  var result = -1 /* Ternary.True */;
@@ -68191,7 +68254,7 @@ var ts;
68191
68254
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
68192
68255
  links.variances = ts.emptyArray;
68193
68256
  var variances = [];
68194
- var _loop_23 = function (tp) {
68257
+ var _loop_24 = function (tp) {
68195
68258
  var modifiers = getVarianceModifiers(tp);
68196
68259
  var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
68197
68260
  modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
@@ -68229,7 +68292,7 @@ var ts;
68229
68292
  };
68230
68293
  for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
68231
68294
  var tp = typeParameters_2[_i];
68232
- _loop_23(tp);
68295
+ _loop_24(tp);
68233
68296
  }
68234
68297
  links.variances = variances;
68235
68298
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
@@ -68821,7 +68884,8 @@ var ts;
68821
68884
  function getOptionalType(type, isProperty) {
68822
68885
  if (isProperty === void 0) { isProperty = false; }
68823
68886
  ts.Debug.assert(strictNullChecks);
68824
- return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
68887
+ var missingOrUndefined = isProperty ? missingType : undefinedType;
68888
+ return type.flags & 32768 /* TypeFlags.Undefined */ || type.flags & 1048576 /* TypeFlags.Union */ && type.types[0] === missingOrUndefined ? type : getUnionType([type, missingOrUndefined]);
68825
68889
  }
68826
68890
  function getGlobalNonNullableTypeInstantiation(type) {
68827
68891
  if (!deferredGlobalNonNullableTypeAlias) {
@@ -70186,7 +70250,7 @@ var ts;
70186
70250
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
70187
70251
  // succeed. That would be a pointless and confusing outcome.
70188
70252
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
70189
- var _loop_24 = function (i) {
70253
+ var _loop_25 = function (i) {
70190
70254
  var source_1 = matches ? matches[i] : neverType;
70191
70255
  var target_3 = types[i];
70192
70256
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -70236,7 +70300,7 @@ var ts;
70236
70300
  inferFromTypes(source_1, target_3);
70237
70301
  };
70238
70302
  for (var i = 0; i < types.length; i++) {
70239
- _loop_24(i);
70303
+ _loop_25(i);
70240
70304
  }
70241
70305
  }
70242
70306
  }
@@ -70700,7 +70764,7 @@ var ts;
70700
70764
  return name;
70701
70765
  }
70702
70766
  }
70703
- if (ts.hasOnlyExpressionInitializer(declaration)) {
70767
+ if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
70704
70768
  var initializer = ts.getEffectiveInitializer(declaration);
70705
70769
  return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
70706
70770
  }
@@ -70760,7 +70824,7 @@ var ts;
70760
70824
  function mapTypesByKeyProperty(types, name) {
70761
70825
  var map = new ts.Map();
70762
70826
  var count = 0;
70763
- var _loop_25 = function (type) {
70827
+ var _loop_26 = function (type) {
70764
70828
  if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
70765
70829
  var discriminant = getTypeOfPropertyOfType(type, name);
70766
70830
  if (discriminant) {
@@ -70786,9 +70850,9 @@ var ts;
70786
70850
  };
70787
70851
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70788
70852
  var type = types_15[_i];
70789
- var state_9 = _loop_25(type);
70790
- if (typeof state_9 === "object")
70791
- return state_9.value;
70853
+ var state_10 = _loop_26(type);
70854
+ if (typeof state_10 === "object")
70855
+ return state_10.value;
70792
70856
  }
70793
70857
  return count >= 10 && count * 2 >= types.length ? map : undefined;
70794
70858
  }
@@ -77243,7 +77307,7 @@ var ts;
77243
77307
  if (spreadIndex >= 0) {
77244
77308
  // Create synthetic arguments from spreads of tuple types.
77245
77309
  var effectiveArgs_1 = args.slice(0, spreadIndex);
77246
- var _loop_26 = function (i) {
77310
+ var _loop_27 = function (i) {
77247
77311
  var arg = args[i];
77248
77312
  // We can call checkExpressionCached because spread expressions never have a contextual type.
77249
77313
  var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -77260,7 +77324,7 @@ var ts;
77260
77324
  }
77261
77325
  };
77262
77326
  for (var i = spreadIndex; i < args.length; i++) {
77263
- _loop_26(i);
77327
+ _loop_27(i);
77264
77328
  }
77265
77329
  return effectiveArgs_1;
77266
77330
  }
@@ -77589,7 +77653,7 @@ var ts;
77589
77653
  var min_3 = Number.MAX_VALUE;
77590
77654
  var minIndex = 0;
77591
77655
  var i_1 = 0;
77592
- var _loop_27 = function (c) {
77656
+ var _loop_28 = function (c) {
77593
77657
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
77594
77658
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
77595
77659
  if (diags_2) {
@@ -77607,7 +77671,7 @@ var ts;
77607
77671
  };
77608
77672
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
77609
77673
  var c = candidatesForArgumentError_1[_a];
77610
- _loop_27(c);
77674
+ _loop_28(c);
77611
77675
  }
77612
77676
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
77613
77677
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -77765,7 +77829,7 @@ var ts;
77765
77829
  }
77766
77830
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
77767
77831
  var parameters = [];
77768
- var _loop_28 = function (i) {
77832
+ var _loop_29 = function (i) {
77769
77833
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
77770
77834
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
77771
77835
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -77773,7 +77837,7 @@ var ts;
77773
77837
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
77774
77838
  };
77775
77839
  for (var i = 0; i < maxNonRestParam; i++) {
77776
- _loop_28(i);
77840
+ _loop_29(i);
77777
77841
  }
77778
77842
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
77779
77843
  var flags = 0 /* SignatureFlags.None */;
@@ -80555,6 +80619,7 @@ var ts;
80555
80619
  var eqType = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */;
80556
80620
  error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
80557
80621
  }
80622
+ checkNaNEquality(errorNode, operator, left, right);
80558
80623
  reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
80559
80624
  return booleanType;
80560
80625
  case 102 /* SyntaxKind.InstanceOfKeyword */:
@@ -80760,6 +80825,26 @@ var ts;
80760
80825
  return undefined;
80761
80826
  }
80762
80827
  }
80828
+ function checkNaNEquality(errorNode, operator, left, right) {
80829
+ var isLeftNaN = isGlobalNaN(ts.skipParentheses(left));
80830
+ var isRightNaN = isGlobalNaN(ts.skipParentheses(right));
80831
+ if (isLeftNaN || isRightNaN) {
80832
+ var err = error(errorNode, ts.Diagnostics.This_condition_will_always_return_0, ts.tokenToString(operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? 95 /* SyntaxKind.FalseKeyword */ : 110 /* SyntaxKind.TrueKeyword */));
80833
+ if (isLeftNaN && isRightNaN)
80834
+ return;
80835
+ var operatorString = operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? ts.tokenToString(53 /* SyntaxKind.ExclamationToken */) : "";
80836
+ var location = isLeftNaN ? right : left;
80837
+ var expression = ts.skipParentheses(location);
80838
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(location, ts.Diagnostics.Did_you_mean_0, "".concat(operatorString, "Number.isNaN(").concat(ts.isEntityNameExpression(expression) ? ts.entityNameToString(expression) : "...", ")")));
80839
+ }
80840
+ }
80841
+ function isGlobalNaN(expr) {
80842
+ if (ts.isIdentifier(expr) && expr.escapedText === "NaN") {
80843
+ var globalNaNSymbol = getGlobalNaNSymbol();
80844
+ return !!globalNaNSymbol && globalNaNSymbol === getResolvedSymbol(expr);
80845
+ }
80846
+ return false;
80847
+ }
80763
80848
  }
80764
80849
  function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
80765
80850
  var effectiveLeft = leftType;
@@ -81797,7 +81882,7 @@ var ts;
81797
81882
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
81798
81883
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
81799
81884
  var indexSignatureMap_1 = new ts.Map();
81800
- var _loop_29 = function (declaration) {
81885
+ var _loop_30 = function (declaration) {
81801
81886
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
81802
81887
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
81803
81888
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -81812,7 +81897,7 @@ var ts;
81812
81897
  };
81813
81898
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
81814
81899
  var declaration = _a[_i];
81815
- _loop_29(declaration);
81900
+ _loop_30(declaration);
81816
81901
  }
81817
81902
  indexSignatureMap_1.forEach(function (entry) {
81818
81903
  if (entry.declarations.length > 1) {
@@ -85412,7 +85497,7 @@ var ts;
85412
85497
  var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
85413
85498
  name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
85414
85499
  var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
85415
- var _loop_30 = function (info) {
85500
+ var _loop_31 = function (info) {
85416
85501
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
85417
85502
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
85418
85503
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -85429,7 +85514,7 @@ var ts;
85429
85514
  };
85430
85515
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
85431
85516
  var info = indexInfos_9[_i];
85432
- _loop_30(info);
85517
+ _loop_31(info);
85433
85518
  }
85434
85519
  }
85435
85520
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -85437,7 +85522,7 @@ var ts;
85437
85522
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
85438
85523
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
85439
85524
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
85440
- var _loop_31 = function (info) {
85525
+ var _loop_32 = function (info) {
85441
85526
  if (info === checkInfo)
85442
85527
  return "continue";
85443
85528
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -85452,7 +85537,7 @@ var ts;
85452
85537
  };
85453
85538
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
85454
85539
  var info = indexInfos_10[_i];
85455
- _loop_31(info);
85540
+ _loop_32(info);
85456
85541
  }
85457
85542
  }
85458
85543
  function checkTypeNameIsReserved(name, message) {
@@ -85772,7 +85857,7 @@ var ts;
85772
85857
  var baseTypes = baseTypeNode && getBaseTypes(type);
85773
85858
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
85774
85859
  var baseStaticType = getBaseConstructorTypeOfClass(type);
85775
- var _loop_32 = function (member) {
85860
+ var _loop_33 = function (member) {
85776
85861
  if (ts.hasAmbientModifier(member)) {
85777
85862
  return "continue";
85778
85863
  }
@@ -85789,7 +85874,7 @@ var ts;
85789
85874
  };
85790
85875
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85791
85876
  var member = _a[_i];
85792
- _loop_32(member);
85877
+ _loop_33(member);
85793
85878
  }
85794
85879
  }
85795
85880
  /**
@@ -85877,7 +85962,7 @@ var ts;
85877
85962
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
85878
85963
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
85879
85964
  var issuedMemberError = false;
85880
- var _loop_33 = function (member) {
85965
+ var _loop_34 = function (member) {
85881
85966
  if (ts.isStatic(member)) {
85882
85967
  return "continue";
85883
85968
  }
@@ -85896,7 +85981,7 @@ var ts;
85896
85981
  };
85897
85982
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85898
85983
  var member = _a[_i];
85899
- _loop_33(member);
85984
+ _loop_34(member);
85900
85985
  }
85901
85986
  if (!issuedMemberError) {
85902
85987
  // check again with diagnostics to generate a less-specific error
@@ -85967,7 +86052,7 @@ var ts;
85967
86052
  var _a, _b, _c, _d;
85968
86053
  // NOTE: assignability is checked in checkClassDeclaration
85969
86054
  var baseProperties = getPropertiesOfType(baseType);
85970
- var _loop_34 = function (baseProperty) {
86055
+ var _loop_35 = function (baseProperty) {
85971
86056
  var base = getTargetSymbol(baseProperty);
85972
86057
  if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
85973
86058
  return "continue";
@@ -86077,8 +86162,8 @@ var ts;
86077
86162
  };
86078
86163
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
86079
86164
  var baseProperty = baseProperties_1[_i];
86080
- var state_10 = _loop_34(baseProperty);
86081
- switch (state_10) {
86165
+ var state_11 = _loop_35(baseProperty);
86166
+ switch (state_11) {
86082
86167
  case "continue-basePropertyCheck": continue basePropertyCheck;
86083
86168
  }
86084
86169
  }
@@ -115319,6 +115404,7 @@ var ts;
115319
115404
  writeTrailingSemicolon();
115320
115405
  }
115321
115406
  function emitExportDeclaration(node) {
115407
+ emitModifiers(node, node.modifiers);
115322
115408
  var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node);
115323
115409
  writeSpace();
115324
115410
  if (node.isTypeOnly) {
@@ -124921,7 +125007,7 @@ var ts;
124921
125007
  });
124922
125008
  // Sort by paths closest to importing file Name directory
124923
125009
  var sortedPaths = [];
124924
- var _loop_35 = function (directory) {
125010
+ var _loop_36 = function (directory) {
124925
125011
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
124926
125012
  var pathsInDirectory;
124927
125013
  allFileNames.forEach(function (_a, fileName) {
@@ -124945,9 +125031,9 @@ var ts;
124945
125031
  };
124946
125032
  var out_directory_1;
124947
125033
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
124948
- var state_11 = _loop_35(directory);
125034
+ var state_12 = _loop_36(directory);
124949
125035
  directory = out_directory_1;
124950
- if (state_11 === "break")
125036
+ if (state_12 === "break")
124951
125037
  break;
124952
125038
  }
124953
125039
  if (allFileNames.size) {
@@ -125016,7 +125102,7 @@ var ts;
125016
125102
  }
125017
125103
  function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
125018
125104
  for (var key in paths) {
125019
- var _loop_36 = function (patternText_1) {
125105
+ var _loop_37 = function (patternText_1) {
125020
125106
  var pattern = ts.normalizePath(patternText_1);
125021
125107
  var indexOfStar = pattern.indexOf("*");
125022
125108
  // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
@@ -125083,9 +125169,9 @@ var ts;
125083
125169
  };
125084
125170
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
125085
125171
  var patternText_1 = _a[_i];
125086
- var state_12 = _loop_36(patternText_1);
125087
- if (typeof state_12 === "object")
125088
- return state_12.value;
125172
+ var state_13 = _loop_37(patternText_1);
125173
+ if (typeof state_13 === "object")
125174
+ return state_13.value;
125089
125175
  }
125090
125176
  }
125091
125177
  function validateEnding(_a) {
@@ -135424,7 +135510,7 @@ var ts;
135424
135510
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
135425
135511
  }
135426
135512
  function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
135427
- var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
135513
+ var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importStatementCompletion = completionData.importStatementCompletion, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
135428
135514
  // Verify if the file is JSX language variant
135429
135515
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) {
135430
135516
  var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
@@ -135438,7 +135524,7 @@ var ts;
135438
135524
  return undefined;
135439
135525
  }
135440
135526
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
135441
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
135527
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
135442
135528
  if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) {
135443
135529
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
135444
135530
  var keywordEntry = _a[_i];
@@ -135556,7 +135642,7 @@ var ts;
135556
135642
  function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
135557
135643
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority };
135558
135644
  }
135559
- function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
135645
+ function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importStatementCompletion, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
135560
135646
  var _a, _b;
135561
135647
  var insertText;
135562
135648
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
@@ -135612,8 +135698,8 @@ var ts;
135612
135698
  }
135613
135699
  if (originIsResolvedExport(origin)) {
135614
135700
  sourceDisplay = [ts.textPart(origin.moduleSpecifier)];
135615
- if (importCompletionNode) {
135616
- (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
135701
+ if (importStatementCompletion) {
135702
+ (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
135617
135703
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
135618
135704
  }
135619
135705
  }
@@ -135668,7 +135754,7 @@ var ts;
135668
135754
  }
135669
135755
  if (originIsExport(origin) || originIsResolvedExport(origin)) {
135670
135756
  data = originToCompletionEntryData(origin);
135671
- hasAction = !importCompletionNode;
135757
+ hasAction = !importStatementCompletion;
135672
135758
  }
135673
135759
  // TODO(drosen): Right now we just permit *all* semantic meanings when calling
135674
135760
  // 'getSymbolKind' which is permissible given that it is backwards compatible; but
@@ -135691,7 +135777,7 @@ var ts;
135691
135777
  labelDetails: labelDetails,
135692
135778
  isSnippet: isSnippet,
135693
135779
  isPackageJsonImport: originIsPackageJsonImport(origin) || undefined,
135694
- isImportStatementCompletion: !!importCompletionNode || undefined,
135780
+ isImportStatementCompletion: !!importStatementCompletion || undefined,
135695
135781
  data: data,
135696
135782
  };
135697
135783
  }
@@ -136063,19 +136149,16 @@ var ts;
136063
136149
  };
136064
136150
  return unresolvedOrigin;
136065
136151
  }
136066
- function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences) {
136067
- var _a, _b, _c;
136068
- var sourceFile = importCompletionNode.getSourceFile();
136069
- var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile);
136152
+ function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences) {
136153
+ var replacementSpan = importStatementCompletion.replacementSpan;
136070
136154
  var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier);
136071
136155
  var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ :
136072
136156
  origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ :
136073
136157
  0 /* ExportKind.Named */;
136074
136158
  var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : "";
136075
136159
  var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true);
136076
- var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly);
136077
- var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
136078
- var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : " ";
136160
+ var isImportSpecifierTypeOnly = importStatementCompletion.couldBeTypeOnlyImportSpecifier;
136161
+ var topLevelTypeOnlyText = importStatementCompletion.isTopLevelTypeOnly ? " ".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : " ";
136079
136162
  var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : "";
136080
136163
  var suffix = useSemicolons ? ";" : "";
136081
136164
  switch (importKind) {
@@ -136109,7 +136192,7 @@ var ts;
136109
136192
  return CompletionSource.TypeOnlyAlias;
136110
136193
  }
136111
136194
  }
136112
- function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag) {
136195
+ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag) {
136113
136196
  var _a;
136114
136197
  var start = ts.timestamp();
136115
136198
  var variableDeclaration = getVariableDeclaration(location);
@@ -136130,7 +136213,7 @@ var ts;
136130
136213
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
136131
136214
  var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
136132
136215
  var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
136133
- var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
136216
+ var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importStatementCompletion, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
136134
136217
  if (!entry) {
136135
136218
  continue;
136136
136219
  }
@@ -136321,7 +136404,7 @@ var ts;
136321
136404
  Completions.createCompletionDetails = createCompletionDetails;
136322
136405
  function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source, cancellationToken) {
136323
136406
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
136324
- if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
136407
+ if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementSpan) {
136325
136408
  // Import statement completion: 'import c|'
136326
136409
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
136327
136410
  }
@@ -136522,34 +136605,34 @@ var ts;
136522
136605
  var isStartingCloseTag = false;
136523
136606
  var isJsxInitializer = false;
136524
136607
  var isJsxIdentifierExpected = false;
136525
- var importCompletionNode;
136608
+ var importStatementCompletion;
136526
136609
  var location = ts.getTouchingPropertyName(sourceFile, position);
136527
136610
  var keywordFilters = 0 /* KeywordCompletionFilters.None */;
136528
136611
  var isNewIdentifierLocation = false;
136529
136612
  var flags = 0 /* CompletionInfoFlags.None */;
136530
136613
  if (contextToken) {
136531
- var importStatementCompletion = getImportStatementCompletionInfo(contextToken);
136532
- isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation;
136533
- if (importStatementCompletion.keywordCompletion) {
136534
- if (importStatementCompletion.isKeywordOnlyCompletion) {
136614
+ var importStatementCompletionInfo = getImportStatementCompletionInfo(contextToken);
136615
+ if (importStatementCompletionInfo.keywordCompletion) {
136616
+ if (importStatementCompletionInfo.isKeywordOnlyCompletion) {
136535
136617
  return {
136536
136618
  kind: 4 /* CompletionDataKind.Keywords */,
136537
- keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)],
136538
- isNewIdentifierLocation: isNewIdentifierLocation,
136619
+ keywordCompletions: [keywordToCompletionEntry(importStatementCompletionInfo.keywordCompletion)],
136620
+ isNewIdentifierLocation: importStatementCompletionInfo.isNewIdentifierLocation,
136539
136621
  };
136540
136622
  }
136541
- keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletion.keywordCompletion);
136623
+ keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletionInfo.keywordCompletion);
136542
136624
  }
136543
- if (importStatementCompletion.replacementNode && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
136625
+ if (importStatementCompletionInfo.replacementSpan && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
136544
136626
  // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier`
136545
136627
  // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature
136546
136628
  // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
136547
136629
  // to opt in with the `includeCompletionsForImportStatements` user preference.
136548
- importCompletionNode = importStatementCompletion.replacementNode;
136549
136630
  flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */;
136631
+ importStatementCompletion = importStatementCompletionInfo;
136632
+ isNewIdentifierLocation = importStatementCompletionInfo.isNewIdentifierLocation;
136550
136633
  }
136551
136634
  // Bail out if this is a known invalid completion location
136552
- if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
136635
+ if (!importStatementCompletionInfo.replacementSpan && isCompletionListBlocker(contextToken)) {
136553
136636
  log("Returning an empty list because completion was requested in an invalid position.");
136554
136637
  return keywordFilters
136555
136638
  ? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierDefinitionLocation())
@@ -136595,7 +136678,7 @@ var ts;
136595
136678
  return undefined;
136596
136679
  }
136597
136680
  }
136598
- else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) {
136681
+ else if (!importStatementCompletion) {
136599
136682
  // <UI.Test /* completion position */ />
136600
136683
  // If the tagname is a property access expression, we will then walk up to the top most of property access expression.
136601
136684
  // Then, try to get a JSX container and its associated attributes type.
@@ -136738,7 +136821,7 @@ var ts;
136738
136821
  isTypeOnlyLocation: isTypeOnlyLocation,
136739
136822
  isJsxIdentifierExpected: isJsxIdentifierExpected,
136740
136823
  isRightOfOpenTag: isRightOfOpenTag,
136741
- importCompletionNode: importCompletionNode,
136824
+ importStatementCompletion: importStatementCompletion,
136742
136825
  hasUnresolvedAutoImports: hasUnresolvedAutoImports,
136743
136826
  flags: flags,
136744
136827
  };
@@ -136992,7 +137075,7 @@ var ts;
136992
137075
  return 1 /* GlobalsSearch.Success */;
136993
137076
  }
136994
137077
  function tryGetImportCompletionSymbols() {
136995
- if (!importCompletionNode)
137078
+ if (!importStatementCompletion)
136996
137079
  return 0 /* GlobalsSearch.Continue */;
136997
137080
  isNewIdentifierLocation = true;
136998
137081
  collectAutoImports();
@@ -137075,7 +137158,7 @@ var ts;
137075
137158
  }
137076
137159
  function shouldOfferImportCompletions() {
137077
137160
  // If already typing an import statement, provide completions for it.
137078
- if (importCompletionNode)
137161
+ if (importStatementCompletion)
137079
137162
  return true;
137080
137163
  // If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols
137081
137164
  if (isNonContextualObjectLiteral)
@@ -137105,7 +137188,7 @@ var ts;
137105
137188
  }
137106
137189
  function isTypeOnlyCompletion() {
137107
137190
  return insideJsDocTagTypeExpression
137108
- || !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
137191
+ || !!importStatementCompletion && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
137109
137192
  || !isContextTokenValueLocation(contextToken) &&
137110
137193
  (ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)
137111
137194
  || ts.isPartOfTypeNode(location)
@@ -137155,8 +137238,7 @@ var ts;
137155
137238
  flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */;
137156
137239
  // import { type | -> token text should be blank
137157
137240
  var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
137158
- && importCompletionNode
137159
- && couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
137241
+ && importStatementCompletion;
137160
137242
  var lowerCaseTokenText = isAfterTypeOnlyImportSpecifierModifier ? "" :
137161
137243
  previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
137162
137244
  "";
@@ -137164,14 +137246,14 @@ var ts;
137164
137246
  var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
137165
137247
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
137166
137248
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
137167
- resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
137249
+ resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importStatementCompletion, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
137168
137250
  exportInfo.search(sourceFile.path,
137169
137251
  /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
137170
137252
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
137171
137253
  return false;
137172
137254
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
137173
137255
  return false;
137174
- if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */))
137256
+ if (!isTypeOnlyLocation && !importStatementCompletion && !(targetFlags & 111551 /* SymbolFlags.Value */))
137175
137257
  return false;
137176
137258
  if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */)))
137177
137259
  return false;
@@ -137252,7 +137334,7 @@ var ts;
137252
137334
  return;
137253
137335
  }
137254
137336
  symbolToOriginInfoMap[symbols.length] = origin;
137255
- symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
137337
+ symbolToSortTextMap[symbolId] = importStatementCompletion ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
137256
137338
  symbols.push(symbol);
137257
137339
  }
137258
137340
  /* Mutates `symbols` and `symbolToOriginInfoMap`. */
@@ -138519,6 +138601,7 @@ var ts;
138519
138601
  return undefined;
138520
138602
  }
138521
138603
  function getImportStatementCompletionInfo(contextToken) {
138604
+ var _a, _b, _c;
138522
138605
  var keywordCompletion;
138523
138606
  var isKeywordOnlyCompletion = false;
138524
138607
  var candidate = getCandidate();
@@ -138526,9 +138609,9 @@ var ts;
138526
138609
  isKeywordOnlyCompletion: isKeywordOnlyCompletion,
138527
138610
  keywordCompletion: keywordCompletion,
138528
138611
  isNewIdentifierLocation: !!(candidate || keywordCompletion === 154 /* SyntaxKind.TypeKeyword */),
138529
- replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile())
138530
- ? candidate
138531
- : undefined
138612
+ isTopLevelTypeOnly: !!((_b = (_a = ts.tryCast(candidate, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || !!((_c = ts.tryCast(candidate, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly),
138613
+ couldBeTypeOnlyImportSpecifier: !!candidate && couldBeTypeOnlyImportSpecifier(candidate, contextToken),
138614
+ replacementSpan: getSingleLineReplacementSpanForImportCompletionNode(candidate),
138532
138615
  };
138533
138616
  function getCandidate() {
138534
138617
  var parent = contextToken.parent;
@@ -138570,14 +138653,71 @@ var ts;
138570
138653
  return undefined;
138571
138654
  }
138572
138655
  }
138656
+ function getSingleLineReplacementSpanForImportCompletionNode(node) {
138657
+ var _a, _b, _c;
138658
+ if (!node)
138659
+ return undefined;
138660
+ var top = (_a = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration))) !== null && _a !== void 0 ? _a : node;
138661
+ var sourceFile = top.getSourceFile();
138662
+ if (ts.rangeIsOnSingleLine(top, sourceFile)) {
138663
+ return ts.createTextSpanFromNode(top, sourceFile);
138664
+ }
138665
+ // ImportKeyword was necessarily on one line; ImportSpecifier was necessarily parented in an ImportDeclaration
138666
+ ts.Debug.assert(top.kind !== 100 /* SyntaxKind.ImportKeyword */ && top.kind !== 273 /* SyntaxKind.ImportSpecifier */);
138667
+ // Guess which point in the import might actually be a later statement parsed as part of the import
138668
+ // during parser recovery - either in the middle of named imports, or the module specifier.
138669
+ var potentialSplitPoint = top.kind === 269 /* SyntaxKind.ImportDeclaration */
138670
+ ? (_c = getPotentiallyInvalidImportSpecifier((_b = top.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings)) !== null && _c !== void 0 ? _c : top.moduleSpecifier
138671
+ : top.moduleReference;
138672
+ var withoutModuleSpecifier = {
138673
+ pos: top.getFirstToken().getStart(),
138674
+ end: potentialSplitPoint.pos,
138675
+ };
138676
+ // The module specifier/reference was previously found to be missing, empty, or
138677
+ // not a string literal - in this last case, it's likely that statement on a following
138678
+ // line was parsed as the module specifier of a partially-typed import, e.g.
138679
+ // import Foo|
138680
+ // interface Blah {}
138681
+ // This appears to be a multiline-import, and editors can't replace multiple lines.
138682
+ // But if everything but the "module specifier" is on one line, by this point we can
138683
+ // assume that the "module specifier" is actually just another statement, and return
138684
+ // the single-line range of the import excluding that probable statement.
138685
+ if (ts.rangeIsOnSingleLine(withoutModuleSpecifier, sourceFile)) {
138686
+ return ts.createTextSpanFromRange(withoutModuleSpecifier);
138687
+ }
138688
+ }
138689
+ // Tries to identify the first named import that is not really a named import, but rather
138690
+ // just parser recovery for a situation like:
138691
+ // import { Foo|
138692
+ // interface Bar {}
138693
+ // in which `Foo`, `interface`, and `Bar` are all parsed as import specifiers. The caller
138694
+ // will also check if this token is on a separate line from the rest of the import.
138695
+ function getPotentiallyInvalidImportSpecifier(namedBindings) {
138696
+ var _a;
138697
+ return ts.find((_a = ts.tryCast(namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements, function (e) {
138698
+ var _a;
138699
+ return !e.propertyName &&
138700
+ ts.isStringANonContextualKeyword(e.name.text) &&
138701
+ ((_a = ts.findPrecedingToken(e.name.pos, namedBindings.getSourceFile(), namedBindings)) === null || _a === void 0 ? void 0 : _a.kind) !== 27 /* SyntaxKind.CommaToken */;
138702
+ });
138703
+ }
138573
138704
  function couldBeTypeOnlyImportSpecifier(importSpecifier, contextToken) {
138574
138705
  return ts.isImportSpecifier(importSpecifier)
138575
138706
  && (importSpecifier.isTypeOnly || contextToken === importSpecifier.name && ts.isTypeKeywordTokenOrIdentifier(contextToken));
138576
138707
  }
138577
138708
  function canCompleteFromNamedBindings(namedBindings) {
138578
- return isModuleSpecifierMissingOrEmpty(namedBindings.parent.parent.moduleSpecifier)
138579
- && (ts.isNamespaceImport(namedBindings) || namedBindings.elements.length < 2)
138580
- && !namedBindings.parent.name;
138709
+ if (!isModuleSpecifierMissingOrEmpty(namedBindings.parent.parent.moduleSpecifier) || namedBindings.parent.name) {
138710
+ return false;
138711
+ }
138712
+ if (ts.isNamedImports(namedBindings)) {
138713
+ // We can only complete on named imports if there are no other named imports already,
138714
+ // but parser recovery sometimes puts later statements in the named imports list, so
138715
+ // we try to only consider the probably-valid ones.
138716
+ var invalidNamedImport = getPotentiallyInvalidImportSpecifier(namedBindings);
138717
+ var validImports = invalidNamedImport ? namedBindings.elements.indexOf(invalidNamedImport) : namedBindings.elements.length;
138718
+ return validImports < 2;
138719
+ }
138720
+ return true;
138581
138721
  }
138582
138722
  function isModuleSpecifierMissingOrEmpty(specifier) {
138583
138723
  var _a;
@@ -146612,6 +146752,10 @@ var ts;
146612
146752
  pushSelectionCommentRange(comment.pos, comment.end);
146613
146753
  }
146614
146754
  if (positionShouldSnapToNode(sourceFile, pos, node)) {
146755
+ if (ts.isFunctionBody(node)
146756
+ && ts.isFunctionLikeDeclaration(parentNode) && !ts.positionsAreOnSameLine(node.getStart(sourceFile), node.getEnd(), sourceFile)) {
146757
+ pushSelectionRange(node.getStart(sourceFile), node.getEnd());
146758
+ }
146615
146759
  // 1. Blocks are effectively redundant with SyntaxLists.
146616
146760
  // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
146617
146761
  // of things that should be considered independently.
@@ -157310,7 +157454,7 @@ var ts;
157310
157454
  var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
157311
157455
  if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
157312
157456
  return;
157313
- var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
157457
+ var declaration = codefix.findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
157314
157458
  if (declaration === undefined)
157315
157459
  return;
157316
157460
  if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
@@ -157344,14 +157488,6 @@ var ts;
157344
157488
  }
157345
157489
  }
157346
157490
  }
157347
- function findAncestorMatchingSpan(sourceFile, span) {
157348
- var end = ts.textSpanEnd(span);
157349
- var token = ts.getTokenAtPosition(sourceFile, span.start);
157350
- while (token.end < end) {
157351
- token = token.parent;
157352
- }
157353
- return token;
157354
- }
157355
157491
  function tryGetConstraintFromDiagnosticMessage(messageText) {
157356
157492
  var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
157357
157493
  return constraint;
@@ -158232,7 +158368,7 @@ var ts;
158232
158368
  return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
158233
158369
  }
158234
158370
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
158235
- if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158371
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
158236
158372
  return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
158237
158373
  }
158238
158374
  return undefined;
@@ -158897,6 +159033,63 @@ var ts;
158897
159033
  })(ts || (ts = {}));
158898
159034
  /* @internal */
158899
159035
  var ts;
159036
+ (function (ts) {
159037
+ var codefix;
159038
+ (function (codefix) {
159039
+ var fixId = "fixNaNEquality";
159040
+ var errorCodes = [
159041
+ ts.Diagnostics.This_condition_will_always_return_0.code,
159042
+ ];
159043
+ codefix.registerCodeFix({
159044
+ errorCodes: errorCodes,
159045
+ getCodeActions: function (context) {
159046
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
159047
+ var info = getInfo(program, sourceFile, span);
159048
+ if (info === undefined)
159049
+ return;
159050
+ var suggestion = info.suggestion, expression = info.expression, arg = info.arg;
159051
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, arg, expression); });
159052
+ return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Use_0, suggestion], fixId, ts.Diagnostics.Use_Number_isNaN_in_all_conditions)];
159053
+ },
159054
+ fixIds: [fixId],
159055
+ getAllCodeActions: function (context) {
159056
+ return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
159057
+ var info = getInfo(context.program, diag.file, ts.createTextSpan(diag.start, diag.length));
159058
+ if (info) {
159059
+ doChange(changes, diag.file, info.arg, info.expression);
159060
+ }
159061
+ });
159062
+ }
159063
+ });
159064
+ function getInfo(program, sourceFile, span) {
159065
+ var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
159066
+ if (diag === undefined || diag.relatedInformation === undefined)
159067
+ return;
159068
+ var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_mean_0.code; });
159069
+ if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
159070
+ return;
159071
+ var token = codefix.findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
159072
+ if (token === undefined)
159073
+ return;
159074
+ if (ts.isExpression(token) && ts.isBinaryExpression(token.parent)) {
159075
+ return { suggestion: getSuggestion(related.messageText), expression: token.parent, arg: token };
159076
+ }
159077
+ return undefined;
159078
+ }
159079
+ function doChange(changes, sourceFile, arg, expression) {
159080
+ var callExpression = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Number"), ts.factory.createIdentifier("isNaN")), /*typeArguments*/ undefined, [arg]);
159081
+ var operator = expression.operatorToken.kind;
159082
+ changes.replaceNode(sourceFile, expression, operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */
159083
+ ? ts.factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, callExpression) : callExpression);
159084
+ }
159085
+ function getSuggestion(messageText) {
159086
+ var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/\'(.*)\'/) || [], _ = _a[0], suggestion = _a[1];
159087
+ return suggestion;
159088
+ }
159089
+ })(codefix = ts.codefix || (ts.codefix = {}));
159090
+ })(ts || (ts = {}));
159091
+ /* @internal */
159092
+ var ts;
158900
159093
  (function (ts) {
158901
159094
  var codefix;
158902
159095
  (function (codefix) {
@@ -161614,6 +161807,15 @@ var ts;
161614
161807
  symbols.forEach(function (s) { return importAdder.addImportFromExportedSymbol(s, /*isValidTypeOnlyUseSite*/ true); });
161615
161808
  }
161616
161809
  codefix.importSymbols = importSymbols;
161810
+ function findAncestorMatchingSpan(sourceFile, span) {
161811
+ var end = ts.textSpanEnd(span);
161812
+ var token = ts.getTokenAtPosition(sourceFile, span.start);
161813
+ while (token.end < end) {
161814
+ token = token.parent;
161815
+ }
161816
+ return token;
161817
+ }
161818
+ codefix.findAncestorMatchingSpan = findAncestorMatchingSpan;
161617
161819
  })(codefix = ts.codefix || (ts.codefix = {}));
161618
161820
  })(ts || (ts = {}));
161619
161821
  /* @internal */