@typescript-deploys/pr-build 5.3.0-pr-55991-50 → 5.3.0-pr-56004-10

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
@@ -54055,7 +54055,12 @@ function createTypeChecker(host) {
54055
54055
  const checkType = type.checkType;
54056
54056
  const constraint = getLowerBoundOfKeyType(checkType);
54057
54057
  if (constraint !== checkType) {
54058
- return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54058
+ return getConditionalTypeInstantiation(
54059
+ type,
54060
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
54061
+ /*forConstraint*/
54062
+ false
54063
+ );
54059
54064
  }
54060
54065
  }
54061
54066
  return type;
@@ -54407,7 +54412,12 @@ function createTypeChecker(host) {
54407
54412
  );
54408
54413
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
54409
54414
  if (constraint && constraint !== type.checkType) {
54410
- const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54415
+ const instantiated = getConditionalTypeInstantiation(
54416
+ type,
54417
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
54418
+ /*forConstraint*/
54419
+ true
54420
+ );
54411
54421
  if (!(instantiated.flags & 131072 /* Never */)) {
54412
54422
  type.resolvedConstraintOfDistributive = instantiated;
54413
54423
  return instantiated;
@@ -57970,7 +57980,7 @@ function createTypeChecker(host) {
57970
57980
  function isDeferredType(type, checkTuples) {
57971
57981
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
57972
57982
  }
57973
- function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
57983
+ function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
57974
57984
  let result;
57975
57985
  let extraTypes;
57976
57986
  let tailCount = 0;
@@ -58016,7 +58026,7 @@ function createTypeChecker(host) {
58016
58026
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
58017
58027
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
58018
58028
  if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
58019
- if (checkType.flags & 1 /* Any */) {
58029
+ if (checkType.flags & 1 /* Any */ || forConstraint && areTypesComparable(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType))) {
58020
58030
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
58021
58031
  }
58022
58032
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -58126,7 +58136,9 @@ function createTypeChecker(host) {
58126
58136
  links.resolvedType = getConditionalType(
58127
58137
  root,
58128
58138
  /*mapper*/
58129
- void 0
58139
+ void 0,
58140
+ /*forConstraint*/
58141
+ false
58130
58142
  );
58131
58143
  if (outerTypeParameters) {
58132
58144
  root.instantiations = /* @__PURE__ */ new Map();
@@ -58980,17 +58992,17 @@ function createTypeChecker(host) {
58980
58992
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
58981
58993
  return result;
58982
58994
  }
58983
- function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
58995
+ function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
58984
58996
  const root = type.root;
58985
58997
  if (root.outerTypeParameters) {
58986
58998
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
58987
- const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
58999
+ const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
58988
59000
  let result = root.instantiations.get(id);
58989
59001
  if (!result) {
58990
59002
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
58991
59003
  const checkType = root.checkType;
58992
59004
  const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
58993
- result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments);
59005
+ result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
58994
59006
  root.instantiations.set(id, result);
58995
59007
  }
58996
59008
  return result;
@@ -59078,7 +59090,14 @@ function createTypeChecker(host) {
59078
59090
  );
59079
59091
  }
59080
59092
  if (flags & 16777216 /* Conditional */) {
59081
- return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
59093
+ return getConditionalTypeInstantiation(
59094
+ type,
59095
+ combineTypeMappers(type.mapper, mapper),
59096
+ /*forConstraint*/
59097
+ false,
59098
+ aliasSymbol,
59099
+ aliasTypeArguments
59100
+ );
59082
59101
  }
59083
59102
  if (flags & 33554432 /* Substitution */) {
59084
59103
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -61619,13 +61638,6 @@ function createTypeChecker(host) {
61619
61638
  return result2;
61620
61639
  }
61621
61640
  }
61622
- } else {
61623
- const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
61624
- if (distributiveConstraint) {
61625
- if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
61626
- return result2;
61627
- }
61628
- }
61629
61641
  }
61630
61642
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
61631
61643
  if (defaultConstraint) {
@@ -61633,6 +61645,13 @@ function createTypeChecker(host) {
61633
61645
  return result2;
61634
61646
  }
61635
61647
  }
61648
+ const distributiveConstraint = !(targetFlags & 16777216 /* Conditional */) && hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
61649
+ if (distributiveConstraint) {
61650
+ resetErrorInfo(saveErrorInfo);
61651
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
61652
+ return result2;
61653
+ }
61654
+ }
61636
61655
  } else {
61637
61656
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
61638
61657
  return -1 /* True */;
@@ -65740,7 +65759,16 @@ function createTypeChecker(host) {
65740
65759
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
65741
65760
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65742
65761
  } else if (expr.kind === 112 /* TrueKeyword */) {
65743
- type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65762
+ const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart);
65763
+ const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0;
65764
+ if (clauseExpression) {
65765
+ type = narrowType(
65766
+ type,
65767
+ clauseExpression,
65768
+ /*assumeTrue*/
65769
+ true
65770
+ );
65771
+ }
65744
65772
  } else {
65745
65773
  if (strictNullChecks) {
65746
65774
  if (optionalChainContainsReference(expr, reference)) {
@@ -66286,45 +66314,6 @@ function createTypeChecker(host) {
66286
66314
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
66287
66315
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
66288
66316
  }
66289
- function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
66290
- const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
66291
- const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
66292
- const clausesBefore = switchStatement.caseBlock.clauses.slice(0, clauseStart);
66293
- for (const clause of clausesBefore) {
66294
- if (clause.kind === 296 /* CaseClause */) {
66295
- type = narrowType(
66296
- type,
66297
- clause.expression,
66298
- /*assumeTrue*/
66299
- false
66300
- );
66301
- }
66302
- }
66303
- if (hasDefaultClause) {
66304
- const clausesAfter = switchStatement.caseBlock.clauses.slice(clauseEnd);
66305
- for (const clause of clausesAfter) {
66306
- if (clause.kind === 296 /* CaseClause */) {
66307
- type = narrowType(
66308
- type,
66309
- clause.expression,
66310
- /*assumeTrue*/
66311
- false
66312
- );
66313
- }
66314
- }
66315
- return type;
66316
- }
66317
- const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
66318
- return narrowTypeForTrueClauses(type, clauses);
66319
- }
66320
- function narrowTypeForTrueClauses(type, clauses) {
66321
- return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
66322
- type,
66323
- clause.expression,
66324
- /*assumeTrue*/
66325
- true
66326
- ) : neverType));
66327
- }
66328
66317
  function isMatchingConstructorReference(expr) {
66329
66318
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
66330
66319
  }
