@typescript-deploys/pr-build 5.2.0-pr-53356-21 → 5.2.0-pr-48838-5

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-insiders.20230615`;
21
+ var version = `${versionMajorMinor}.0-insiders.20230617`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -2315,7 +2315,7 @@ var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
2315
2315
  var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
2316
2316
  var buildPartRegExp = /^[a-z0-9-]+$/i;
2317
2317
  var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
2318
- var _Version = class {
2318
+ var _Version = class _Version {
2319
2319
  constructor(major, minor = 0, patch = 0, prerelease = "", build2 = "") {
2320
2320
  if (typeof major === "string") {
2321
2321
  const result = Debug.checkDefined(tryParseComponents(major), "Invalid version");
@@ -2379,8 +2379,8 @@ var _Version = class {
2379
2379
  return result;
2380
2380
  }
2381
2381
  };
2382
+ _Version.zero = new _Version(0, 0, 0, ["0"]);
2382
2383
  var Version = _Version;
2383
- Version.zero = new _Version(0, 0, 0, ["0"]);
2384
2384
  function tryParseComponents(text) {
2385
2385
  const match = versionRegExp.exec(text);
2386
2386
  if (!match)
@@ -2427,14 +2427,14 @@ function comparePrereleaseIdentifiers(left, right) {
2427
2427
  }
2428
2428
  return compareValues(left.length, right.length);
2429
2429
  }
2430
- var VersionRange = class {
2430
+ var VersionRange = class _VersionRange {
2431
2431
  constructor(spec) {
2432
2432
  this._alternatives = spec ? Debug.checkDefined(parseRange(spec), "Invalid range spec.") : emptyArray;
2433
2433
  }
2434
2434
  static tryParse(text) {
2435
2435
  const sets = parseRange(text);
2436
2436
  if (sets) {
2437
- const range = new VersionRange("");
2437
+ const range = new _VersionRange("");
2438
2438
  range._alternatives = sets;
2439
2439
  return range;
2440
2440
  }
@@ -6808,6 +6808,7 @@ var Diagnostics = {
6808
6808
  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}."),
6809
6809
  _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}'."),
6810
6810
  Cannot_read_file_0: diag(5083, 1 /* Error */, "Cannot_read_file_0_5083", "Cannot read file '{0}'."),
6811
+ 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."),
6811
6812
  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."),
6812
6813
  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."),
6813
6814
  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."),
@@ -47706,18 +47707,19 @@ function createTypeChecker(host) {
47706
47707
  const arity = getTypeReferenceArity(type2);
47707
47708
  const tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
47708
47709
  if (tupleConstituentNodes) {
47709
- const { labeledElementDeclarations } = type2.target;
47710
- for (let i = 0; i < tupleConstituentNodes.length; i++) {
47711
- const flags = type2.target.elementFlags[i];
47712
- const labeledElementDeclaration = labeledElementDeclarations == null ? void 0 : labeledElementDeclarations[i];
47713
- if (labeledElementDeclaration) {
47710
+ if (type2.target.labeledElementDeclarations) {
47711
+ for (let i = 0; i < tupleConstituentNodes.length; i++) {
47712
+ const flags = type2.target.elementFlags[i];
47714
47713
  tupleConstituentNodes[i] = factory.createNamedTupleMember(
47715
47714
  flags & 12 /* Variable */ ? factory.createToken(26 /* DotDotDotToken */) : void 0,
47716
- factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(labeledElementDeclaration))),
47715
+ factory.createIdentifier(unescapeLeadingUnderscores(getTupleElementLabel(type2.target.labeledElementDeclarations[i]))),
47717
47716
  flags & 2 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
47718
47717
  flags & 4 /* Rest */ ? factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]
47719
47718
  );
47720
- } else {
47719
+ }
47720
+ } else {
47721
+ for (let i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) {
47722
+ const flags = type2.target.elementFlags[i];
47721
47723
  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];
47722
47724
  }
47723
47725
  }
@@ -52824,18 +52826,17 @@ function createTypeChecker(host) {
52824
52826
  function getExpandedParameters(sig, skipUnionExpanding) {
52825
52827
  if (signatureHasRestParameter(sig)) {
52826
52828
  const restIndex = sig.parameters.length - 1;
52827
- const restName = sig.parameters[restIndex].escapedName;
52828
52829
  const restType = getTypeOfSymbol(sig.parameters[restIndex]);
52829
52830
  if (isTupleType(restType)) {
52830
- return [expandSignatureParametersWithTupleMembers(restType, restIndex, restName)];
52831
+ return [expandSignatureParametersWithTupleMembers(restType, restIndex)];
52831
52832
  } else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && every(restType.types, isTupleType)) {
52832
- return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex, restName));
52833
+ return map(restType.types, (t) => expandSignatureParametersWithTupleMembers(t, restIndex));
52833
52834
  }
52834
52835
  }
52835
52836
  return [sig.parameters];
52836
- function expandSignatureParametersWithTupleMembers(restType, restIndex, restName) {
52837
- const elementTypes = getTypeArguments(restType);
52838
- const associatedNames = getUniqAssociatedNamesFromTupleType(restType, restName);
52837
+ function expandSignatureParametersWithTupleMembers(restType, restIndex) {
52838
+ const elementTypes = getElementTypes(restType);
52839
+ const associatedNames = getUniqAssociatedNamesFromTupleType(restType);
52839
52840
  const restParams = map(elementTypes, (t, i) => {
52840
52841
  const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
52841
52842
  const flags = restType.target.elementFlags[i];
@@ -52846,10 +52847,10 @@ function createTypeChecker(host) {
52846
52847
  });
52847
52848
  return concatenate(sig.parameters.slice(0, restIndex), restParams);
52848
52849
  }
52849
- function getUniqAssociatedNamesFromTupleType(type, restName) {
52850
+ function getUniqAssociatedNamesFromTupleType(type) {
52850
52851
  const associatedNamesMap = /* @__PURE__ */ new Map();
52851
- return map(type.target.labeledElementDeclarations, (labeledElement, i) => {
52852
- const name = getTupleElementLabel(labeledElement, i, restName);
52852
+ return map(type.target.labeledElementDeclarations, (labeledElement) => {
52853
+ const name = getTupleElementLabel(labeledElement);
52853
52854
  const prevCounter = associatedNamesMap.get(name);
52854
52855
  if (prevCounter === void 0) {
52855
52856
  associatedNamesMap.set(name, 1);
@@ -53648,9 +53649,9 @@ function createTypeChecker(host) {
53648
53649
  function getConstraintOfTypeParameter(typeParameter) {
53649
53650
  return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : void 0;
53650
53651
  }
53651
- function isConstTypeVariable(type) {
53652
+ function isConstTypeVariable(type, depth = 0) {
53652
53653
  var _a;
53653
- return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0));
53654
+ return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
53654
53655
  }
53655
53656
  function getConstraintOfIndexedAccess(type) {
53656
53657
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -55767,10 +55768,13 @@ function createTypeChecker(host) {
55767
55768
  return readonly ? globalReadonlyArrayType : globalArrayType;
55768
55769
  }
55769
55770
  const elementFlags = map(node.elements, getTupleElementFlags);
55770
- return getTupleTargetType(elementFlags, readonly, map(node.elements, memberIfLabeledElementDeclaration));
55771
- }
55772
- function memberIfLabeledElementDeclaration(member) {
55773
- return isNamedTupleMember(member) || isParameter(member) ? member : void 0;
55771
+ const missingName = some(node.elements, (e) => e.kind !== 201 /* NamedTupleMember */);
55772
+ return getTupleTargetType(
55773
+ elementFlags,
55774
+ readonly,
55775
+ /*associatedNames*/
55776
+ missingName ? void 0 : node.elements
55777
+ );
55774
55778
  }
55775
55779
  function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
55776
55780
  return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 187 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : node.kind === 188 /* TupleType */ ? some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || some(node.typeArguments, mayResolveTypeAlias));
@@ -55845,7 +55849,7 @@ function createTypeChecker(host) {
55845
55849
  function isReadonlyTypeOperator(node) {
55846
55850
  return isTypeOperatorNode(node) && node.operator === 148 /* ReadonlyKeyword */;
55847
55851
  }
55848
- function createTupleType(elementTypes, elementFlags, readonly = false, namedMemberDeclarations = []) {
55852
+ function createTupleType(elementTypes, elementFlags, readonly = false, namedMemberDeclarations) {
55849
55853
  const tupleTarget = getTupleTargetType(elementFlags || map(elementTypes, (_) => 1 /* Required */), readonly, namedMemberDeclarations);
55850
55854
  return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget;
55851
55855
  }
@@ -55853,8 +55857,7 @@ function createTypeChecker(host) {
55853
55857
  if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) {
55854
55858
  return readonly ? globalReadonlyArrayType : globalArrayType;
55855
55859
  }
55856
- const memberIds = mapDefined(namedMemberDeclarations, (node) => node ? getNodeId(node) : void 0);
55857
- const key = map(elementFlags, (f) => f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*").join() + (readonly ? "R" : "") + (memberIds.length ? "," + memberIds.join(",") : "");
55860
+ const key = map(elementFlags, (f) => f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*").join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + map(namedMemberDeclarations, getNodeId).join(",") : "");
55858
55861
  let type = tupleTypes.get(key);
55859
55862
  if (!type) {
55860
55863
  tupleTypes.set(key, type = createTupleTargetType(elementFlags, readonly, namedMemberDeclarations));
@@ -55936,7 +55939,7 @@ function createTypeChecker(host) {
55936
55939
  }
55937
55940
  const expandedTypes = [];
55938
55941
  const expandedFlags = [];
55939
- const expandedDeclarations = [];
55942
+ let expandedDeclarations = [];
55940
55943
  let lastRequiredIndex = -1;
55941
55944
  let firstRestIndex = -1;
55942
55945
  let lastOptionalOrRestIndex = -1;
@@ -55974,7 +55977,7 @@ function createTypeChecker(host) {
55974
55977
  ));
55975
55978
  expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
55976
55979
  expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
55977
- expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
55980
+ expandedDeclarations == null ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
55978
55981
  }
55979
55982
  const tupleTarget = getTupleTargetType(expandedFlags, target.readonly, expandedDeclarations);
55980
55983
  return tupleTarget === emptyGenericType ? emptyObjectType : expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget;
@@ -55994,7 +55997,11 @@ function createTypeChecker(host) {
55994
55997
  true
55995
55998
  ) : type);
55996
55999
  expandedFlags.push(flags);
55997
- expandedDeclarations.push(declaration);
56000
+ if (expandedDeclarations && declaration) {
56001
+ expandedDeclarations.push(declaration);
56002
+ } else {
56003
+ expandedDeclarations = void 0;
56004
+ }
55998
56005
  }
55999
56006
  }
56000
56007
  function sliceTupleType(type, index, endSkipCount = 0) {
@@ -67195,7 +67202,7 @@ function createTypeChecker(host) {
67195
67202
  function instantiateContextualType(contextualType, node, contextFlags) {
67196
67203
  if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) {
67197
67204
  const inferenceContext = getInferenceContext(node);
67198
- if (inferenceContext && contextFlags & 1 /* Signature */ && some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
67205
+ if (inferenceContext && (contextFlags & 1 /* Signature */ || maybeTypeOfKind(contextualType, 25165824 /* Simplifiable */)) && some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
67199
67206
  return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
67200
67207
  }
67201
67208
  if (inferenceContext == null ? void 0 : inferenceContext.returnMapper) {
@@ -71726,10 +71733,7 @@ function createTypeChecker(host) {
71726
71733
  }
71727
71734
  return type;
71728
71735
  }
71729
- function getTupleElementLabel(d, index, restParameterName = "arg") {
71730
- if (!d) {
71731
- return `${restParameterName}_${index}`;
71732
- }
71736
+ function getTupleElementLabel(d) {
71733
71737
  Debug.assert(isIdentifier(d.name));
71734
71738
  return d.name.escapedText;
71735
71739
  }
@@ -71743,7 +71747,7 @@ function createTypeChecker(host) {
71743
71747
  if (isTupleType(restType)) {
71744
71748
  const associatedNames = restType.target.labeledElementDeclarations;
71745
71749
  const index = pos - paramCount;
71746
- return getTupleElementLabel(associatedNames == null ? void 0 : associatedNames[index], index, restParameter.escapedName);
71750
+ return associatedNames && getTupleElementLabel(associatedNames[index]) || restParameter.escapedName + "_" + index;
71747
71751
  }
71748
71752
  return restParameter.escapedName;
71749
71753
  }
@@ -75098,7 +75102,12 @@ function createTypeChecker(host) {
75098
75102
  const elementTypes = node.elements;
75099
75103
  let seenOptionalElement = false;
75100
75104
  let seenRestElement = false;
75105
+ const hasNamedElement = some(elementTypes, isNamedTupleMember);
75101
75106
  for (const e of elementTypes) {
75107
+ if (e.kind !== 201 /* NamedTupleMember */ && hasNamedElement) {
75108
+ grammarErrorOnNode(e, Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
75109
+ break;
75110
+ }
75102
75111
  const flags = getTupleElementFlags(e);
75103
75112
  if (flags & 8 /* Variadic */) {
75104
75113
  const type = getTypeFromTypeNode(e.type);
@@ -83349,13 +83358,13 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
83349
83358
  readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
83350
83359
  };
83351
83360
  }
83352
- var SymbolTrackerImpl = class {
83361
+ var SymbolTrackerImpl = class _SymbolTrackerImpl {
83353
83362
  constructor(context, tracker, moduleResolverHost) {
83354
83363
  this.moduleResolverHost = void 0;
83355
83364
  this.inner = void 0;
83356
83365
  this.disableTrackSymbol = false;
83357
83366
  var _a;
83358
- while (tracker instanceof SymbolTrackerImpl) {
83367
+ while (tracker instanceof _SymbolTrackerImpl) {
83359
83368
  tracker = tracker.inner;
83360
83369
  }
83361
83370
  this.inner = tracker;