typescript 4.9.0-dev.20220920 → 4.9.0-dev.20220921

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.
@@ -108,7 +108,7 @@ var ts;
108
108
  // The following is baselined as a literal template type without intervention
109
109
  /** The version of the TypeScript compiler release */
110
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
111
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220920");
111
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220921");
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -3017,7 +3017,7 @@ var ts;
3017
3017
  ];
3018
3018
  for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
3019
3019
  var ctor = nodeConstructors_1[_i];
3020
- if (!ts.hasProperty(ctor, "__debugKind")) {
3020
+ if (!ts.hasProperty(ctor.prototype, "__debugKind")) {
3021
3021
  Object.defineProperties(ctor.prototype, {
3022
3022
  // for use with vscode-js-debug's new customDescriptionGenerator in launch.json
3023
3023
  __tsDebuggerDisplay: {
@@ -9132,6 +9132,7 @@ var ts;
9132
9132
  _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?"),
9133
9133
  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."),
9134
9134
  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."),
9135
+ This_condition_will_always_return_0: diag(2845, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
9135
9136
  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}'."),
9136
9137
  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}'."),
9137
9138
  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}'."),
@@ -10074,6 +10075,8 @@ var ts;
10074
10075
  Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
10075
10076
  Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
10076
10077
  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}'"),
10078
+ Use_0: diag(95174, ts.DiagnosticCategory.Message, "Use_0_95174", "Use `{0}`."),
10079
+ Use_Number_isNaN_in_all_conditions: diag(95175, ts.DiagnosticCategory.Message, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
10077
10080
  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."),
10078
10081
  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'."),
10079
10082
  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?"),
@@ -11896,12 +11899,36 @@ var ts;
11896
11899
  pos++;
11897
11900
  return token = 0 /* SyntaxKind.Unknown */;
11898
11901
  }
11899
- if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) {
11902
+ var charAfterHash = codePointAt(text, pos + 1);
11903
+ if (charAfterHash === 92 /* CharacterCodes.backslash */) {
11900
11904
  pos++;
11901
- scanIdentifier(codePointAt(text, pos), languageVersion);
11905
+ var extendedCookedChar_1 = peekExtendedUnicodeEscape();
11906
+ if (extendedCookedChar_1 >= 0 && isIdentifierStart(extendedCookedChar_1, languageVersion)) {
11907
+ pos += 3;
11908
+ tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */;
11909
+ tokenValue = "#" + scanExtendedUnicodeEscape() + scanIdentifierParts();
11910
+ return token = 80 /* SyntaxKind.PrivateIdentifier */;
11911
+ }
11912
+ var cookedChar_1 = peekUnicodeEscape();
11913
+ if (cookedChar_1 >= 0 && isIdentifierStart(cookedChar_1, languageVersion)) {
11914
+ pos += 6;
11915
+ tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */;
11916
+ tokenValue = "#" + String.fromCharCode(cookedChar_1) + scanIdentifierParts();
11917
+ return token = 80 /* SyntaxKind.PrivateIdentifier */;
11918
+ }
11919
+ pos--;
11920
+ }
11921
+ if (isIdentifierStart(charAfterHash, languageVersion)) {
11922
+ pos++;
11923
+ // We're relying on scanIdentifier's behavior and adjusting the token kind after the fact.
11924
+ // Notably absent from this block is the fact that calling a function named "scanIdentifier",
11925
+ // but identifiers don't include '#', and that function doesn't deal with it at all.
11926
+ // This works because 'scanIdentifier' tries to reuse source characters and builds up substrings;
11927
+ // however, it starts at the 'tokenPos' which includes the '#', and will "accidentally" prepend the '#' for us.
11928
+ scanIdentifier(charAfterHash, languageVersion);
11902
11929
  }
11903
11930
  else {
11904
- tokenValue = String.fromCharCode(codePointAt(text, pos));
11931
+ tokenValue = "#";
11905
11932
  error(ts.Diagnostics.Invalid_character, pos++, charSize(ch));
11906
11933
  }
11907
11934
  return token = 80 /* SyntaxKind.PrivateIdentifier */;
@@ -33139,7 +33166,7 @@ var ts;
33139
33166
  }
33140
33167
  function parsePrivateIdentifier() {
33141
33168
  var pos = getNodePos();
33142
- var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenText()));
33169
+ var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenValue()));
33143
33170
  nextToken();
33144
33171
  return finishNode(node, pos);
33145
33172
  }
@@ -49772,6 +49799,7 @@ var ts;
49772
49799
  var deferredGlobalOmitSymbol;
49773
49800
  var deferredGlobalAwaitedSymbol;
49774
49801
  var deferredGlobalBigIntType;
49802
+ var deferredGlobalNaNSymbol;
49775
49803
  var deferredGlobalRecordSymbol;
49776
49804
  var allPotentiallyUnusedIdentifiers = new ts.Map(); // key is file name
49777
49805
  var flowLoopStart = 0;
@@ -60260,7 +60288,7 @@ var ts;
60260
60288
  var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp);
60261
60289
  // If the symbols are instances of one another with identical types - consider the symbols
60262
60290
  // equivalent and just use the first one, which thus allows us to avoid eliding private
60263
- // members when intersecting a (this-)instantiations of a class with it's raw base or another instance
60291
+ // members when intersecting a (this-)instantiations of a class with its raw base or another instance
60264
60292
  if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) {
60265
60293
  // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used
60266
60294
  // to do when we recorded multiple distinct symbols so that we still get, eg, `Array<T>.length` printed
@@ -60308,7 +60336,11 @@ var ts;
60308
60336
  }
60309
60337
  }
60310
60338
  }
60311
- if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) {
60339
+ if (!singleProp ||
60340
+ isUnion &&
60341
+ (propSet || checkFlags & 48 /* CheckFlags.Partial */) &&
60342
+ checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */) &&
60343
+ !(propSet && getCommonDeclarationsOfSymbols(ts.arrayFrom(propSet.values())))) {
60312
60344
  // No property was found, or, in a union, a property has a private or protected declaration in one
60313
60345
  // constituent, but is missing or has a different declaration in another constituent.
60314
60346
  return undefined;
@@ -60410,6 +60442,33 @@ var ts;
60410
60442
  }
60411
60443
  return property;
60412
60444
  }
