typescript 5.2.0-dev.20230625 → 5.2.0-dev.20230627

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
@@ -2327,7 +2327,7 @@ module.exports = __toCommonJS(server_exports);
2327
2327
 
2328
2328
  // src/compiler/corePublic.ts
2329
2329
  var versionMajorMinor = "5.2";
2330
- var version = `${versionMajorMinor}.0-dev.20230625`;
2330
+ var version = `${versionMajorMinor}.0-dev.20230627`;
2331
2331
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2332
2332
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2333
2333
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9733,7 +9733,6 @@ var Diagnostics = {
9733
9733
  This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, 1 /* Error */, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."),
9734
9734
  Type_0_does_not_satisfy_the_constraint_1: diag(2344, 1 /* Error */, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."),
9735
9735
  Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, 1 /* Error */, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."),
9736
- Call_target_does_not_contain_any_signatures: diag(2346, 1 /* Error */, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."),
9737
9736
  Untyped_function_calls_may_not_accept_type_arguments: diag(2347, 1 /* Error */, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."),
9738
9737
  Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, 1 /* Error */, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"),
9739
9738
  This_expression_is_not_callable: diag(2349, 1 /* Error */, "This_expression_is_not_callable_2349", "This expression is not callable."),
@@ -10343,7 +10342,6 @@ var Diagnostics = {
10343
10342
  Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0: diag(5081, 1 /* Error */, "Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0_5081", "Cannot find a tsconfig.json file at the current directory: {0}."),
10344
10343
  _0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1: diag(5082, 1 /* Error */, "_0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1_5082", "'{0}' could be instantiated with an arbitrary type which could be unrelated to '{1}'."),
10345
10344
  Cannot_read_file_0: diag(5083, 1 /* Error */, "Cannot_read_file_0_5083", "Cannot read file '{0}'."),
10346
- Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, 1 /* Error */, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."),
10347
10345
  A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, 1 /* Error */, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."),
10348
10346
  A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, 1 /* Error */, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."),
10349
10347
  A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, 1 /* Error */, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a '...' before the name, rather than before the type."),
@@ -11269,6 +11267,7 @@ var Diagnostics = {
11269
11267
  Inline_variable: diag(95184, 3 /* Message */, "Inline_variable_95184", "Inline variable"),
11270
11268
  Could_not_find_variable_to_inline: diag(95185, 3 /* Message */, "Could_not_find_variable_to_inline_95185", "Could not find variable to inline."),
11271
11269
  Variables_with_multiple_declarations_cannot_be_inlined: diag(95186, 3 /* Message */, "Variables_with_multiple_declarations_cannot_be_inlined_95186", "Variables with multiple declarations cannot be inlined."),
11270
+ Add_missing_comma_for_object_member_completion_0: diag(95187, 3 /* Message */, "Add_missing_comma_for_object_member_completion_0_95187", "Add missing comma for object member completion '{0}'."),
11272
11271
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* 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."),
11273
11272
  Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
11274
11273
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* 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?"),
@@ -52640,19 +52639,18 @@ function createTypeChecker(host) {
52640
52639
  const arity = getTypeReferenceArity(type2);
52641
52640
  const tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
52642
52641
  if (tupleConstituentNodes) {
52643
- if (type2.target.labeledElementDeclarations) {
52644
- for (let i = 0; i < tupleConstituentNodes.length; i++) {
52645
- const flags = type2.target.elementFlags[i];
52642
+ const { labeledElementDeclarations } = type2.target;
52643
+ for (let i = 0; i < tupleConstituentNodes.length; i++) {
52644
+ const flags = type2.target.elementFlags[i];
52645
+ const labeledElementDeclaration = labeledElementDeclarations == null ? void 0 : labeledElementDeclarations[i];
52646
+ if (labeledElementDeclaration) {
52646
52647
  tupleConstituentNodes[i] = factory.createNamedTupleMember(
52647
52648
  flags & 12 /* Variable */ ? factory.createToken(26 /* DotDotDotToken */) : void 0,
52648
- factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(type2.target.labeledElementDeclarations[i]))),
52649
+ factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(labeledElementDeclaration))),
52649
52650
  flags & 2 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
52650
52651
  flags & 4 /* Rest */ ? factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]
52651
52652
  );
52652
- }
52653
- } else {
52654
- for (let i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) {
52655
- const flags = type2.target.elementFlags[i];
52653
+ } else {
52656
52654
  tupleConstituentNodes[i] = flags & 12 /* Variable */ ? factory.createRestTypeNode(flags & 4 /* Rest */ ? factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : flags & 2 /* Optional */ ? factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i];
52657
52655
  }
52658
52656
  }
@@ -57764,17 +57762,18 @@ function createTypeChecker(host) {
57764
57762
  function getExpandedParameters(sig, skipUnionExpanding) {
57765
57763
  if (signatureHasRestParameter(sig)) {
57766
57764
  const restIndex = sig.parameters.length - 1;
57765
+ const restName = sig.parameters[restIndex].escapedName;
57767
57766
  const restType = getTypeOfSymbol(sig.parameters[restIndex]);
57768
57767
  if (isTupleType(restType)) {
57769
- return [expandSignatureParametersWithTupleMembers(restType, restIndex)];
57768
+ return [expandSignatureParametersWithTupleMembers(restType, restIndex, restName)];
57770
57769
  } else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && every(restType.types, isTupleType)) {
57771
- return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex));
57770
+ return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex, restName));
57772
57771
  }
57773
57772
  }
57774
57773
  return [sig.parameters];
57775
- function expandSignatureParametersWithTupleMembers(restType, restIndex) {
57776
- const elementTypes = getElementTypes(restType);
57777
- const associatedNames = getUniqAssociatedNamesFromTupleType(restType);
57774
+ function expandSignatureParametersWithTupleMembers(restType, restIndex, restName) {
57775
+ const elementTypes = getTypeArguments(restType);
57776
+ const associatedNames = getUniqAssociatedNamesFromTupleType(restType, restName);
57778
57777
  const restParams = map(elementTypes, (t, i) => {
57779
57778
  const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
57780
57779
  const flags = restType.target.elementFlags[i];
@@ -57785,10 +57784,10 @@ function createTypeChecker(host) {
57785
57784
  });
57786
57785
  return concatenate(sig.parameters.slice(0, restIndex), restParams);
57787
57786
  }
57788
- function getUniqAssociatedNamesFromTupleType(type) {
57787
+ function getUniqAssociatedNamesFromTupleType(type, restName) {
57789
57788
  const associatedNamesMap = /* @__PURE__ */ new Map();
57790
- return map(type.target.labeledElementDeclarations, (labeledElement) => {
57791
- const name = getTupleElementLabel(labeledElement);
57789
+ return map(type.target.labeledElementDeclarations, (labeledElement, i) => {
57790
+ const name = getTupleElementLabel(labeledElement, i, restName);
57792
57791
  const prevCounter = associatedNamesMap.get(name);
57793
57792
  if (prevCounter === void 0) {
57794
57793
  associatedNamesMap.set(name, 1);
@@ -60722,13 +60721,10 @@ function createTypeChecker(host) {
60722
60721
  return readonly ? globalReadonlyArrayType : globalArrayType;
60723
60722
  }
60724
60723
  const elementFlags = map(node.elements, getTupleElementFlags);
60725
- const missingName = some(node.elements, (e) => e.kind !== 202 /* NamedTupleMember */);
60726
- return getTupleTargetType(
60727
- elementFlags,
60728
- readonly,
60729
- /*associatedNames*/
60730
- missingName ? void 0 : node.elements
60731
- );
60724
+ return getTupleTargetType(elementFlags, readonly, map(node.elements, memberIfLabeledElementDeclaration));
60725
+ }
60726
+ function memberIfLabeledElementDeclaration(member) {
60727
+ return isNamedTupleMember(member) || isParameter(member) ? member : void 0;
60732
60728
  }
60733
60729
  function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
60734
60730
  return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 188 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : node.kind === 189 /* TupleType */ ? some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || some(node.typeArguments, mayResolveTypeAlias));
@@ -60803,7 +60799,7 @@ function createTypeChecker(host) {
60803
60799
  function isReadonlyTypeOperator(node) {
60804
60800
  return isTypeOperatorNode(node) && node.operator === 148 /* ReadonlyKeyword */;
60805
60801
  }
60806
- function createTupleType(elementTypes, elementFlags, readonly = false, namedMemberDeclarations) {
60802
+ function createTupleType(elementTypes, elementFlags, readonly = false, namedMemberDeclarations = []) {
60807
60803
  const tupleTarget = getTupleTargetType(elementFlags || map(elementTypes, (_) => 1 /* Required */), readonly, namedMemberDeclarations);
60808
60804
  return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget;
60809
60805
  }
@@ -60811,7 +60807,8 @@ function createTypeChecker(host) {
60811
60807
  if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) {
60812
60808
  return readonly ? globalReadonlyArrayType : globalArrayType;
60813
60809
  }
60814
- const key = map(elementFlags, (f) => f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*").join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + map(namedMemberDeclarations, getNodeId).join(",") : "");
60810
+ const memberIds = mapDefined(namedMemberDeclarations, (node) => node ? getNodeId(node) : void 0);
60811
+ const key = map(elementFlags, (f) => f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*").join() + (readonly ? "R" : "") + (memberIds.length ? "," + memberIds.join(",") : "");
60815
60812
  let type = tupleTypes.get(key);
60816
60813
  if (!type) {
60817
60814
  tupleTypes.set(key, type = createTupleTargetType(elementFlags, readonly, namedMemberDeclarations));
@@ -60893,7 +60890,7 @@ function createTypeChecker(host) {
60893
60890
  }
60894
60891
  const expandedTypes = [];
60895
60892
  const expandedFlags = [];
60896
- let expandedDeclarations = [];
60893
+ const expandedDeclarations = [];
60897
60894
  let lastRequiredIndex = -1;
60898
60895
  let firstRestIndex = -1;
60899
60896
  let lastOptionalOrRestIndex = -1;
@@ -60931,7 +60928,7 @@ function createTypeChecker(host) {
60931
60928
  ));
60932
60929
  expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
60933
60930
  expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
60934
- expandedDeclarations == null ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
60931
+ expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
60935
60932
  }
60936
60933
  const tupleTarget = getTupleTargetType(expandedFlags, target.readonly, expandedDeclarations);
60937
60934
  return tupleTarget === emptyGenericType ? emptyObjectType : expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget;
@@ -60951,11 +60948,7 @@ function createTypeChecker(host) {
60951
60948
  true
60952
60949
  ) : type);
60953
60950
  expandedFlags.push(flags);
60954
- if (expandedDeclarations && declaration) {
60955
- expandedDeclarations.push(declaration);
60956
- } else {
60957
- expandedDeclarations = void 0;
60958
- }
60951
+ expandedDeclarations.push(declaration);
60959
60952
  }
60960
60953
  }
60961
60954
  function sliceTupleType(type, index, endSkipCount = 0) {
@@ -65629,7 +65622,6 @@ function createTypeChecker(host) {
65629
65622
  } else if (targetFlags & 8388608 /* IndexedAccess */) {
65630
65623
  if (sourceFlags & 8388608 /* IndexedAccess */) {
65631
65624
  if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
65632
- instantiateType(source2.objectType, reportUnreliableMapper);
65633
65625
  result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
65634
65626
  }
65635
65627
  if (result2) {
@@ -71314,17 +71306,14 @@ function createTypeChecker(host) {
71314
71306
  }
71315
71307
  }
71316
71308
  function getTypeForThisExpressionFromJSDoc(node) {
71317
- const jsdocType = getJSDocType(node);
71318
- if (jsdocType && jsdocType.kind === 324 /* JSDocFunctionType */) {
71319
- const jsDocFunctionType = jsdocType;
71320
- if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) {
71321
- return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
71322
- }
71323
- }
71324
71309
  const thisTag = getJSDocThisTag(node);
71325
71310
  if (thisTag && thisTag.typeExpression) {
71326
71311
  return getTypeFromTypeNode(thisTag.typeExpression);
71327
71312
  }
71313
+ const signature = getSignatureOfTypeTag(node);
71314
+ if (signature) {
71315
+ return getThisTypeOfSignature(signature);
71316
+ }
71328
71317
  }
71329
71318
  function isInConstructorArgumentInitializer(node, constructorDecl) {
71330
71319
  return !!findAncestor(node, (n) => isFunctionLikeDeclaration(n) ? "quit" : n.kind === 169 /* Parameter */ && n.parent === constructorDecl);
@@ -75226,12 +75215,7 @@ function createTypeChecker(host) {
75226
75215
  }
75227
75216
  const candidates = candidatesOutArray || [];
75228
75217
  reorderCandidates(signatures, candidates, callChainFlags);
75229
- if (!candidates.length) {
75230
- if (reportErrors2) {
75231
- diagnostics.add(getDiagnosticForCallNode(node, Diagnostics.Call_target_does_not_contain_any_signatures));
75232
- }
75233
- return resolveErrorCall(node);
75234
- }
75218
+ Debug.assert(candidates.length, "Revert #54442 and add a testcase with whatever triggered this");
75235
75219
  const args = getEffectiveCallArguments(node);
75236
75220
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75237
75221
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
@@ -76683,7 +76667,10 @@ function createTypeChecker(host) {
76683
76667
  }
76684
76668
  return type;
76685
76669
  }
76686
- function getTupleElementLabel(d) {
76670
+ function getTupleElementLabel(d, index, restParameterName = "arg") {
76671
+ if (!d) {
76672
+ return `${restParameterName}_${index}`;
76673
+ }
76687
76674
  Debug.assert(isIdentifier(d.name));
76688
76675
  return d.name.escapedText;
76689
76676
  }
@@ -76697,7 +76684,7 @@ function createTypeChecker(host) {
76697
76684
  if (isTupleType(restType)) {
76698
76685
  const associatedNames = restType.target.labeledElementDeclarations;
76699
76686
  const index = pos - paramCount;
76700
- return associatedNames && getTupleElementLabel(associatedNames[index]) || restParameter.escapedName + "_" + index;
76687
+ return getTupleElementLabel(associatedNames == null ? void 0 : associatedNames[index], index, restParameter.escapedName);
76701
76688
  }
76702
76689
  return restParameter.escapedName;
76703
76690
  }
@@ -80052,12 +80039,7 @@ function createTypeChecker(host) {
80052
80039
  const elementTypes = node.elements;
80053
80040
  let seenOptionalElement = false;
80054
80041
  let seenRestElement = false;
80055
- const hasNamedElement = some(elementTypes, isNamedTupleMember);
80056
80042
  for (const e of elementTypes) {
80057
- if (e.kind !== 202 /* NamedTupleMember */ && hasNamedElement) {
80058
- grammarErrorOnNode(e, Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
80059
- break;
80060
- }
80061
80043
  const flags = getTupleElementFlags(e);
80062
80044
  if (flags & 8 /* Variadic */) {
80063
80045
  const type = getTypeFromTypeNode(e.type);
@@ -112383,6 +112365,21 @@ function transformDeclarations(context) {
112383
112365
  const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
112384
112366
  return factory2.updateModifiers(statement, modifiers);
112385
112367
  }
112368
+ function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
112369
+ const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
112370
+ if (isAmbientModule(updated) || updated.flags & 32 /* Namespace */) {
112371
+ return updated;
112372
+ }
112373
+ const fixed = factory2.createModuleDeclaration(
112374
+ updated.modifiers,
112375
+ updated.name,
112376
+ updated.body,
112377
+ updated.flags | 32 /* Namespace */
112378
+ );
112379
+ setOriginalNode(fixed, updated);
112380
+ setTextRange(fixed, updated);
112381
+ return fixed;
112382
+ }
112386
112383
  function transformTopLevelDeclaration(input) {
112387
112384
  if (lateMarkedStatements) {
112388
112385
  while (orderedRemoveItem(lateMarkedStatements, input))
@@ -112570,7 +112567,7 @@ function transformDeclarations(context) {
112570
112567
  needsScopeFixMarker = oldNeedsScopeFix;
112571
112568
  resultHasScopeMarker = oldHasScopeFix;
112572
112569
  const mods = ensureModifiers(input);
112573
- return cleanup(factory2.updateModuleDeclaration(
112570
+ return cleanup(updateModuleDeclarationAndKeyword(
112574
112571
  input,
112575
112572
  mods,
112576
112573
  isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name,
@@ -112584,7 +112581,7 @@ function transformDeclarations(context) {
112584
112581
  const id = getOriginalNodeId(inner);
112585
112582
  const body = lateStatementReplacementMap.get(id);
112586
112583
  lateStatementReplacementMap.delete(id);
112587
- return cleanup(factory2.updateModuleDeclaration(
112584
+ return cleanup(updateModuleDeclarationAndKeyword(
112588
112585
  input,
112589
112586
  mods,
112590
112587
  input.name,
@@ -138043,7 +138040,10 @@ function getReplacementExpression(reference, replacement) {
138043
138040
  if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
138044
138041
  return factory.createParenthesizedExpression(replacement);
138045
138042
  }
138046
- if (isFunctionLike(replacement) && isCallLikeExpression(parent2)) {
138043
+ if (isFunctionLike(replacement) && (isCallLikeExpression(parent2) || isPropertyAccessExpression(parent2))) {
138044
+ return factory.createParenthesizedExpression(replacement);
138045
+ }
138046
+ if (isPropertyAccessExpression(parent2) && (isNumericLiteral(replacement) || isObjectLiteralExpression(replacement))) {
138047
138047
  return factory.createParenthesizedExpression(replacement);
138048
138048
  }
138049
138049
  return replacement;
@@ -156661,6 +156661,7 @@ var CompletionSource = /* @__PURE__ */ ((CompletionSource2) => {
156661
156661
  CompletionSource2["TypeOnlyAlias"] = "TypeOnlyAlias/";
156662
156662
  CompletionSource2["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
156663
156663
  CompletionSource2["SwitchCases"] = "SwitchCases/";
156664
+ CompletionSource2["ObjectLiteralMemberWithComma"] = "ObjectLiteralMemberWithComma/";
156664
156665
  return CompletionSource2;
156665
156666
  })(CompletionSource || {});
156666
156667
  var SymbolOriginInfoKind = /* @__PURE__ */ ((SymbolOriginInfoKind2) => {
@@ -157539,6 +157540,7 @@ function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
157539
157540
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
157540
157541
  }
157541
157542
  function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, position, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importStatementCompletion, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag, includeSymbol) {
157543
+ var _a, _b;
157542
157544
  let insertText;
157543
157545
  let filterText;
157544
157546
  let replacementSpan = getReplacementSpanForContextToken(replacementToken);
@@ -157597,6 +157599,12 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
157597
157599
  if ((origin == null ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
157598
157600
  hasAction = true;
157599
157601
  }
157602
+ if (completionKind === 0 /* ObjectPropertyDeclaration */ && contextToken && ((_a = findPrecedingToken(contextToken.pos, sourceFile, contextToken)) == null ? void 0 : _a.kind) !== 28 /* CommaToken */) {
157603
+ if (isMethodDeclaration(contextToken.parent.parent) || isGetAccessorDeclaration(contextToken.parent.parent) || isSetAccessorDeclaration(contextToken.parent.parent) || isSpreadAssignment(contextToken.parent) || ((_b = findAncestor(contextToken.parent, isPropertyAssignment)) == null ? void 0 : _b.getLastToken(sourceFile)) === contextToken || isShorthandPropertyAssignment(contextToken.parent) && getLineAndCharacterOfPosition(sourceFile, contextToken.getEnd()).line !== getLineAndCharacterOfPosition(sourceFile, position).line) {
157604
+ source = "ObjectLiteralMemberWithComma/" /* ObjectLiteralMemberWithComma */;
157605
+ hasAction = true;
157606
+ }
157607
+ }
157600
157608
  if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && completionKind === 3 /* MemberLike */ && isClassLikeMemberCompletion(symbol, location, sourceFile)) {
157601
157609
  let importAdder;
157602
157610
  const memberCompletionEntry = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, position, contextToken, formatContext);
@@ -158160,7 +158168,7 @@ function getSourceFromOrigin(origin) {
158160
158168
  }
158161
158169
  function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, position, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag, includeSymbol = false) {
158162
158170
  const start2 = timestamp();
158163
- const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken);
158171
+ const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken, location);
158164
158172
  const useSemicolons = probablyUsesSemicolons(sourceFile);
158165
158173
  const typeChecker = program.getTypeChecker();
158166
158174
  const uniques = /* @__PURE__ */ new Map();
@@ -158327,7 +158335,7 @@ function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entr
158327
158335
  return firstDefined(symbols, (symbol, index) => {
158328
158336
  const origin = symbolToOriginInfoMap[index];
158329
158337
  const info = getCompletionEntryDisplayNameForSymbol(symbol, getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
158330
- return info && info.name === entryId.name && (entryId.source === "ClassMemberSnippet/" /* ClassMemberSnippet */ && symbol.flags & 106500 /* ClassMember */ || entryId.source === "ObjectLiteralMethodSnippet/" /* ObjectLiteralMethodSnippet */ && symbol.flags & (4 /* Property */ | 8192 /* Method */) || getSourceFromOrigin(origin) === entryId.source) ? { type: "symbol", symbol, location, origin, contextToken, previousToken, isJsxInitializer, isTypeOnlyLocation } : void 0;
158338
+ return info && info.name === entryId.name && (entryId.source === "ClassMemberSnippet/" /* ClassMemberSnippet */ && symbol.flags & 106500 /* ClassMember */ || entryId.source === "ObjectLiteralMethodSnippet/" /* ObjectLiteralMethodSnippet */ && symbol.flags & (4 /* Property */ | 8192 /* Method */) || getSourceFromOrigin(origin) === entryId.source || entryId.source === "ObjectLiteralMemberWithComma/" /* ObjectLiteralMemberWithComma */) ? { type: "symbol", symbol, location, origin, contextToken, previousToken, isJsxInitializer, isTypeOnlyLocation } : void 0;
158331
158339
  }) || { type: "none" };
158332
158340
  }
158333
158341
  function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) {
@@ -158472,6 +158480,21 @@ function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextTo
158472
158480
  Debug.assertIsDefined(codeAction2, "Expected to have a code action for promoting type-only alias");
158473
158481
  return { codeActions: [codeAction2], sourceDisplay: void 0 };
158474
158482
  }
158483
+ if (source === "ObjectLiteralMemberWithComma/" /* ObjectLiteralMemberWithComma */ && contextToken) {
158484
+ const changes = ts_textChanges_exports.ChangeTracker.with(
158485
+ { host, formatContext, preferences },
158486
+ (tracker) => tracker.insertText(sourceFile, contextToken.end, ",")
158487
+ );
158488
+ if (changes) {
158489
+ return {
158490
+ sourceDisplay: void 0,
158491
+ codeActions: [{
158492
+ changes,
158493
+ description: diagnosticToString([Diagnostics.Add_missing_comma_for_object_member_completion_0, name])
158494
+ }]
158495
+ };
158496
+ }
158497
+ }
158475
158498
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
158476
158499
  return { codeActions: void 0, sourceDisplay: void 0 };
158477
158500
  }
@@ -159378,7 +159401,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
159378
159401
  }
159379
159402
  function tryGetObjectLikeCompletionSymbols() {
159380
159403
  const symbolsStartIndex = symbols.length;
159381
- const objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
159404
+ const objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken, position, sourceFile);
159382
159405
  if (!objectLikeContainer)
159383
159406
  return 0 /* Continue */;
159384
159407
  completionKind = 0 /* ObjectPropertyDeclaration */;
@@ -159864,7 +159887,8 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
159864
159887
  return node2.getStart(sourceFile) <= position && position <= node2.getEnd();
159865
159888
  }
159866
159889
  }
159867
- function tryGetObjectLikeCompletionContainer(contextToken) {
159890
+ function tryGetObjectLikeCompletionContainer(contextToken, position, sourceFile) {
159891
+ var _a;
159868
159892
  if (contextToken) {
159869
159893
  const { parent: parent2 } = contextToken;
159870
159894
  switch (contextToken.kind) {
@@ -159879,7 +159903,29 @@ function tryGetObjectLikeCompletionContainer(contextToken) {
159879
159903
  case 134 /* AsyncKeyword */:
159880
159904
  return tryCast(parent2.parent, isObjectLiteralExpression);
159881
159905
  case 80 /* Identifier */:
159882
- return contextToken.text === "async" && isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : void 0;
159906
+ if (contextToken.text === "async" && isShorthandPropertyAssignment(contextToken.parent)) {
159907
+ return contextToken.parent.parent;
159908
+ } else {
159909
+ if (isObjectLiteralExpression(contextToken.parent.parent) && (isSpreadAssignment(contextToken.parent) || isShorthandPropertyAssignment(contextToken.parent) && getLineAndCharacterOfPosition(sourceFile, contextToken.getEnd()).line !== getLineAndCharacterOfPosition(sourceFile, position).line)) {
159910
+ return contextToken.parent.parent;
159911
+ }
159912
+ const ancestorNode2 = findAncestor(parent2, isPropertyAssignment);
159913
+ if ((ancestorNode2 == null ? void 0 : ancestorNode2.getLastToken(sourceFile)) === contextToken && isObjectLiteralExpression(ancestorNode2.parent)) {
159914
+ return ancestorNode2.parent;
159915
+ }
159916
+ }
159917
+ break;
159918
+ default:
159919
+ if (((_a = parent2.parent) == null ? void 0 : _a.parent) && (isMethodDeclaration(parent2.parent) || isGetAccessorDeclaration(parent2.parent) || isSetAccessorDeclaration(parent2.parent)) && isObjectLiteralExpression(parent2.parent.parent)) {
159920
+ return parent2.parent.parent;
159921
+ }
159922
+ if (isSpreadAssignment(parent2) && isObjectLiteralExpression(parent2.parent)) {
159923
+ return parent2.parent;
159924
+ }
159925
+ const ancestorNode = findAncestor(parent2, isPropertyAssignment);
159926
+ if (contextToken.kind !== 59 /* ColonToken */ && (ancestorNode == null ? void 0 : ancestorNode.getLastToken(sourceFile)) === contextToken && isObjectLiteralExpression(ancestorNode.parent)) {
159927
+ return ancestorNode.parent;
159928
+ }
159883
159929
  }
159884
159930
  }
159885
159931
  return void 0;
@@ -160346,11 +160392,12 @@ function isModuleSpecifierMissingOrEmpty(specifier) {
160346
160392
  return true;
160347
160393
  return !((_a = tryCast(isExternalModuleReference(specifier) ? specifier.expression : specifier, isStringLiteralLike)) == null ? void 0 : _a.text);
160348
160394
  }
160349
- function getVariableOrParameterDeclaration(contextToken) {
160395
+ function getVariableOrParameterDeclaration(contextToken, location) {
160350
160396
  if (!contextToken)
160351
160397
  return;
160352
- const declaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node) || (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
160353
- return declaration;
160398
+ const possiblyParameterDeclaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
160399
+ const possiblyVariableDeclaration = findAncestor(location, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node));
160400
+ return possiblyParameterDeclaration || possiblyVariableDeclaration;
160354
160401
  }
160355
160402
  function isArrowFunctionBody(node) {
160356
160403
  return node.parent && isArrowFunction(node.parent) && (node.parent.body === node || // const a = () => /**/;
@@ -6951,7 +6951,7 @@ declare namespace ts {
6951
6951
  hasRestElement: boolean;
6952
6952
  combinedFlags: ElementFlags;
6953
6953
  readonly: boolean;
6954
- labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[];
6954
+ labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration | undefined)[];
6955
6955
  }
6956
6956
  interface TupleTypeReference extends TypeReference {
6957
6957
  target: TupleType;