typescript 4.9.0-dev.20220919 → 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.20220919");
111
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220921");
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -2692,7 +2692,7 @@ var ts;
2692
2692
  if (typeof func !== "function") {
2693
2693
  return "";
2694
2694
  }
2695
- else if (func.hasOwnProperty("name")) {
2695
+ else if (ts.hasProperty(func, "name")) {
2696
2696
  return func.name;
2697
2697
  }
2698
2698
  else {
@@ -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 (!ctor.prototype.hasOwnProperty("__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: {
@@ -3872,7 +3872,6 @@ var ts;
3872
3872
  var typeCatalog = []; // NB: id is index + 1
3873
3873
  var legendPath;
3874
3874
  var legend = [];
3875
- ;
3876
3875
  /** Starts tracing for the given project. */
3877
3876
  function startTracing(tracingMode, traceDir, configFilePath) {
3878
3877
  ts.Debug.assert(!ts.tracing, "Tracing already started");
@@ -8704,8 +8703,6 @@ var ts;
8704
8703
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
8705
8704
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
8706
8705
  The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
8707
- The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or__2360", "The left-hand side of an 'in' expression must be a private identifier or of type 'any', 'string', 'number', or 'symbol'."),
8708
- The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."),
8709
8706
  The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
8710
8707
  The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
8711
8708
  The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."),
@@ -8954,6 +8951,7 @@ var ts;
8954
8951
  Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
8955
8952
  Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."),
8956
8953
  Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."),
8954
+ Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operator: diag(2638, ts.DiagnosticCategory.Error, "Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operato_2638", "Type '{0}' may represent a primitive value, which is not permitted as the right operand of the 'in' operator."),
8957
8955
  Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
8958
8956
  A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
8959
8957
  Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
@@ -9134,6 +9132,7 @@ var ts;
9134
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?"),
9135
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."),
9136
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}'."),
9137
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}'."),
9138
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}'."),
9139
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}'."),
@@ -10076,6 +10075,8 @@ var ts;
10076
10075
  Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
10077
10076
  Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
10078
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."),
10079
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."),
10080
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'."),
10081
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?"),
@@ -10337,7 +10338,7 @@ var ts;
10337
10338
  ts.stringToToken = stringToToken;
10338
10339
  /* @internal */
10339
10340
  function computeLineStarts(text) {
10340
- var result = new Array();
10341
+ var result = [];
10341
10342
  var pos = 0;
10342
10343
  var lineStart = 0;
10343
10344
  while (pos < text.length) {
@@ -11898,12 +11899,36 @@ var ts;
11898
11899
  pos++;
11899
11900
  return token = 0 /* SyntaxKind.Unknown */;
11900
11901
  }
11901
- if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) {
11902
+ var charAfterHash = codePointAt(text, pos + 1);
11903
+ if (charAfterHash === 92 /* CharacterCodes.backslash */) {
11904
+ pos++;
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)) {
11902
11922
  pos++;
11903
- scanIdentifier(codePointAt(text, pos), languageVersion);
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);
11904
11929
  }
11905
11930
  else {
11906
- tokenValue = String.fromCharCode(codePointAt(text, pos));
11931
+ tokenValue = "#";
11907
11932
  error(ts.Diagnostics.Invalid_character, pos++, charSize(ch));
11908
11933
  }
11909
11934
  return token = 80 /* SyntaxKind.PrivateIdentifier */;
@@ -13470,7 +13495,7 @@ var ts;
13470
13495
  // Node Arrays
13471
13496
  /* @internal */
13472
13497
  function isNodeArray(array) {
13473
- return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
13498
+ return ts.hasProperty(array, "pos") && ts.hasProperty(array, "end");
13474
13499
  }
13475
13500
  ts.isNodeArray = isNodeArray;
13476
13501
  // Literals
@@ -14942,7 +14967,6 @@ var ts;
14942
14967
  return emitNode && emitNode.flags || 0;
14943
14968
  }
14944
14969
  ts.getEmitFlags = getEmitFlags;
14945
- ;
14946
14970
  function getScriptTargetFeatures() {
14947
14971
  return {
14948
14972
  es2015: {
@@ -19668,7 +19692,7 @@ var ts;
19668
19692
  }
19669
19693
  function isWatchSet(options) {
19670
19694
  // Firefox has Object.prototype.watch
19671
- return options.watch && options.hasOwnProperty("watch");
19695
+ return options.watch && ts.hasProperty(options, "watch");
19672
19696
  }
19673
19697
  ts.isWatchSet = isWatchSet;
19674
19698
  function closeFileWatcher(watcher) {
@@ -26953,7 +26977,7 @@ var ts;
26953
26977
  clone.transformFlags = node.transformFlags;
26954
26978
  setOriginalNode(clone, node);
26955
26979
  for (var key in node) {
26956
- if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) {
26980
+ if (ts.hasProperty(clone, key) || !ts.hasProperty(node, key)) {
26957
26981
  continue;
26958
26982
  }
26959
26983
  clone[key] = node[key];
@@ -31841,7 +31865,6 @@ var ts;
31841
31865
  visitNodes(cbNode, cbNodes, node.parameters) ||
31842
31866
  visitNode(cbNode, node.type);
31843
31867
  }
31844
- ;
31845
31868
  function forEachChildInUnionOrIntersectionType(node, cbNode, cbNodes) {
31846
31869
  return visitNodes(cbNode, cbNodes, node.types);
31847
31870
  }
@@ -33143,7 +33166,7 @@ var ts;
33143
33166
  }
33144
33167
  function parsePrivateIdentifier() {
33145
33168
  var pos = getNodePos();
33146
- var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenText()));
33169
+ var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenValue()));
33147
33170
  nextToken();
33148
33171
  return finishNode(node, pos);
33149
33172
  }
@@ -43157,7 +43180,7 @@ var ts;
43157
43180
  function convertCompilerOptionsForTelemetry(opts) {
43158
43181
  var out = {};
43159
43182
  for (var key in opts) {
43160
- if (opts.hasOwnProperty(key)) {
43183
+ if (ts.hasProperty(opts, key)) {
43161
43184
  var type = getOptionFromName(key);
43162
43185
  if (type !== undefined) { // Ignore unknown options
43163
43186
  out[key] = getOptionValueWithEmptyStrings(opts[key], type);
@@ -49661,7 +49684,8 @@ var ts;
49661
49684
  var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */);
49662
49685
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
49663
49686
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49664
- var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
49687
+ var unknownEmptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49688
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, unknownEmptyObjectType]) : unknownType;
49665
49689
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49666
49690
  emptyGenericType.instantiations = new ts.Map();
49667
49691
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -49775,6 +49799,8 @@ var ts;
49775
49799
  var deferredGlobalOmitSymbol;
49776
49800
  var deferredGlobalAwaitedSymbol;
49777
49801
  var deferredGlobalBigIntType;
49802
+ var deferredGlobalNaNSymbol;
49803
+ var deferredGlobalRecordSymbol;
49778
49804
  var allPotentiallyUnusedIdentifiers = new ts.Map(); // key is file name
49779
49805
  var flowLoopStart = 0;
49780
49806
  var flowLoopCount = 0;
@@ -50570,12 +50596,13 @@ var ts;
50570
50596
  * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
50571
50597
  * the given name can be found.
50572
50598
  *
50599
+ * @param nameNotFoundMessage If defined, we will report errors found during resolve.
50573
50600
  * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
50574
50601
  */
50575
- function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
50602
+ function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions) {
50576
50603
  if (excludeGlobals === void 0) { excludeGlobals = false; }
50577
- if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
50578
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
50604
+ if (getSpellingSuggestions === void 0) { getSpellingSuggestions = true; }
50605
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol);
50579
50606
  }