60445
+ function getCommonDeclarationsOfSymbols(symbols) {
60446
+ var commonDeclarations;
60447
+ var _loop_14 = function (symbol) {
60448
+ if (!symbol.declarations) {
60449
+ return { value: undefined };
60450
+ }
60451
+ if (!commonDeclarations) {
60452
+ commonDeclarations = new ts.Set(symbol.declarations);
60453
+ return "continue";
60454
+ }
60455
+ commonDeclarations.forEach(function (declaration) {
60456
+ if (!ts.contains(symbol.declarations, declaration)) {
60457
+ commonDeclarations.delete(declaration);
60458
+ }
60459
+ });
60460
+ if (commonDeclarations.size === 0) {
60461
+ return { value: undefined };
60462
+ }
60463
+ };
60464
+ for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) {
60465
+ var symbol = symbols_3[_i];
60466
+ var state_4 = _loop_14(symbol);
60467
+ if (typeof state_4 === "object")
60468
+ return state_4.value;
60469
+ }
60470
+ return commonDeclarations;
60471
+ }
60413
60472
  function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) {
60414
60473
  var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
60415
60474
  // We need to filter out partial properties in union types
@@ -61124,7 +61183,7 @@ var ts;
61124
61183
  function getIndexInfosOfIndexSymbol(indexSymbol) {
61125
61184
  if (indexSymbol.declarations) {
61126
61185
  var indexInfos_4 = [];
61127
- var _loop_14 = function (declaration) {
61186
+ var _loop_15 = function (declaration) {
61128
61187
  if (declaration.parameters.length === 1) {
61129
61188
  var parameter = declaration.parameters[0];
61130
61189
  if (parameter.type) {
@@ -61138,7 +61197,7 @@ var ts;
61138
61197
  };
61139
61198
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
61140
61199
  var declaration = _a[_i];
61141
- _loop_14(declaration);
61200
+ _loop_15(declaration);
61142
61201
  }
61143
61202
  return indexInfos_4;
61144
61203
  }
@@ -61155,7 +61214,7 @@ var ts;
61155
61214
  var _a;
61156
61215
  var inferences;
61157
61216
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
61158
- var _loop_15 = function (declaration) {
61217
+ var _loop_16 = function (declaration) {
61159
61218
  if (declaration.parent.kind === 192 /* SyntaxKind.InferType */) {
61160
61219
  // When an 'infer T' declaration is immediately contained in a type reference node
61161
61220
  // (such as 'Foo<infer T>'), T's constraint is inferred from the constraint of the
@@ -61219,7 +61278,7 @@ var ts;
61219
61278
  };
61220
61279
  for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
61221
61280
  var declaration = _b[_i];
61222
- _loop_15(declaration);
61281
+ _loop_16(declaration);
61223
61282
  }
61224
61283
  }
61225
61284
  return inferences && getIntersectionType(inferences);
@@ -61876,6 +61935,9 @@ var ts;
61876
61935
  function getGlobalBigIntType() {
61877
61936
  return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
61878
61937
  }
61938
+ function getGlobalNaNSymbol() {
61939
+ return (deferredGlobalNaNSymbol || (deferredGlobalNaNSymbol = getGlobalValueSymbol("NaN", /*reportErrors*/ false)));
61940
+ }
61879
61941
  function getGlobalRecordSymbol() {
61880
61942
  deferredGlobalRecordSymbol || (deferredGlobalRecordSymbol = getGlobalTypeAliasSymbol("Record", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol);
61881
61943
  return deferredGlobalRecordSymbol === unknownSymbol ? undefined : deferredGlobalRecordSymbol;
@@ -62116,7 +62178,7 @@ var ts;
62116
62178
  var lastRequiredIndex = -1;
62117
62179
  var firstRestIndex = -1;
62118
62180
  var lastOptionalOrRestIndex = -1;
62119
- var _loop_16 = function (i) {
62181
+ var _loop_17 = function (i) {
62120
62182
  var type = elementTypes[i];
62121
62183
  var flags = target.elementFlags[i];
62122
62184
  if (flags & 8 /* ElementFlags.Variadic */) {
@@ -62146,9 +62208,9 @@ var ts;
62146
62208
  }
62147
62209
  };
62148
62210
  for (var i = 0; i < elementTypes.length; i++) {
62149
- var state_4 = _loop_16(i);
62150
- if (typeof state_4 === "object")
62151
- return state_4.value;
62211
+ var state_5 = _loop_17(i);
62212
+ if (typeof state_5 === "object")
62213
+ return state_5.value;
62152
62214
  }
62153
62215
  // Turn optional elements preceding the last required element into required elements
62154
62216
  for (var i = 0; i < lastRequiredIndex; i++) {
@@ -62176,7 +62238,7 @@ var ts;
62176
62238
  if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) {
62177
62239
  lastOptionalOrRestIndex = expandedFlags.length;
62178
62240
  }
62179
- expandedTypes.push(type);
62241
+ expandedTypes.push(flags & 2 /* ElementFlags.Optional */ ? addOptionality(type, /*isProperty*/ true) : type);
62180
62242
  expandedFlags.push(flags);
62181
62243
  if (expandedDeclarations && declaration) {
62182
62244
  expandedDeclarations.push(declaration);
@@ -62342,7 +62404,7 @@ var ts;
62342
62404
  var templates = ts.filter(types, isPatternLiteralType);
62343
62405
  if (templates.length) {
62344
62406
  var i = types.length;
62345
- var _loop_17 = function () {
62407
+ var _loop_18 = function () {
62346
62408
  i--;
62347
62409
  var t = types[i];
62348
62410
  if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
@@ -62350,7 +62412,7 @@ var ts;
62350
62412
  }
62351
62413
  };
62352
62414
  while (i > 0) {
62353
- _loop_17();
62415
+ _loop_18();
62354
62416
  }
62355
62417
  }
62356
62418
  }
@@ -62427,14 +62489,14 @@ var ts;
62427
62489
  var namedUnions = [];
62428
62490
  addNamedUnions(namedUnions, types);
62429
62491
  var reducedTypes = [];
62430
- var _loop_18 = function (t) {
62492
+ var _loop_19 = function (t) {
62431
62493
  if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) {
62432
62494
  reducedTypes.push(t);
62433
62495
  }
62434
62496
  };
62435
62497
  for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) {
62436
62498
  var t = typeSet_1[_i];
62437
- _loop_18(t);
62499
+ _loop_19(t);
62438
62500
  }
62439
62501
  if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) {
62440
62502
  return namedUnions[0];
@@ -63664,7 +63726,7 @@ var ts;
63664
63726
  var result;
63665
63727
  var extraTypes;
63666
63728
  var tailCount = 0;
63667
- var _loop_19 = function () {
63729
+ var _loop_20 = function () {
63668
63730
  if (tailCount === 1000) {
63669
63731
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
63670
63732
  result = errorType;
@@ -63785,10 +63847,10 @@ var ts;
63785
63847
  // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63786
63848
  // cases we increment the tail recursion counter and stop after 1000 iterations.
63787
63849
  while (true) {
63788
- var state_5 = _loop_19();
63789
- if (typeof state_5 === "object")
63790
- return state_5.value;
63791
- if (state_5 === "break")
63850
+ var state_6 = _loop_20();
63851
+ if (typeof state_6 === "object")
63852
+ return state_6.value;
63853
+ if (state_6 === "break")
63792
63854
  break;
63793
63855
  }
63794
63856
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
@@ -66403,7 +66465,7 @@ var ts;
66403
66465
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
66404
66466
  checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
66405
66467
  }
66406
- var _loop_20 = function (prop) {
66468
+ var _loop_21 = function (prop) {
66407
66469
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
66408
66470
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
66409
66471
  if (reportErrors) {
@@ -66466,9 +66528,9 @@ var ts;
66466
66528
  };
66467
66529
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
66468
66530
  var prop = _b[_i];
66469
- var state_6 = _loop_20(prop);
66470
- if (typeof state_6 === "object")
66471
- return state_6.value;
66531
+ var state_7 = _loop_21(prop);
66532
+ if (typeof state_7 === "object")
66533
+ return state_7.value;
66472
66534
  }
66473
66535
  return false;
66474
66536
  }
@@ -67459,11 +67521,11 @@ var ts;
67459
67521
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
67460
67522
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
67461
67523
  var matchingTypes = [];
67462
- var _loop_21 = function (combination) {
67524
+ var _loop_22 = function (combination) {
67463
67525
  var hasMatch = false;
67464
67526
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
67465
67527
  var type = _d[_c];
67466
- var _loop_22 = function (i) {
67528
+ var _loop_23 = function (i) {
67467
67529
  var sourceProperty = sourcePropertiesFiltered[i];
67468
67530
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
67469
67531
  if (!targetProperty)
@@ -67479,8 +67541,8 @@ var ts;
67479
67541
  }
67480
67542
  };
67481
67543
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
67482
- var state_8 = _loop_22(i);
67483
- switch (state_8) {
67544
+ var state_9 = _loop_23(i);
67545
+ switch (state_9) {
67484
67546
  case "continue-outer": continue outer;
67485
67547
  }
67486
67548
  }
@@ -67493,9 +67555,9 @@ var ts;
67493
67555
  };
67494
67556
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
67495
67557
  var combination = discriminantCombinations_1[_a];
67496
- var state_7 = _loop_21(combination);
67497
- if (typeof state_7 === "object")
67498
- return state_7.value;
67558
+ var state_8 = _loop_22(combination);
67559
+ if (typeof state_8 === "object")
67560
+ return state_8.value;
67499
67561
  }
67500
67562
  // Compare the remaining non-discriminant properties of each match.
67501
67563
  var result = -1 /* Ternary.True */;
@@ -68200,7 +68262,7 @@ var ts;
68200
68262
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
68201
68263
  links.variances = ts.emptyArray;
68202
68264
  var variances = [];
68203
- var _loop_23 = function (tp) {
68265
+ var _loop_24 = function (tp) {
68204
68266
  var modifiers = getVarianceModifiers(tp);
68205
68267
  var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
68206
68268
  modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
@@ -68238,7 +68300,7 @@ var ts;
68238
68300
  };
68239
68301
  for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
68240
68302
  var tp = typeParameters_2[_i];
68241
- _loop_23(tp);
68303
+ _loop_24(tp);
68242
68304
  }
68243
68305
  links.variances = variances;
68244
68306
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
@@ -68830,7 +68892,8 @@ var ts;
68830
68892
  function getOptionalType(type, isProperty) {
68831
68893
  if (isProperty === void 0) { isProperty = false; }
68832
68894
  ts.Debug.assert(strictNullChecks);
68833
- return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
68895
+ var missingOrUndefined = isProperty ? missingType : undefinedType;
68896
+ return type.flags & 32768 /* TypeFlags.Undefined */ || type.flags & 1048576 /* TypeFlags.Union */ && type.types[0] === missingOrUndefined ? type : getUnionType([type, missingOrUndefined]);
68834
68897
  }
68835
68898
  function getGlobalNonNullableTypeInstantiation(type) {
68836
68899
  if (!deferredGlobalNonNullableTypeAlias) {
@@ -70195,7 +70258,7 @@ var ts;
70195
70258
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
70196
70259
  // succeed. That would be a pointless and confusing outcome.
70197
70260
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
70198
- var _loop_24 = function (i) {
70261
+ var _loop_25 = function (i) {
70199
70262
  var source_1 = matches ? matches[i] : neverType;
70200
70263
  var target_3 = types[i];
70201
70264
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -70245,7 +70308,7 @@ var ts;
70245
70308
  inferFromTypes(source_1, target_3);
70246
70309
  };
70247
70310
  for (var i = 0; i < types.length; i++) {
70248
- _loop_24(i);
70311
+ _loop_25(i);
70249
70312
  }
70250
70313
  }
70251
70314
  }
@@ -70709,7 +70772,7 @@ var ts;
70709
70772
  return name;
70710
70773
  }
70711
70774
  }
70712
- if (ts.hasOnlyExpressionInitializer(declaration)) {
70775
+ if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
70713
70776
  var initializer = ts.getEffectiveInitializer(declaration);
70714
70777
  return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
70715
70778
  }
@@ -70769,7 +70832,7 @@ var ts;
70769
70832
  function mapTypesByKeyProperty(types, name) {
70770
70833
  var map = new ts.Map();
70771
70834
  var count = 0;
70772
- var _loop_25 = function (type) {
70835
+ var _loop_26 = function (type) {
70773
70836
  if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
70774
70837
  var discriminant = getTypeOfPropertyOfType(type, name);
70775
70838
  if (discriminant) {
@@ -70795,9 +70858,9 @@ var ts;
70795
70858
  };
70796
70859
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70797
70860
  var type = types_15[_i];
70798
- var state_9 = _loop_25(type);
70799
- if (typeof state_9 === "object")
70800
- return state_9.value;
70861
+ var state_10 = _loop_26(type);
70862
+ if (typeof state_10 === "object")
70863
+ return state_10.value;
70801
70864
  }
70802
70865
  return count >= 10 && count * 2 >= types.length ? map : undefined;
70803
70866
  }
@@ -77252,7 +77315,7 @@ var ts;
77252
77315
  if (spreadIndex >= 0) {
77253
77316
  // Create synthetic arguments from spreads of tuple types.
77254
77317
  var effectiveArgs_1 = args.slice(0, spreadIndex);
77255
- var _loop_26 = function (i) {
77318
+ var _loop_27 = function (i) {
77256
77319
  var arg = args[i];
77257
77320
  // We can call checkExpressionCached because spread expressions never have a contextual type.
77258
77321
  var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -77269,7 +77332,7 @@ var ts;
77269
77332
  }
77270
77333
  };
77271
77334
  for (var i = spreadIndex; i < args.length; i++) {
77272
- _loop_26(i);
77335
+ _loop_27(i);
77273
77336
  }
77274
77337
  return effectiveArgs_1;
77275
77338
  }
@@ -77598,7 +77661,7 @@ var ts;
77598
77661
  var min_3 = Number.MAX_VALUE;
77599
77662
  var minIndex = 0;
77600
77663
  var i_1 = 0;
77601
- var _loop_27 = function (c) {
77664
+ var _loop_28 = function (c) {
77602
77665
  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)); };
77603
77666
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
77604
77667
  if (diags_2) {
@@ -77616,7 +77679,7 @@ var ts;
77616
77679
  };
77617
77680
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
77618
77681
  var c = candidatesForArgumentError_1[_a];
77619
- _loop_27(c);
77682
+ _loop_28(c);
77620
77683
  }
77621
77684
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
77622
77685
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -77774,7 +77837,7 @@ var ts;
77774
77837
  }
77775
77838
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
77776
77839
  var parameters = [];
77777
- var _loop_28 = function (i) {
77840
+ var _loop_29 = function (i) {
77778
77841
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
77779
77842
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
77780
77843
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -77782,7 +77845,7 @@ var ts;
77782
77845
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
77783
77846
  };
77784
77847
  for (var i = 0; i < maxNonRestParam; i++) {
77785
- _loop_28(i);
77848
+ _loop_29(i);
77786
77849
  }
77787
77850
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
77788
77851
  var flags = 0 /* SignatureFlags.None */;
@@ -80564,6 +80627,7 @@ var ts;
80564
80627
  var eqType = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */;
80565
80628
  error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
80566
80629
  }
80630
+ checkNaNEquality(errorNode, operator, left, right);
80567
80631
  reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
80568
80632
  return booleanType;
80569
80633
  case 102 /* SyntaxKind.InstanceOfKeyword */:
@@ -80769,6 +80833,26 @@ var ts;
80769
80833
  return undefined;
80770
80834
  }
80771
80835
  }
80836
+ function checkNaNEquality(errorNode, operator, left, right) {
80837
+ var isLeftNaN = isGlobalNaN(ts.skipParentheses(left));
80838
+ var isRightNaN = isGlobalNaN(ts.skipParentheses(right));
80839
+ if (isLeftNaN || isRightNaN) {
80840
+ 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 */));
80841
+ if (isLeftNaN && isRightNaN)
80842
+ return;
80843
+ var operatorString = operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? ts.tokenToString(53 /* SyntaxKind.ExclamationToken */) : "";
80844
+ var location = isLeftNaN ? right : left;
80845
+ var expression = ts.skipParentheses(location);
80846
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(location, ts.Diagnostics.Did_you_mean_0, "".concat(operatorString, "Number.isNaN(").concat(ts.isEntityNameExpression(expression) ? ts.entityNameToString(expression) : "...", ")")));
80847
+ }
80848
+ }
80849
+ function isGlobalNaN(expr) {
80850
+ if (ts.isIdentifier(expr) && expr.escapedText === "NaN") {
80851
+ var globalNaNSymbol = getGlobalNaNSymbol();
80852
+ return !!globalNaNSymbol && globalNaNSymbol === getResolvedSymbol(expr);
80853
+ }
80854
+ return false;
80855
+ }
80772
80856
  }
