typescript 4.6.0-dev.20211203 → 4.6.0-dev.20211207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20211203";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20211207";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -843,7 +843,11 @@ var ts;
843
843
  }
844
844
  return deduplicated;
845
845
  }
846
- function insertSorted(array, insert, compare) {
846
+ function createSortedArray() {
847
+ return []; // TODO: GH#19873
848
+ }
849
+ ts.createSortedArray = createSortedArray;
850
+ function insertSorted(array, insert, compare, allowDuplicates) {
847
851
  if (array.length === 0) {
848
852
  array.push(insert);
849
853
  return;
@@ -852,6 +856,9 @@ var ts;
852
856
  if (insertIndex < 0) {
853
857
  array.splice(~insertIndex, 0, insert);
854
858
  }
859
+ else if (allowDuplicates) {
860
+ array.splice(insertIndex, 0, insert);
861
+ }
855
862
  }
856
863
  ts.insertSorted = insertSorted;
857
864
  function sortAndDeduplicate(array, comparer, equalityComparer) {
@@ -7930,7 +7937,7 @@ var ts;
7930
7937
  Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."),
7931
7938
  A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."),
7932
7939
  A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."),
7933
- An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."),
7940
+ An_object_literal_cannot_have_multiple_properties_with_the_same_name: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_1117", "An object literal cannot have multiple properties with the same name."),
7934
7941
  An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."),
7935
7942
  An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."),
7936
7943
  An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
@@ -8217,6 +8224,7 @@ var ts;
8217
8224
  Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."),
8218
8225
  An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."),
8219
8226
  Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."),
8227
+ Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function: diag(2311, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function_2311", "Cannot find name '{0}'. Did you mean to write this in an async function?"),
8220
8228
  An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."),
8221
8229
  Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."),
8222
8230
  Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."),
@@ -20758,6 +20766,10 @@ var ts;
20758
20766
  return text.replace(/\$/gm, "\\$");
20759
20767
  }
20760
20768
  ts.escapeSnippetText = escapeSnippetText;
20769
+ function isThisTypeParameter(type) {
20770
+ return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
20771
+ }
20772
+ ts.isThisTypeParameter = isThisTypeParameter;
20761
20773
  })(ts || (ts = {}));
20762
20774
  /* @internal */
20763
20775
  var ts;
@@ -33608,10 +33620,14 @@ var ts;
33608
33620
  // - "(x,y)" is a comma expression parsed as a signature with two parameters.
33609
33621
  // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation.
33610
33622
  // - "a ? (b): function() {}" will too, since function() is a valid JSDoc function type.
33611
- // - "a ? (b): (function() {})" as well, but inside of a parenthesized type.
33623
+ // - "a ? (b): (function() {})" as well, but inside of a parenthesized type with an arbitrary amount of nesting.
33612
33624
  //
33613
33625
  // So we need just a bit of lookahead to ensure that it can only be a signature.
33614
- var hasJSDocFunctionType = type && (ts.isJSDocFunctionType(type) || ts.isParenthesizedTypeNode(type) && ts.isJSDocFunctionType(type.type));
33626
+ var unwrappedType = type;
33627
+ while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 190 /* ParenthesizedType */) {
33628
+ unwrappedType = unwrappedType.type; // Skip parens if need be
33629
+ }
33630
+ var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType);
33615
33631
  if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) {
33616
33632
  // Returning undefined here will cause our caller to rewind to where we started from.
33617
33633
  return undefined;
@@ -41453,7 +41469,10 @@ var ts;
41453
41469
  }
41454
41470
  }
41455
41471
  var failedLookupLocations = [];
41456
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] };
41472
+ var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41473
+ ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41474
+ NodeResolutionFeatures.None;
41475
+ var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
41457
41476
  var resolved = primaryLookup();
41458
41477
  var primary = true;
41459
41478
  if (!resolved) {
@@ -42128,13 +42147,15 @@ var ts;
42128
42147
  // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
42129
42148
  NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
42130
42149
  NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
42150
+ NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default";
42151
+ NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault";
42131
42152
  NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
42132
42153
  })(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
42133
42154
  function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
42134
- return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42155
+ return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42135
42156
  }
42136
42157
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
42137
- return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.AllFeatures, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42158
+ return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42138
42159
  }
42139
42160
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
42140
42161
  var containingDirectory = ts.getDirectoryPath(containingFile);
@@ -44937,10 +44958,6 @@ var ts;
44937
44958
  seen.set(identifier.escapedText, currentKind);
44938
44959
  continue;
44939
44960
  }
