@typescript-deploys/pr-build 5.2.0-pr-54781-9 → 5.2.0-pr-52493-8

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
@@ -1414,6 +1414,7 @@ __export(server_exports, {
1414
1414
  isImportTypeNode: () => isImportTypeNode,
1415
1415
  isImportableFile: () => isImportableFile,
1416
1416
  isInComment: () => isInComment,
1417
+ isInCompoundLikeAssignment: () => isInCompoundLikeAssignment,
1417
1418
  isInExpressionContext: () => isInExpressionContext,
1418
1419
  isInJSDoc: () => isInJSDoc,
1419
1420
  isInJSFile: () => isInJSFile,
@@ -1706,6 +1707,7 @@ __export(server_exports, {
1706
1707
  isSetAccessor: () => isSetAccessor,
1707
1708
  isSetAccessorDeclaration: () => isSetAccessorDeclaration,
1708
1709
  isShebangTrivia: () => isShebangTrivia,
1710
+ isShiftOperatorOrHigher: () => isShiftOperatorOrHigher,
1709
1711
  isShorthandAmbientModuleSymbol: () => isShorthandAmbientModuleSymbol,
1710
1712
  isShorthandPropertyAssignment: () => isShorthandPropertyAssignment,
1711
1713
  isSignedNumericLiteral: () => isSignedNumericLiteral,
@@ -2327,7 +2329,7 @@ module.exports = __toCommonJS(server_exports);
2327
2329
 
2328
2330
  // src/compiler/corePublic.ts
2329
2331
  var versionMajorMinor = "5.2";
2330
- var version = `${versionMajorMinor}.0-insiders.20230626`;
2332
+ var version = `${versionMajorMinor}.0-insiders.20230627`;
2331
2333
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2332
2334
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2333
2335
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9733,7 +9735,6 @@ var Diagnostics = {
9733
9735
  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
9736
  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
9737
  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
9738
  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
9739
  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
9740
  This_expression_is_not_callable: diag(2349, 1 /* Error */, "This_expression_is_not_callable_2349", "This expression is not callable."),
@@ -10343,7 +10344,6 @@ var Diagnostics = {
10343
10344
  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
10345
  _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
10346
  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
10347
  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
10348
  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
10349
  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 +11269,7 @@ var Diagnostics = {
11269
11269
  Inline_variable: diag(95184, 3 /* Message */, "Inline_variable_95184", "Inline variable"),
11270
11270
  Could_not_find_variable_to_inline: diag(95185, 3 /* Message */, "Could_not_find_variable_to_inline_95185", "Could not find variable to inline."),
11271
11271
  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."),
11272
+ 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
11273
  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
11274
  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
11275
  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?"),
@@ -17126,8 +17127,8 @@ function isInExpressionContext(node) {
17126
17127
  return forStatement.initializer === node && forStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forStatement.condition === node || forStatement.incrementor === node;
17127
17128
  case 249 /* ForInStatement */:
17128
17129
  case 250 /* ForOfStatement */:
17129
- const forInStatement = parent2;
17130
- return forInStatement.initializer === node && forInStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forInStatement.expression === node;
17130
+ const forInOrOfStatement = parent2;
17131
+ return forInOrOfStatement.initializer === node && forInOrOfStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forInOrOfStatement.expression === node;
17131
17132
  case 216 /* TypeAssertionExpression */:
17132
17133
  case 234 /* AsExpression */:
17133
17134
  return node === parent2.expression;
@@ -17823,20 +17824,23 @@ var AssignmentKind = /* @__PURE__ */ ((AssignmentKind2) => {
17823
17824
  AssignmentKind2[AssignmentKind2["Compound"] = 2] = "Compound";
17824
17825
  return AssignmentKind2;
17825
17826
  })(AssignmentKind || {});
17826
- function getAssignmentTargetKind(node) {
17827
+ function getAssignmentTarget(node) {
17827
17828
  let parent2 = node.parent;
17828
17829
  while (true) {
17829
17830
  switch (parent2.kind) {
17830
17831
  case 226 /* BinaryExpression */:
17831
- const binaryOperator = parent2.operatorToken.kind;
17832
- return isAssignmentOperator(binaryOperator) && parent2.left === node ? binaryOperator === 64 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */;
17832
+ const binaryExpression = parent2;
17833
+ const binaryOperator = binaryExpression.operatorToken.kind;
17834
+ return isAssignmentOperator(binaryOperator) && binaryExpression.left === node ? binaryExpression : void 0;
17833
17835
  case 224 /* PrefixUnaryExpression */:
17834
17836
  case 225 /* PostfixUnaryExpression */:
17835
- const unaryOperator = parent2.operator;
17836
- return unaryOperator === 46 /* PlusPlusToken */ || unaryOperator === 47 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */;
17837
+ const unaryExpression = parent2;
17838
+ const unaryOperator = unaryExpression.operator;
17839
+ return unaryOperator === 46 /* PlusPlusToken */ || unaryOperator === 47 /* MinusMinusToken */ ? unaryExpression : void 0;
17837
17840
  case 249 /* ForInStatement */:
17838
17841
  case 250 /* ForOfStatement */:
17839
- return parent2.initializer === node ? 1 /* Definite */ : 0 /* None */;
17842
+ const forInOrOfStatement = parent2;
17843
+ return forInOrOfStatement.initializer === node ? forInOrOfStatement : void 0;
17840
17844
  case 217 /* ParenthesizedExpression */:
17841
17845
  case 209 /* ArrayLiteralExpression */:
17842
17846
  case 230 /* SpreadElement */:
@@ -17848,24 +17852,53 @@ function getAssignmentTargetKind(node) {
17848
17852
  break;
17849
17853
  case 304 /* ShorthandPropertyAssignment */:
17850
17854
  if (parent2.name !== node) {
17851
- return 0 /* None */;
17855
+ return void 0;
17852
17856
  }
17853
17857
  node = parent2.parent;
17854
17858
  break;
17855
17859
  case 303 /* PropertyAssignment */:
17856
17860
  if (parent2.name === node) {
17857
- return 0 /* None */;
17861
+ return void 0;
17858
17862
  }
17859
17863
  node = parent2.parent;
17860
17864
  break;
17861
17865
  default:
17862
- return 0 /* None */;
17866
+ return void 0;
17863
17867
  }
17864
17868
  parent2 = node.parent;
17865
17869
  }
17866
17870
  }
17871
+ function getAssignmentTargetKind(node) {
17872
+ const target = getAssignmentTarget(node);
17873
+ if (!target) {
17874
+ return 0 /* None */;
17875
+ }
17876
+ switch (target.kind) {
17877
+ case 226 /* BinaryExpression */:
17878
+ const binaryOperator = target.operatorToken.kind;
17879
+ return binaryOperator === 64 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */;
17880
+ case 224 /* PrefixUnaryExpression */:
17881
+ case 225 /* PostfixUnaryExpression */:
17882
+ return 2 /* Compound */;
17883
+ case 249 /* ForInStatement */:
17884
+ case 250 /* ForOfStatement */:
17885
+ return 1 /* Definite */;
17886
+ }
17887
+ }
17867
17888
  function isAssignmentTarget(node) {
17868
- return getAssignmentTargetKind(node) !== 0 /* None */;
17889
+ return !!getAssignmentTarget(node);
17890
+ }
17891
+ function isCompoundLikeAssignment(assignment) {
17892
+ const right = skipParentheses(assignment.right);
17893
+ return right.kind === 226 /* BinaryExpression */ && isShiftOperatorOrHigher(right.operatorToken.kind);
17894
+ }
17895
+ function isInCompoundLikeAssignment(node) {
17896
+ const target = getAssignmentTarget(node);
17897
+ return !!target && isAssignmentExpression(
17898
+ target,
17899
+ /*excludeCompoundAssignment*/
17900
+ true
17901
+ ) && isCompoundLikeAssignment(target);
17869
17902
  }
17870
17903
  function isNodeWithPossibleHoistedDeclaration(node) {
17871
17904
  switch (node.kind) {
@@ -52640,19 +52673,18 @@ function createTypeChecker(host) {
52640
52673
  const arity = getTypeReferenceArity(type2);
52641
52674
  const tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
52642
52675
  if (tupleConstituentNodes) {
52643
- if (type2.target.labeledElementDeclarations) {
52644
- for (let i = 0; i < tupleConstituentNodes.length; i++) {
52645
- const flags = type2.target.elementFlags[i];
52676
+ const { labeledElementDeclarations } = type2.target;
52677
+ for (let i = 0; i < tupleConstituentNodes.length; i++) {
52678
+ const flags = type2.target.elementFlags[i];
52679
+ const labeledElementDeclaration = labeledElementDeclarations == null ? void 0 : labeledElementDeclarations[i];
52680
+ if (labeledElementDeclaration) {
52646
52681
  tupleConstituentNodes[i] = factory.createNamedTupleMember(
52647
52682
  flags & 12 /* Variable */ ? factory.createToken(26 /* DotDotDotToken */) : void 0,
52648
- factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(type2.target.labeledElementDeclarations[i]))),
52683
+ factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(labeledElementDeclaration))),
52649
52684
  flags & 2 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
52650
52685
  flags & 4 /* Rest */ ? factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]
52651
52686
  );
52652
- }
52653
- } else {
52654
- for (let i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) {
52655
- const flags = type2.target.elementFlags[i];
52687
+ } else {
52656
52688
  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
52689
  }
52658
52690
  }
@@ -57764,17 +57796,18 @@ function createTypeChecker(host) {
57764
57796
  function getExpandedParameters(sig, skipUnionExpanding) {
57765
57797
  if (signatureHasRestParameter(sig)) {
57766
57798
  const restIndex = sig.parameters.length - 1;
57799
+ const restName = sig.parameters[restIndex].escapedName;
57767
57800
  const restType = getTypeOfSymbol(sig.parameters[restIndex]);
57768
57801
  if (isTupleType(restType)) {
57769
- return [expandSignatureParametersWithTupleMembers(restType, restIndex)];
57802
+ return [expandSignatureParametersWithTupleMembers(restType, restIndex, restName)];
57770
57803
  } else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && every(restType.types, isTupleType)) {
57771
- return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex));
57804
+ return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex, restName));
57772
57805
  }
57773
57806
  }
57774
57807
  return [sig.parameters];
57775
- function expandSignatureParametersWithTupleMembers(restType, restIndex) {
57776
- const elementTypes = getElementTypes(restType);
57777
- const associatedNames = getUniqAssociatedNamesFromTupleType(restType);
57808
+ function expandSignatureParametersWithTupleMembers(restType, restIndex, restName) {
57809
+ const elementTypes = getTypeArguments(restType);
57810
+ const associatedNames = getUniqAssociatedNamesFromTupleType(restType, restName);
57778
57811
  const restParams = map(elementTypes, (t, i) => {
57779
57812
  const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
57780
57813
  const flags = restType.target.elementFlags[i];
@@ -57785,10 +57818,10 @@ function createTypeChecker(host) {
57785
57818
  });
57786
57819
  return concatenate(sig.parameters.slice(0, restIndex), restParams);
57787
57820
  }
57788
- function getUniqAssociatedNamesFromTupleType(type) {
57821
+ function getUniqAssociatedNamesFromTupleType(type, restName) {
57789
57822
  const associatedNamesMap = /* @__PURE__ */ new Map();
57790
- return map(type.target.labeledElementDeclarations, (labeledElement) => {
57791
- const name = getTupleElementLabel(labeledElement);
57823
+ return map(type.target.labeledElementDeclarations, (labeledElement, i) => {
57824
+ const name = getTupleElementLabel(labeledElement, i, restName);
57792
57825
  const prevCounter = associatedNamesMap.get(name);
57793
57826
  if (prevCounter === void 0) {
57794
57827
  associatedNamesMap.set(name, 1);
@@ -60722,13 +60755,10 @@ function createTypeChecker(host) {
60722
60755
  return readonly ? globalReadonlyArrayType : globalArrayType;
60723
60756
  }
60724
60757
  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
- );
60758
+ return getTupleTargetType(elementFlags, readonly, map(node.elements, memberIfLabeledElementDeclaration));
60759
+ }
60760
+ function memberIfLabeledElementDeclaration(member) {
60761
+ return isNamedTupleMember(member) || isParameter(member) ? member : void 0;
60732
60762
  }
60733
60763
  function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
60734
60764
  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 +60833,7 @@ function createTypeChecker(host) {
60803
60833
  function isReadonlyTypeOperator(node) {
60804
60834
  return isTypeOperatorNode(node) && node.operator === 148 /* ReadonlyKeyword */;
60805
60835
  }
60806
- function createTupleType(elementTypes, elementFlags, readonly = false, namedMemberDeclarations) {
60836
+ function createTupleType(elementTypes, elementFlags, readonly = false, namedMemberDeclarations = []) {
60807
60837
  const tupleTarget = getTupleTargetType(elementFlags || map(elementTypes, (_) => 1 /* Required */), readonly, namedMemberDeclarations);
60808
60838
  return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget;
60809
60839
  }
@@ -60811,7 +60841,8 @@ function createTypeChecker(host) {
60811
60841
  if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) {
60812
60842
  return readonly ? globalReadonlyArrayType : globalArrayType;
60813
60843
  }
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(",") : "");
60844
+ const memberIds = mapDefined(namedMemberDeclarations, (node) => node ? getNodeId(node) : void 0);
60845
+ const key = map(elementFlags, (f) => f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*").join() + (readonly ? "R" : "") + (memberIds.length ? "," + memberIds.join(",") : "");
60815
60846
  let type = tupleTypes.get(key);
60816
60847
  if (!type) {
60817
60848
  tupleTypes.set(key, type = createTupleTargetType(elementFlags, readonly, namedMemberDeclarations));
@@ -60893,7 +60924,7 @@ function createTypeChecker(host) {
60893
60924
  }
60894
60925
  const expandedTypes = [];
60895
60926
  const expandedFlags = [];
60896
- let expandedDeclarations = [];
60927
+ const expandedDeclarations = [];
60897
60928
  let lastRequiredIndex = -1;
60898
60929
  let firstRestIndex = -1;
60899
60930
  let lastOptionalOrRestIndex = -1;
@@ -60931,7 +60962,7 @@ function createTypeChecker(host) {
60931
60962
  ));
60932
60963
  expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
60933
60964
  expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
60934
- expandedDeclarations == null ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
60965
+ expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
60935
60966
  }
60936
60967
  const tupleTarget = getTupleTargetType(expandedFlags, target.readonly, expandedDeclarations);
60937
60968
  return tupleTarget === emptyGenericType ? emptyObjectType : expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget;
@@ -60951,11 +60982,7 @@ function createTypeChecker(host) {
60951
60982
  true
60952
60983
  ) : type);
60953
60984
  expandedFlags.push(flags);
60954
- if (expandedDeclarations && declaration) {
60955
- expandedDeclarations.push(declaration);
60956
- } else {
60957
- expandedDeclarations = void 0;
60958
- }
60985
+ expandedDeclarations.push(declaration);
60959
60986
  }
60960
60987
  }
60961
60988
  function sliceTupleType(type, index, endSkipCount = 0) {
@@ -69854,10 +69881,11 @@ function createTypeChecker(host) {
69854
69881
  const assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow));
69855
69882
  return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
69856
69883
  }
69857
- if (declaredType.flags & 1048576 /* Union */) {
69858
- return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
69884
+ const t = isInCompoundLikeAssignment(node) ? getBaseTypeOfLiteralType(declaredType) : declaredType;
69885
+ if (t.flags & 1048576 /* Union */) {
69886
+ return getAssignmentReducedType(t, getInitialOrAssignedType(flow));
69859
69887
  }
69860
- return declaredType;
69888
+ return t;
69861
69889
  }
69862
69890
  if (containsMatchingReference(reference, node)) {
69863
69891
  if (!isReachableFlowNode(flow)) {
@@ -70986,7 +71014,7 @@ function createTypeChecker(host) {
70986
71014
  const isAlias = localOrExportSymbol.flags & 2097152 /* Alias */;
70987
71015
  if (localOrExportSymbol.flags & 3 /* Variable */) {
70988
71016
  if (assignmentKind === 1 /* Definite */) {
70989
- return type;
71017
+ return isInCompoundLikeAssignment(node) ? getBaseTypeOfLiteralType(type) : type;
70990
71018
  }
70991
71019
  } else if (isAlias) {
70992
71020
  declaration = getDeclarationOfAliasSymbol(symbol);
@@ -71313,17 +71341,14 @@ function createTypeChecker(host) {
71313
71341
  }
71314
71342
  }
71315
71343
  function getTypeForThisExpressionFromJSDoc(node) {
71316
- const jsdocType = getJSDocType(node);
71317
- if (jsdocType && jsdocType.kind === 324 /* JSDocFunctionType */) {
71318
- const jsDocFunctionType = jsdocType;
71319
- if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) {
71320
- return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
71321
- }
71322
- }
71323
71344
  const thisTag = getJSDocThisTag(node);
71324
71345
  if (thisTag && thisTag.typeExpression) {
71325
71346
  return getTypeFromTypeNode(thisTag.typeExpression);
71326
71347
  }
71348
+ const signature = getSignatureOfTypeTag(node);
71349
+ if (signature) {
71350
+ return getThisTypeOfSignature(signature);
71351
+ }
71327
71352
  }
71328
71353
  function isInConstructorArgumentInitializer(node, constructorDecl) {
71329
71354
  return !!findAncestor(node, (n) => isFunctionLikeDeclaration(n) ? "quit" : n.kind === 169 /* Parameter */ && n.parent === constructorDecl);
@@ -75225,12 +75250,7 @@ function createTypeChecker(host) {
75225
75250
  }
75226
75251
  const candidates = candidatesOutArray || [];
75227
75252
  reorderCandidates(signatures, candidates, callChainFlags);
75228
- if (!candidates.length) {
75229
- if (reportErrors2) {
75230
- diagnostics.add(getDiagnosticForCallNode(node, Diagnostics.Call_target_does_not_contain_any_signatures));
75231
- }
75232
- return resolveErrorCall(node);
75233
- }
75253
+ Debug.assert(candidates.length, "Revert #54442 and add a testcase with whatever triggered this");
75234
75254
  const args = getEffectiveCallArguments(node);
75235
75255
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75236
75256
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
@@ -76682,7 +76702,10 @@ function createTypeChecker(host) {
76682
76702
  }
76683
76703
  return type;
76684
76704
  }
76685
- function getTupleElementLabel(d) {
76705
+ function getTupleElementLabel(d, index, restParameterName = "arg") {
76706
+ if (!d) {
76707
+ return `${restParameterName}_${index}`;
76708
+ }
76686
76709
  Debug.assert(isIdentifier(d.name));
76687
76710
  return d.name.escapedText;
76688
76711
  }
@@ -76696,7 +76719,7 @@ function createTypeChecker(host) {
76696
76719
  if (isTupleType(restType)) {
76697
76720
  const associatedNames = restType.target.labeledElementDeclarations;
76698
76721
  const index = pos - paramCount;
76699
- return associatedNames && getTupleElementLabel(associatedNames[index]) || restParameter.escapedName + "_" + index;
76722
+ return getTupleElementLabel(associatedNames == null ? void 0 : associatedNames[index], index, restParameter.escapedName);
76700
76723
  }
76701
76724
  return restParameter.escapedName;
76702
76725
  }
@@ -80051,12 +80074,7 @@ function createTypeChecker(host) {
80051
80074
  const elementTypes = node.elements;
80052
80075
  let seenOptionalElement = false;
80053
80076
  let seenRestElement = false;
80054
- const hasNamedElement = some(elementTypes, isNamedTupleMember);
80055
80077
  for (const e of elementTypes) {
80056
- if (e.kind !== 202 /* NamedTupleMember */ && hasNamedElement) {
80057
- grammarErrorOnNode(e, Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
80058
- break;
80059
- }
80060
80078
  const flags = getTupleElementFlags(e);
80061
80079
  if (flags & 8 /* Variadic */) {
80062
80080
  const type = getTypeFromTypeNode(e.type);
@@ -138057,7 +138075,10 @@ function getReplacementExpression(reference, replacement) {
138057
138075
  if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
138058
138076
  return factory.createParenthesizedExpression(replacement);
138059
138077
  }
138060
- if (isFunctionLike(replacement) && isCallLikeExpression(parent2)) {
138078
+ if (isFunctionLike(replacement) && (isCallLikeExpression(parent2) || isPropertyAccessExpression(parent2))) {
138079
+ return factory.createParenthesizedExpression(replacement);
138080
+ }
138081
+ if (isPropertyAccessExpression(parent2) && (isNumericLiteral(replacement) || isObjectLiteralExpression(replacement))) {
138061
138082
  return factory.createParenthesizedExpression(replacement);
138062
138083
  }
138063
138084
  return replacement;
@@ -156675,6 +156696,7 @@ var CompletionSource = /* @__PURE__ */ ((CompletionSource2) => {
156675
156696
  CompletionSource2["TypeOnlyAlias"] = "TypeOnlyAlias/";
156676
156697
  CompletionSource2["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
156677
156698
  CompletionSource2["SwitchCases"] = "SwitchCases/";
156699
+ CompletionSource2["ObjectLiteralMemberWithComma"] = "ObjectLiteralMemberWithComma/";
156678
156700
  return CompletionSource2;
156679
156701
  })(CompletionSource || {});
156680
156702
  var SymbolOriginInfoKind = /* @__PURE__ */ ((SymbolOriginInfoKind2) => {
@@ -157553,6 +157575,7 @@ function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
157553
157575
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
157554
157576
  }
157555
157577
  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) {
157578
+ var _a, _b;
157556
157579
  let insertText;
157557
157580
  let filterText;
157558
157581
  let replacementSpan = getReplacementSpanForContextToken(replacementToken);
@@ -157611,6 +157634,12 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
157611
157634
  if ((origin == null ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
157612
157635
  hasAction = true;
157613
157636
  }
157637
+ if (completionKind === 0 /* ObjectPropertyDeclaration */ && contextToken && ((_a = findPrecedingToken(contextToken.pos, sourceFile, contextToken)) == null ? void 0 : _a.kind) !== 28 /* CommaToken */) {
157638
+ 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) {
157639
+ source = "ObjectLiteralMemberWithComma/" /* ObjectLiteralMemberWithComma */;
157640
+ hasAction = true;
157641
+ }
157642
+ }
157614
157643
  if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && completionKind === 3 /* MemberLike */ && isClassLikeMemberCompletion(symbol, location, sourceFile)) {
157615
157644
  let importAdder;
157616
157645
  const memberCompletionEntry = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, position, contextToken, formatContext);
@@ -158174,7 +158203,7 @@ function getSourceFromOrigin(origin) {
158174
158203
  }
158175
158204
  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) {
158176
158205
  const start2 = timestamp();
158177
- const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken);
158206
+ const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken, location);
158178
158207
  const useSemicolons = probablyUsesSemicolons(sourceFile);
158179
158208
  const typeChecker = program.getTypeChecker();
158180
158209
  const uniques = /* @__PURE__ */ new Map();
@@ -158341,7 +158370,7 @@ function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entr
158341
158370
  return firstDefined(symbols, (symbol, index) => {
158342
158371
  const origin = symbolToOriginInfoMap[index];
158343
158372
  const info = getCompletionEntryDisplayNameForSymbol(symbol, getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
158344
- 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;
158373
+ 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;
158345
158374
  }) || { type: "none" };
158346
158375
  }
158347
158376
  function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) {
@@ -158486,6 +158515,21 @@ function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextTo
158486
158515
  Debug.assertIsDefined(codeAction2, "Expected to have a code action for promoting type-only alias");
158487
158516
  return { codeActions: [codeAction2], sourceDisplay: void 0 };
158488
158517
  }
158518
+ if (source === "ObjectLiteralMemberWithComma/" /* ObjectLiteralMemberWithComma */ && contextToken) {
158519
+ const changes = ts_textChanges_exports.ChangeTracker.with(
158520
+ { host, formatContext, preferences },
158521
+ (tracker) => tracker.insertText(sourceFile, contextToken.end, ",")
158522
+ );
158523
+ if (changes) {
158524
+ return {
158525
+ sourceDisplay: void 0,
158526
+ codeActions: [{
158527
+ changes,
158528
+ description: diagnosticToString([Diagnostics.Add_missing_comma_for_object_member_completion_0, name])
158529
+ }]
158530
+ };
158531
+ }
158532
+ }
158489
158533
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
158490
158534
  return { codeActions: void 0, sourceDisplay: void 0 };
158491
158535
  }
@@ -159392,7 +159436,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
159392
159436
  }
159393
159437
  function tryGetObjectLikeCompletionSymbols() {
159394
159438
  const symbolsStartIndex = symbols.length;
159395
- const objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
159439
+ const objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken, position, sourceFile);
159396
159440
  if (!objectLikeContainer)
159397
159441
  return 0 /* Continue */;
159398
159442
  completionKind = 0 /* ObjectPropertyDeclaration */;
@@ -159878,7 +159922,8 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
159878
159922
  return node2.getStart(sourceFile) <= position && position <= node2.getEnd();
159879
159923
  }
159880
159924
  }
159881
- function tryGetObjectLikeCompletionContainer(contextToken) {
159925
+ function tryGetObjectLikeCompletionContainer(contextToken, position, sourceFile) {
159926
+ var _a;
159882
159927
  if (contextToken) {
159883
159928
  const { parent: parent2 } = contextToken;
159884
159929
  switch (contextToken.kind) {
@@ -159893,7 +159938,29 @@ function tryGetObjectLikeCompletionContainer(contextToken) {
159893
159938
  case 134 /* AsyncKeyword */:
159894
159939
  return tryCast(parent2.parent, isObjectLiteralExpression);
159895
159940
  case 80 /* Identifier */:
159896
- return contextToken.text === "async" && isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : void 0;
159941
+ if (contextToken.text === "async" && isShorthandPropertyAssignment(contextToken.parent)) {
159942
+ return contextToken.parent.parent;
159943
+ } else {
159944
+ if (isObjectLiteralExpression(contextToken.parent.parent) && (isSpreadAssignment(contextToken.parent) || isShorthandPropertyAssignment(contextToken.parent) && getLineAndCharacterOfPosition(sourceFile, contextToken.getEnd()).line !== getLineAndCharacterOfPosition(sourceFile, position).line)) {
159945
+ return contextToken.parent.parent;
159946
+ }
159947
+ const ancestorNode2 = findAncestor(parent2, isPropertyAssignment);
159948
+ if ((ancestorNode2 == null ? void 0 : ancestorNode2.getLastToken(sourceFile)) === contextToken && isObjectLiteralExpression(ancestorNode2.parent)) {
159949
+ return ancestorNode2.parent;
159950
+ }
159951
+ }
159952
+ break;
159953
+ default:
159954
+ if (((_a = parent2.parent) == null ? void 0 : _a.parent) && (isMethodDeclaration(parent2.parent) || isGetAccessorDeclaration(parent2.parent) || isSetAccessorDeclaration(parent2.parent)) && isObjectLiteralExpression(parent2.parent.parent)) {
159955
+ return parent2.parent.parent;
159956
+ }
159957
+ if (isSpreadAssignment(parent2) && isObjectLiteralExpression(parent2.parent)) {
159958
+ return parent2.parent;
159959
+ }
159960
+ const ancestorNode = findAncestor(parent2, isPropertyAssignment);
159961
+ if (contextToken.kind !== 59 /* ColonToken */ && (ancestorNode == null ? void 0 : ancestorNode.getLastToken(sourceFile)) === contextToken && isObjectLiteralExpression(ancestorNode.parent)) {
159962
+ return ancestorNode.parent;
159963
+ }
159897
159964
  }
159898
159965
  }
159899
159966
  return void 0;
@@ -160360,11 +160427,12 @@ function isModuleSpecifierMissingOrEmpty(specifier) {
160360
160427
  return true;
160361
160428
  return !((_a = tryCast(isExternalModuleReference(specifier) ? specifier.expression : specifier, isStringLiteralLike)) == null ? void 0 : _a.text);
160362
160429
  }
160363
- function getVariableOrParameterDeclaration(contextToken) {
160430
+ function getVariableOrParameterDeclaration(contextToken, location) {
160364
160431
  if (!contextToken)
160365
160432
  return;
160366
- const declaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node) || (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
160367
- return declaration;
160433
+ const possiblyParameterDeclaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
160434
+ const possiblyVariableDeclaration = findAncestor(location, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node));
160435
+ return possiblyParameterDeclaration || possiblyVariableDeclaration;
160368
160436
  }
160369
160437
  function isArrowFunctionBody(node) {
160370
160438
  return node.parent && isArrowFunction(node.parent) && (node.parent.body === node || // const a = () => /**/;
@@ -172957,6 +173025,7 @@ __export(ts_exports2, {
172957
173025
  isImportTypeNode: () => isImportTypeNode,
172958
173026
  isImportableFile: () => isImportableFile,
172959
173027
  isInComment: () => isInComment,
173028
+ isInCompoundLikeAssignment: () => isInCompoundLikeAssignment,
172960
173029
  isInExpressionContext: () => isInExpressionContext,
172961
173030
  isInJSDoc: () => isInJSDoc,
172962
173031
  isInJSFile: () => isInJSFile,
@@ -173249,6 +173318,7 @@ __export(ts_exports2, {
173249
173318
  isSetAccessor: () => isSetAccessor,
173250
173319
  isSetAccessorDeclaration: () => isSetAccessorDeclaration,
173251
173320
  isShebangTrivia: () => isShebangTrivia,
173321
+ isShiftOperatorOrHigher: () => isShiftOperatorOrHigher,
173252
173322
  isShorthandAmbientModuleSymbol: () => isShorthandAmbientModuleSymbol,
173253
173323
  isShorthandPropertyAssignment: () => isShorthandPropertyAssignment,
173254
173324
  isSignedNumericLiteral: () => isSignedNumericLiteral,
@@ -187470,6 +187540,7 @@ start(initializeNodeSystem(), require("os").platform());
187470
187540
  isImportTypeNode,
187471
187541
  isImportableFile,
187472
187542
  isInComment,
187543
+ isInCompoundLikeAssignment,
187473
187544
  isInExpressionContext,
187474
187545
  isInJSDoc,
187475
187546
  isInJSFile,
@@ -187762,6 +187833,7 @@ start(initializeNodeSystem(), require("os").platform());
187762
187833
  isSetAccessor,
187763
187834
  isSetAccessorDeclaration,
187764
187835
  isShebangTrivia,
187836
+ isShiftOperatorOrHigher,
187765
187837
  isShorthandAmbientModuleSymbol,
187766
187838
  isShorthandPropertyAssignment,
187767
187839
  isSignedNumericLiteral,
@@ -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;