80773
80857
  function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
80774
80858
  var effectiveLeft = leftType;
@@ -81806,7 +81890,7 @@ var ts;
81806
81890
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
81807
81891
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
81808
81892
  var indexSignatureMap_1 = new ts.Map();
81809
- var _loop_29 = function (declaration) {
81893
+ var _loop_30 = function (declaration) {
81810
81894
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
81811
81895
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
81812
81896
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -81821,7 +81905,7 @@ var ts;
81821
81905
  };
81822
81906
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
81823
81907
  var declaration = _a[_i];
81824
- _loop_29(declaration);
81908
+ _loop_30(declaration);
81825
81909
  }
81826
81910
  indexSignatureMap_1.forEach(function (entry) {
81827
81911
  if (entry.declarations.length > 1) {
@@ -85421,7 +85505,7 @@ var ts;
85421
85505
  var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
85422
85506
  name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
85423
85507
  var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
85424
- var _loop_30 = function (info) {
85508
+ var _loop_31 = function (info) {
85425
85509
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
85426
85510
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
85427
85511
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -85438,7 +85522,7 @@ var ts;
85438
85522
  };
85439
85523
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
85440
85524
  var info = indexInfos_9[_i];
85441
- _loop_30(info);
85525
+ _loop_31(info);
85442
85526
  }
85443
85527
  }
85444
85528
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -85446,7 +85530,7 @@ var ts;
85446
85530
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
85447
85531
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
85448
85532
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
85449
- var _loop_31 = function (info) {
85533
+ var _loop_32 = function (info) {
85450
85534
  if (info === checkInfo)
85451
85535
  return "continue";
85452
85536
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -85461,7 +85545,7 @@ var ts;
85461
85545
  };
85462
85546
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
85463
85547
  var info = indexInfos_10[_i];
85464
- _loop_31(info);
85548
+ _loop_32(info);
85465
85549
  }
85466
85550
  }
85467
85551
  function checkTypeNameIsReserved(name, message) {
@@ -85781,7 +85865,7 @@ var ts;
85781
85865
  var baseTypes = baseTypeNode && getBaseTypes(type);
85782
85866
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
85783
85867
  var baseStaticType = getBaseConstructorTypeOfClass(type);
85784
- var _loop_32 = function (member) {
85868
+ var _loop_33 = function (member) {
85785
85869
  if (ts.hasAmbientModifier(member)) {
85786
85870
  return "continue";
85787
85871
  }
@@ -85798,7 +85882,7 @@ var ts;
85798
85882
  };
85799
85883
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85800
85884
  var member = _a[_i];
85801
- _loop_32(member);
85885
+ _loop_33(member);
85802
85886
  }
85803
85887
  }
85804
85888
  /**
@@ -85886,7 +85970,7 @@ var ts;
85886
85970
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
85887
85971
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
85888
85972
  var issuedMemberError = false;
85889
- var _loop_33 = function (member) {
85973
+ var _loop_34 = function (member) {
85890
85974
  if (ts.isStatic(member)) {
85891
85975
  return "continue";
85892
85976
  }
@@ -85905,7 +85989,7 @@ var ts;
85905
85989
  };
85906
85990
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85907
85991
  var member = _a[_i];
85908
- _loop_33(member);
85992
+ _loop_34(member);
85909
85993
  }
85910
85994
  if (!issuedMemberError) {
85911
85995
  // check again with diagnostics to generate a less-specific error
@@ -85976,7 +86060,7 @@ var ts;
85976
86060
  var _a, _b, _c, _d;
85977
86061
  // NOTE: assignability is checked in checkClassDeclaration
85978
86062
  var baseProperties = getPropertiesOfType(baseType);
85979
- var _loop_34 = function (baseProperty) {
86063
+ var _loop_35 = function (baseProperty) {
85980
86064
  var base = getTargetSymbol(baseProperty);
85981
86065
  if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
85982
86066
  return "continue";
@@ -86086,8 +86170,8 @@ var ts;
86086
86170
  };
86087
86171
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
86088
86172
  var baseProperty = baseProperties_1[_i];
86089
- var state_10 = _loop_34(baseProperty);
86090
- switch (state_10) {
86173
+ var state_11 = _loop_35(baseProperty);
86174
+ switch (state_11) {
86091
86175
  case "continue-basePropertyCheck": continue basePropertyCheck;
86092
86176
  }
86093
86177
  }
@@ -124930,7 +125014,7 @@ var ts;
124930
125014
  });
124931
125015
  // Sort by paths closest to importing file Name directory
124932
125016
  var sortedPaths = [];
124933
- var _loop_35 = function (directory) {
125017
+ var _loop_36 = function (directory) {
124934
125018
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
124935
125019
  var pathsInDirectory;
124936
125020
  allFileNames.forEach(function (_a, fileName) {
@@ -124954,9 +125038,9 @@ var ts;
124954
125038
  };
124955
125039
  var out_directory_1;
124956
125040
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
124957
- var state_11 = _loop_35(directory);
125041
+ var state_12 = _loop_36(directory);
124958
125042
  directory = out_directory_1;
124959
- if (state_11 === "break")
125043
+ if (state_12 === "break")
124960
125044
  break;
124961
125045
  }
124962
125046
  if (allFileNames.size) {
@@ -125025,7 +125109,7 @@ var ts;
125025
125109
  }
125026
125110
  function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
125027
125111
  for (var key in paths) {
125028
- var _loop_36 = function (patternText_1) {
125112
+ var _loop_37 = function (patternText_1) {
125029
125113
  var pattern = ts.normalizePath(patternText_1);
125030
125114
  var indexOfStar = pattern.indexOf("*");
125031
125115
  // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
@@ -125092,9 +125176,9 @@ var ts;
125092
125176
  };
125093
125177
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
125094
125178
  var patternText_1 = _a[_i];
125095
- var state_12 = _loop_36(patternText_1);
125096
- if (typeof state_12 === "object")
125097
- return state_12.value;
125179
+ var state_13 = _loop_37(patternText_1);
125180
+ if (typeof state_13 === "object")
125181
+ return state_13.value;
125098
125182
  }
125099
125183
  }
125100
125184
  function validateEnding(_a) {
@@ -135433,7 +135517,7 @@ var ts;
135433
135517
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
135434
135518
  }
135435
135519
  function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
135436
- 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;
135520
+ 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;
135437
135521
  // Verify if the file is JSX language variant
135438
135522
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) {
135439
135523
  var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
@@ -135447,7 +135531,7 @@ var ts;
135447
135531
  return undefined;
135448
135532
  }
135449
135533
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
135450
- /*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);
135534
+ /*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);
135451
135535
  if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) {
135452
135536
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
135453
135537
  var keywordEntry = _a[_i];
@@ -135565,7 +135649,7 @@ var ts;
135565
135649
  function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
135566
135650
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority };
135567
135651
  }
135568
- function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
135652
+ function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importStatementCompletion, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
135569
135653
  var _a, _b;
135570
135654
  var insertText;
135571
135655
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
@@ -135621,8 +135705,8 @@ var ts;
135621
135705
  }
135622
135706
  if (originIsResolvedExport(origin)) {
135623
135707
  sourceDisplay = [ts.textPart(origin.moduleSpecifier)];
135624
- if (importCompletionNode) {
135625
- (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
135708
+ if (importStatementCompletion) {
135709
+ (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
135626
135710
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
135627
135711
  }
135628
135712
  }
@@ -135677,7 +135761,7 @@ var ts;
135677
135761
  }
135678
135762
  if (originIsExport(origin) || originIsResolvedExport(origin)) {
135679
135763
  data = originToCompletionEntryData(origin);
135680
- hasAction = !importCompletionNode;
135764
+ hasAction = !importStatementCompletion;
135681
135765
  }
135682
135766
  // TODO(drosen): Right now we just permit *all* semantic meanings when calling
135683
135767
  // 'getSymbolKind' which is permissible given that it is backwards compatible; but
@@ -135700,7 +135784,7 @@ var ts;
135700
135784
  labelDetails: labelDetails,
135701
135785
  isSnippet: isSnippet,
135702
135786
  isPackageJsonImport: originIsPackageJsonImport(origin) || undefined,
135703
- isImportStatementCompletion: !!importCompletionNode || undefined,
135787
+ isImportStatementCompletion: !!importStatementCompletion || undefined,
135704
135788
  data: data,
135705
135789
  };
135706
135790
  }
@@ -136072,19 +136156,16 @@ var ts;
136072
136156
  };
136073
136157
  return unresolvedOrigin;
136074
136158
  }
136075
- function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences) {
136076
- var _a, _b, _c;
136077
- var sourceFile = importCompletionNode.getSourceFile();
136078
- var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile);
136159
+ function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences) {
136160
+ var replacementSpan = importStatementCompletion.replacementSpan;
136079
136161
  var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier);
136080
136162
  var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ :
136081
136163
  origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ :
136082
136164
  0 /* ExportKind.Named */;
136083
136165
  var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : "";
136084
136166
  var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true);