50580
50607
  function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
50581
50608
  var _a, _b, _c;
@@ -50733,7 +50760,9 @@ var ts;
50733
50760
  // TypeScript 1.0 spec (April 2014): 3.4.1
50734
50761
  // The scope of a type parameter extends over the entire declaration with which the type
50735
50762
  // parameter list is associated, with the exception of static member declarations in classes.
50736
- error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
50763
+ if (nameNotFoundMessage) {
50764
+ error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
50765
+ }
50737
50766
  return undefined;
50738
50767
  }
50739
50768
  break loop;
@@ -50771,7 +50800,9 @@ var ts;
50771
50800
  if (ts.isClassLike(grandparent) || grandparent.kind === 261 /* SyntaxKind.InterfaceDeclaration */) {
50772
50801
  // A reference to this grandparent's type parameters would be an error
50773
50802
  if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) {
50774
- error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
50803
+ if (nameNotFoundMessage) {
50804
+ error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
50805
+ }
50775
50806
  return undefined;
50776
50807
  }
50777
50808
  }
@@ -50967,7 +50998,7 @@ var ts;
50967
50998
  }
50968
50999
  return undefined;
50969
51000
  }
50970
- else if (checkAndReportErrorForInvalidInitializer()) {
51001
+ else if (nameNotFoundMessage && checkAndReportErrorForInvalidInitializer()) {
50971
51002
  return undefined;
50972
51003
  }
50973
51004
  // Perform extra checks only if error reporting was requested
@@ -57128,7 +57159,6 @@ var ts;
57128
57159
  return container;
57129
57160
  }
57130
57161
  }
57131
- ;
57132
57162
  }
57133
57163
  /** Create a synthetic property access flow node after the last statement of the file */
57134
57164
  function getFlowTypeFromCommonJSExport(symbol) {
@@ -60258,7 +60288,7 @@ var ts;
60258
60288
  var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp);
60259
60289
  // If the symbols are instances of one another with identical types - consider the symbols
60260
60290
  // equivalent and just use the first one, which thus allows us to avoid eliding private
60261
- // 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
60262
60292
  if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) {
60263
60293
  // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used
60264
60294
  // to do when we recorded multiple distinct symbols so that we still get, eg, `Array<T>.length` printed
@@ -60306,7 +60336,11 @@ var ts;
60306
60336
  }
60307
60337
  }
60308
60338
  }
60309
- 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())))) {
60310
60344
  // No property was found, or, in a union, a property has a private or protected declaration in one
60311
60345
  // constituent, but is missing or has a different declaration in another constituent.
60312
60346
  return undefined;
@@ -60408,6 +60442,33 @@ var ts;
60408
60442
  }
60409
60443
  return property;