44940
- if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) {
44941
- var span = ts.getErrorSpanForNode(file, identifier);
44942
- file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode));
44943
- }
44944
44961
  }
44945
44962
  }
44946
44963
  return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */);
@@ -45174,7 +45191,7 @@ var ts;
45174
45191
  }
45175
45192
  }
45176
45193
  function checkStrictModeNumericLiteral(node) {
45177
- if (inStrictMode && node.numericLiteralFlags & 32 /* Octal */) {
45194
+ if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) {
45178
45195
  file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
45179
45196
  }
45180
45197
  }
@@ -46840,6 +46857,7 @@ var ts;
46840
46857
  getIndexInfosOfType: getIndexInfosOfType,
46841
46858
  getSignaturesOfType: getSignaturesOfType,
46842
46859
  getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); },
46860
+ getIndexType: function (type) { return getIndexType(type); },
46843
46861
  getBaseTypes: getBaseTypes,
46844
46862
  getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
46845
46863
  getWidenedType: getWidenedType,
@@ -48097,11 +48115,12 @@ var ts;
48097
48115
  *
48098
48116
  * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
48099
48117
  */
48100
- function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals) {
48118
+ function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
48101
48119
  if (excludeGlobals === void 0) { excludeGlobals = false; }
48102
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol);
48120
+ if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
48121
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
48103
48122
  }
48104
- function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup) {
48123
+ function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
48105
48124
  var _a, _b, _c;
48106
48125
  var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
48107
48126
  var result;
@@ -48418,7 +48437,7 @@ var ts;
48418
48437
  }
48419
48438
  }
48420
48439
  if (!result) {
48421
- if (nameNotFoundMessage) {
48440
+ if (nameNotFoundMessage && produceDiagnostics) {
48422
48441
  if (!errorLocation ||
48423
48442
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
48424
48443
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
@@ -48428,7 +48447,7 @@ var ts;
48428
48447
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
48429
48448
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
48430
48449
  var suggestion = void 0;
48431
- if (suggestionCount < maximumSuggestionCount) {
48450
+ if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
48432
48451
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
48433
48452
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
48434
48453
  if (isGlobalScopeAugmentationDeclaration) {
@@ -48464,7 +48483,7 @@ var ts;
48464
48483
  return undefined;
48465
48484
  }
48466
48485
  // Perform extra checks only if error reporting was requested
48467
- if (nameNotFoundMessage) {
48486
+ if (nameNotFoundMessage && produceDiagnostics) {
48468
48487
  if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
48469
48488
  // We have a match, but the reference occurred within a property initializer and the identifier also binds
48470
48489
  // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
@@ -48777,10 +48796,12 @@ var ts;
48777
48796
  }
48778
48797
  /* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached.
48779
48798
  * If at any point current node is equal to 'parent' node - return true.
48799
+ * If current node is an IIFE, continue walking up.
48780
48800
  * Return false if 'stopAt' node is reached or isFunctionLike(current) === true.
48781
48801
  */
48782
48802
  function isSameScopeDescendentOf(initial, parent, stopAt) {
48783
- return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; });
48803
+ return !!parent && !!ts.findAncestor(initial, function (n) { return n === parent
48804
+ || (n === stopAt || ts.isFunctionLike(n) && !ts.getImmediatelyInvokedFunctionExpression(n) ? "quit" : false); });
48784
48805
  }
48785
48806
  function getAnyImportSyntax(node) {
48786
48807
  switch (node.kind) {
@@ -50940,7 +50961,7 @@ var ts;
50940
50961
  context.approximateLength += 6;
50941
50962
  return ts.factory.createKeywordTypeNode(147 /* ObjectKeyword */);
50942
50963
  }
50943
- if (isThisTypeParameter(type)) {
50964
+ if (ts.isThisTypeParameter(type)) {
50944
50965
  if (context.flags & 4194304 /* InObjectTypeLiteral */) {
50945
50966
  if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
50946
50967
  context.encounteredError = true;
@@ -58885,7 +58906,7 @@ var ts;
58885
58906
  }
58886
58907
  function getGlobalSymbol(name, meaning, diagnostic) {
58887
58908
  // Don't track references for global symbols anyway, so value if `isReference` is arbitrary
58888
- return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false);
58909
+ return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false);
58889
58910
  }
58890
58911
  function getGlobalType(name, arity, reportErrors) {
58891
58912
  var symbol = getGlobalTypeSymbol(name, reportErrors);
@@ -60464,9 +60485,6 @@ var ts;
60464
60485
  return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 8388608 /* IsGenericObjectType */ : 0) |
60465
60486
  (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 16777216 /* IsGenericIndexType */ : 0);
60466
60487
  }
60467
- function isThisTypeParameter(type) {
60468
- return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
60469
- }
60470
60488
  function getSimplifiedType(type, writing) {
60471
60489
  return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
60472
60490
  type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
@@ -65565,7 +65583,7 @@ var ts;
65565
65583
  }
65566
65584
  function getBaseTypeOfLiteralType(type) {
65567
65585
  return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) :
65568
- type.flags & 128 /* StringLiteral */ ? stringType :
65586
+ type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType :
65569
65587
  type.flags & 256 /* NumberLiteral */ ? numberType :
65570
65588
  type.flags & 2048 /* BigIntLiteral */ ? bigintType :
65571
65589
  type.flags & 512 /* BooleanLiteral */ ? booleanType :
@@ -65664,7 +65682,7 @@ var ts;
65664
65682
  // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
65665
65683
  // no flags for all other types (including non-falsy literal types).
65666
65684
  function getFalsyFlags(type) {
65667
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
65685
+ return type.flags & 3145728 /* UnionOrIntersection */ ? getFalsyFlagsOfTypes(type.types) :
65668
65686
  type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
65669
65687
  type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
65670
65688
  type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
@@ -67280,6 +67298,11 @@ var ts;
67280
67298
  case "BigInt64Array":
67281
67299
  case "BigUint64Array":
67282
67300
  return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later;
67301
+ case "await":
67302
+ if (ts.isCallExpression(node.parent)) {
67303
+ return ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function;
67304
+ }
67305
+ // falls through
67283
67306
  default:
67284
67307
  if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) {
67285
67308
  return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
@@ -68837,7 +68860,7 @@ var ts;
68837
68860
  function narrowByInKeyword(type, name, assumeTrue) {
68838
68861
  if (type.flags & 1048576 /* Union */
68839
68862
  || type.flags & 524288 /* Object */ && declaredType !== type
68840
- || isThisTypeParameter(type)
68863
+ || ts.isThisTypeParameter(type)
68841
68864
  || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
68842
68865
  return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
68843
68866
  }
@@ -71657,15 +71680,9 @@ var ts;
71657
71680
  }
71658
71681
  }
71659
71682
  function isValidSpreadType(type) {
71660
- if (type.flags & 465829888 /* Instantiable */) {
71661
- var constraint = getBaseConstraintOfType(type);
71662
- if (constraint !== undefined) {
71663
- return isValidSpreadType(constraint);
71664
- }
71665
- }
71666
- return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ||
71667
- getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
71668
- type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType));
71683
+ var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType));
71684
+ return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ||
71685
+ t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType));
71669
71686
  }