136085
- 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);
136086
- var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
136087
- var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : " ";
136167
+ var isImportSpecifierTypeOnly = importStatementCompletion.couldBeTypeOnlyImportSpecifier;
136168
+ var topLevelTypeOnlyText = importStatementCompletion.isTopLevelTypeOnly ? " ".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : " ";
136088
136169
  var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : "";
136089
136170
  var suffix = useSemicolons ? ";" : "";
136090
136171
  switch (importKind) {
@@ -136118,7 +136199,7 @@ var ts;
136118
136199
  return CompletionSource.TypeOnlyAlias;
136119
136200
  }
136120
136201
  }
136121
- 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) {
136202
+ 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) {
136122
136203
  var _a;
136123
136204
  var start = ts.timestamp();
136124
136205
  var variableDeclaration = getVariableDeclaration(location);
@@ -136139,7 +136220,7 @@ var ts;
136139
136220
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
136140
136221
  var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
136141
136222
  var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
136142
- 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);
136223
+ 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);
136143
136224
  if (!entry) {
136144
136225
  continue;
136145
136226
  }
@@ -136330,7 +136411,7 @@ var ts;
136330
136411
  Completions.createCompletionDetails = createCompletionDetails;
136331
136412
  function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source, cancellationToken) {
136332
136413
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
136333
- if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
136414
+ if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementSpan) {
136334
136415
  // Import statement completion: 'import c|'
136335
136416
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
136336
136417
  }
