@typescript-deploys/pr-build 5.3.0-pr-56004-10 → 5.3.0-pr-56048-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/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.3";
21
- var version = `${versionMajorMinor}.0-insiders.20231006`;
21
+ var version = `${versionMajorMinor}.0-insiders.20231009`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -13637,6 +13637,7 @@ function tryGetModuleSpecifierFromDeclaration(node) {
13637
13637
  true
13638
13638
  ))) == null ? void 0 : _a.arguments[0];
13639
13639
  case 272 /* ImportDeclaration */:
13640
+ case 278 /* ExportDeclaration */:
13640
13641
  return tryCast(node.moduleSpecifier, isStringLiteralLike);
13641
13642
  case 271 /* ImportEqualsDeclaration */:
13642
13643
  return tryCast((_b = tryCast(node.moduleReference, isExternalModuleReference)) == null ? void 0 : _b.expression, isStringLiteralLike);
@@ -13648,6 +13649,8 @@ function tryGetModuleSpecifierFromDeclaration(node) {
13648
13649
  return tryCast(node.parent.parent.moduleSpecifier, isStringLiteralLike);
13649
13650
  case 276 /* ImportSpecifier */:
13650
13651
  return tryCast(node.parent.parent.parent.moduleSpecifier, isStringLiteralLike);
13652
+ case 205 /* ImportType */:
13653
+ return isLiteralImportTypeNode(node) ? node.argument.literal : void 0;
13651
13654
  default:
13652
13655
  Debug.assertNever(node);
13653
13656
  }
