@typescript-deploys/pr-build 5.3.0-pr-56004-10 → 5.3.0-pr-56020-20

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
  }
@@ -54055,12 +54058,7 @@ function createTypeChecker(host) {
54055
54058
  const checkType = type.checkType;
54056
54059
  const constraint = getLowerBoundOfKeyType(checkType);
54057
54060
  if (constraint !== checkType) {
54058
- return getConditionalTypeInstantiation(
54059
- type,
54060
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
54061
- /*forConstraint*/
54062
- false
54063
- );
54061
+ return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54064
54062
  }
54065
54063
  }
54066
54064
  return type;
@@ -54412,12 +54410,7 @@ function createTypeChecker(host) {
54412
54410
  );
54413
54411
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
54414
54412
  if (constraint && constraint !== type.checkType) {
54415
- const instantiated = getConditionalTypeInstantiation(
54416
- type,
54417
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
54418
- /*forConstraint*/
54419
- true
54420
- );
54413
+ const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54421
54414
  if (!(instantiated.flags & 131072 /* Never */)) {
54422
54415
  type.resolvedConstraintOfDistributive = instantiated;
54423
54416
  return instantiated;
@@ -57980,7 +57973,7 @@ function createTypeChecker(host) {
57980
57973
  function isDeferredType(type, checkTuples) {
57981
57974
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
57982
57975
  }
57983
- function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
57976
+ function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
57984
57977
  let result;
57985
57978
  let extraTypes;
57986
57979
  let tailCount = 0;
@@ -58026,7 +58019,7 @@ function createTypeChecker(host) {
58026
58019
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
58027
58020
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
58028
58021
  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))) {
58022
+ if (checkType.flags & 1 /* Any */) {
58030
58023
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
58031
58024
  }
58032
58025
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -58136,9 +58129,7 @@ function createTypeChecker(host) {
58136
58129
  links.resolvedType = getConditionalType(
58137
58130
  root,
58138
58131
  /*mapper*/
58139
- void 0,
58140
- /*forConstraint*/
58141
- false
58132
+ void 0
58142
58133
  );
58143
58134
  if (outerTypeParameters) {
58144
58135
  root.instantiations = /* @__PURE__ */ new Map();
@@ -58992,17 +58983,17 @@ function createTypeChecker(host) {
58992
58983
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
58993
58984
  return result;
58994
58985
  }
58995
- function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
58986
+ function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
58996
58987
  const root = type.root;
58997
58988
  if (root.outerTypeParameters) {
58998
58989
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
58999
- const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
58990
+ const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
59000
58991
  let result = root.instantiations.get(id);
59001
58992
  if (!result) {
59002
58993
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
59003
58994
  const checkType = root.checkType;
59004
58995
  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);
58996
+ 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
58997
  root.instantiations.set(id, result);
59007
58998
  }
59008
58999
  return result;
@@ -59090,14 +59081,7 @@ function createTypeChecker(host) {
59090
59081
  );
59091
59082
  }
59092
59083
  if (flags & 16777216 /* Conditional */) {
59093
- return getConditionalTypeInstantiation(
59094
- type,
59095
- combineTypeMappers(type.mapper, mapper),
59096
- /*forConstraint*/
59097
- false,
59098
- aliasSymbol,
59099
- aliasTypeArguments
59100
- );
59084
+ return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
59101
59085
  }
59102
59086
  if (flags & 33554432 /* Substitution */) {
59103
59087
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -61638,6 +61622,13 @@ function createTypeChecker(host) {
61638
61622
  return result2;
61639
61623
  }
61640
61624
  }
61625
+ } else {
61626
+ const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
61627
+ if (distributiveConstraint) {
61628
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
61629
+ return result2;
61630
+ }
61631
+ }
61641
61632
  }
61642
61633
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
61643
61634
  if (defaultConstraint) {
@@ -61645,13 +61636,6 @@ function createTypeChecker(host) {
61645
61636
  return result2;
61646
61637
  }
61647
61638
  }
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
61639
  } else {
61656
61640
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
61657
61641
  return -1 /* True */;
@@ -65751,7 +65735,7 @@ function createTypeChecker(host) {
65751
65735
  return createFlowType(narrowedType, isIncomplete(flowType));
65752
65736
  }
65753
65737
  function getTypeAtSwitchClause(flow) {
65754
- const expr = flow.switchStatement.expression;
65738
+ const expr = skipParentheses(flow.switchStatement.expression);
65755
65739
  const flowType = getTypeAtFlowNode(flow.antecedent);
65756
65740
  let type = getTypeFromFlowType(flowType);
65757
65741
  if (isMatchingReference(reference, expr)) {
@@ -65759,16 +65743,7 @@ function createTypeChecker(host) {
65759
65743
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
65760
65744
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65761
65745
  } 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
- }
65746
+ type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65772
65747
  } else {
65773
65748
  if (strictNullChecks) {
65774
65749
  if (optionalChainContainsReference(expr, reference)) {
@@ -66314,6 +66289,42 @@ function createTypeChecker(host) {
66314
66289
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
66315
66290
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
66316
66291
  }
66292
+ function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
66293
+ const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
66294
+ const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
66295
+ for (let i = 0; i < clauseStart; i++) {
66296
+ const clause = switchStatement.caseBlock.clauses[i];
66297
+ if (clause.kind === 296 /* CaseClause */) {
66298
+ type = narrowType(
66299
+ type,
66300
+ clause.expression,
66301
+ /*assumeTrue*/
66302
+ false
66303
+ );
66304
+ }
66305
+ }
66306
+ if (hasDefaultClause) {
66307
+ for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) {
66308
+ const clause = switchStatement.caseBlock.clauses[i];
66309
+ if (clause.kind === 296 /* CaseClause */) {
66310
+ type = narrowType(
66311
+ type,
66312
+ clause.expression,
66313
+ /*assumeTrue*/
66314
+ false
66315
+ );
66316
+ }
66317
+ }
66318
+ return type;
66319
+ }
66320
+ const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
66321
+ return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
66322
+ type,
66323
+ clause.expression,
66324
+ /*assumeTrue*/
66325
+ true
66326
+ ) : neverType));
66327
+ }
66317
66328
  function isMatchingConstructorReference(expr) {
66318
66329
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
66319
66330
  }