@@ -136531,34 +136612,34 @@ var ts;
136531
136612
  var isStartingCloseTag = false;
136532
136613
  var isJsxInitializer = false;
136533
136614
  var isJsxIdentifierExpected = false;
136534
- var importCompletionNode;
136615
+ var importStatementCompletion;
136535
136616
  var location = ts.getTouchingPropertyName(sourceFile, position);
136536
136617
  var keywordFilters = 0 /* KeywordCompletionFilters.None */;
136537
136618
  var isNewIdentifierLocation = false;
136538
136619
  var flags = 0 /* CompletionInfoFlags.None */;
136539
136620
  if (contextToken) {
136540
- var importStatementCompletion = getImportStatementCompletionInfo(contextToken);
136541
- isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation;
136542
- if (importStatementCompletion.keywordCompletion) {
136543
- if (importStatementCompletion.isKeywordOnlyCompletion) {
136621
+ var importStatementCompletionInfo = getImportStatementCompletionInfo(contextToken);
136622
+ if (importStatementCompletionInfo.keywordCompletion) {
136623
+ if (importStatementCompletionInfo.isKeywordOnlyCompletion) {
136544
136624
  return {
136545
136625
  kind: 4 /* CompletionDataKind.Keywords */,
136546
- keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)],
136547
- isNewIdentifierLocation: isNewIdentifierLocation,
136626
+ keywordCompletions: [keywordToCompletionEntry(importStatementCompletionInfo.keywordCompletion)],
136627
+ isNewIdentifierLocation: importStatementCompletionInfo.isNewIdentifierLocation,
136548
136628
  };
136549
136629
  }
136550
- keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletion.keywordCompletion);
136630
+ keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletionInfo.keywordCompletion);
136551
136631
  }