@@ -39964,6 +39967,9 @@ function createBinder() {
39964
39967
  case 213 /* CallExpression */:
39965
39968
  return hasNarrowableArgument(expr);
39966
39969
  case 217 /* ParenthesizedExpression */:
39970
+ if (isJSDocTypeAssertion(expr)) {
39971
+ return false;
39972
+ }
39967
39973
  case 235 /* NonNullExpression */:
39968
39974
  return isNarrowingExpression(expr.expression);
39969
39975
  case 226 /* BinaryExpression */:
@@ -54055,12 +54061,7 @@ function createTypeChecker(host) {
54055
54061
  const checkType = type.checkType;
54056
54062
  const constraint = getLowerBoundOfKeyType(checkType);
54057
54063
  if (constraint !== checkType) {
54058
- return getConditionalTypeInstantiation(
54059
- type,
54060
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
54061
- /*forConstraint*/
54062
- false
54063
- );
54064
+ return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54064
54065
  }
54065
54066
  }
54066
54067
  return type;
@@ -54412,12 +54413,7 @@ function createTypeChecker(host) {
54412
54413
  );
54413
54414
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
54414
54415
  if (constraint && constraint !== type.checkType) {
54415
- const instantiated = getConditionalTypeInstantiation(
54416
- type,
54417
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
54418
- /*forConstraint*/
54419
- true
54420
- );
54416
+ const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54421
54417
  if (!(instantiated.flags & 131072 /* Never */)) {
54422
54418
  type.resolvedConstraintOfDistributive = instantiated;
54423
54419
  return instantiated;
@@ -57980,7 +57976,7 @@ function createTypeChecker(host) {
57980
57976
  function isDeferredType(type, checkTuples) {
57981
57977
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
57982
57978
  }
57983
- function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
57979
+ function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
57984
57980
  let result;
57985
57981
  let extraTypes;
57986
57982
  let tailCount = 0;
@@ -58026,7 +58022,7 @@ function createTypeChecker(host) {
58026
58022
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
58027
58023
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
58028
58024
  if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
58029
- if (checkType.flags & 1 /* Any */ || forConstraint && areTypesComparable(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType))) {
58025
+ if (checkType.flags & 1 /* Any */) {
58030
58026
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
58031
58027
  }
58032
58028
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -58136,9 +58132,7 @@ function createTypeChecker(host) {
58136
58132
  links.resolvedType = getConditionalType(
58137
58133
  root,
58138
58134
  /*mapper*/
58139
- void 0,
58140
- /*forConstraint*/
58141
- false
58135
+ void 0
58142
58136
  );
58143
58137
  if (outerTypeParameters) {
58144
58138
  root.instantiations = /* @__PURE__ */ new Map();
@@ -58992,17 +58986,17 @@ function createTypeChecker(host) {
58992
58986
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
58993
58987
  return result;
58994
58988
  }
58995
- function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
58989
+ function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
58996
58990
  const root = type.root;
58997
58991
  if (root.outerTypeParameters) {
58998
58992
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
58999
- const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
58993
+ const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
59000
58994
  let result = root.instantiations.get(id);
59001
58995
  if (!result) {
59002
58996
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
59003
58997
  const checkType = root.checkType;
59004
58998
  const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
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);
58999
+ 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);
59006
59000
  root.instantiations.set(id, result);
59007
59001
  }
59008
59002
  return result;
@@ -59090,14 +59084,7 @@ function createTypeChecker(host) {
59090
59084
  );
59091
59085
  }
59092
59086
  if (flags & 16777216 /* Conditional */) {
59093
- return getConditionalTypeInstantiation(
59094
- type,
59095
- combineTypeMappers(type.mapper, mapper),
59096
- /*forConstraint*/
59097
- false,
59098
- aliasSymbol,
59099
- aliasTypeArguments
59100
- );
59087
+ return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
59101
59088
  }
59102
59089
  if (flags & 33554432 /* Substitution */) {
59103
59090
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -61638,6 +61625,13 @@ function createTypeChecker(host) {
61638
61625
  return result2;
61639
61626
  }
61640
61627
  }
61628
+ } else {
61629
+ const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
61630
+ if (distributiveConstraint) {
61631
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
61632
+ return result2;
61633
+ }
61634
+ }
61641
61635
  }
61642
61636
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
61643
61637
  if (defaultConstraint) {
@@ -61645,13 +61639,6 @@ function createTypeChecker(host) {
61645
61639
  return result2;
61646
61640
  }
61647
61641
  }
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
- }
61655
61642
  } else {
61656
61643
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
61657
61644
  return -1 /* True */;
@@ -65751,7 +65738,7 @@ function createTypeChecker(host) {
65751
65738
  return createFlowType(narrowedType, isIncomplete(flowType));
65752
65739
  }
65753
65740
  function getTypeAtSwitchClause(flow) {
65754
- const expr = flow.switchStatement.expression;
65741
+ const expr = skipParentheses(flow.switchStatement.expression);
65755
65742
  const flowType = getTypeAtFlowNode(flow.antecedent);
65756
65743
  let type = getTypeFromFlowType(flowType);
65757
65744
  if (isMatchingReference(reference, expr)) {
@@ -65759,16 +65746,7 @@ function createTypeChecker(host) {
65759
65746
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
65760
65747
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65761
65748
  } else if (expr.kind === 112 /* TrueKeyword */) {
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
- }
65749
+ type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65772
65750
  } else {
65773
65751
  if (strictNullChecks) {
65774
65752
  if (optionalChainContainsReference(expr, reference)) {
@@ -66314,6 +66292,42 @@ function createTypeChecker(host) {
66314
66292
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
66315
66293
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
66316
66294
  }
66295
+ function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
66296
+ const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
66297
+ const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
66298
+ for (let i = 0; i < clauseStart; i++) {
66299
+ const clause = switchStatement.caseBlock.clauses[i];
66300
+ if (clause.kind === 296 /* CaseClause */) {
66301
+ type = narrowType(
66302
+ type,
66303
+ clause.expression,
66304
+ /*assumeTrue*/
66305
+ false
66306
+ );
66307
+ }
66308
+ }
66309
+ if (hasDefaultClause) {
66310
+ for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) {
66311
+ const clause = switchStatement.caseBlock.clauses[i];
66312
+ if (clause.kind === 296 /* CaseClause */) {
66313
+ type = narrowType(
66314
+ type,
66315
+ clause.expression,
66316
+ /*assumeTrue*/
66317
+ false
66318
+ );
66319
+ }
66320
+ }
66321
+ return type;
66322
+ }
66323
+ const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
66324
+ return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
66325
+ type,
66326
+ clause.expression,
66327
+ /*assumeTrue*/
66328
+ true
66329
+ ) : neverType));
66330
+ }
66317
66331
  function isMatchingConstructorReference(expr) {
66318
66332
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
66319
66333
  }
@@ -82318,7 +82332,16 @@ function createTypeChecker(host) {
82318
82332
  }
82319
82333
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
82320
82334
  },
82321
- isImportRequiredByAugmentation
82335
+ isImportRequiredByAugmentation,
82336
+ tryFindAmbientModule: (moduleReferenceExpression) => {
82337
+ const node = getParseTreeNode(moduleReferenceExpression);
82338
+ const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0;
82339
+ return moduleSpecifier !== void 0 ? tryFindAmbientModule(
82340
+ moduleSpecifier,
82341
+ /*withAugmentations*/
82342
+ true
82343
+ ) : void 0;
82344
+ }
82322
82345
  };