@@ -73340,8 +73351,20 @@ function createTypeChecker(host) {
73340
73351
  let hasReturnWithNoExpression = functionHasImplicitReturn(func);
73341
73352
  let hasReturnOfTypeNever = false;
73342
73353
  forEachReturnStatement(func.body, (returnStatement) => {
73343
- const expr = returnStatement.expression;
73354
+ let expr = returnStatement.expression;
73344
73355
  if (expr) {
73356
+ expr = skipParentheses(
73357
+ expr,
73358
+ /*excludeJSDocTypeAssertions*/
73359
+ true
73360
+ );
73361
+ if (functionFlags & 2 /* Async */ && expr.kind === 223 /* AwaitExpression */) {
73362
+ expr = skipParentheses(
73363
+ expr.expression,
73364
+ /*excludeJSDocTypeAssertions*/
73365
+ true
73366
+ );
73367
+ }
73345
73368
  if (expr.kind === 213 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) {
73346
73369
  hasReturnOfTypeNever = true;
73347
73370
  return;
@@ -82318,7 +82341,16 @@ function createTypeChecker(host) {
82318
82341
  }
82319
82342
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
82320
82343
  },
82321
- isImportRequiredByAugmentation
82344
+ isImportRequiredByAugmentation,
82345
+ tryFindAmbientModule: (moduleReferenceExpression) => {
82346
+ const node = getParseTreeNode(moduleReferenceExpression);
82347
+ const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0;
82348
+ return moduleSpecifier !== void 0 ? tryFindAmbientModule(
82349
+ moduleSpecifier,
82350
+ /*withAugmentations*/
82351
+ true
82352
+ ) : void 0;
82353
+ }
82322
82354
  };
82323
82355
  function isImportRequiredByAugmentation(node) {
82324
82356
  const file = getSourceFileOfNode(node);
@@ -107078,6 +107110,17 @@ function transformDeclarations(context) {
107078
107110
  const container = getSourceFileOfNode(node);
107079
107111
  refs.set(getOriginalNodeId(container), container);
107080
107112
  }
107113
+ function trackReferencedAmbientModuleFromImport(node) {
107114
+ const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node);
107115
+ const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier);
107116
+ if (symbol == null ? void 0 : symbol.declarations) {
107117
+ for (const decl of symbol.declarations) {
107118
+ if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) {
107119
+ trackReferencedAmbientModule(decl, symbol);
107120
+ }
107121
+ }
107122
+ }
107123
+ }
107081
107124
  function handleSymbolAccessibilityError(symbolAccessibilityResult) {
107082
107125
  if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
107083
107126
  if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -108025,6 +108068,7 @@ function transformDeclarations(context) {
108025
108068
  case 205 /* ImportType */: {
108026
108069
  if (!isLiteralImportTypeNode(input))
108027
108070
  return cleanup(input);
108071
+ trackReferencedAmbientModuleFromImport(input);
108028
108072
  return cleanup(factory2.updateImportTypeNode(
108029
108073
  input,
108030
108074
  factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)),
@@ -108076,6 +108120,7 @@ function transformDeclarations(context) {
108076
108120
  resultHasExternalModuleIndicator = true;
108077
108121
  }
108078
108122
  resultHasScopeMarker = true;
108123
+ trackReferencedAmbientModuleFromImport(input);
108079
108124
  return factory2.updateExportDeclaration(
108080
108125
  input,
108081
108126
  input.modifiers,
@@ -108150,10 +108195,18 @@ function transformDeclarations(context) {
108150
108195
  return;
108151
108196
  switch (input.kind) {
108152
108197
  case 271 /* ImportEqualsDeclaration */: {
108153
- return transformImportEqualsDeclaration(input);
108198
+ const transformed = transformImportEqualsDeclaration(input);
108199
+ if (transformed) {
108200
+ trackReferencedAmbientModuleFromImport(input);
108201
+ }
108202
+ return transformed;
108154
108203
  }
108155
108204
  case 272 /* ImportDeclaration */: {
108156
- return transformImportDeclaration(input);
108205
+ const transformed = transformImportDeclaration(input);
108206
+ if (transformed) {
108207
+ trackReferencedAmbientModuleFromImport(input);
108208
+ }
108209
+ return transformed;
108157
108210
  }
108158
108211
  }
108159
108212
  if (isDeclaration(input) && isDeclarationAndNotVisible(input))
@@ -109756,7 +109809,8 @@ var notImplementedResolver = {
109756
109809
  getSymbolOfExternalModuleSpecifier: notImplemented,
109757
109810
  isBindingCapturedByNode: notImplemented,
109758
109811
  getDeclarationStatementsForSourceFile: notImplemented,
109759
- isImportRequiredByAugmentation: notImplemented
109812
+ isImportRequiredByAugmentation: notImplemented,
109813
+ tryFindAmbientModule: notImplemented
109760
109814
  };
109761
109815
  function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
109762
109816
  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
  }
@@ -58767,12 +58770,7 @@ function createTypeChecker(host) {
58767
58770
  const checkType = type.checkType;
58768
58771
  const constraint = getLowerBoundOfKeyType(checkType);
58769
58772
  if (constraint !== checkType) {
58770
- return getConditionalTypeInstantiation(
58771
- type,
58772
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
58773
- /*forConstraint*/
58774
- false
58775
- );
58773
+ return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
58776
58774
  }
58777
58775
  }
58778
58776
  return type;
@@ -59124,12 +59122,7 @@ function createTypeChecker(host) {
59124
59122
  );
59125
59123
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
59126
59124
  if (constraint && constraint !== type.checkType) {
59127
- const instantiated = getConditionalTypeInstantiation(
59128
- type,
59129
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
59130
- /*forConstraint*/
59131
- true
59132
- );
59125
+ const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
59133
59126
  if (!(instantiated.flags & 131072 /* Never */)) {
59134
59127
  type.resolvedConstraintOfDistributive = instantiated;
59135
59128
  return instantiated;
@@ -62692,7 +62685,7 @@ function createTypeChecker(host) {
62692
62685
  function isDeferredType(type, checkTuples) {
62693
62686
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
62694
62687
  }
62695
- function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
62688
+ function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
62696
62689
  let result;
62697
62690
  let extraTypes;
62698
62691
  let tailCount = 0;
@@ -62738,7 +62731,7 @@ function createTypeChecker(host) {
62738
62731
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
62739
62732
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
62740
62733
  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))) {
62734
+ if (checkType.flags & 1 /* Any */) {
62742
62735
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
62743
62736
  }
62744
62737
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -62848,9 +62841,7 @@ function createTypeChecker(host) {
62848
62841
  links.resolvedType = getConditionalType(
62849
62842
  root,
62850
62843
  /*mapper*/
62851
- void 0,
62852
- /*forConstraint*/
62853
- false
62844
+ void 0
62854
62845
  );
62855
62846
  if (outerTypeParameters) {
62856
62847
  root.instantiations = /* @__PURE__ */ new Map();
@@ -63704,17 +63695,17 @@ function createTypeChecker(host) {
63704
63695
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
63705
63696
  return result;
63706
63697
  }
63707
- function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
63698
+ function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
63708
63699
  const root = type.root;
63709
63700
  if (root.outerTypeParameters) {
63710
63701
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
63711
- const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
63702
+ const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
63712
63703
  let result = root.instantiations.get(id);
63713
63704
  if (!result) {
63714
63705
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
63715
63706
  const checkType = root.checkType;
63716
63707
  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);
63708
+ 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
63709
  root.instantiations.set(id, result);
63719
63710
  }
63720
63711
  return result;
@@ -63802,14 +63793,7 @@ function createTypeChecker(host) {
63802
63793
  );
63803
63794
  }
63804
63795
  if (flags & 16777216 /* Conditional */) {
63805
- return getConditionalTypeInstantiation(
63806
- type,
63807
- combineTypeMappers(type.mapper, mapper),
63808
- /*forConstraint*/
63809
- false,
63810
- aliasSymbol,
63811
- aliasTypeArguments
63812
- );
63796
+ return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
63813
63797
  }
63814
63798
  if (flags & 33554432 /* Substitution */) {
63815
63799
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -66350,6 +66334,13 @@ function createTypeChecker(host) {
66350
66334
  return result2;
66351
66335
  }
66352
66336
  }
66337
+ } else {
66338
+ const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
66339
+ if (distributiveConstraint) {
66340
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
66341
+ return result2;
66342
+ }
66343
+ }
66353
66344
  }
66354
66345
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
66355
66346
  if (defaultConstraint) {
@@ -66357,13 +66348,6 @@ function createTypeChecker(host) {
66357
66348
  return result2;
66358
66349
  }
66359
66350
  }
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
66351
  } else {
66368
66352
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
66369
66353
  return -1 /* True */;
@@ -70463,7 +70447,7 @@ function createTypeChecker(host) {
70463
70447
  return createFlowType(narrowedType, isIncomplete(flowType));
70464
70448
  }
70465
70449
  function getTypeAtSwitchClause(flow) {
70466
- const expr = flow.switchStatement.expression;
70450
+ const expr = skipParentheses(flow.switchStatement.expression);
70467
70451
  const flowType = getTypeAtFlowNode(flow.antecedent);
70468
70452
  let type = getTypeFromFlowType(flowType);
70469
70453
  if (isMatchingReference(reference, expr)) {
@@ -70471,16 +70455,7 @@ function createTypeChecker(host) {
70471
70455
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
70472
70456
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70473
70457
  } 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
- }
70458
+ type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70484
70459
  } else {
70485
70460
  if (strictNullChecks) {
70486
70461
  if (optionalChainContainsReference(expr, reference)) {
@@ -71026,6 +71001,42 @@ function createTypeChecker(host) {
71026
71001
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
71027
71002
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
71028
71003
  }
71004
+ function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
71005
+ const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
71006
+ const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
71007
+ for (let i = 0; i < clauseStart; i++) {
71008
+ const clause = switchStatement.caseBlock.clauses[i];
71009
+ if (clause.kind === 296 /* CaseClause */) {
71010
+ type = narrowType(
71011
+ type,
71012
+ clause.expression,
71013
+ /*assumeTrue*/
71014
+ false
71015
+ );
71016
+ }
71017
+ }
71018
+ if (hasDefaultClause) {
71019
+ for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) {
71020
+ const clause = switchStatement.caseBlock.clauses[i];
71021
+ if (clause.kind === 296 /* CaseClause */) {
71022
+ type = narrowType(
71023
+ type,
71024
+ clause.expression,
71025
+ /*assumeTrue*/
71026
+ false
71027
+ );
71028
+ }
71029
+ }
71030
+ return type;
71031
+ }
71032
+ const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
71033
+ return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
71034
+ type,
71035
+ clause.expression,
71036
+ /*assumeTrue*/
71037
+ true
71038
+ ) : neverType));
71039
+ }
71029
71040
  function isMatchingConstructorReference(expr) {
71030
71041
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
71031
71042
  }
@@ -78052,8 +78063,20 @@ function createTypeChecker(host) {
78052
78063
  let hasReturnWithNoExpression = functionHasImplicitReturn(func);
78053
78064
  let hasReturnOfTypeNever = false;
78054
78065
  forEachReturnStatement(func.body, (returnStatement) => {
78055
- const expr = returnStatement.expression;
78066
+ let expr = returnStatement.expression;
78056
78067
  if (expr) {
78068
+ expr = skipParentheses(
78069
+ expr,
78070
+ /*excludeJSDocTypeAssertions*/
78071
+ true
78072
+ );
78073
+ if (functionFlags & 2 /* Async */ && expr.kind === 223 /* AwaitExpression */) {
78074
+ expr = skipParentheses(
78075
+ expr.expression,
78076
+ /*excludeJSDocTypeAssertions*/
78077
+ true
78078
+ );
78079
+ }
78057
78080
  if (expr.kind === 213 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) {
78058
78081
  hasReturnOfTypeNever = true;
78059
78082
  return;
@@ -87030,7 +87053,16 @@ function createTypeChecker(host) {
87030
87053
  }
87031
87054
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
87032
87055
  },
87033
- isImportRequiredByAugmentation
87056
+ isImportRequiredByAugmentation,
87057
+ tryFindAmbientModule: (moduleReferenceExpression) => {
87058
+ const node = getParseTreeNode(moduleReferenceExpression);
87059
+ const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0;
87060
+ return moduleSpecifier !== void 0 ? tryFindAmbientModule(
87061
+ moduleSpecifier,
87062
+ /*withAugmentations*/
87063
+ true
87064
+ ) : void 0;
87065
+ }
87034
87066
  };
87035
87067
  function isImportRequiredByAugmentation(node) {
87036
87068
  const file = getSourceFileOfNode(node);
@@ -111961,6 +111993,17 @@ function transformDeclarations(context) {
111961
111993
  const container = getSourceFileOfNode(node);
111962
111994
  refs.set(getOriginalNodeId(container), container);
111963
111995
  }
111996
+ function trackReferencedAmbientModuleFromImport(node) {
111997
+ const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node);
111998
+ const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier);
111999
+ if (symbol == null ? void 0 : symbol.declarations) {
112000
+ for (const decl of symbol.declarations) {
112001
+ if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) {
112002
+ trackReferencedAmbientModule(decl, symbol);
112003
+ }
112004
+ }
112005
+ }
112006
+ }
111964
112007
  function handleSymbolAccessibilityError(symbolAccessibilityResult) {
111965
112008
  if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
111966
112009
  if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -112908,6 +112951,7 @@ function transformDeclarations(context) {
112908
112951
  case 205 /* ImportType */: {
112909
112952
  if (!isLiteralImportTypeNode(input))
112910
112953
  return cleanup(input);
112954
+ trackReferencedAmbientModuleFromImport(input);
112911
112955
  return cleanup(factory2.updateImportTypeNode(
112912
112956
  input,
112913
112957
  factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)),
@@ -112959,6 +113003,7 @@ function transformDeclarations(context) {
112959
113003
  resultHasExternalModuleIndicator = true;
112960
113004
  }
112961
113005
  resultHasScopeMarker = true;
113006
+ trackReferencedAmbientModuleFromImport(input);
112962
113007
  return factory2.updateExportDeclaration(
112963
113008
  input,
112964
113009
  input.modifiers,
@@ -113033,10 +113078,18 @@ function transformDeclarations(context) {
113033
113078
  return;
113034
113079
  switch (input.kind) {
113035
113080
  case 271 /* ImportEqualsDeclaration */: {
113036
- return transformImportEqualsDeclaration(input);
113081
+ const transformed = transformImportEqualsDeclaration(input);
113082
+ if (transformed) {
113083
+ trackReferencedAmbientModuleFromImport(input);
113084
+ }
113085
+ return transformed;
113037
113086
  }
113038
113087
  case 272 /* ImportDeclaration */: {
113039
- return transformImportDeclaration(input);
113088
+ const transformed = transformImportDeclaration(input);
113089
+ if (transformed) {
113090
+ trackReferencedAmbientModuleFromImport(input);
113091
+ }
113092
+ return transformed;
113040
113093
  }
113041
113094
  }
113042
113095
  if (isDeclaration(input) && isDeclarationAndNotVisible(input))
@@ -114650,7 +114703,8 @@ var notImplementedResolver = {
114650
114703
  getSymbolOfExternalModuleSpecifier: notImplemented,
114651
114704
  isBindingCapturedByNode: notImplemented,
114652
114705
  getDeclarationStatementsForSourceFile: notImplemented,
114653
- isImportRequiredByAugmentation: notImplemented
114706
+ isImportRequiredByAugmentation: notImplemented,
114707
+ tryFindAmbientModule: notImplemented
114654
114708
  };
114655
114709
  function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
114656
114710
  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
  }
@@ -56534,12 +56537,7 @@ ${lanes.join("\n")}
56534
56537
  const checkType = type.checkType;
56535
56538
  const constraint = getLowerBoundOfKeyType(checkType);
56536
56539
  if (constraint !== checkType) {
56537
- return getConditionalTypeInstantiation(
56538
- type,
56539
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
56540
- /*forConstraint*/
56541
- false
56542
- );
56540
+ return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
56543
56541
  }
56544
56542
  }
56545
56543
  return type;
@@ -56891,12 +56889,7 @@ ${lanes.join("\n")}
56891
56889
  );
56892
56890
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
56893
56891
  if (constraint && constraint !== type.checkType) {
56894
- const instantiated = getConditionalTypeInstantiation(
56895
- type,
56896
- prependTypeMapping(type.root.checkType, constraint, type.mapper),
56897
- /*forConstraint*/
56898
- true
56899
- );
56892
+ const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
56900
56893
  if (!(instantiated.flags & 131072 /* Never */)) {
56901
56894
  type.resolvedConstraintOfDistributive = instantiated;
56902
56895
  return instantiated;
@@ -60459,7 +60452,7 @@ ${lanes.join("\n")}
60459
60452
  function isDeferredType(type, checkTuples) {
60460
60453
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
60461
60454
  }
60462
- function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
60455
+ function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
60463
60456
  let result;
60464
60457
  let extraTypes;
60465
60458
  let tailCount = 0;
@@ -60505,7 +60498,7 @@ ${lanes.join("\n")}
60505
60498
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
60506
60499
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
60507
60500
  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))) {
60501
+ if (checkType.flags & 1 /* Any */) {
60509
60502
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
60510
60503
  }
60511
60504
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -60615,9 +60608,7 @@ ${lanes.join("\n")}
60615
60608
  links.resolvedType = getConditionalType(
60616
60609
  root,
60617
60610
  /*mapper*/
60618
- void 0,
60619
- /*forConstraint*/
60620
- false
60611
+ void 0
60621
60612
  );
60622
60613
  if (outerTypeParameters) {
60623
60614
  root.instantiations = /* @__PURE__ */ new Map();
@@ -61471,17 +61462,17 @@ ${lanes.join("\n")}
61471
61462
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
61472
61463
  return result;
61473
61464
  }
61474
- function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
61465
+ function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
61475
61466
  const root = type.root;
61476
61467
  if (root.outerTypeParameters) {
61477
61468
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
61478
- const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
61469
+ const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
61479
61470
  let result = root.instantiations.get(id);
61480
61471
  if (!result) {
61481
61472
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
61482
61473
  const checkType = root.checkType;
61483
61474
  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);
61475
+ 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
61476
  root.instantiations.set(id, result);
61486
61477
  }
61487
61478
  return result;
@@ -61569,14 +61560,7 @@ ${lanes.join("\n")}
61569
61560
  );
61570
61561
  }
61571
61562
  if (flags & 16777216 /* Conditional */) {
61572
- return getConditionalTypeInstantiation(
61573
- type,
61574
- combineTypeMappers(type.mapper, mapper),
61575
- /*forConstraint*/
61576
- false,
61577
- aliasSymbol,
61578
- aliasTypeArguments
61579
- );
61563
+ return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
61580
61564
  }
61581
61565
  if (flags & 33554432 /* Substitution */) {
61582
61566
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -64117,6 +64101,13 @@ ${lanes.join("\n")}
64117
64101
  return result2;
64118
64102
  }
64119
64103
  }
64104
+ } else {
64105
+ const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
64106
+ if (distributiveConstraint) {
64107
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
64108
+ return result2;
64109
+ }
64110
+ }
64120
64111
  }
64121
64112
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
64122
64113
  if (defaultConstraint) {
@@ -64124,13 +64115,6 @@ ${lanes.join("\n")}
64124
64115
  return result2;
64125
64116
  }
64126
64117
  }
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
64118
  } else {
64135
64119
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
64136
64120
  return -1 /* True */;
@@ -68230,7 +68214,7 @@ ${lanes.join("\n")}
68230
68214
  return createFlowType(narrowedType, isIncomplete(flowType));
68231
68215
  }