136552
- if (importStatementCompletion.replacementNode && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
136632
+ if (importStatementCompletionInfo.replacementSpan && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
136553
136633
  // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier`
136554
136634
  // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature
136555
136635
  // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
136556
136636
  // to opt in with the `includeCompletionsForImportStatements` user preference.
136557
- importCompletionNode = importStatementCompletion.replacementNode;
136558
136637
  flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */;
136638
+ importStatementCompletion = importStatementCompletionInfo;
136639
+ isNewIdentifierLocation = importStatementCompletionInfo.isNewIdentifierLocation;
136559
136640
  }
136560
136641
  // Bail out if this is a known invalid completion location
136561
- if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
136642
+ if (!importStatementCompletionInfo.replacementSpan && isCompletionListBlocker(contextToken)) {
136562
136643
  log("Returning an empty list because completion was requested in an invalid position.");
136563
136644
  return keywordFilters
136564
136645
  ? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierDefinitionLocation())
@@ -136604,7 +136685,7 @@ var ts;
136604
136685
  return undefined;
136605
136686
  }
136606
136687
  }
136607
- else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) {
136688
+ else if (!importStatementCompletion) {
136608
136689
  // <UI.Test /* completion position */ />
136609
136690
  // If the tagname is a property access expression, we will then walk up to the top most of property access expression.
136610
136691
  // Then, try to get a JSX container and its associated attributes type.
@@ -136747,7 +136828,7 @@ var ts;
136747
136828
  isTypeOnlyLocation: isTypeOnlyLocation,
136748
136829
  isJsxIdentifierExpected: isJsxIdentifierExpected,
136749
136830
  isRightOfOpenTag: isRightOfOpenTag,
136750
- importCompletionNode: importCompletionNode,
136831
+ importStatementCompletion: importStatementCompletion,
136751
136832
  hasUnresolvedAutoImports: hasUnresolvedAutoImports,
136752
136833
  flags: flags,
136753
136834
  };
@@ -137001,7 +137082,7 @@ var ts;
137001
137082
  return 1 /* GlobalsSearch.Success */;
137002
137083
  }
137003
137084
  function tryGetImportCompletionSymbols() {
137004
- if (!importCompletionNode)
137085
+ if (!importStatementCompletion)
137005
137086
  return 0 /* GlobalsSearch.Continue */;
137006
137087
  isNewIdentifierLocation = true;
137007
137088
  collectAutoImports();
@@ -137084,7 +137165,7 @@ var ts;
137084
137165
  }