71670
71687
  function checkJsxSelfClosingElementDeferred(node) {
71671
71688
  checkJsxOpeningLikeElementOrOpeningFragment(node);
@@ -72616,7 +72633,7 @@ var ts;
72616
72633
  }
72617
72634
  var propType;
72618
72635
  if (!prop) {
72619
- var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ?
72636
+ var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ?
72620
72637
  getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined;
72621
72638
  if (!(indexInfo && indexInfo.type)) {
72622
72639
  var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true);
@@ -72633,7 +72650,7 @@ var ts;
72633
72650
  return anyType;
72634
72651
  }
72635
72652
  if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
72636
- reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
72653
+ reportNonexistentProperty(right, ts.isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
72637
72654
  }
72638
72655
  return errorType;
72639
72656
  }
@@ -72926,7 +72943,7 @@ var ts;
72926
72943
  }
72927
72944
  function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
72928
72945
  ts.Debug.assert(outerName !== undefined, "outername should always be defined");
72929
- var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, function (symbols, name, meaning) {
72946
+ var result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ true, function (symbols, name, meaning) {
72930
72947
  ts.Debug.assertEqual(outerName, name, "name should equal outerName");
72931
72948
  var symbol = getSymbol(symbols, name, meaning);
72932
72949
  // Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function
@@ -73172,7 +73189,7 @@ var ts;
73172
73189
  }
73173
73190
  var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
73174
73191
  var accessFlags = ts.isAssignmentTarget(node) ?
73175
- 4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
73192
+ 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
73176
73193
  32 /* ExpressionPosition */;
73177
73194
  var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType;
73178
73195
  return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node);
@@ -85934,9 +85951,12 @@ var ts;
85934
85951
  seen.set(effectiveName, currentKind);
85935
85952
  }
85936
85953
  else {
85937
- if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) {
85954
+ if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) {
85938
85955
  grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
85939
85956
  }