82323
82346
  function isImportRequiredByAugmentation(node) {
82324
82347
  const file = getSourceFileOfNode(node);
@@ -107078,6 +107101,17 @@ function transformDeclarations(context) {
107078
107101
  const container = getSourceFileOfNode(node);
107079
107102
  refs.set(getOriginalNodeId(container), container);
107080
107103
  }
107104
+ function trackReferencedAmbientModuleFromImport(node) {
107105
+ const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node);
107106
+ const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier);
107107
+ if (symbol == null ? void 0 : symbol.declarations) {
107108
+ for (const decl of symbol.declarations) {
107109
+ if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) {
107110
+ trackReferencedAmbientModule(decl, symbol);
107111
+ }
107112
+ }
107113
+ }
107114
+ }
107081
107115
  function handleSymbolAccessibilityError(symbolAccessibilityResult) {
107082
107116
  if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
107083
107117
  if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -108025,6 +108059,7 @@ function transformDeclarations(context) {
108025
108059
  case 205 /* ImportType */: {
108026
108060
  if (!isLiteralImportTypeNode(input))
108027
108061
  return cleanup(input);
108062
+ trackReferencedAmbientModuleFromImport(input);
108028
108063
  return cleanup(factory2.updateImportTypeNode(
108029
108064
  input,
108030
108065
  factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)),
@@ -108076,6 +108111,7 @@ function transformDeclarations(context) {
108076
108111
  resultHasExternalModuleIndicator = true;
108077
108112
  }
108078
108113
  resultHasScopeMarker = true;
108114
+ trackReferencedAmbientModuleFromImport(input);
108079
108115
  return factory2.updateExportDeclaration(
108080
108116
  input,
108081
108117
  input.modifiers,
@@ -108150,10 +108186,18 @@ function transformDeclarations(context) {
108150
108186
  return;
108151
108187
  switch (input.kind) {
108152
108188
  case 271 /* ImportEqualsDeclaration */: {
108153
- return transformImportEqualsDeclaration(input);
108189
+ const transformed = transformImportEqualsDeclaration(input);
108190
+ if (transformed) {
108191
+ trackReferencedAmbientModuleFromImport(input);
108192
+ }
108193
+ return transformed;
108154
108194
  }
108155
108195
  case 272 /* ImportDeclaration */: {
108156
- return transformImportDeclaration(input);
108196
+ const transformed = transformImportDeclaration(input);
108197
+ if (transformed) {
108198
+ trackReferencedAmbientModuleFromImport(input);
108199
+ }
108200
+ return transformed;
108157
108201
  }
108158
108202
  }
108159
108203
  if (isDeclaration(input) && isDeclarationAndNotVisible(input))
@@ -109756,7 +109800,8 @@ var notImplementedResolver = {
109756
109800
  getSymbolOfExternalModuleSpecifier: notImplemented,
109757
109801
  isBindingCapturedByNode: notImplemented,
109758
109802
  getDeclarationStatementsForSourceFile: notImplemented,
109759
- isImportRequiredByAugmentation: notImplemented
109803
+ isImportRequiredByAugmentation: notImplemented,
109804
+ tryFindAmbientModule: notImplemented
109760
109805
  };
109761
109806
  function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
109762
109807
  var _a;
package/lib/tsserver.js CHANGED
@@ -2328,7 +2328,7 @@ module.exports = __toCommonJS(server_exports);
2328
2328
 
2329
2329
  // src/compiler/corePublic.ts
2330
2330
  var versionMajorMinor = "5.3";
2331
- var version = `${versionMajorMinor}.0-insiders.20231006`;
2331
+ var version = `${versionMajorMinor}.0-insiders.20231009`;
2332
2332
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2333
2333
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2334
2334
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -17481,6 +17481,7 @@ function tryGetModuleSpecifierFromDeclaration(node) {
17481
17481
  true
17482
17482
  ))) == null ? void 0 : _a.arguments[0];
17483
17483
  case 272 /* ImportDeclaration */:
17484
+ case 278 /* ExportDeclaration */:
17484
17485
  return tryCast(node.moduleSpecifier, isStringLiteralLike);
17485
17486
  case 271 /* ImportEqualsDeclaration */:
17486
17487
  return tryCast((_b = tryCast(node.moduleReference, isExternalModuleReference)) == null ? void 0 : _b.expression, isStringLiteralLike);
@@ -17492,6 +17493,8 @@ function tryGetModuleSpecifierFromDeclaration(node) {
17492
17493
  return tryCast(node.parent.parent.moduleSpecifier, isStringLiteralLike);
17493
17494
  case 276 /* ImportSpecifier */:
17494
17495
  return tryCast(node.parent.parent.parent.moduleSpecifier, isStringLiteralLike);
17496
+ case 205 /* ImportType */:
17497
+ return isLiteralImportTypeNode(node) ? node.argument.literal : void 0;
17495
17498
  default:
17496
17499
  Debug.assertNever(node);
17497
17500
  }
@@ -44631,6 +44634,9 @@ function createBinder() {
44631
44634
  case 213 /* CallExpression */:
44632
44635
  return hasNarrowableArgument(expr);
44633
44636
  case 217 /* ParenthesizedExpression */:
44637
+ if (isJSDocTypeAssertion(expr)) {
44638
+ return false;
44639
+ }
44634
44640
  case 235 /* NonNullExpression */:
44635
44641
  return isNarrowingExpression(expr.expression);
44636
44642
  case 226 /* BinaryExpression */:
@@ -58767,12 +58773,7 @@ function createTypeChecker(host) {
58767
58773
  const checkType = type.checkType;
58768
58774
  const constraint = getLowerBoundOfKeyType(checkType);
58769
58775
  if (constraint !== checkType) {
58770
- return getConditionalTypeInstantiation(
58771
- type,
58772
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
58773
- /*forConstraint*/
58774
- false
58775
- );
58776
+ return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
58776
58777
  }
58777
58778
  }
58778
58779
  return type;
@@ -59124,12 +59125,7 @@ function createTypeChecker(host) {
59124
59125
  );
59125
59126
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
59126
59127
  if (constraint && constraint !== type.checkType) {
59127
- const instantiated = getConditionalTypeInstantiation(
59128
- type,
59129
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
59130
- /*forConstraint*/
59131
- true
59132
- );
59128
+ const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
59133
59129
  if (!(instantiated.flags & 131072 /* Never */)) {
59134
59130
  type.resolvedConstraintOfDistributive = instantiated;
59135
59131
  return instantiated;
@@ -62692,7 +62688,7 @@ function createTypeChecker(host) {
62692
62688
  function isDeferredType(type, checkTuples) {
62693
62689
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
62694
62690
  }
62695
- function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
62691
+ function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
62696
62692
  let result;
62697
62693
  let extraTypes;
62698
62694
  let tailCount = 0;
@@ -62738,7 +62734,7 @@ function createTypeChecker(host) {
62738
62734
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
62739
62735
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
62740
62736
  if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
62741
- if (checkType.flags & 1 /* Any */ || forConstraint && areTypesComparable(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType))) {
62737
+ if (checkType.flags & 1 /* Any */) {
62742
62738
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
62743
62739
  }
62744
62740
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -62848,9 +62844,7 @@ function createTypeChecker(host) {
62848
62844
  links.resolvedType = getConditionalType(
62849
62845
  root,
62850
62846
  /*mapper*/
62851
- void 0,
62852
- /*forConstraint*/
62853
- false
62847
+ void 0
62854
62848
  );
62855
62849
  if (outerTypeParameters) {
62856
62850
  root.instantiations = /* @__PURE__ */ new Map();
@@ -63704,17 +63698,17 @@ function createTypeChecker(host) {
63704
63698
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
63705
63699
  return result;
63706
63700
  }
63707
- function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
63701
+ function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
63708
63702
  const root = type.root;
63709
63703
  if (root.outerTypeParameters) {
63710
63704
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
63711
- const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
63705
+ const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
63712
63706
  let result = root.instantiations.get(id);
63713
63707
  if (!result) {
63714
63708
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
63715
63709
  const checkType = root.checkType;
63716
63710
  const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
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);
63711
+ 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);
63718
63712
  root.instantiations.set(id, result);
63719
63713
  }
63720
63714
  return result;
@@ -63802,14 +63796,7 @@ function createTypeChecker(host) {
63802
63796
  );
63803
63797
  }
63804
63798
  if (flags & 16777216 /* Conditional */) {
63805
- return getConditionalTypeInstantiation(
63806
- type,
63807
- combineTypeMappers(type.mapper, mapper),
63808
- /*forConstraint*/
63809
- false,
63810
- aliasSymbol,
63811
- aliasTypeArguments
63812
- );
63799
+ return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
63813
63800
  }
63814
63801
  if (flags & 33554432 /* Substitution */) {
63815
63802
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -66350,6 +66337,13 @@ function createTypeChecker(host) {
66350
66337
  return result2;
66351
66338
  }
66352
66339
  }
66340
+ } else {
66341
+ const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
66342
+ if (distributiveConstraint) {
66343
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
66344
+ return result2;
66345
+ }
66346
+ }
66353
66347
  }
66354
66348
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
66355
66349
  if (defaultConstraint) {
@@ -66357,13 +66351,6 @@ function createTypeChecker(host) {
66357
66351
  return result2;
66358
66352
  }
66359
66353
  }
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
- }
66367
66354
  } else {
66368
66355
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
66369
66356
  return -1 /* True */;
@@ -70463,7 +70450,7 @@ function createTypeChecker(host) {
70463
70450
  return createFlowType(narrowedType, isIncomplete(flowType));
70464
70451
  }
70465
70452
  function getTypeAtSwitchClause(flow) {
70466
- const expr = flow.switchStatement.expression;
70453
+ const expr = skipParentheses(flow.switchStatement.expression);
70467
70454
  const flowType = getTypeAtFlowNode(flow.antecedent);
70468
70455
  let type = getTypeFromFlowType(flowType);
70469
70456
  if (isMatchingReference(reference, expr)) {
@@ -70471,16 +70458,7 @@ function createTypeChecker(host) {
70471
70458
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
70472
70459
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70473
70460
  } else if (expr.kind === 112 /* TrueKeyword */) {
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
- }
70461
+ type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70484
70462
  } else {
70485
70463
  if (strictNullChecks) {
70486
70464
  if (optionalChainContainsReference(expr, reference)) {
@@ -71026,6 +71004,42 @@ function createTypeChecker(host) {
71026
71004
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
71027
71005
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
71028
71006
  }
71007
+ function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
71008
+ const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
71009
+ const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
71010
+ for (let i = 0; i < clauseStart; i++) {
71011
+ const clause = switchStatement.caseBlock.clauses[i];
71012
+ if (clause.kind === 296 /* CaseClause */) {
71013
+ type = narrowType(
71014
+ type,
71015
+ clause.expression,
71016
+ /*assumeTrue*/
71017
+ false
71018
+ );
71019
+ }
71020
+ }
71021
+ if (hasDefaultClause) {
71022
+ for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) {
71023
+ const clause = switchStatement.caseBlock.clauses[i];
71024
+ if (clause.kind === 296 /* CaseClause */) {
71025
+ type = narrowType(
71026
+ type,
71027
+ clause.expression,
71028
+ /*assumeTrue*/
71029
+ false
71030
+ );
71031
+ }
71032
+ }
71033
+ return type;
71034
+ }
71035
+ const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
71036
+ return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
71037
+ type,
71038
+ clause.expression,
71039
+ /*assumeTrue*/
71040
+ true
71041
+ ) : neverType));
71042
+ }
71029
71043
  function isMatchingConstructorReference(expr) {
71030
71044
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
71031
71045
  }
@@ -87030,7 +87044,16 @@ function createTypeChecker(host) {
87030
87044
  }
87031
87045
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
87032
87046
  },
87033
- isImportRequiredByAugmentation
87047
+ isImportRequiredByAugmentation,
87048
+ tryFindAmbientModule: (moduleReferenceExpression) => {
87049
+ const node = getParseTreeNode(moduleReferenceExpression);
87050
+ const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0;
87051
+ return moduleSpecifier !== void 0 ? tryFindAmbientModule(
87052
+ moduleSpecifier,
87053
+ /*withAugmentations*/
87054
+ true
87055
+ ) : void 0;
87056
+ }
87034
87057
  };
87035
87058
  function isImportRequiredByAugmentation(node) {
87036
87059
  const file = getSourceFileOfNode(node);
@@ -111961,6 +111984,17 @@ function transformDeclarations(context) {
111961
111984
  const container = getSourceFileOfNode(node);
111962
111985
  refs.set(getOriginalNodeId(container), container);
111963
111986
  }
111987
+ function trackReferencedAmbientModuleFromImport(node) {
111988
+ const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node);
111989
+ const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier);
111990
+ if (symbol == null ? void 0 : symbol.declarations) {
111991
+ for (const decl of symbol.declarations) {
111992
+ if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) {
111993
+ trackReferencedAmbientModule(decl, symbol);
111994
+ }
111995
+ }
111996
+ }
111997
+ }
111964
111998
  function handleSymbolAccessibilityError(symbolAccessibilityResult) {
111965
111999
  if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
111966
112000
  if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -112908,6 +112942,7 @@ function transformDeclarations(context) {
112908
112942
  case 205 /* ImportType */: {
112909
112943
  if (!isLiteralImportTypeNode(input))
112910
112944
  return cleanup(input);
112945
+ trackReferencedAmbientModuleFromImport(input);
112911
112946
  return cleanup(factory2.updateImportTypeNode(
112912
112947
  input,
112913
112948
  factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)),
@@ -112959,6 +112994,7 @@ function transformDeclarations(context) {
112959
112994
  resultHasExternalModuleIndicator = true;
112960
112995
  }
112961
112996
  resultHasScopeMarker = true;
112997
+ trackReferencedAmbientModuleFromImport(input);
112962
112998
  return factory2.updateExportDeclaration(
112963
112999
  input,
112964
113000
  input.modifiers,
@@ -113033,10 +113069,18 @@ function transformDeclarations(context) {
113033
113069
  return;
113034
113070
  switch (input.kind) {
113035
113071
  case 271 /* ImportEqualsDeclaration */: {
113036
- return transformImportEqualsDeclaration(input);
113072
+ const transformed = transformImportEqualsDeclaration(input);
113073
+ if (transformed) {
113074
+ trackReferencedAmbientModuleFromImport(input);
113075
+ }
113076
+ return transformed;
113037
113077
  }
113038
113078
  case 272 /* ImportDeclaration */: {
113039
- return transformImportDeclaration(input);
113079
+ const transformed = transformImportDeclaration(input);
113080
+ if (transformed) {
113081
+ trackReferencedAmbientModuleFromImport(input);
113082
+ }
113083
+ return transformed;
113040
113084
  }
113041
113085
  }
113042
113086
  if (isDeclaration(input) && isDeclarationAndNotVisible(input))
@@ -114650,7 +114694,8 @@ var notImplementedResolver = {
114650
114694
  getSymbolOfExternalModuleSpecifier: notImplemented,
114651
114695
  isBindingCapturedByNode: notImplemented,
114652
114696
  getDeclarationStatementsForSourceFile: notImplemented,
114653
- isImportRequiredByAugmentation: notImplemented
114697
+ isImportRequiredByAugmentation: notImplemented,
114698
+ tryFindAmbientModule: notImplemented
114654
114699
  };
114655
114700
  function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
114656
114701
  var _a;
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.3";
38
- version = `${versionMajorMinor}.0-insiders.20231006`;
38
+ version = `${versionMajorMinor}.0-insiders.20231009`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -14864,6 +14864,7 @@ ${lanes.join("\n")}
14864
14864
  true
14865
14865
  ))) == null ? void 0 : _a.arguments[0];
14866
14866
  case 272 /* ImportDeclaration */:
14867
+ case 278 /* ExportDeclaration */:
14867
14868
  return tryCast(node.moduleSpecifier, isStringLiteralLike);
14868
14869
  case 271 /* ImportEqualsDeclaration */:
14869
14870
  return tryCast((_b = tryCast(node.moduleReference, isExternalModuleReference)) == null ? void 0 : _b.expression, isStringLiteralLike);
@@ -14875,6 +14876,8 @@ ${lanes.join("\n")}
14875
14876
  return tryCast(node.parent.parent.moduleSpecifier, isStringLiteralLike);
14876
14877
  case 276 /* ImportSpecifier */:
14877
14878
  return tryCast(node.parent.parent.parent.moduleSpecifier, isStringLiteralLike);
14879
+ case 205 /* ImportType */:
14880
+ return isLiteralImportTypeNode(node) ? node.argument.literal : void 0;
14878
14881
  default:
14879
14882
  Debug.assertNever(node);
14880
14883
  }
@@ -42478,6 +42481,9 @@ ${lanes.join("\n")}
42478
42481
  case 213 /* CallExpression */:
42479
42482
  return hasNarrowableArgument(expr);
42480
42483
  case 217 /* ParenthesizedExpression */:
42484
+ if (isJSDocTypeAssertion(expr)) {
42485
+ return false;
42486
+ }
42481
42487
  case 235 /* NonNullExpression */:
42482
42488
  return isNarrowingExpression(expr.expression);
42483
42489
  case 226 /* BinaryExpression */:
@@ -56534,12 +56540,7 @@ ${lanes.join("\n")}
56534
56540
  const checkType = type.checkType;
56535
56541
  const constraint = getLowerBoundOfKeyType(checkType);
56536
56542
  if (constraint !== checkType) {
56537
- return getConditionalTypeInstantiation(
56538
- type,
56539
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
56540
- /*forConstraint*/
56541
- false
56542
- );
56543
+ return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
56543
56544
  }
56544
56545
  }