137085
137166
  function shouldOfferImportCompletions() {
137086
137167
  // If already typing an import statement, provide completions for it.
137087
- if (importCompletionNode)
137168
+ if (importStatementCompletion)
137088
137169
  return true;
137089
137170
  // If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols
137090
137171
  if (isNonContextualObjectLiteral)
@@ -137114,7 +137195,7 @@ var ts;
137114
137195
  }
137115
137196
  function isTypeOnlyCompletion() {
137116
137197
  return insideJsDocTagTypeExpression
137117
- || !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
137198
+ || !!importStatementCompletion && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
137118
137199
  || !isContextTokenValueLocation(contextToken) &&
137119
137200
  (ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)
137120
137201
  || ts.isPartOfTypeNode(location)
@@ -137164,8 +137245,7 @@ var ts;
137164
137245
  flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */;
137165
137246
  // import { type | -> token text should be blank
137166
137247
  var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
137167
- && importCompletionNode
137168
- && couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
137248
+ && importStatementCompletion;
137169
137249
  var lowerCaseTokenText = isAfterTypeOnlyImportSpecifierModifier ? "" :
137170
137250
  previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
137171
137251
  "";
@@ -137173,14 +137253,14 @@ var ts;
137173
137253
  var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
137174
137254
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
137175
137255
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
137176
- resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
137256
+ resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importStatementCompletion, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
137177
137257
  exportInfo.search(sourceFile.path,
137178
137258
  /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
137179
137259
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
137180
137260
  return false;
137181
137261
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
137182
137262
  return false;
137183
- if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */))
137263
+ if (!isTypeOnlyLocation && !importStatementCompletion && !(targetFlags & 111551 /* SymbolFlags.Value */))
137184
137264
  return false;
137185
137265
  if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */)))
137186
137266
  return false;
@@ -137261,7 +137341,7 @@ var ts;
137261
137341
  return;
137262
137342
  }
137263
137343
  symbolToOriginInfoMap[symbols.length] = origin;
137264
- symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
137344
+ symbolToSortTextMap[symbolId] = importStatementCompletion ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
137265
137345
  symbols.push(symbol);
137266
137346
  }
137267
137347
  /* Mutates `symbols` and `symbolToOriginInfoMap`. */
@@ -138528,6 +138608,7 @@ var ts;
138528
138608
  return undefined;
138529
138609
  }
138530
138610
  function getImportStatementCompletionInfo(contextToken) {
138611
+ var _a, _b, _c;
138531
138612
  var keywordCompletion;
138532
138613
  var isKeywordOnlyCompletion = false;
138533
138614
  var candidate = getCandidate();
@@ -138535,9 +138616,9 @@ var ts;
138535
138616
  isKeywordOnlyCompletion: isKeywordOnlyCompletion,
138536
138617
  keywordCompletion: keywordCompletion,
138537
138618
  isNewIdentifierLocation: !!(candidate || keywordCompletion === 154 /* SyntaxKind.TypeKeyword */),
138538
- replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile())
138539
- ? candidate
138540
- : undefined
138619
+ 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),
138620
+ couldBeTypeOnlyImportSpecifier: !!candidate && couldBeTypeOnlyImportSpecifier(candidate, contextToken),
138621
+ replacementSpan: getSingleLineReplacementSpanForImportCompletionNode(candidate),
138541
138622
  };
138542
138623
  function getCandidate() {
138543
138624
  var parent = contextToken.parent;
@@ -138579,14 +138660,71 @@ var ts;
138579
138660
  return undefined;
138580
138661
  }
138581
138662
  }
138663
+ function getSingleLineReplacementSpanForImportCompletionNode(node) {
138664
+ var _a, _b, _c;
138665
+ if (!node)
138666
+ return undefined;
138667
+ var top = (_a = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration))) !== null && _a !== void 0 ? _a : node;
138668
+ var sourceFile = top.getSourceFile();
138669
+ if (ts.rangeIsOnSingleLine(top, sourceFile)) {
138670
+ return ts.createTextSpanFromNode(top, sourceFile);
138671
+ }
138672
+ // ImportKeyword was necessarily on one line; ImportSpecifier was necessarily parented in an ImportDeclaration
138673
+ ts.Debug.assert(top.kind !== 100 /* SyntaxKind.ImportKeyword */ && top.kind !== 273 /* SyntaxKind.ImportSpecifier */);
138674
+ // Guess which point in the import might actually be a later statement parsed as part of the import
138675
+ // during parser recovery - either in the middle of named imports, or the module specifier.
138676
+ var potentialSplitPoint = top.kind === 269 /* SyntaxKind.ImportDeclaration */
138677
+ ? (_c = getPotentiallyInvalidImportSpecifier((_b = top.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings)) !== null && _c !== void 0 ? _c : top.moduleSpecifier
138678
+ : top.moduleReference;
138679
+ var withoutModuleSpecifier = {
138680
+ pos: top.getFirstToken().getStart(),
138681
+ end: potentialSplitPoint.pos,
138682
+ };
138683
+ // The module specifier/reference was previously found to be missing, empty, or
138684
+ // not a string literal - in this last case, it's likely that statement on a following
138685
+ // line was parsed as the module specifier of a partially-typed import, e.g.
138686
+ // import Foo|
138687
+ // interface Blah {}
138688
+ // This appears to be a multiline-import, and editors can't replace multiple lines.
138689
+ // But if everything but the "module specifier" is on one line, by this point we can
138690
+ // assume that the "module specifier" is actually just another statement, and return
138691
+ // the single-line range of the import excluding that probable statement.
138692
+ if (ts.rangeIsOnSingleLine(withoutModuleSpecifier, sourceFile)) {
138693
+ return ts.createTextSpanFromRange(withoutModuleSpecifier);
138694
+ }
138695
+ }
138696
+ // Tries to identify the first named import that is not really a named import, but rather
138697
+ // just parser recovery for a situation like:
138698
+ // import { Foo|
138699
+ // interface Bar {}
138700
+ // in which `Foo`, `interface`, and `Bar` are all parsed as import specifiers. The caller
138701
+ // will also check if this token is on a separate line from the rest of the import.
138702
+ function getPotentiallyInvalidImportSpecifier(namedBindings) {
138703
+ var _a;
138704
+ return ts.find((_a = ts.tryCast(namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements, function (e) {
138705
+ var _a;
138706
+ return !e.propertyName &&
138707
+ ts.isStringANonContextualKeyword(e.name.text) &&
138708
+ ((_a = ts.findPrecedingToken(e.name.pos, namedBindings.getSourceFile(), namedBindings)) === null || _a === void 0 ? void 0 : _a.kind) !== 27 /* SyntaxKind.CommaToken */;
138709
+ });
138710
+ }
138582
138711
  function couldBeTypeOnlyImportSpecifier(importSpecifier, contextToken) {
138583
138712
  return ts.isImportSpecifier(importSpecifier)
138584
138713
  && (importSpecifier.isTypeOnly || contextToken === importSpecifier.name && ts.isTypeKeywordTokenOrIdentifier(contextToken));
138585
138714
  }
138586
138715
  function canCompleteFromNamedBindings(namedBindings) {
138587
- return isModuleSpecifierMissingOrEmpty(namedBindings.parent.parent.moduleSpecifier)
138588
- && (ts.isNamespaceImport(namedBindings) || namedBindings.elements.length < 2)
138589
- && !namedBindings.parent.name;
138716
+ if (!isModuleSpecifierMissingOrEmpty(namedBindings.parent.parent.moduleSpecifier) || namedBindings.parent.name) {
138717
+ return false;
138718
+ }
138719
+ if (ts.isNamedImports(namedBindings)) {
138720
+ // We can only complete on named imports if there are no other named imports already,
138721
+ // but parser recovery sometimes puts later statements in the named imports list, so
138722
+ // we try to only consider the probably-valid ones.
138723
+ var invalidNamedImport = getPotentiallyInvalidImportSpecifier(namedBindings);
138724
+ var validImports = invalidNamedImport ? namedBindings.elements.indexOf(invalidNamedImport) : namedBindings.elements.length;
138725
+ return validImports < 2;
138726
+ }
138727
+ return true;
138590
138728
  }
138591
138729
  function isModuleSpecifierMissingOrEmpty(specifier) {
138592
138730
  var _a;
@@ -157319,7 +157457,7 @@ var ts;
157319
157457
  var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
157320
157458
  if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
157321
157459
  return;
157322
- var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
157460
+ var declaration = codefix.findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
157323
157461
  if (declaration === undefined)
157324
157462
  return;
157325
157463
  if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
@@ -157353,14 +157491,6 @@ var ts;
157353
157491
  }
157354
157492
  }
157355
157493
  }