60410
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
+ }
60411
60472
  function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) {
60412
60473
  var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
60413
60474
  // We need to filter out partial properties in union types
@@ -61122,7 +61183,7 @@ var ts;
61122
61183
  function getIndexInfosOfIndexSymbol(indexSymbol) {
61123
61184
  if (indexSymbol.declarations) {
61124
61185
  var indexInfos_4 = [];
61125
- var _loop_14 = function (declaration) {
61186
+ var _loop_15 = function (declaration) {
61126
61187
  if (declaration.parameters.length === 1) {
61127
61188
  var parameter = declaration.parameters[0];
61128
61189
  if (parameter.type) {
@@ -61136,7 +61197,7 @@ var ts;
61136
61197
  };
61137
61198
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
61138
61199
  var declaration = _a[_i];
61139
- _loop_14(declaration);
61200
+ _loop_15(declaration);
61140
61201
  }
61141
61202
  return indexInfos_4;
61142
61203
  }
@@ -61153,7 +61214,7 @@ var ts;
61153
61214
  var _a;
61154
61215
  var inferences;
61155
61216
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
61156
- var _loop_15 = function (declaration) {
61217
+ var _loop_16 = function (declaration) {
61157
61218
  if (declaration.parent.kind === 192 /* SyntaxKind.InferType */) {
61158
61219
  // When an 'infer T' declaration is immediately contained in a type reference node
61159
61220
  // (such as 'Foo<infer T>'), T's constraint is inferred from the constraint of the
@@ -61217,7 +61278,7 @@ var ts;
61217
61278
  };
61218
61279
  for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) {
61219
61280
  var declaration = _b[_i];
61220
- _loop_15(declaration);
61281
+ _loop_16(declaration);
61221
61282
  }
61222
61283
  }
61223
61284
  return inferences && getIntersectionType(inferences);
@@ -61874,6 +61935,13 @@ var ts;
61874
61935
  function getGlobalBigIntType() {
61875
61936
  return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
61876
61937
  }
61938
+ function getGlobalNaNSymbol() {
61939
+ return (deferredGlobalNaNSymbol || (deferredGlobalNaNSymbol = getGlobalValueSymbol("NaN", /*reportErrors*/ false)));
61940
+ }
61941
+ function getGlobalRecordSymbol() {
61942
+ deferredGlobalRecordSymbol || (deferredGlobalRecordSymbol = getGlobalTypeAliasSymbol("Record", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol);
61943
+ return deferredGlobalRecordSymbol === unknownSymbol ? undefined : deferredGlobalRecordSymbol;
61944
+ }
61877
61945
  /**
61878
61946
  * Instantiates a global type that is generic with some element type, and returns that instantiation.
61879
61947
  */
@@ -62110,7 +62178,7 @@ var ts;
62110
62178
  var lastRequiredIndex = -1;
62111
62179
  var firstRestIndex = -1;
62112
62180
  var lastOptionalOrRestIndex = -1;
62113
- var _loop_16 = function (i) {
62181
+ var _loop_17 = function (i) {
62114
62182
  var type = elementTypes[i];
62115
62183
  var flags = target.elementFlags[i];
62116
62184
  if (flags & 8 /* ElementFlags.Variadic */) {
@@ -62140,9 +62208,9 @@ var ts;
62140
62208
  }
62141
62209
  };
62142
62210
  for (var i = 0; i < elementTypes.length; i++) {
62143
- var state_4 = _loop_16(i);
62144
- if (typeof state_4 === "object")
62145
- return state_4.value;
62211
+ var state_5 = _loop_17(i);
62212
+ if (typeof state_5 === "object")
62213
+ return state_5.value;
62146
62214
  }
62147
62215
  // Turn optional elements preceding the last required element into required elements
62148
62216
  for (var i = 0; i < lastRequiredIndex; i++) {
@@ -62170,7 +62238,7 @@ var ts;
62170
62238
  if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) {
62171
62239
  lastOptionalOrRestIndex = expandedFlags.length;
62172
62240
  }
62173
- expandedTypes.push(type);
62241
+ expandedTypes.push(flags & 2 /* ElementFlags.Optional */ ? addOptionality(type, /*isProperty*/ true) : type);
62174
62242
  expandedFlags.push(flags);
62175
62243
  if (expandedDeclarations && declaration) {
62176
62244
  expandedDeclarations.push(declaration);
@@ -62336,7 +62404,7 @@ var ts;
62336
62404
  var templates = ts.filter(types, isPatternLiteralType);
62337
62405
  if (templates.length) {
62338
62406
  var i = types.length;
62339
- var _loop_17 = function () {
62407
+ var _loop_18 = function () {
62340
62408
  i--;
62341
62409
  var t = types[i];
62342
62410
  if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
@@ -62344,7 +62412,7 @@ var ts;
62344
62412
  }
62345
62413
  };
62346
62414
  while (i > 0) {
62347
- _loop_17();
62415
+ _loop_18();
62348
62416
  }
62349
62417
  }
62350
62418
  }
@@ -62421,14 +62489,14 @@ var ts;
62421
62489
  var namedUnions = [];
62422
62490
  addNamedUnions(namedUnions, types);
62423
62491
  var reducedTypes = [];
62424
- var _loop_18 = function (t) {
62492
+ var _loop_19 = function (t) {
62425
62493
  if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) {
62426
62494
  reducedTypes.push(t);
62427
62495
  }
62428
62496
  };
62429
62497
  for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) {
62430
62498
  var t = typeSet_1[_i];
62431
- _loop_18(t);
62499
+ _loop_19(t);
62432
62500
  }
62433
62501
  if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) {
62434
62502
  return namedUnions[0];
@@ -63658,7 +63726,7 @@ var ts;
63658
63726
  var result;
63659
63727
  var extraTypes;
63660
63728
  var tailCount = 0;
63661
- var _loop_19 = function () {
63729
+ var _loop_20 = function () {
63662
63730
  if (tailCount === 1000) {
63663
63731
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
63664
63732
  result = errorType;
@@ -63779,10 +63847,10 @@ var ts;
63779
63847
  // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
63780
63848
  // cases we increment the tail recursion counter and stop after 1000 iterations.
63781
63849
  while (true) {
63782
- var state_5 = _loop_19();
63783
- if (typeof state_5 === "object")
63784
- return state_5.value;
63785
- 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")
63786
63854
  break;
63787
63855
  }
63788
63856
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
@@ -66397,7 +66465,7 @@ var ts;
66397
66465
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
66398
66466
  checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
66399
66467
  }
66400
- var _loop_20 = function (prop) {
66468
+ var _loop_21 = function (prop) {
66401
66469
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
66402
66470
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
66403
66471
  if (reportErrors) {
@@ -66460,9 +66528,9 @@ var ts;
66460
66528
  };
66461
66529
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
66462
66530
  var prop = _b[_i];
66463
- var state_6 = _loop_20(prop);
66464
- if (typeof state_6 === "object")
66465
- return state_6.value;
66531
+ var state_7 = _loop_21(prop);
66532
+ if (typeof state_7 === "object")
66533
+ return state_7.value;
66466
66534
  }
66467
66535
  return false;
66468
66536
  }
@@ -67453,11 +67521,11 @@ var ts;
67453
67521
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
67454
67522
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
67455
67523
  var matchingTypes = [];
67456
- var _loop_21 = function (combination) {
67524
+ var _loop_22 = function (combination) {
67457
67525
  var hasMatch = false;
67458
67526
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
67459
67527
  var type = _d[_c];
67460
- var _loop_22 = function (i) {
67528
+ var _loop_23 = function (i) {
67461
67529
  var sourceProperty = sourcePropertiesFiltered[i];
67462
67530
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
67463
67531
  if (!targetProperty)
@@ -67473,8 +67541,8 @@ var ts;
67473
67541
  }
67474
67542
  };
67475
67543
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
67476
- var state_8 = _loop_22(i);
67477
- switch (state_8) {
67544
+ var state_9 = _loop_23(i);
67545
+ switch (state_9) {
67478
67546
  case "continue-outer": continue outer;
67479
67547
  }
67480
67548
  }
@@ -67487,9 +67555,9 @@ var ts;
67487
67555
  };
67488
67556
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
67489
67557
  var combination = discriminantCombinations_1[_a];
67490
- var state_7 = _loop_21(combination);
67491
- if (typeof state_7 === "object")
67492
- return state_7.value;
67558
+ var state_8 = _loop_22(combination);
67559
+ if (typeof state_8 === "object")
67560
+ return state_8.value;
67493
67561
  }
67494
67562
  // Compare the remaining non-discriminant properties of each match.
67495
67563
  var result = -1 /* Ternary.True */;
@@ -68194,7 +68262,7 @@ var ts;
68194
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)) });
68195
68263
  links.variances = ts.emptyArray;
68196
68264
  var variances = [];
68197
- var _loop_23 = function (tp) {
68265
+ var _loop_24 = function (tp) {
68198
68266
  var modifiers = getVarianceModifiers(tp);
68199
68267
  var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
68200
68268
  modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
@@ -68232,7 +68300,7 @@ var ts;
68232
68300
  };
68233
68301
  for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
68234
68302
  var tp = typeParameters_2[_i];
68235
- _loop_23(tp);
68303
+ _loop_24(tp);
68236
68304
  }
68237
68305
  links.variances = variances;
68238
68306
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
@@ -68824,7 +68892,8 @@ var ts;
68824
68892
  function getOptionalType(type, isProperty) {
68825
68893
  if (isProperty === void 0) { isProperty = false; }
68826
68894
  ts.Debug.assert(strictNullChecks);
68827
- 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]);
68828
68897
  }
68829
68898
  function getGlobalNonNullableTypeInstantiation(type) {
68830
68899
  if (!deferredGlobalNonNullableTypeAlias) {
@@ -70189,7 +70258,7 @@ var ts;
70189
70258
  // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
70190
70259
  // succeed. That would be a pointless and confusing outcome.
70191
70260
  if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
70192
- var _loop_24 = function (i) {
70261
+ var _loop_25 = function (i) {
70193
70262
  var source_1 = matches ? matches[i] : neverType;
70194
70263
  var target_3 = types[i];
70195
70264
  // If we are inferring from a string literal type to a type variable whose constraint includes one of the
@@ -70239,7 +70308,7 @@ var ts;
70239
70308
  inferFromTypes(source_1, target_3);
70240
70309
  };
70241
70310
  for (var i = 0; i < types.length; i++) {
70242
- _loop_24(i);
70311
+ _loop_25(i);
70243
70312
  }
70244
70313
  }
70245
70314
  }
@@ -70703,7 +70772,7 @@ var ts;
70703
70772
  return name;
70704
70773
  }
70705
70774
  }
70706
- if (ts.hasOnlyExpressionInitializer(declaration)) {
70775
+ if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
70707
70776
  var initializer = ts.getEffectiveInitializer(declaration);
70708
70777
  return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
70709
70778
  }
@@ -70763,7 +70832,7 @@ var ts;
70763
70832
  function mapTypesByKeyProperty(types, name) {
70764
70833
  var map = new ts.Map();
70765
70834
  var count = 0;
70766
- var _loop_25 = function (type) {
70835
+ var _loop_26 = function (type) {
70767
70836
  if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
70768
70837
  var discriminant = getTypeOfPropertyOfType(type, name);
70769
70838
  if (discriminant) {
@@ -70789,9 +70858,9 @@ var ts;
70789
70858
  };
70790
70859
  for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
70791
70860
  var type = types_15[_i];
70792
- var state_9 = _loop_25(type);
70793
- if (typeof state_9 === "object")
70794
- return state_9.value;
70861
+ var state_10 = _loop_26(type);
70862
+ if (typeof state_10 === "object")
70863
+ return state_10.value;
70795
70864
  }
70796
70865
  return count >= 10 && count * 2 >= types.length ? map : undefined;
70797
70866
  }
@@ -72190,18 +72259,26 @@ var ts;
72190
72259
  }