56545
56546
  return type;
@@ -56891,12 +56892,7 @@ ${lanes.join("\n")}
56891
56892
  );
56892
56893
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
56893
56894
  if (constraint && constraint !== type.checkType) {
56894
- const instantiated = getConditionalTypeInstantiation(
56895
- type,
56896
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
56897
- /*forConstraint*/
56898
- true
56899
- );
56895
+ const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
56900
56896
  if (!(instantiated.flags & 131072 /* Never */)) {
56901
56897
  type.resolvedConstraintOfDistributive = instantiated;
56902
56898
  return instantiated;
@@ -60459,7 +60455,7 @@ ${lanes.join("\n")}
60459
60455
  function isDeferredType(type, checkTuples) {
60460
60456
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
60461
60457
  }
60462
- function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
60458
+ function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
60463
60459
  let result;
60464
60460
  let extraTypes;
60465
60461
  let tailCount = 0;
@@ -60505,7 +60501,7 @@ ${lanes.join("\n")}
60505
60501
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
60506
60502
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
60507
60503
  if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
60508
- if (checkType.flags & 1 /* Any */ || forConstraint && areTypesComparable(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType))) {
60504
+ if (checkType.flags & 1 /* Any */) {
60509
60505
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
60510
60506
  }
60511
60507
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -60615,9 +60611,7 @@ ${lanes.join("\n")}
60615
60611
  links.resolvedType = getConditionalType(
60616
60612
  root,
60617
60613
  /*mapper*/
60618
- void 0,
60619
- /*forConstraint*/
60620
- false
60614
+ void 0
60621
60615
  );
60622
60616
  if (outerTypeParameters) {
60623
60617
  root.instantiations = /* @__PURE__ */ new Map();
@@ -61471,17 +61465,17 @@ ${lanes.join("\n")}
61471
61465
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
61472
61466
  return result;
61473
61467
  }
61474
- function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
61468
+ function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
61475
61469
  const root = type.root;
61476
61470
  if (root.outerTypeParameters) {
61477
61471
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
61478
- const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
61472
+ const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
61479
61473
  let result = root.instantiations.get(id);
61480
61474
  if (!result) {
61481
61475
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
61482
61476
  const checkType = root.checkType;
61483
61477
  const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
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);
61478
+ 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);
61485
61479
  root.instantiations.set(id, result);
61486
61480
  }
61487
61481
  return result;
@@ -61569,14 +61563,7 @@ ${lanes.join("\n")}
61569
61563
  );