package/lib/tsserver.js CHANGED
@@ -58767,7 +58767,12 @@ function createTypeChecker(host) {
58767
58767
  const checkType = type.checkType;
58768
58768
  const constraint = getLowerBoundOfKeyType(checkType);
58769
58769
  if (constraint !== checkType) {
58770
- return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
58770
+ return getConditionalTypeInstantiation(
58771
+ type,
58772
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
58773
+ /*forConstraint*/
58774
+ false
58775
+ );
58771
58776
  }
58772
58777
  }
58773
58778
  return type;
@@ -59119,7 +59124,12 @@ function createTypeChecker(host) {
59119
59124
  );
59120
59125
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
59121
59126
  if (constraint && constraint !== type.checkType) {
59122
- const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
59127
+ const instantiated = getConditionalTypeInstantiation(
59128
+ type,
59129
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
59130
+ /*forConstraint*/
59131
+ true
59132
+ );
59123
59133
  if (!(instantiated.flags & 131072 /* Never */)) {
59124
59134
  type.resolvedConstraintOfDistributive = instantiated;
59125
59135
  return instantiated;
@@ -62682,7 +62692,7 @@ function createTypeChecker(host) {
62682
62692
  function isDeferredType(type, checkTuples) {
62683
62693
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
62684
62694
  }
62685
- function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
62695
+ function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
62686
62696
  let result;
62687
62697
  let extraTypes;
62688
62698
  let tailCount = 0;
@@ -62728,7 +62738,7 @@ function createTypeChecker(host) {
62728
62738
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
62729
62739
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
62730
62740
  if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
62731
- if (checkType.flags & 1 /* Any */) {
62741
+ if (checkType.flags & 1 /* Any */ || forConstraint && areTypesComparable(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType))) {
62732
62742
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
62733
62743
  }
62734
62744
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -62838,7 +62848,9 @@ function createTypeChecker(host) {
62838
62848
  links.resolvedType = getConditionalType(
62839
62849
  root,
62840
62850
  /*mapper*/
62841
- void 0
62851
+ void 0,
62852
+ /*forConstraint*/
62853
+ false
62842
62854
  );
62843
62855
  if (outerTypeParameters) {
62844
62856
  root.instantiations = /* @__PURE__ */ new Map();
@@ -63692,17 +63704,17 @@ function createTypeChecker(host) {
63692
63704
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
63693
63705
  return result;
63694
63706
  }
63695
- function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
63707
+ function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
63696
63708
  const root = type.root;
63697
63709
  if (root.outerTypeParameters) {
63698
63710
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
63699
- const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
63711
+ const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
63700
63712
  let result = root.instantiations.get(id);
63701
63713
  if (!result) {
63702
63714
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
63703
63715
  const checkType = root.checkType;
63704
63716
  const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
63705
- result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments);
63717
+ result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
63706
63718
  root.instantiations.set(id, result);
63707
63719
  }
63708
63720
  return result;
@@ -63790,7 +63802,14 @@ function createTypeChecker(host) {
63790
63802
  );
63791
63803
  }
63792
63804
  if (flags & 16777216 /* Conditional */) {
63793
- return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
63805
+ return getConditionalTypeInstantiation(
63806
+ type,
63807
+ combineTypeMappers(type.mapper, mapper),
63808
+ /*forConstraint*/
63809
+ false,
63810
+ aliasSymbol,
63811
+ aliasTypeArguments
63812
+ );
63794
63813
  }
63795
63814
  if (flags & 33554432 /* Substitution */) {
63796
63815
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -66331,13 +66350,6 @@ function createTypeChecker(host) {
66331
66350
  return result2;
66332
66351
  }
66333
66352
  }
66334
- } else {
66335
- const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
66336
- if (distributiveConstraint) {
66337
- if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
66338
- return result2;
66339
- }
66340
- }
66341
66353
  }
66342
66354
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
66343
66355
  if (defaultConstraint) {
@@ -66345,6 +66357,13 @@ function createTypeChecker(host) {
66345
66357
  return result2;
66346
66358
  }
66347
66359
  }
66360
+ const distributiveConstraint = !(targetFlags & 16777216 /* Conditional */) && hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
66361
+ if (distributiveConstraint) {
66362
+ resetErrorInfo(saveErrorInfo);
66363
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
66364
+ return result2;
66365
+ }
66366
+ }
66348
66367
  } else {
66349
66368
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
66350
66369
  return -1 /* True */;
@@ -70452,7 +70471,16 @@ function createTypeChecker(host) {
70452
70471
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
70453
70472
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70454
70473
  } else if (expr.kind === 112 /* TrueKeyword */) {
70455
- type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70474
+ const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart);
70475
+ const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0;
70476
+ if (clauseExpression) {
70477
+ type = narrowType(
70478
+ type,
70479
+ clauseExpression,
70480
+ /*assumeTrue*/
70481
+ true
70482
+ );
70483
+ }
70456
70484
  } else {
70457
70485
  if (strictNullChecks) {
70458
70486
  if (optionalChainContainsReference(expr, reference)) {
@@ -70998,45 +71026,6 @@ function createTypeChecker(host) {
70998
71026
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
70999
71027
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
71000
71028
  }
71001
- function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
71002
- const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
71003
- const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
71004
- const clausesBefore = switchStatement.caseBlock.clauses.slice(0, clauseStart);
71005
- for (const clause of clausesBefore) {
71006
- if (clause.kind === 296 /* CaseClause */) {
71007
- type = narrowType(
71008
- type,
71009
- clause.expression,
71010
- /*assumeTrue*/
71011
- false
71012
- );
71013
- }
71014
- }
71015
- if (hasDefaultClause) {
71016
- const clausesAfter = switchStatement.caseBlock.clauses.slice(clauseEnd);
71017
- for (const clause of clausesAfter) {
71018
- if (clause.kind === 296 /* CaseClause */) {
71019
- type = narrowType(
71020
- type,
71021
- clause.expression,
71022
- /*assumeTrue*/
71023
- false
71024
- );
71025
- }
71026
- }
71027
- return type;
71028
- }
71029
- const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
71030
- return narrowTypeForTrueClauses(type, clauses);
71031
- }
71032
- function narrowTypeForTrueClauses(type, clauses) {
71033
- return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
71034
- type,
71035
- clause.expression,
71036
- /*assumeTrue*/
71037
- true
71038
- ) : neverType));
71039
- }
71040
71029
  function isMatchingConstructorReference(expr) {
71041
71030
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
71042
71031
  }