68232
68216
  function getTypeAtSwitchClause(flow) {
68233
- const expr = flow.switchStatement.expression;
68217
+ const expr = skipParentheses(flow.switchStatement.expression);
68234
68218
  const flowType = getTypeAtFlowNode(flow.antecedent);
68235
68219
  let type = getTypeFromFlowType(flowType);
68236
68220
  if (isMatchingReference(reference, expr)) {
@@ -68238,16 +68222,7 @@ ${lanes.join("\n")}
68238
68222
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
68239
68223
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68240
68224
  } 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
- }
68225
+ type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68251
68226
  } else {
68252
68227
  if (strictNullChecks) {
68253
68228
  if (optionalChainContainsReference(expr, reference)) {
@@ -68793,6 +68768,42 @@ ${lanes.join("\n")}
68793
68768
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
68794
68769
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
68795
68770
  }
68771
+ function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
68772
+ const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
68773
+ const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
68774
+ for (let i = 0; i < clauseStart; i++) {
68775
+ const clause = switchStatement.caseBlock.clauses[i];
68776
+ if (clause.kind === 296 /* CaseClause */) {
68777
+ type = narrowType(
68778
+ type,
68779
+ clause.expression,
68780
+ /*assumeTrue*/
68781
+ false
68782
+ );
68783
+ }
68784
+ }
68785
+ if (hasDefaultClause) {
68786
+ for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) {
68787
+ const clause = switchStatement.caseBlock.clauses[i];
68788
+ if (clause.kind === 296 /* CaseClause */) {
68789
+ type = narrowType(
68790
+ type,
68791
+ clause.expression,
68792
+ /*assumeTrue*/
68793
+ false
68794
+ );
68795
+ }
68796
+ }
68797
+ return type;
68798
+ }
68799
+ const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
68800
+ return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
68801
+ type,
68802
+ clause.expression,
68803
+ /*assumeTrue*/
68804
+ true
68805
+ ) : neverType));
68806
+ }
68796
68807
  function isMatchingConstructorReference(expr) {
68797
68808
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
68798
68809
  }