61570
61564
  }
61571
61565
  if (flags & 16777216 /* Conditional */) {
61572
- return getConditionalTypeInstantiation(
61573
- type,
61574
- combineTypeMappers(type.mapper, mapper),
61575
- /*forConstraint*/
61576
- false,
61577
- aliasSymbol,
61578
- aliasTypeArguments
61579
- );
61566
+ return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
61580
61567
  }
61581
61568
  if (flags & 33554432 /* Substitution */) {
61582
61569
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -64117,6 +64104,13 @@ ${lanes.join("\n")}
64117
64104
  return result2;
64118
64105
  }
64119
64106
  }
64107
+ } else {
64108
+ const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
64109
+ if (distributiveConstraint) {
64110
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
64111
+ return result2;
64112
+ }
64113
+ }
64120
64114
  }
64121
64115
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
64122
64116
  if (defaultConstraint) {
@@ -64124,13 +64118,6 @@ ${lanes.join("\n")}
64124
64118
  return result2;
64125
64119
  }
64126
64120
  }
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
- }
64134
64121
  } else {
64135
64122
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
64136
64123
  return -1 /* True */;
@@ -68230,7 +68217,7 @@ ${lanes.join("\n")}
68230
68217
  return createFlowType(narrowedType, isIncomplete(flowType));
68231
68218
  }