72191
72260
  function isTypePresencePossible(type, propName, assumeTrue) {
72192
72261
  var prop = getPropertyOfType(type, propName);
72193
- if (prop) {
72194
- return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue;
72195
- }
72196
- return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue;
72197
- }
72198
- function narrowByInKeyword(type, name, assumeTrue) {
72199
- if (type.flags & 1048576 /* TypeFlags.Union */
72200
- || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type && !(declaredType === unknownType && isEmptyAnonymousObjectType(type))
72201
- || ts.isThisTypeParameter(type)
72202
- || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
72262
+ return prop ?
72263
+ !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72264
+ !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72265
+ }
72266
+ function narrowByInKeyword(type, nameType, assumeTrue) {
72267
+ var name = getPropertyNameFromType(nameType);
72268
+ var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72269
+ if (isKnownProperty) {
72270
+ // If the check is for a known property (i.e. a property declared in some constituent of
72271
+ // the target type), we filter the target type by presence of absence of the property.
72203
72272
  return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
72204
72273
  }
72274
+ if (assumeTrue) {
72275
+ // If the check is for an unknown property, we intersect the target type with `Record<X, unknown>`,
72276
+ // where X is the name of the property.
72277
+ var recordSymbol = getGlobalRecordSymbol();
72278
+ if (recordSymbol) {
72279
+ return getIntersectionType([type, getTypeAliasInstantiation(recordSymbol, [nameType, unknownType])]);
72280
+ }
72281
+ }
72205
72282
  return type;
72206
72283
  }
72207
72284
  function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
@@ -72260,15 +72337,14 @@ var ts;
72260
72337
  return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
72261
72338
  }
72262
72339
  var target = getReferenceCandidate(expr.right);
72263
- var leftType = getTypeOfNode(expr.left);
72264
- if (leftType.flags & 128 /* TypeFlags.StringLiteral */) {
72265
- var name = ts.escapeLeadingUnderscores(leftType.value);
72340
+ var leftType = getTypeOfExpression(expr.left);
72341
+ if (leftType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */) {
72266
72342
  if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) &&
72267
- getAccessedPropertyName(reference) === name) {
72343
+ getAccessedPropertyName(reference) === getPropertyNameFromType(leftType)) {
72268
72344
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72269
72345
  }
72270
72346
  if (isMatchingReference(reference, target)) {
72271
- return narrowByInKeyword(type, name, assumeTrue);
72347
+ return narrowByInKeyword(type, leftType, assumeTrue);
72272
72348
  }
72273
72349
  }
72274
72350
  break;
@@ -76438,7 +76514,6 @@ var ts;
76438
76514
  }
76439
76515
  return false;
76440
76516
  }
76441
- ;
76442
76517
  var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
76443
76518
  if (!hasProp(suggestedMethod)) {
76444
76519
  return undefined;
@@ -77240,7 +77315,7 @@ var ts;
77240
77315
  if (spreadIndex >= 0) {
77241
77316
  // Create synthetic arguments from spreads of tuple types.
77242
77317
  var effectiveArgs_1 = args.slice(0, spreadIndex);
77243
- var _loop_26 = function (i) {
77318
+ var _loop_27 = function (i) {
77244
77319
  var arg = args[i];
77245
77320
  // We can call checkExpressionCached because spread expressions never have a contextual type.
77246
77321
  var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -77257,7 +77332,7 @@ var ts;
77257
77332
  }
77258
77333
  };
77259
77334
  for (var i = spreadIndex; i < args.length; i++) {
77260
- _loop_26(i);
77335
+ _loop_27(i);
77261
77336
  }
77262
77337
  return effectiveArgs_1;
77263
77338
  }
@@ -77586,7 +77661,7 @@ var ts;
77586
77661
  var min_3 = Number.MAX_VALUE;
77587
77662
  var minIndex = 0;
77588
77663
  var i_1 = 0;
77589
- var _loop_27 = function (c) {
77664
+ var _loop_28 = function (c) {
77590
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)); };
77591
77666
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
77592
77667
  if (diags_2) {
@@ -77604,7 +77679,7 @@ var ts;
77604
77679
  };
77605
77680
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
77606
77681
  var c = candidatesForArgumentError_1[_a];
77607
- _loop_27(c);
77682
+ _loop_28(c);
77608
77683
  }
77609
77684
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
77610
77685
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -77762,7 +77837,7 @@ var ts;
77762
77837
  }
77763
77838
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
77764
77839
  var parameters = [];
77765
- var _loop_28 = function (i) {
77840
+ var _loop_29 = function (i) {
77766
77841
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
77767
77842
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
77768
77843
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -77770,7 +77845,7 @@ var ts;
77770
77845
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
77771
77846
  };
77772
77847
  for (var i = 0; i < maxNonRestParam; i++) {
77773
- _loop_28(i);
77848
+ _loop_29(i);
77774
77849
  }
77775
77850
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
77776
77851
  var flags = 0 /* SignatureFlags.None */;
@@ -80009,6 +80084,9 @@ var ts;
80009
80084
  }
80010
80085
  return booleanType;
80011
80086
  }
80087
+ function hasEmptyObjectIntersection(type) {
80088
+ return someType(type, function (t) { return t === unknownEmptyObjectType || !!(t.flags & 2097152 /* TypeFlags.Intersection */) && ts.some(t.types, isEmptyAnonymousObjectType); });
80089
+ }
80012
80090
  function checkInExpression(left, right, leftType, rightType) {
80013
80091
  if (leftType === silentNeverType || rightType === silentNeverType) {
80014
80092
  return silentNeverType;
@@ -80025,40 +80103,20 @@ var ts;
80025
80103
  }
80026
80104
  }
80027
80105
  else {
80028
- leftType = checkNonNullType(leftType, left);
80029
- // TypeScript 1.0 spec (April 2014): 4.15.5
80030
- // Require the left operand to be of type Any, the String primitive type, or the Number primitive type.
80031
- if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) ||
80032
- isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) {
80033
- error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol);
80106
+ // The type of the lef operand must be assignable to string, number, or symbol.
80107
+ checkTypeAssignableTo(checkNonNullType(leftType, left), stringNumberSymbolType, left);
80108
+ }
80109
+ // The type of the right operand must be assignable to 'object'.
80110
+ if (checkTypeAssignableTo(checkNonNullType(rightType, right), nonPrimitiveType, right)) {
80111
+ // The {} type is assignable to the object type, yet {} might represent a primitive type. Here we
80112
+ // detect and error on {} that results from narrowing the unknown type, as well as intersections
80113
+ // that include {} (we know that the other types in such intersections are assignable to object
80114
+ // since we already checked for that).
80115
+ if (hasEmptyObjectIntersection(rightType)) {
80116
+ error(right, ts.Diagnostics.Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operator, typeToString(rightType));
80034
80117
  }
80035
80118
  }