85957
+ else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) {
85958
+ grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name));
85959
+ }
85940
85960
  else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) {
85941
85961
  if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) {
85942
85962
  seen.set(effectiveName, currentKind | existingKind);
@@ -127615,7 +127635,7 @@ var ts;
127615
127635
  case 0 /* Paths */:
127616
127636
  return convertPathCompletions(completion.paths);
127617
127637
  case 1 /* Properties */: {
127618
- var entries = [];
127638
+ var entries = ts.createSortedArray();
127619
127639
  Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary
127620
127640
  return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
127621
127641
  }
@@ -127813,7 +127833,7 @@ var ts;
127813
127833
  var types = ts.flatMap(candidates, function (candidate) {
127814
127834
  if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
127815
127835
  return;
127816
- var type = checker.getParameterType(candidate, argumentInfo.argumentIndex);
127836
+ var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
127817
127837
  isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
127818
127838
  return getStringLiteralTypes(type, uniques);
127819
127839
  });
@@ -128497,6 +128517,29 @@ var ts;
128497
128517
  }
128498
128518
  }
128499
128519
  Completions.getCompletionsAtPosition = getCompletionsAtPosition;
128520
+ // Editors will use the `sortText` and then fall back to `name` for sorting, but leave ties in response order.
128521
+ // So, it's important that we sort those ties in the order we want them displayed if it matters. We don't
128522
+ // strictly need to sort by name or SortText here since clients are going to do it anyway, but we have to
128523
+ // do the work of comparing them so we can sort those ties appropriately; plus, it makes the order returned
128524
+ // by the language service consistent with what TS Server does and what editors typically do. This also makes
128525
+ // completions tests make more sense. We used to sort only alphabetically and only in the server layer, but
128526
+ // this made tests really weird, since most fourslash tests don't use the server.
128527
+ function compareCompletionEntries(entryInArray, entryToInsert) {
128528
+ var _a, _b;
128529
+ var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText);
128530
+ if (result === 0 /* EqualTo */) {
128531
+ result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name);
128532
+ }
128533
+ if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) {
128534
+ // Sort same-named auto-imports by module specifier
128535
+ result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier);
128536
+ }
128537
+ if (result === 0 /* EqualTo */) {
128538
+ // Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first.
128539
+ return -1 /* LessThan */;
128540
+ }
128541
+ return result;
128542
+ }
128500
128543
  function completionEntryDataIsResolved(data) {
128501
128544
  return !!(data === null || data === void 0 ? void 0 : data.moduleSpecifier);
128502
128545
  }
@@ -128583,7 +128626,7 @@ var ts;
128583
128626
  return completionInfo;
128584
128627
  }
128585
128628
  }
128586
- var entries = [];
128629
+ var entries = ts.createSortedArray();
128587
128630
  if (isUncheckedFile(sourceFile, compilerOptions)) {
128588
128631
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
128589
128632
  /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
@@ -128601,13 +128644,13 @@ var ts;
128601
128644
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
128602
128645
  var keywordEntry = _a[_i];
128603
128646
  if (!entryNames.has(keywordEntry.name)) {
128604
- entries.push(keywordEntry);
128647
+ ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
128605
128648
  }
128606
128649
  }
128607
128650
  }
128608
128651
  for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
128609
128652
  var literal = literals_1[_b];
128610
- entries.push(createCompletionEntryForLiteral(sourceFile, preferences, literal));
128653
+ ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
128611
128654
  }
128612
128655
  return {
128613
128656
  isGlobalCompletion: isInSnippetScope,
@@ -128683,13 +128726,13 @@ var ts;
128683
128726
  var realName = ts.unescapeLeadingUnderscores(name);
128684
128727
  if (!uniqueNames.has(realName) && ts.isIdentifierText(realName, target)) {
128685
128728
  uniqueNames.add(realName);
128686
- entries.push({
128729
+ ts.insertSorted(entries, {
128687
128730
  name: realName,
128688
128731
  kind: "warning" /* warning */,
128689
128732
  kindModifiers: "",
128690
128733
  sortText: SortText.JavascriptIdentifiers,
128691
128734
  isFromUncheckedFile: true
128692
- });
128735
+ }, compareCompletionEntries);
128693
128736
  }
128694
128737
  });
128695
128738
  }
@@ -129113,7 +129156,7 @@ var ts;
129113
129156
  /** True for locals; false for globals, module exports from other files, `this.` completions. */
129114
129157
  var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
129115
129158
  uniques.set(name, shouldShadowLaterSymbols);
129116
- entries.push(entry);
129159
+ ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
129117
129160
  }
129118
129161
  log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start));