68232
68219
  function getTypeAtSwitchClause(flow) {
68233
- const expr = flow.switchStatement.expression;
68220
+ const expr = skipParentheses(flow.switchStatement.expression);
68234
68221
  const flowType = getTypeAtFlowNode(flow.antecedent);
68235
68222
  let type = getTypeFromFlowType(flowType);
68236
68223
  if (isMatchingReference(reference, expr)) {
@@ -68238,16 +68225,7 @@ ${lanes.join("\n")}
68238
68225
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
68239
68226
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68240
68227
  } else if (expr.kind === 112 /* TrueKeyword */) {
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
- }
68228
+ type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68251
68229
  } else {
68252
68230
  if (strictNullChecks) {
68253
68231
  if (optionalChainContainsReference(expr, reference)) {
@@ -68793,6 +68771,42 @@ ${lanes.join("\n")}
68793
68771
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
68794
68772
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
68795
68773
  }
68774
+ function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
68775
+ const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
68776
+ const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
68777
+ for (let i = 0; i < clauseStart; i++) {
68778
+ const clause = switchStatement.caseBlock.clauses[i];
68779
+ if (clause.kind === 296 /* CaseClause */) {
68780
+ type = narrowType(
68781
+ type,
68782
+ clause.expression,
68783
+ /*assumeTrue*/
68784
+ false
68785
+ );
68786
+ }
68787
+ }
68788
+ if (hasDefaultClause) {
68789
+ for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) {
68790
+ const clause = switchStatement.caseBlock.clauses[i];
68791
+ if (clause.kind === 296 /* CaseClause */) {
68792
+ type = narrowType(
68793
+ type,
68794
+ clause.expression,
68795
+ /*assumeTrue*/
68796
+ false
68797
+ );
68798
+ }
68799
+ }
68800
+ return type;
68801
+ }
68802
+ const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
68803
+ return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
68804
+ type,
68805
+ clause.expression,
68806
+ /*assumeTrue*/
68807
+ true
68808
+ ) : neverType));
68809
+ }
68796
68810
  function isMatchingConstructorReference(expr) {
68797
68811
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
68798
68812
  }