80036
- rightType = checkNonNullType(rightType, right);
80037
- // TypeScript 1.0 spec (April 2014): 4.15.5
80038
- // The in operator requires the right operand to be
80039
- //
80040
- // 1. assignable to the non-primitive type,
80041
- // 2. an unconstrained type parameter,
80042
- // 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the
80043
- // the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the
80044
- // non-primitive type, or
80045
- // 4. a type parameter whose constraint is
80046
- // i. an object type,
80047
- // ii. the non-primitive type, or
80048
- // iii. a union or intersection with at least one constituent assignable to an object or non-primitive type.
80049
- //
80050
- // The divergent behavior for type parameters and unions containing type parameters is a workaround for type
80051
- // parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance
80052
- // it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error
80053
- // unless *all* instantiations would result in an error.
80054
- //
80055
80119
  // The result is always of the Boolean primitive type.
80056
- var rightTypeConstraint = getConstraintOfType(rightType);
80057
- if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
80058
- rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
80059
- !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) {
80060
- error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive);
80061
- }
80062
80120
  return booleanType;
80063
80121
  }
80064
80122
  function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
@@ -80569,6 +80627,7 @@ var ts;
80569
80627
  var eqType = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */;
80570
80628
  error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
80571
80629
  }
80630
+ checkNaNEquality(errorNode, operator, left, right);
80572
80631
  reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
80573
80632
  return booleanType;
80574
80633
  case 102 /* SyntaxKind.InstanceOfKeyword */:
@@ -80774,6 +80833,26 @@ var ts;
80774
80833
  return undefined;
80775
80834
  }
80776
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
+ }
80777
80856
  }
80778
80857
  function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
80779
80858
  var effectiveLeft = leftType;
@@ -81811,7 +81890,7 @@ var ts;
81811
81890
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
81812
81891
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
81813
81892
  var indexSignatureMap_1 = new ts.Map();
81814
- var _loop_29 = function (declaration) {
81893
+ var _loop_30 = function (declaration) {
81815
81894
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
81816
81895
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
81817
81896
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -81826,7 +81905,7 @@ var ts;
81826
81905
  };
81827
81906
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
81828
81907
  var declaration = _a[_i];
81829
- _loop_29(declaration);
81908
+ _loop_30(declaration);
81830
81909
  }
81831
81910
  indexSignatureMap_1.forEach(function (entry) {
81832
81911
  if (entry.declarations.length > 1) {
@@ -85426,7 +85505,7 @@ var ts;
85426
85505
  var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
85427
85506
  name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
85428
85507
  var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
85429
- var _loop_30 = function (info) {
85508
+ var _loop_31 = function (info) {
85430
85509
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
85431
85510
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
85432
85511
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -85443,7 +85522,7 @@ var ts;
85443
85522
  };
85444
85523
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
85445
85524
  var info = indexInfos_9[_i];
85446
- _loop_30(info);
85525
+ _loop_31(info);
85447
85526
  }
85448
85527
  }
85449
85528
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -85451,7 +85530,7 @@ var ts;
85451
85530
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
85452
85531
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
85453
85532
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
85454
- var _loop_31 = function (info) {
85533
+ var _loop_32 = function (info) {
85455
85534
  if (info === checkInfo)
85456
85535
  return "continue";
85457
85536
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -85466,7 +85545,7 @@ var ts;
85466
85545
  };
85467
85546
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
85468
85547
  var info = indexInfos_10[_i];
85469
- _loop_31(info);
85548
+ _loop_32(info);
85470
85549
  }
85471
85550
  }
85472
85551
  function checkTypeNameIsReserved(name, message) {
@@ -85786,7 +85865,7 @@ var ts;
85786
85865
  var baseTypes = baseTypeNode && getBaseTypes(type);
85787
85866
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
85788
85867
  var baseStaticType = getBaseConstructorTypeOfClass(type);
85789
- var _loop_32 = function (member) {
85868
+ var _loop_33 = function (member) {
85790
85869
  if (ts.hasAmbientModifier(member)) {
85791
85870
  return "continue";
85792
85871
  }
@@ -85803,7 +85882,7 @@ var ts;
85803
85882
  };
85804
85883
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85805
85884
  var member = _a[_i];
85806
- _loop_32(member);
85885
+ _loop_33(member);
85807
85886
  }
85808
85887
  }
85809
85888
  /**
@@ -85891,7 +85970,7 @@ var ts;
85891
85970
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
85892
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
85893
85972
  var issuedMemberError = false;
85894
- var _loop_33 = function (member) {
85973
+ var _loop_34 = function (member) {
85895
85974
  if (ts.isStatic(member)) {
85896
85975
  return "continue";
85897
85976
  }
@@ -85910,7 +85989,7 @@ var ts;
85910
85989
  };
85911
85990
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
85912
85991
  var member = _a[_i];
85913
- _loop_33(member);
85992
+ _loop_34(member);
85914
85993
  }
85915
85994
  if (!issuedMemberError) {
85916
85995
  // check again with diagnostics to generate a less-specific error
@@ -85981,7 +86060,7 @@ var ts;
85981
86060
  var _a, _b, _c, _d;
85982
86061
  // NOTE: assignability is checked in checkClassDeclaration
85983
86062
  var baseProperties = getPropertiesOfType(baseType);
85984
- var _loop_34 = function (baseProperty) {
86063
+ var _loop_35 = function (baseProperty) {
85985
86064
  var base = getTargetSymbol(baseProperty);
85986
86065
  if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
85987
86066
  return "continue";
@@ -86091,8 +86170,8 @@ var ts;
86091
86170
  };
86092
86171
  basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
86093
86172
  var baseProperty = baseProperties_1[_i];
86094
- var state_10 = _loop_34(baseProperty);
86095
- switch (state_10) {
86173
+ var state_11 = _loop_35(baseProperty);
86174
+ switch (state_11) {
86096
86175
  case "continue-basePropertyCheck": continue basePropertyCheck;
86097
86176
  }
86098
86177
  }
@@ -88500,7 +88579,7 @@ var ts;
88500
88579
  }
88501
88580
  var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
88502
88581
  if (node) {
88503
- var symbol = getReferencedValueSymbol(node);
88582
+ var symbol = getReferencedValueOrAliasSymbol(node);
88504
88583
  // We should only get the declaration of an alias if there isn't a local value
88505
88584
  // declaration for the symbol
88506
88585
  if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
@@ -88867,6 +88946,25 @@ var ts;
88867
88946
  }
88868
88947
  return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
88869
88948
  }
88949
+ /**
88950
+ * Get either a value-meaning symbol or an alias symbol.
88951
+ * Unlike `getReferencedValueSymbol`, if the cached resolved symbol is the unknown symbol,
88952
+ * we call `resolveName` to find a symbol.
88953
+ * This is because when caching the resolved symbol, we only consider value symbols, but here
88954
+ * we want to also get an alias symbol if one exists.
88955
+ */
88956
+ function getReferencedValueOrAliasSymbol(reference) {
88957
+ var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
88958
+ if (resolvedSymbol && resolvedSymbol !== unknownSymbol) {
88959
+ return resolvedSymbol;
88960
+ }
88961
+ return resolveName(reference, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */,
88962
+ /*nodeNotFoundMessage*/ undefined,
88963
+ /*nameArg*/ undefined,
88964
+ /*isUse*/ true,
88965
+ /*excludeGlobals*/ undefined,
88966
+ /*getSpellingSuggestions*/ undefined);
88967
+ }
88870
88968
  function getReferencedValueDeclaration(referenceIn) {
88871
88969
  if (!ts.isGeneratedIdentifier(referenceIn)) {
88872
88970
  var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
@@ -95316,9 +95414,10 @@ var ts;
95316
95414
  return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
95317
95415
  }
95318
95416
  function shouldEmitAliasDeclaration(node) {
95319
- return compilerOptions.preserveValueImports
95320
- ? resolver.isValueAliasDeclaration(node)
95321
- : resolver.isReferencedAliasDeclaration(node);
95417
+ return ts.isInJSFile(node) ||
95418
+ (compilerOptions.preserveValueImports
95419
+ ? resolver.isValueAliasDeclaration(node)
95420
+ : resolver.isReferencedAliasDeclaration(node));
95322
95421
  }
95323
95422
  }
95324
95423
  ts.transformTypeScript = transformTypeScript;
@@ -110490,7 +110589,7 @@ var ts;
110490
110589
  var _a;
110491
110590
  var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
110492
110591
  var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
110493
- if (augmentingDeclarations) {
110592
+ if (primaryDeclaration && augmentingDeclarations) {
110494
110593
  for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
110495
110594
  var augmentations = augmentingDeclarations_1[_i];
110496
110595
  context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file)));
