typescript 5.2.0-dev.20230626 → 5.2.0-dev.20230628

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/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.2";
21
- var version = `${versionMajorMinor}.0-dev.20230626`;
21
+ var version = `${versionMajorMinor}.0-dev.20230628`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6212,7 +6212,6 @@ var Diagnostics = {
6212
6212
  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}'."),
6213
6213
  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}'."),
6214
6214
  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}'."),
6215
- 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."),
6216
6215
  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."),
6217
6216
  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'?"),
6218
6217
  This_expression_is_not_callable: diag(2349, 1 /* Error */, "This_expression_is_not_callable_2349", "This expression is not callable."),
@@ -6822,7 +6821,6 @@ var Diagnostics = {
6822
6821
  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}."),
6823
6822
  _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}'."),
6824
6823
  Cannot_read_file_0: diag(5083, 1 /* Error */, "Cannot_read_file_0_5083", "Cannot read file '{0}'."),
6825
- 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."),
6826
6824
  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."),
6827
6825
  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."),
6828
6826
  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."),
@@ -7748,6 +7746,7 @@ var Diagnostics = {
7748
7746
  Inline_variable: diag(95184, 3 /* Message */, "Inline_variable_95184", "Inline variable"),
7749
7747
  Could_not_find_variable_to_inline: diag(95185, 3 /* Message */, "Could_not_find_variable_to_inline_95185", "Could not find variable to inline."),
7750
7748
  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."),
7749
+ 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}'."),
7751
7750
  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."),
7752
7751
  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'."),
7753
7752
  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?"),
@@ -47964,19 +47963,18 @@ function createTypeChecker(host) {
47964
47963
  const arity = getTypeReferenceArity(type2);
47965
47964
  const tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
47966
47965
  if (tupleConstituentNodes) {
47967
- if (type2.target.labeledElementDeclarations) {
47968
- for (let i = 0; i < tupleConstituentNodes.length; i++) {
47969
- const flags = type2.target.elementFlags[i];
47966
+ const { labeledElementDeclarations } = type2.target;
47967
+ for (let i = 0; i < tupleConstituentNodes.length; i++) {
47968
+ const flags = type2.target.elementFlags[i];
47969
+ const labeledElementDeclaration = labeledElementDeclarations == null ? void 0 : labeledElementDeclarations[i];
47970
+ if (labeledElementDeclaration) {
47970
47971
  tupleConstituentNodes[i] = factory.createNamedTupleMember(
47971
47972
  flags & 12 /* Variable */ ? factory.createToken(26 /* DotDotDotToken */) : void 0,
47972
- factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(type2.target.labeledElementDeclarations[i]))),
47973
+ factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(labeledElementDeclaration))),
47973
47974
  flags & 2 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
47974
47975
  flags & 4 /* Rest */ ? factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]
47975
47976
  );
47976
- }
47977
- } else {
47978
- for (let i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) {
47979
- const flags = type2.target.elementFlags[i];
47977
+ } else {
47980
47978
  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];
47981
47979
  }
47982
47980
  }
@@ -53088,17 +53086,18 @@ function createTypeChecker(host) {
53088
53086
  function getExpandedParameters(sig, skipUnionExpanding) {
53089
53087
  if (signatureHasRestParameter(sig)) {
53090
53088
  const restIndex = sig.parameters.length - 1;
53089
+ const restName = sig.parameters[restIndex].escapedName;
53091
53090
  const restType = getTypeOfSymbol(sig.parameters[restIndex]);
53092
53091
  if (isTupleType(restType)) {
53093
- return [expandSignatureParametersWithTupleMembers(restType, restIndex)];
53092
+ return [expandSignatureParametersWithTupleMembers(restType, restIndex, restName)];
53094
53093
  } else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && every(restType.types, isTupleType)) {
53095
- return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex));
53094
+ return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex, restName));
53096
53095
  }
53097
53096
  }
53098
53097
  return [sig.parameters];