package/lib/typescript.js CHANGED
@@ -56534,7 +56534,12 @@ ${lanes.join("\n")}
56534
56534
  const checkType = type.checkType;
56535
56535
  const constraint = getLowerBoundOfKeyType(checkType);
56536
56536
  if (constraint !== checkType) {
56537
- return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
56537
+ return getConditionalTypeInstantiation(
56538
+ type,
56539
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
56540
+ /*forConstraint*/
56541
+ false
56542
+ );
56538
56543
  }
56539
56544
  }
56540
56545
  return type;
@@ -56886,7 +56891,12 @@ ${lanes.join("\n")}
56886
56891
  );
56887
56892
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
56888
56893
  if (constraint && constraint !== type.checkType) {
56889
- const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
56894
+ const instantiated = getConditionalTypeInstantiation(
56895
+ type,
56896
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
56897
+ /*forConstraint*/
56898
+ true
56899
+ );
56890
56900
  if (!(instantiated.flags & 131072 /* Never */)) {
56891
56901
  type.resolvedConstraintOfDistributive = instantiated;
56892
56902
  return instantiated;
@@ -60449,7 +60459,7 @@ ${lanes.join("\n")}
60449
60459
  function isDeferredType(type, checkTuples) {
60450
60460
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
60451
60461
  }
60452
- function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
60462
+ function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
60453
60463
  let result;
60454
60464
  let extraTypes;
60455
60465
  let tailCount = 0;
@@ -60495,7 +60505,7 @@ ${lanes.join("\n")}
60495
60505
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
60496
60506
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
60497
60507
  if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
60498
- if (checkType.flags & 1 /* Any */) {
60508
+ if (checkType.flags & 1 /* Any */ || forConstraint && areTypesComparable(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType))) {
60499
60509
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
60500
60510
  }
60501
60511
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -60605,7 +60615,9 @@ ${lanes.join("\n")}
60605
60615
  links.resolvedType = getConditionalType(
60606
60616
  root,
60607
60617
  /*mapper*/
60608
- void 0
60618
+ void 0,
60619
+ /*forConstraint*/
60620
+ false
60609
60621
  );
60610
60622
  if (outerTypeParameters) {
60611
60623
  root.instantiations = /* @__PURE__ */ new Map();
@@ -61459,17 +61471,17 @@ ${lanes.join("\n")}
61459
61471
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
61460
61472
  return result;
61461
61473
  }
61462
- function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
61474
+ function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
61463
61475
  const root = type.root;
61464
61476
  if (root.outerTypeParameters) {
61465
61477
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
61466
- const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
61478
+ const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
61467
61479
  let result = root.instantiations.get(id);
61468
61480
  if (!result) {
61469
61481
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
61470
61482
  const checkType = root.checkType;
61471
61483
  const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
61472
- result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments);
61484
+ result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
61473
61485
  root.instantiations.set(id, result);
61474
61486
  }
61475
61487
  return result;
@@ -61557,7 +61569,14 @@ ${lanes.join("\n")}
61557
61569
  );
61558
61570
  }