@@ -118539,7 +118638,6 @@ var ts;
118539
118638
  return resolutions;
118540
118639
  }
118541
118640
  ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
118542
- ;
118543
118641
  /**
118544
118642
  * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
118545
118643
  * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
@@ -124916,7 +125014,7 @@ var ts;
124916
125014
  });
124917
125015
  // Sort by paths closest to importing file Name directory
124918
125016
  var sortedPaths = [];
124919
- var _loop_35 = function (directory) {
125017
+ var _loop_36 = function (directory) {
124920
125018
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
124921
125019
  var pathsInDirectory;
124922
125020
  allFileNames.forEach(function (_a, fileName) {
@@ -124940,9 +125038,9 @@ var ts;
124940
125038
  };
124941
125039
  var out_directory_1;
124942
125040
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
124943
- var state_11 = _loop_35(directory);
125041
+ var state_12 = _loop_36(directory);
124944
125042
  directory = out_directory_1;
124945
- if (state_11 === "break")
125043
+ if (state_12 === "break")
124946
125044
  break;
124947
125045
  }
124948
125046
  if (allFileNames.size) {
@@ -125011,7 +125109,7 @@ var ts;
125011
125109
  }
125012
125110
  function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
125013
125111
  for (var key in paths) {
125014
- var _loop_36 = function (patternText_1) {
125112
+ var _loop_37 = function (patternText_1) {
125015
125113
  var pattern = ts.normalizePath(patternText_1);
125016
125114
  var indexOfStar = pattern.indexOf("*");
125017
125115
  // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
@@ -125078,9 +125176,9 @@ var ts;
125078
125176
  };
125079
125177
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
125080
125178
  var patternText_1 = _a[_i];
125081
- var state_12 = _loop_36(patternText_1);
125082
- if (typeof state_12 === "object")
125083
- return state_12.value;
125179
+ var state_13 = _loop_37(patternText_1);
125180
+ if (typeof state_13 === "object")
125181
+ return state_13.value;
125084
125182
  }
125085
125183
  }
125086
125184
  function validateEnding(_a) {
@@ -135035,7 +135133,7 @@ var ts;
135035
135133
  if (!dependencies)
135036
135134
  continue;
135037
135135
  for (var dep in dependencies) {
135038
- if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) {
135136
+ if (ts.hasProperty(dependencies, dep) && !ts.startsWith(dep, "@types/")) {
135039
135137
  result.push(dep);
135040
135138
  }
135041
135139
  }
@@ -135419,7 +135517,7 @@ var ts;
135419
135517
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
135420
135518
  }
135421
135519
  function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
135422
- 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;
135423
135521
  // Verify if the file is JSX language variant
135424
135522
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) {
135425
135523
  var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
@@ -135433,7 +135531,7 @@ var ts;
135433
135531
  return undefined;
135434
135532
  }
135435
135533
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
135436
- /*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);
135437
135535
  if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) {
135438
135536
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
135439
135537
  var keywordEntry = _a[_i];
@@ -135551,7 +135649,7 @@ var ts;
135551
135649
  function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
135552
135650
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority };
135553
135651
  }
135554
- 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) {
135555
135653
  var _a, _b;
135556
135654
  var insertText;
135557
135655
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
@@ -135607,8 +135705,8 @@ var ts;
135607
135705
  }
135608
135706
  if (originIsResolvedExport(origin)) {
135609
135707
  sourceDisplay = [ts.textPart(origin.moduleSpecifier)];
135610
- if (importCompletionNode) {
135611
- (_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);
135612
135710
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
135613
135711
  }
135614
135712
  }
@@ -135663,7 +135761,7 @@ var ts;
135663
135761
  }
135664
135762
  if (originIsExport(origin) || originIsResolvedExport(origin)) {
135665
135763
  data = originToCompletionEntryData(origin);
135666
- hasAction = !importCompletionNode;
135764
+ hasAction = !importStatementCompletion;
135667
135765
  }
135668
135766
  // TODO(drosen): Right now we just permit *all* semantic meanings when calling
135669
135767
  // 'getSymbolKind' which is permissible given that it is backwards compatible; but
@@ -135686,7 +135784,7 @@ var ts;
135686
135784
  labelDetails: labelDetails,
135687
135785
  isSnippet: isSnippet,
135688
135786
  isPackageJsonImport: originIsPackageJsonImport(origin) || undefined,
135689
- isImportStatementCompletion: !!importCompletionNode || undefined,
135787
+ isImportStatementCompletion: !!importStatementCompletion || undefined,
135690
135788
  data: data,
135691
135789
  };
135692
135790
  }
@@ -135888,7 +135986,6 @@ var ts;
135888
135986
  var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) };
135889
135987
  return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
135890
135988
  }
135891
- ;
135892
135989
  function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
135893
135990
  var declarations = symbol.getDeclarations();
135894
135991
  if (!(declarations && declarations.length)) {
@@ -136059,19 +136156,16 @@ var ts;
136059
136156
  };
136060
136157
  return unresolvedOrigin;
136061
136158
  }
136062
- function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences) {
136063
- var _a, _b, _c;
136064
- var sourceFile = importCompletionNode.getSourceFile();
136065
- 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;
136066
136161
  var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier);
136067
136162
  var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ :
136068
136163
  origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ :
136069
136164
  0 /* ExportKind.Named */;
136070
136165
  var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : "";
136071
136166
  var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true);
136072
- 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);
136073
- var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
136074
- 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 */), " ") : " ";
136075
136169
  var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : "";
136076
136170
  var suffix = useSemicolons ? ";" : "";
136077
136171
  switch (importKind) {
@@ -136105,7 +136199,7 @@ var ts;
136105
136199
  return CompletionSource.TypeOnlyAlias;
136106
136200
  }
136107
136201
  }