129119
129162
  // Prevent consumers of this map from having to worry about
@@ -140869,7 +140912,7 @@ var ts;
140869
140912
  displayParts.push(ts.spacePart());
140870
140913
  displayParts.push(ts.operatorPart(63 /* EqualsToken */));
140871
140914
  displayParts.push(ts.spacePart());
140872
- ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
140915
+ ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
140873
140916
  }
140874
140917
  if (symbolFlags & 384 /* Enum */) {
140875
140918
  prefixNextMeaning();
@@ -151590,6 +151633,7 @@ var ts;
151590
151633
  var errorCodes = [
151591
151634
  ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
151592
151635
  ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
151636
+ ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
151593
151637
  ];
151594
151638
  codefix.registerCodeFix({
151595
151639
  errorCodes: errorCodes,
@@ -159400,6 +159444,9 @@ var ts;
159400
159444
  TypeObject.prototype.isClass = function () {
159401
159445
  return !!(ts.getObjectFlags(this) & 1 /* Class */);
159402
159446
  };
159447
+ TypeObject.prototype.isIndexType = function () {
159448
+ return !!(this.flags & 4194304 /* Index */);
159449
+ };
159403
159450
  Object.defineProperty(TypeObject.prototype, "typeArguments", {
159404
159451
  /**
159405
159452
  * This polyfills `referenceType.typeArguments` for API consumers
@@ -159432,6 +159479,16 @@ var ts;
159432
159479
  SignatureObject.prototype.getReturnType = function () {
159433
159480
  return this.checker.getReturnTypeOfSignature(this);
159434
159481
  };
159482
+ SignatureObject.prototype.getTypeParameterAtPosition = function (pos) {
159483
+ var type = this.checker.getParameterType(this, pos);
159484
+ if (type.isIndexType() && ts.isThisTypeParameter(type.type)) {
159485
+ var constraint = type.type.getConstraint();
159486
+ if (constraint) {
159487
+ return this.checker.getIndexType(constraint);
159488
+ }
159489
+ }
159490
+ return type;
159491
+ };
159435
159492
  SignatureObject.prototype.getDocumentationComment = function () {
159436
159493
  return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
159437
159494
  };
@@ -171777,14 +171834,14 @@ var ts;
171777
171834
  if (kind === "completions-full" /* CompletionsFull */)
171778
171835
  return completions;
171779
171836
  var prefix = args.prefix || "";
171780
- var entries = ts.stableSort(ts.mapDefined(completions.entries, function (entry) {
171837
+ var entries = ts.mapDefined(completions.entries, function (entry) {
171781
171838
  if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) {
171782
171839
  var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, sourceDisplay = entry.sourceDisplay, isSnippet = entry.isSnippet, isRecommended = entry.isRecommended, isPackageJsonImport = entry.isPackageJsonImport, isImportStatementCompletion = entry.isImportStatementCompletion, data = entry.data;
171783
171840
  var convertedSpan = replacementSpan ? toProtocolTextSpan(replacementSpan, scriptInfo) : undefined;
171784
171841
  // Use `hasAction || undefined` to avoid serializing `false`.
171785
171842
  return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, isSnippet: isSnippet, hasAction: hasAction || undefined, source: source, sourceDisplay: sourceDisplay, isRecommended: isRecommended, isPackageJsonImport: isPackageJsonImport, isImportStatementCompletion: isImportStatementCompletion, data: data };
171786
171843
  }
171787
- }), function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); });
171844
+ });
171788
171845
  if (kind === "completions" /* Completions */) {
171789
171846
  if (completions.metadata)
171790
171847
  entries.metadata = completions.metadata;
@@ -5560,6 +5560,7 @@ declare namespace ts {
5560
5560
  isTypeParameter(): this is TypeParameter;
5561
5561
  isClassOrInterface(): this is InterfaceType;
5562
5562
  isClass(): this is InterfaceType;
5563
+ isIndexType(): this is IndexType;
5563
5564
  }
5564
5565
  interface TypeReference {
5565
5566
  typeArguments?: readonly Type[];
@@ -5568,6 +5569,7 @@ declare namespace ts {
5568
5569
  getDeclaration(): SignatureDeclaration;
5569
5570
  getTypeParameters(): TypeParameter[] | undefined;
5570
5571
  getParameters(): Symbol[];
5572
+ getTypeParameterAtPosition(pos: number): Type;
5571
5573
  getReturnType(): Type;
5572
5574
  getDocumentationComment(typeChecker: TypeChecker | undefined): SymbolDisplayPart[];
5573
5575
  getJsDocTags(): JSDocTagInfo[];