157356
- function findAncestorMatchingSpan(sourceFile, span) {
157357
- var end = ts.textSpanEnd(span);
157358
- var token = ts.getTokenAtPosition(sourceFile, span.start);
157359
- while (token.end < end) {
157360
- token = token.parent;
157361
- }
157362
- return token;
157363
- }
157364
157494
  function tryGetConstraintFromDiagnosticMessage(messageText) {
157365
157495
  var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
157366
157496
  return constraint;
@@ -158906,6 +159036,63 @@ var ts;
158906
159036
  })(ts || (ts = {}));
158907
159037
  /* @internal */
158908
159038
  var ts;
159039
+ (function (ts) {
159040
+ var codefix;
159041
+ (function (codefix) {
159042
+ var fixId = "fixNaNEquality";
159043
+ var errorCodes = [
159044
+ ts.Diagnostics.This_condition_will_always_return_0.code,
159045
+ ];
159046
+ codefix.registerCodeFix({
159047
+ errorCodes: errorCodes,
159048
+ getCodeActions: function (context) {
159049
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
159050
+ var info = getInfo(program, sourceFile, span);
159051
+ if (info === undefined)
159052
+ return;
159053
+ var suggestion = info.suggestion, expression = info.expression, arg = info.arg;
159054
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, arg, expression); });
159055
+ return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Use_0, suggestion], fixId, ts.Diagnostics.Use_Number_isNaN_in_all_conditions)];
159056
+ },
159057
+ fixIds: [fixId],
159058
+ getAllCodeActions: function (context) {
159059
+ return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
159060
+ var info = getInfo(context.program, diag.file, ts.createTextSpan(diag.start, diag.length));
159061
+ if (info) {
159062
+ doChange(changes, diag.file, info.arg, info.expression);
159063
+ }
159064
+ });
159065
+ }
159066
+ });
159067
+ function getInfo(program, sourceFile, span) {
159068
+ var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
159069
+ if (diag === undefined || diag.relatedInformation === undefined)
159070
+ return;
159071
+ var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_mean_0.code; });
159072
+ if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
159073
+ return;
159074
+ var token = codefix.findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
159075
+ if (token === undefined)
159076
+ return;
159077
+ if (ts.isExpression(token) && ts.isBinaryExpression(token.parent)) {
159078
+ return { suggestion: getSuggestion(related.messageText), expression: token.parent, arg: token };
159079
+ }
159080
+ return undefined;
159081
+ }
159082
+ function doChange(changes, sourceFile, arg, expression) {
159083
+ var callExpression = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Number"), ts.factory.createIdentifier("isNaN")), /*typeArguments*/ undefined, [arg]);
159084
+ var operator = expression.operatorToken.kind;
159085
+ changes.replaceNode(sourceFile, expression, operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */
159086
+ ? ts.factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, callExpression) : callExpression);
159087
+ }
159088
+ function getSuggestion(messageText) {
159089
+ var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/\'(.*)\'/) || [], _ = _a[0], suggestion = _a[1];
159090
+ return suggestion;
159091
+ }
159092
+ })(codefix = ts.codefix || (ts.codefix = {}));
159093
+ })(ts || (ts = {}));
159094
+ /* @internal */
159095
+ var ts;
158909
159096
  (function (ts) {
158910
159097
  var codefix;
158911
159098
  (function (codefix) {
@@ -161623,6 +161810,15 @@ var ts;
161623
161810
  symbols.forEach(function (s) { return importAdder.addImportFromExportedSymbol(s, /*isValidTypeOnlyUseSite*/ true); });
161624
161811
  }
161625
161812
  codefix.importSymbols = importSymbols;
161813
+ function findAncestorMatchingSpan(sourceFile, span) {
161814
+ var end = ts.textSpanEnd(span);
161815
+ var token = ts.getTokenAtPosition(sourceFile, span.start);
161816
+ while (token.end < end) {
161817
+ token = token.parent;
161818
+ }
161819
+ return token;
161820
+ }
161821
+ codefix.findAncestorMatchingSpan = findAncestorMatchingSpan;
161626
161822
  })(codefix = ts.codefix || (ts.codefix = {}));
161627
161823
  })(ts || (ts = {}));
161628
161824
  /* @internal */