@@ -84797,7 +84811,16 @@ ${lanes.join("\n")}
84797
84811
  }
84798
84812
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
84799
84813
  },
84800
- isImportRequiredByAugmentation
84814
+ isImportRequiredByAugmentation,
84815
+ tryFindAmbientModule: (moduleReferenceExpression) => {
84816
+ const node = getParseTreeNode(moduleReferenceExpression);
84817
+ const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0;
84818
+ return moduleSpecifier !== void 0 ? tryFindAmbientModule(
84819
+ moduleSpecifier,
84820
+ /*withAugmentations*/
84821
+ true
84822
+ ) : void 0;
84823
+ }
84801
84824
  };
84802
84825
  function isImportRequiredByAugmentation(node) {
84803
84826
  const file = getSourceFileOfNode(node);
@@ -110037,6 +110060,17 @@ ${lanes.join("\n")}
110037
110060
  const container = getSourceFileOfNode(node);
110038
110061
  refs.set(getOriginalNodeId(container), container);
110039
110062
  }
110063
+ function trackReferencedAmbientModuleFromImport(node) {
110064
+ const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node);
110065
+ const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier);
110066
+ if (symbol == null ? void 0 : symbol.declarations) {
110067
+ for (const decl of symbol.declarations) {
110068
+ if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) {
110069
+ trackReferencedAmbientModule(decl, symbol);
110070
+ }
110071
+ }
110072
+ }
110073
+ }
110040
110074
  function handleSymbolAccessibilityError(symbolAccessibilityResult) {
110041
110075
  if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
110042
110076
  if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -110984,6 +111018,7 @@ ${lanes.join("\n")}
110984
111018
  case 205 /* ImportType */: {
110985
111019
  if (!isLiteralImportTypeNode(input))
110986
111020
  return cleanup(input);
111021
+ trackReferencedAmbientModuleFromImport(input);
110987
111022
  return cleanup(factory2.updateImportTypeNode(
110988
111023
  input,
110989
111024
  factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)),
@@ -111035,6 +111070,7 @@ ${lanes.join("\n")}
111035
111070
  resultHasExternalModuleIndicator = true;
111036
111071
  }
111037
111072
  resultHasScopeMarker = true;
111073
+ trackReferencedAmbientModuleFromImport(input);
111038
111074
  return factory2.updateExportDeclaration(
111039
111075
  input,
111040
111076
  input.modifiers,
@@ -111109,10 +111145,18 @@ ${lanes.join("\n")}
111109
111145
  return;
111110
111146
  switch (input.kind) {
111111
111147
  case 271 /* ImportEqualsDeclaration */: {
111112
- return transformImportEqualsDeclaration(input);
111148
+ const transformed = transformImportEqualsDeclaration(input);
111149
+ if (transformed) {
111150
+ trackReferencedAmbientModuleFromImport(input);
111151
+ }
111152
+ return transformed;
111113
111153
  }
111114
111154
  case 272 /* ImportDeclaration */: {
111115
- return transformImportDeclaration(input);
111155
+ const transformed = transformImportDeclaration(input);
111156
+ if (transformed) {
111157
+ trackReferencedAmbientModuleFromImport(input);
111158
+ }
111159
+ return transformed;
111116
111160
  }
111117
111161
  }
111118
111162
  if (isDeclaration(input) && isDeclarationAndNotVisible(input))
@@ -117599,7 +117643,8 @@ ${lanes.join("\n")}
117599
117643
  getSymbolOfExternalModuleSpecifier: notImplemented,
117600
117644
  isBindingCapturedByNode: notImplemented,
117601
117645
  getDeclarationStatementsForSourceFile: notImplemented,
117602
- isImportRequiredByAugmentation: notImplemented
117646
+ isImportRequiredByAugmentation: notImplemented,
117647
+ tryFindAmbientModule: notImplemented
117603
117648
  };
117604
117649
  createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
117605
117650
  createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.3";
57
- var version = `${versionMajorMinor}.0-insiders.20231006`;
57
+ var version = `${versionMajorMinor}.0-insiders.20231009`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
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-56004-10",
5
+ "version": "5.3.0-pr-56048-8",
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": "833be10fdbb871b107e14d5b092c9b17a912b60f"
117
+ "gitHead": "d09aeb7782ade4b30c6b675d3cb08364e487f298"
118
118
  }