61559
61571
  if (flags & 16777216 /* Conditional */) {
61560
- return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
61572
+ return getConditionalTypeInstantiation(
61573
+ type,
61574
+ combineTypeMappers(type.mapper, mapper),
61575
+ /*forConstraint*/
61576
+ false,
61577
+ aliasSymbol,
61578
+ aliasTypeArguments
61579
+ );
61561
61580
  }
61562
61581
  if (flags & 33554432 /* Substitution */) {
61563
61582
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -64098,13 +64117,6 @@ ${lanes.join("\n")}
64098
64117
  return result2;
64099
64118
  }
64100
64119
  }
64101
- } else {
64102
- const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
64103
- if (distributiveConstraint) {
64104
- if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
64105
- return result2;
64106
- }
64107
- }
64108
64120
  }
64109
64121
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
64110
64122
  if (defaultConstraint) {
@@ -64112,6 +64124,13 @@ ${lanes.join("\n")}
64112
64124
  return result2;
64113
64125
  }
64114
64126
  }
64127
+ const distributiveConstraint = !(targetFlags & 16777216 /* Conditional */) && hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
64128
+ if (distributiveConstraint) {
64129
+ resetErrorInfo(saveErrorInfo);
64130
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
64131
+ return result2;
64132
+ }
64133
+ }
64115
64134
  } else {
64116
64135
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
64117
64136
  return -1 /* True */;
@@ -68219,7 +68238,16 @@ ${lanes.join("\n")}
68219
68238
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
68220
68239
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68221
68240
  } else if (expr.kind === 112 /* TrueKeyword */) {
68222
- type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68241
+ const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart);
68242
+ const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0;
68243
+ if (clauseExpression) {
68244
+ type = narrowType(
68245
+ type,
68246
+ clauseExpression,
68247
+ /*assumeTrue*/
68248
+ true
68249
+ );
68250
+ }
68223
68251
  } else {
68224
68252
  if (strictNullChecks) {
68225
68253
  if (optionalChainContainsReference(expr, reference)) {
@@ -68765,45 +68793,6 @@ ${lanes.join("\n")}
68765
68793
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
68766
68794
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
68767
68795
  }
68768
- function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
68769
- const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
68770
- const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
68771
- const clausesBefore = switchStatement.caseBlock.clauses.slice(0, clauseStart);
68772
- for (const clause of clausesBefore) {
68773
- if (clause.kind === 296 /* CaseClause */) {
68774
- type = narrowType(
68775
- type,
68776
- clause.expression,
68777
- /*assumeTrue*/
68778
- false
68779
- );
68780
- }
68781
- }
68782
- if (hasDefaultClause) {
68783
- const clausesAfter = switchStatement.caseBlock.clauses.slice(clauseEnd);
68784
- for (const clause of clausesAfter) {
68785
- if (clause.kind === 296 /* CaseClause */) {
68786
- type = narrowType(
68787
- type,
68788
- clause.expression,
68789
- /*assumeTrue*/
68790
- false
68791
- );
68792
- }
68793
- }
68794
- return type;
68795
- }
68796
- const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
68797
- return narrowTypeForTrueClauses(type, clauses);
68798
- }
68799
- function narrowTypeForTrueClauses(type, clauses) {
68800
- return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
68801
- type,
68802
- clause.expression,
68803
- /*assumeTrue*/
68804
- true
68805
- ) : neverType));
68806
- }
68807
68796
  function isMatchingConstructorReference(expr) {
68808
68797
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
68809
68798
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.3.0-pr-55991-50",
5
+ "version": "5.3.0-pr-56004-10",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -114,5 +114,5 @@
114
114
  "node": "20.1.0",
115
115
  "npm": "8.19.4"
116
116
  },
117
- "gitHead": "d46ee1f895d233aaf9267f951a06b8a60feb10c7"
117
+ "gitHead": "833be10fdbb871b107e14d5b092c9b17a912b60f"
118
118
  }