136108
- 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) {
136109
136203
  var _a;
136110
136204
  var start = ts.timestamp();
136111
136205
  var variableDeclaration = getVariableDeclaration(location);
@@ -136126,7 +136220,7 @@ var ts;
136126
136220
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
136127
136221
  var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
136128
136222
  var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
136129
- 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);
136130
136224
  if (!entry) {
136131
136225
  continue;
136132
136226
  }
@@ -136317,7 +136411,7 @@ var ts;
136317
136411
  Completions.createCompletionDetails = createCompletionDetails;
136318
136412
  function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source, cancellationToken) {
136319
136413
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
136320
- if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
136414
+ if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementSpan) {
136321
136415
  // Import statement completion: 'import c|'
136322
136416
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
136323
136417
  }
@@ -136518,34 +136612,34 @@ var ts;
136518
136612
  var isStartingCloseTag = false;
136519
136613
  var isJsxInitializer = false;
136520
136614
  var isJsxIdentifierExpected = false;
136521
- var importCompletionNode;
136615
+ var importStatementCompletion;
136522
136616
  var location = ts.getTouchingPropertyName(sourceFile, position);
136523
136617
  var keywordFilters = 0 /* KeywordCompletionFilters.None */;
136524
136618
  var isNewIdentifierLocation = false;
136525
136619
  var flags = 0 /* CompletionInfoFlags.None */;
136526
136620
  if (contextToken) {
136527
- var importStatementCompletion = getImportStatementCompletionInfo(contextToken);
136528
- isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation;
136529
- if (importStatementCompletion.keywordCompletion) {
136530
- if (importStatementCompletion.isKeywordOnlyCompletion) {
136621
+ var importStatementCompletionInfo = getImportStatementCompletionInfo(contextToken);
136622
+ if (importStatementCompletionInfo.keywordCompletion) {
136623
+ if (importStatementCompletionInfo.isKeywordOnlyCompletion) {
136531
136624
  return {
136532
136625
  kind: 4 /* CompletionDataKind.Keywords */,
136533
- keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)],
136534
- isNewIdentifierLocation: isNewIdentifierLocation,
136626
+ keywordCompletions: [keywordToCompletionEntry(importStatementCompletionInfo.keywordCompletion)],
136627
+ isNewIdentifierLocation: importStatementCompletionInfo.isNewIdentifierLocation,
136535
136628
  };
136536
136629
  }
136537
- keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletion.keywordCompletion);
136630
+ keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletionInfo.keywordCompletion);
136538
136631
  }
136539
- if (importStatementCompletion.replacementNode && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
136632
+ if (importStatementCompletionInfo.replacementSpan && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
136540
136633
  // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier`
136541
136634
  // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature
136542
136635
  // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
136543
136636
  // to opt in with the `includeCompletionsForImportStatements` user preference.
136544
- importCompletionNode = importStatementCompletion.replacementNode;
136545
136637
  flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */;
136638
+ importStatementCompletion = importStatementCompletionInfo;
136639
+ isNewIdentifierLocation = importStatementCompletionInfo.isNewIdentifierLocation;
136546
136640
  }
136547
136641
  // Bail out if this is a known invalid completion location
136548
- if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
136642
+ if (!importStatementCompletionInfo.replacementSpan && isCompletionListBlocker(contextToken)) {
136549
136643
  log("Returning an empty list because completion was requested in an invalid position.");
136550
136644
  return keywordFilters
136551
136645
  ? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierDefinitionLocation())
@@ -136591,7 +136685,7 @@ var ts;
136591
136685
  return undefined;
136592
136686
  }
136593
136687
  }
136594
- else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) {
136688
+ else if (!importStatementCompletion) {
136595
136689
  // <UI.Test /* completion position */ />
136596
136690
  // If the tagname is a property access expression, we will then walk up to the top most of property access expression.
136597
136691
  // Then, try to get a JSX container and its associated attributes type.
@@ -136734,7 +136828,7 @@ var ts;
136734
136828
  isTypeOnlyLocation: isTypeOnlyLocation,
136735
136829
  isJsxIdentifierExpected: isJsxIdentifierExpected,
136736
136830
  isRightOfOpenTag: isRightOfOpenTag,
136737
- importCompletionNode: importCompletionNode,
136831
+ importStatementCompletion: importStatementCompletion,
136738
136832
  hasUnresolvedAutoImports: hasUnresolvedAutoImports,
136739
136833
  flags: flags,
136740
136834
  };
@@ -136988,7 +137082,7 @@ var ts;
136988
137082
  return 1 /* GlobalsSearch.Success */;
136989
137083
  }
136990
137084
  function tryGetImportCompletionSymbols() {
136991
- if (!importCompletionNode)
137085
+ if (!importStatementCompletion)
136992
137086
  return 0 /* GlobalsSearch.Continue */;
136993
137087
  isNewIdentifierLocation = true;
136994
137088
  collectAutoImports();
@@ -137071,7 +137165,7 @@ var ts;
137071
137165
  }
137072
137166
  function shouldOfferImportCompletions() {
137073
137167
  // If already typing an import statement, provide completions for it.
137074
- if (importCompletionNode)
137168
+ if (importStatementCompletion)
137075
137169
  return true;
137076
137170
  // If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols
137077
137171
  if (isNonContextualObjectLiteral)
@@ -137101,7 +137195,7 @@ var ts;
137101
137195
  }
137102
137196
  function isTypeOnlyCompletion() {
137103
137197
  return insideJsDocTagTypeExpression
137104
- || !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
137198
+ || !!importStatementCompletion && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
137105
137199
  || !isContextTokenValueLocation(contextToken) &&
137106
137200
  (ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)
137107
137201
  || ts.isPartOfTypeNode(location)
@@ -137151,8 +137245,7 @@ var ts;
137151
137245
  flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */;
137152
137246
  // import { type | -> token text should be blank
137153
137247
  var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
137154
- && importCompletionNode
137155
- && couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
137248
+ && importStatementCompletion;
137156
137249
  var lowerCaseTokenText = isAfterTypeOnlyImportSpecifierModifier ? "" :
137157
137250
  previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
137158
137251
  "";
@@ -137160,14 +137253,14 @@ var ts;
137160
137253
  var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
137161
137254
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
137162
137255
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
137163
- 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) {
137164
137257
  exportInfo.search(sourceFile.path,
137165
137258
  /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
137166
137259
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
137167
137260
  return false;
137168
137261
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
137169
137262
  return false;
137170
- if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */))
137263
+ if (!isTypeOnlyLocation && !importStatementCompletion && !(targetFlags & 111551 /* SymbolFlags.Value */))
137171
137264
  return false;
137172
137265
  if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */)))
137173
137266
  return false;
@@ -137248,7 +137341,7 @@ var ts;
137248
137341
  return;
137249
137342
  }
137250
137343
  symbolToOriginInfoMap[symbols.length] = origin;
137251
- symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
137344
+ symbolToSortTextMap[symbolId] = importStatementCompletion ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
137252
137345
  symbols.push(symbol);
137253
137346
  }
137254
137347
  /* Mutates `symbols` and `symbolToOriginInfoMap`. */
@@ -138515,6 +138608,7 @@ var ts;
138515
138608
  return undefined;
138516
138609
  }