@@ -75819,8 +75830,20 @@ ${lanes.join("\n")}
75819
75830
  let hasReturnWithNoExpression = functionHasImplicitReturn(func);
75820
75831
  let hasReturnOfTypeNever = false;
75821
75832
  forEachReturnStatement(func.body, (returnStatement) => {
75822
- const expr = returnStatement.expression;
75833
+ let expr = returnStatement.expression;
75823
75834
  if (expr) {
75835
+ expr = skipParentheses(
75836
+ expr,
75837
+ /*excludeJSDocTypeAssertions*/
75838
+ true
75839
+ );
75840
+ if (functionFlags & 2 /* Async */ && expr.kind === 223 /* AwaitExpression */) {
75841
+ expr = skipParentheses(
75842
+ expr.expression,
75843
+ /*excludeJSDocTypeAssertions*/
75844
+ true
75845
+ );
75846
+ }
75824
75847
  if (expr.kind === 213 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) {
75825
75848
  hasReturnOfTypeNever = true;
75826
75849
  return;
@@ -84797,7 +84820,16 @@ ${lanes.join("\n")}
84797
84820
  }
84798
84821
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
84799
84822
  },
84800
- isImportRequiredByAugmentation
84823
+ isImportRequiredByAugmentation,
84824
+ tryFindAmbientModule: (moduleReferenceExpression) => {
84825
+ const node = getParseTreeNode(moduleReferenceExpression);
84826
+ const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0;
84827
+ return moduleSpecifier !== void 0 ? tryFindAmbientModule(
84828
+ moduleSpecifier,
84829
+ /*withAugmentations*/
84830
+ true
84831
+ ) : void 0;
84832
+ }
84801
84833
  };
84802
84834
  function isImportRequiredByAugmentation(node) {
84803
84835
  const file = getSourceFileOfNode(node);
@@ -110037,6 +110069,17 @@ ${lanes.join("\n")}
110037
110069
  const container = getSourceFileOfNode(node);
110038
110070
  refs.set(getOriginalNodeId(container), container);
110039
110071
  }
110072
+ function trackReferencedAmbientModuleFromImport(node) {
110073
+ const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node);
110074
+ const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier);
110075
+ if (symbol == null ? void 0 : symbol.declarations) {
110076
+ for (const decl of symbol.declarations) {
110077
+ if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) {
110078
+ trackReferencedAmbientModule(decl, symbol);
110079
+ }
110080
+ }
110081
+ }
110082
+ }
110040
110083
  function handleSymbolAccessibilityError(symbolAccessibilityResult) {
110041
110084
  if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
110042
110085
  if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -110984,6 +111027,7 @@ ${lanes.join("\n")}
110984
111027
  case 205 /* ImportType */: {
110985
111028
  if (!isLiteralImportTypeNode(input))
110986
111029
  return cleanup(input);
111030
+ trackReferencedAmbientModuleFromImport(input);
110987
111031
  return cleanup(factory2.updateImportTypeNode(
110988
111032
  input,
110989
111033
  factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)),
@@ -111035,6 +111079,7 @@ ${lanes.join("\n")}
111035
111079
  resultHasExternalModuleIndicator = true;
111036
111080
  }
111037
111081
  resultHasScopeMarker = true;
111082
+ trackReferencedAmbientModuleFromImport(input);
111038
111083
  return factory2.updateExportDeclaration(
111039
111084
  input,
111040
111085
  input.modifiers,
@@ -111109,10 +111154,18 @@ ${lanes.join("\n")}
111109
111154
  return;
111110
111155
  switch (input.kind) {
111111
111156
  case 271 /* ImportEqualsDeclaration */: {
111112
- return transformImportEqualsDeclaration(input);
111157
+ const transformed = transformImportEqualsDeclaration(input);
111158
+ if (transformed) {
111159
+ trackReferencedAmbientModuleFromImport(input);
111160
+ }
111161
+ return transformed;
111113
111162
  }
111114
111163
  case 272 /* ImportDeclaration */: {
111115
- return transformImportDeclaration(input);
111164
+ const transformed = transformImportDeclaration(input);
111165
+ if (transformed) {
111166
+ trackReferencedAmbientModuleFromImport(input);
111167
+ }
111168
+ return transformed;
111116
111169
  }
111117
111170
  }
111118
111171
  if (isDeclaration(input) && isDeclarationAndNotVisible(input))
@@ -117599,7 +117652,8 @@ ${lanes.join("\n")}
117599
117652
  getSymbolOfExternalModuleSpecifier: notImplemented,
117600
117653
  isBindingCapturedByNode: notImplemented,
117601
117654
  getDeclarationStatementsForSourceFile: notImplemented,
117602
- isImportRequiredByAugmentation: notImplemented
117655
+ isImportRequiredByAugmentation: notImplemented,
117656
+ tryFindAmbientModule: notImplemented
117603
117657
  };
117604
117658
  createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
117605
117659
  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-56020-20",
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": "255c2861a6df15f9f602ff6c283a577d34f58fab"
118
118
  }