53099
- function expandSignatureParametersWithTupleMembers(restType, restIndex) {
53100
- const elementTypes = getElementTypes(restType);
53101
- const associatedNames = getUniqAssociatedNamesFromTupleType(restType);
53098
+ function expandSignatureParametersWithTupleMembers(restType, restIndex, restName) {
53099
+ const elementTypes = getTypeArguments(restType);
53100
+ const associatedNames = getUniqAssociatedNamesFromTupleType(restType, restName);
53102
53101
  const restParams = map(elementTypes, (t, i) => {
53103
53102
  const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
53104
53103
  const flags = restType.target.elementFlags[i];
@@ -53109,10 +53108,10 @@ function createTypeChecker(host) {
53109
53108
  });
53110
53109
  return concatenate(sig.parameters.slice(0, restIndex), restParams);
53111
53110
  }
53112
- function getUniqAssociatedNamesFromTupleType(type) {
53111
+ function getUniqAssociatedNamesFromTupleType(type, restName) {
53113
53112
  const associatedNamesMap = /* @__PURE__ */ new Map();
53114
- return map(type.target.labeledElementDeclarations, (labeledElement) => {
53115
- const name = getTupleElementLabel(labeledElement);
53113
+ return map(type.target.labeledElementDeclarations, (labeledElement, i) => {
53114
+ const name = getTupleElementLabel(labeledElement, i, restName);
53116
53115
  const prevCounter = associatedNamesMap.get(name);
53117
53116
  if (prevCounter === void 0) {
53118
53117
  associatedNamesMap.set(name, 1);
@@ -56046,13 +56045,10 @@ function createTypeChecker(host) {
56046
56045
  return readonly ? globalReadonlyArrayType : globalArrayType;
56047
56046
  }
56048
56047
  const elementFlags = map(node.elements, getTupleElementFlags);
56049
- const missingName = some(node.elements, (e) => e.kind !== 202 /* NamedTupleMember */);
56050
- return getTupleTargetType(
56051
- elementFlags,
56052
- readonly,
56053
- /*associatedNames*/
56054
- missingName ? void 0 : node.elements
56055
- );
56048
+ return getTupleTargetType(elementFlags, readonly, map(node.elements, memberIfLabeledElementDeclaration));
56049
+ }
56050
+ function memberIfLabeledElementDeclaration(member) {
56051
+ return isNamedTupleMember(member) || isParameter(member) ? member : void 0;
56056
56052
  }
56057
56053
  function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
56058
56054
  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));
@@ -56127,7 +56123,7 @@ function createTypeChecker(host) {
56127
56123
  function isReadonlyTypeOperator(node) {
56128
56124
  return isTypeOperatorNode(node) && node.operator === 148 /* ReadonlyKeyword */;
56129
56125
  }
56130
- function createTupleType(elementTypes, elementFlags, readonly = false, namedMemberDeclarations) {
56126
+ function createTupleType(elementTypes, elementFlags, readonly = false, namedMemberDeclarations = []) {
56131
56127
  const tupleTarget = getTupleTargetType(elementFlags || map(elementTypes, (_) => 1 /* Required */), readonly, namedMemberDeclarations);
56132
56128
  return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget;
56133
56129
  }
@@ -56135,7 +56131,8 @@ function createTypeChecker(host) {
56135
56131
  if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) {
56136
56132
  return readonly ? globalReadonlyArrayType : globalArrayType;
56137
56133
  }
56138
- const key = map(elementFlags, (f) => f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*").join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + map(namedMemberDeclarations, getNodeId).join(",") : "");
56134
+ const memberIds = mapDefined(namedMemberDeclarations, (node) => node ? getNodeId(node) : void 0);
56135
+ const key = map(elementFlags, (f) => f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*").join() + (readonly ? "R" : "") + (memberIds.length ? "," + memberIds.join(",") : "");
56139
56136
  let type = tupleTypes.get(key);
56140
56137
  if (!type) {
56141
56138
  tupleTypes.set(key, type = createTupleTargetType(elementFlags, readonly, namedMemberDeclarations));
@@ -56217,7 +56214,7 @@ function createTypeChecker(host) {
56217
56214
  }
56218
56215
  const expandedTypes = [];
56219
56216
  const expandedFlags = [];
56220
- let expandedDeclarations = [];
56217
+ const expandedDeclarations = [];
56221
56218
  let lastRequiredIndex = -1;
56222
56219
  let firstRestIndex = -1;
56223
56220
  let lastOptionalOrRestIndex = -1;
@@ -56255,7 +56252,7 @@ function createTypeChecker(host) {
56255
56252
  ));
56256
56253
  expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
56257
56254
  expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
56258
- expandedDeclarations == null ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
56255
+ expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
56259
56256
  }
56260
56257
  const tupleTarget = getTupleTargetType(expandedFlags, target.readonly, expandedDeclarations);
56261
56258
  return tupleTarget === emptyGenericType ? emptyObjectType : expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget;
@@ -56275,11 +56272,7 @@ function createTypeChecker(host) {
56275
56272
  true
56276
56273
  ) : type);
56277
56274
  expandedFlags.push(flags);
56278
- if (expandedDeclarations && declaration) {
56279
- expandedDeclarations.push(declaration);
56280
- } else {
56281
- expandedDeclarations = void 0;
56282
- }
56275
+ expandedDeclarations.push(declaration);
56283
56276
  }
56284
56277
  }
56285
56278
  function sliceTupleType(type, index, endSkipCount = 0) {
@@ -60953,7 +60946,6 @@ function createTypeChecker(host) {
60953
60946
  } else if (targetFlags & 8388608 /* IndexedAccess */) {
60954
60947
  if (sourceFlags & 8388608 /* IndexedAccess */) {
60955
60948
  if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
60956
- instantiateType(source2.objectType, reportUnreliableMapper);
60957
60949
  result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
60958
60950
  }
60959
60951
  if (result2) {
@@ -62108,7 +62100,7 @@ function createTypeChecker(host) {
62108
62100
  }
62109
62101
  }
62110
62102
  }
62111
- const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
62103
+ const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i]), 0 /* None */) : target;
62112
62104
  return filtered.flags & 131072 /* Never */ ? target : filtered;
62113
62105
  }
62114
62106
  function isWeakType(type) {
@@ -66638,17 +66630,14 @@ function createTypeChecker(host) {
66638
66630
  }
66639
66631
  }
66640
66632
  function getTypeForThisExpressionFromJSDoc(node) {
66641
- const jsdocType = getJSDocType(node);
66642
- if (jsdocType && jsdocType.kind === 324 /* JSDocFunctionType */) {
66643
- const jsDocFunctionType = jsdocType;
66644
- if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) {
66645
- return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
66646
- }
66647
- }
66648
66633
  const thisTag = getJSDocThisTag(node);
66649
66634
  if (thisTag && thisTag.typeExpression) {
66650
66635
  return getTypeFromTypeNode(thisTag.typeExpression);
66651
66636
  }
66637
+ const signature = getSignatureOfTypeTag(node);
66638
+ if (signature) {
66639
+ return getThisTypeOfSignature(signature);
66640
+ }
66652
66641
  }
66653
66642
  function isInConstructorArgumentInitializer(node, constructorDecl) {
66654
66643
  return !!findAncestor(node, (n) => isFunctionLikeDeclaration(n) ? "quit" : n.kind === 169 /* Parameter */ && n.parent === constructorDecl);
@@ -70550,12 +70539,7 @@ function createTypeChecker(host) {
70550
70539
  }
70551
70540
  const candidates = candidatesOutArray || [];
70552
70541
  reorderCandidates(signatures, candidates, callChainFlags);
70553
- if (!candidates.length) {
70554
- if (reportErrors2) {
70555
- diagnostics.add(getDiagnosticForCallNode(node, Diagnostics.Call_target_does_not_contain_any_signatures));
70556
- }
70557
- return resolveErrorCall(node);
70558
- }
70542
+ Debug.assert(candidates.length, "Revert #54442 and add a testcase with whatever triggered this");
70559
70543
  const args = getEffectiveCallArguments(node);
70560
70544
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
70561
70545
  let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
@@ -72007,7 +71991,10 @@ function createTypeChecker(host) {
72007
71991
  }
72008
71992
  return type;
72009
71993
  }
72010
- function getTupleElementLabel(d) {
71994
+ function getTupleElementLabel(d, index, restParameterName = "arg") {
71995
+ if (!d) {
71996
+ return `${restParameterName}_${index}`;
71997
+ }
72011
71998
  Debug.assert(isIdentifier(d.name));
72012
71999
  return d.name.escapedText;
72013
72000
  }
@@ -72021,7 +72008,7 @@ function createTypeChecker(host) {
72021
72008
  if (isTupleType(restType)) {
72022
72009
  const associatedNames = restType.target.labeledElementDeclarations;
72023
72010
  const index = pos - paramCount;
72024
- return associatedNames && getTupleElementLabel(associatedNames[index]) || restParameter.escapedName + "_" + index;
72011
+ return getTupleElementLabel(associatedNames == null ? void 0 : associatedNames[index], index, restParameter.escapedName);
72025
72012
  }
72026
72013
  return restParameter.escapedName;
72027
72014
  }
@@ -75376,12 +75363,7 @@ function createTypeChecker(host) {
75376
75363
  const elementTypes = node.elements;
75377
75364
  let seenOptionalElement = false;
75378
75365
  let seenRestElement = false;
75379
- const hasNamedElement = some(elementTypes, isNamedTupleMember);
75380
75366
  for (const e of elementTypes) {
75381
- if (e.kind !== 202 /* NamedTupleMember */ && hasNamedElement) {
75382
- grammarErrorOnNode(e, Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
75383
- break;
75384
- }
75385
75367
  const flags = getTupleElementFlags(e);
75386
75368
  if (flags & 8 /* Variadic */) {
75387
75369
  const type = getTypeFromTypeNode(e.type);
@@ -107536,6 +107518,21 @@ function transformDeclarations(context) {
107536
107518
  const modifiers = factory2.createModifiersFromModifierFlags(getEffectiveModifierFlags(statement) & (258047 /* All */ ^ 1 /* Export */));
107537
107519
  return factory2.updateModifiers(statement, modifiers);
107538
107520
  }
107521
+ function updateModuleDeclarationAndKeyword(node, modifiers, name, body) {
107522
+ const updated = factory2.updateModuleDeclaration(node, modifiers, name, body);
107523
+ if (isAmbientModule(updated) || updated.flags & 32 /* Namespace */) {
107524
+ return updated;
107525
+ }
107526
+ const fixed = factory2.createModuleDeclaration(
107527
+ updated.modifiers,
107528
+ updated.name,
107529
+ updated.body,
107530
+ updated.flags | 32 /* Namespace */
107531
+ );
107532
+ setOriginalNode(fixed, updated);
107533
+ setTextRange(fixed, updated);
107534
+ return fixed;
107535
+ }
107539
107536
  function transformTopLevelDeclaration(input) {
107540
107537
  if (lateMarkedStatements) {
107541
107538
  while (orderedRemoveItem(lateMarkedStatements, input))
@@ -107723,7 +107720,7 @@ function transformDeclarations(context) {
107723
107720
  needsScopeFixMarker = oldNeedsScopeFix;
107724
107721
  resultHasScopeMarker = oldHasScopeFix;
107725
107722
  const mods = ensureModifiers(input);
107726
- return cleanup(factory2.updateModuleDeclaration(
107723
+ return cleanup(updateModuleDeclarationAndKeyword(
107727
107724
  input,
107728
107725
  mods,
107729
107726
  isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name,
@@ -107737,7 +107734,7 @@ function transformDeclarations(context) {
107737
107734
  const id = getOriginalNodeId(inner);
107738
107735
  const body = lateStatementReplacementMap.get(id);
107739
107736
  lateStatementReplacementMap.delete(id);
107740
- return cleanup(factory2.updateModuleDeclaration(
107737
+ return cleanup(updateModuleDeclarationAndKeyword(
107741
107738
  input,
107742
107739
  mods,
107743
107740
  input.name,