138517
138610
  function getImportStatementCompletionInfo(contextToken) {
138611
+ var _a, _b, _c;
138518
138612
  var keywordCompletion;
138519
138613
  var isKeywordOnlyCompletion = false;
138520
138614
  var candidate = getCandidate();
@@ -138522,9 +138616,9 @@ var ts;
138522
138616
  isKeywordOnlyCompletion: isKeywordOnlyCompletion,
138523
138617
  keywordCompletion: keywordCompletion,
138524
138618
  isNewIdentifierLocation: !!(candidate || keywordCompletion === 154 /* SyntaxKind.TypeKeyword */),
138525
- replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile())
138526
- ? candidate
138527
- : 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),
138528
138622
  };
138529
138623
  function getCandidate() {
138530
138624
  var parent = contextToken.parent;
@@ -138566,14 +138660,71 @@ var ts;
138566
138660
  return undefined;
138567
138661
  }
138568
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
+ }
138569
138711
  function couldBeTypeOnlyImportSpecifier(importSpecifier, contextToken) {
138570
138712
  return ts.isImportSpecifier(importSpecifier)
138571
138713
  && (importSpecifier.isTypeOnly || contextToken === importSpecifier.name && ts.isTypeKeywordTokenOrIdentifier(contextToken));
138572
138714
  }
138573
138715
  function canCompleteFromNamedBindings(namedBindings) {
138574
- return isModuleSpecifierMissingOrEmpty(namedBindings.parent.parent.moduleSpecifier)
138575
- && (ts.isNamespaceImport(namedBindings) || namedBindings.elements.length < 2)
138576
- && !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;
138577
138728
  }
138578
138729
  function isModuleSpecifierMissingOrEmpty(specifier) {
138579
138730
  var _a;
@@ -138592,7 +138743,6 @@ var ts;
138592
138743
  function isArrowFunctionBody(node) {
138593
138744
  return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node;
138594
138745
  }
138595
- ;
138596
138746
  /** True if symbol is a type or a module containing at least one type. */
138597
138747
  function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
138598
138748
  if (seenModules === void 0) { seenModules = new ts.Map(); }
@@ -149673,19 +149823,19 @@ var ts;
149673
149823
  return function (context) { return context.options && context.options[optionName] === optionValue; };
149674
149824
  }
149675
149825
  function isOptionEnabled(optionName) {
149676
- return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; };
149826
+ return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !!context.options[optionName]; };
149677
149827
  }
149678
149828
  function isOptionDisabled(optionName) {
149679
- return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !context.options[optionName]; };
149829
+ return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !context.options[optionName]; };
149680
149830
  }
149681
149831
  function isOptionDisabledOrUndefined(optionName) {
149682
- return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !context.options[optionName]; };
149832
+ return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName]; };
149683
149833
  }
149684
149834
  function isOptionDisabledOrUndefinedOrTokensOnSameLine(optionName) {
149685
- return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !context.options[optionName] || context.TokensAreOnSameLine(); };
149835
+ return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName] || context.TokensAreOnSameLine(); };
149686
149836
  }
149687
149837
  function isOptionEnabledOrUndefined(optionName) {
149688
- return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; };
149838
+ return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !!context.options[optionName]; };
149689
149839
  }
149690
149840
  function isForContext(context) {
149691
149841
  return context.contextNode.kind === 245 /* SyntaxKind.ForStatement */;
@@ -157307,7 +157457,7 @@ var ts;
157307
157457
  var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
157308
157458
  if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
157309
157459
  return;
157310
- var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
157460
+ var declaration = codefix.findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
157311
157461
  if (declaration === undefined)
157312
157462
  return;
157313
157463
  if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
@@ -157341,14 +157491,6 @@ var ts;
157341
157491
  }
157342
157492
  }
157343
157493
  }
157344
- function findAncestorMatchingSpan(sourceFile, span) {
157345
- var end = ts.textSpanEnd(span);
157346
- var token = ts.getTokenAtPosition(sourceFile, span.start);
157347
- while (token.end < end) {
157348
- token = token.parent;
157349
- }
157350
- return token;
157351
- }
157352
157494
  function tryGetConstraintFromDiagnosticMessage(messageText) {
157353
157495
  var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
157354
157496
  return constraint;
@@ -158894,6 +159036,63 @@ var ts;
158894
159036
  })(ts || (ts = {}));
158895
159037
  /* @internal */
158896
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;
158897
159096
  (function (ts) {
158898
159097
  var codefix;
158899
159098
  (function (codefix) {
@@ -161611,6 +161810,15 @@ var ts;
161611
161810
  symbols.forEach(function (s) { return importAdder.addImportFromExportedSymbol(s, /*isValidTypeOnlyUseSite*/ true); });
161612
161811
  }
161613
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;
161614
161822
  })(codefix = ts.codefix || (ts.codefix = {}));
161615
161823
  })(ts || (ts = {}));
161616
161824
  /* @internal */
@@ -162669,7 +162877,6 @@ var ts;
162669
162877
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
162670
162878
  },
162671
162879
  });
162672
- ;
162673
162880
  function getInfo(context, considerPartialSpans) {
162674
162881
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
162675
162882
  var file = context.file, program = context.program;
@@ -163146,7 +163353,6 @@ var ts;
163146
163353
  });
163147
163354
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
163148
163355
  }
163149
- ;
163150
163356
  function isValidExpression(node) {
163151
163357
  return ts.isBinaryExpression(node) || ts.isConditionalExpression(node);
163152
163358
  }
@@ -163194,7 +163400,6 @@ var ts;
163194
163400
  if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) {
163195
163401
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) };
163196
163402
  }
163197
- ;
163198
163403
  var finalExpression = getFinalExpressionInChain(expression.right);
163199
163404
  if (!finalExpression)
163200
163405
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_convertible_access_expression) };
@@ -165538,7 +165743,6 @@ var ts;
165538
165743
  (function (ts) {
165539
165744
  var refactor;
165540
165745
  (function (refactor) {
165541
- ;
165542
165746
  /**
165543
165747
  * Checks if some refactor info has refactor error info.
165544
165748
  */
@@ -165643,7 +165847,6 @@ var ts;
165643
165847
  // Imports will be copied to the new file anyway, and may still be needed in the old file.
165644
165848
  // Prologue directives will be copied to the new file and should be left in the old file.
165645
165849
  return !isPureImport(statement) && !ts.isPrologueDirective(statement);
165646
- ;
165647
165850
  }
165648
165851
  function isPureImport(node) {
165649
165852
  switch (node.kind) {
@@ -175279,7 +175482,7 @@ var ts;
175279
175482
  // raw is now fixed and ready
175280
175483
  this.safelist = raw.typesMap;
175281
175484
  for (var key in raw.simpleMap) {
175282
- if (raw.simpleMap.hasOwnProperty(key)) {
175485
+ if (ts.hasProperty(raw.simpleMap, key)) {
175283
175486
  this.legacySafelist.set(key, raw.simpleMap[key].toLowerCase());
175284
175487
  }
175285
175488
  }
@@ -178693,7 +178896,6 @@ var ts;
178693
178896
  }
178694
178897
  return ts.deduplicate(outputs, ts.equateValues);
178695
178898
  }
178696
- ;
178697
178899
  function createDocumentSpanSet() {
178698
178900
  return ts.createSet(function (_a) {
178699
178901
  var textSpan = _a.textSpan;