typescript 5.2.0-dev.20230802 → 5.2.0-dev.20230804

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.2";
21
- var version = `${versionMajorMinor}.0-dev.20230802`;
21
+ var version = `${versionMajorMinor}.0-dev.20230804`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -34361,7 +34361,7 @@ var commandOptionsWithoutBuild = [
34361
34361
  strictFlag: true,
34362
34362
  category: Diagnostics.Type_Checking,
34363
34363
  description: Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
34364
- defaultValueDescription: false
34364
+ defaultValueDescription: Diagnostics.false_unless_strict_is_set
34365
34365
  },
34366
34366
  {
34367
34367
  name: "alwaysStrict",
@@ -44357,7 +44357,7 @@ function createTypeChecker(host) {
44357
44357
  return symbol;
44358
44358
  }
44359
44359
  if (symbol.flags & 2097152 /* Alias */) {
44360
- const targetFlags = getAllSymbolFlags(symbol);
44360
+ const targetFlags = getSymbolFlags(symbol);
44361
44361
  if (targetFlags & meaning) {
44362
44362
  return symbol;
44363
44363
  }
@@ -45117,7 +45117,7 @@ function createTypeChecker(host) {
45117
45117
  /*isUse*/
45118
45118
  false
45119
45119
  ));
45120
- const allFlags = symbol && getAllSymbolFlags(symbol);
45120
+ const allFlags = symbol && getSymbolFlags(symbol);
45121
45121
  if (symbol && allFlags !== void 0 && !(allFlags & 111551 /* Value */)) {
45122
45122
  const rawName = unescapeLeadingUnderscores(name);
45123
45123
  if (isES2015OrLaterConstructorName(name)) {
@@ -45853,11 +45853,23 @@ function createTypeChecker(host) {
45853
45853
  }
45854
45854
  return void 0;
45855
45855
  }
45856
- function getAllSymbolFlags(symbol) {
45857
- let flags = symbol.flags;
45856
+ function getSymbolFlags(symbol, excludeTypeOnlyMeanings, excludeLocalMeanings) {
45857
+ const typeOnlyDeclaration = excludeTypeOnlyMeanings && getTypeOnlyAliasDeclaration(symbol);
45858
+ const typeOnlyDeclarationIsExportStar = typeOnlyDeclaration && isExportDeclaration(typeOnlyDeclaration);
45859
+ const typeOnlyResolution = typeOnlyDeclaration && (typeOnlyDeclarationIsExportStar ? resolveExternalModuleName(
45860
+ typeOnlyDeclaration.moduleSpecifier,
45861
+ typeOnlyDeclaration.moduleSpecifier,
45862
+ /*ignoreErrors*/
45863
+ true
45864
+ ) : resolveAlias(typeOnlyDeclaration.symbol));
45865
+ const typeOnlyExportStarTargets = typeOnlyDeclarationIsExportStar && typeOnlyResolution ? getExportsOfModule(typeOnlyResolution) : void 0;
45866
+ let flags = excludeLocalMeanings ? 0 /* None */ : symbol.flags;
45858
45867
  let seenSymbols;
45859
45868
  while (symbol.flags & 2097152 /* Alias */) {
45860
- const target = resolveAlias(symbol);
45869
+ const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
45870
+ if (!typeOnlyDeclarationIsExportStar && target === typeOnlyResolution || (typeOnlyExportStarTargets == null ? void 0 : typeOnlyExportStarTargets.get(target.escapedName)) === target) {
45871
+ break;
45872
+ }
45861
45873
  if (target === unknownSymbol) {
45862
45874
  return 67108863 /* All */;
45863
45875
  }
@@ -45915,7 +45927,7 @@ function createTypeChecker(host) {
45915
45927
  }
45916
45928
  if (links.typeOnlyDeclaration) {
45917
45929
  const resolved = links.typeOnlyDeclaration.kind === 278 /* ExportDeclaration */ ? resolveSymbol(getExportsOfModule(links.typeOnlyDeclaration.symbol.parent).get(links.typeOnlyExportStarName || symbol.escapedName)) : resolveAlias(links.typeOnlyDeclaration.symbol);
45918
- return getAllSymbolFlags(resolved) & include ? links.typeOnlyDeclaration : void 0;
45930
+ return getSymbolFlags(resolved) & include ? links.typeOnlyDeclaration : void 0;
45919
45931
  }
45920
45932
  return void 0;
45921
45933
  }
@@ -45926,7 +45938,11 @@ function createTypeChecker(host) {
45926
45938
  const symbol = getSymbolOfDeclaration(node);
45927
45939
  const target = resolveAlias(symbol);
45928
45940
  if (target) {
45929
- const markAlias = target === unknownSymbol || getAllSymbolFlags(target) & 111551 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* Value */);
45941
+ const markAlias = target === unknownSymbol || getSymbolFlags(
45942
+ symbol,
45943
+ /*excludeTypeOnlyMeanings*/
45944
+ true
45945
+ ) & 111551 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target);
45930
45946
  if (markAlias) {
45931
45947
  markAliasSymbolAsReferenced(symbol);
45932
45948
  }
@@ -45941,7 +45957,7 @@ function createTypeChecker(host) {
45941
45957
  if (!node)
45942
45958
  return Debug.fail();
45943
45959
  if (isInternalModuleImportEqualsDeclaration(node)) {
45944
- if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* Value */) {
45960
+ if (getSymbolFlags(resolveSymbol(symbol)) & 111551 /* Value */) {
45945
45961
  checkExpressionCached(node.moduleReference);
45946
45962
  }
45947
45963
  }
@@ -46792,7 +46808,7 @@ function createTypeChecker(host) {
46792
46808
  return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol);
46793
46809
  }
46794
46810
  function symbolIsValue(symbol, includeTypeOnlyMembers) {
46795
- return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && getAllSymbolFlags(symbol) & 111551 /* Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
46811
+ return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && getSymbolFlags(symbol, !includeTypeOnlyMembers) & 111551 /* Value */);
46796
46812
  }
46797
46813
  function findConstructorDeclaration(node) {
46798
46814
  const members = node.members;
@@ -47059,7 +47075,7 @@ function createTypeChecker(host) {
47059
47075
  }
47060
47076
  const shouldResolveAlias = symbolFromSymbolTable.flags & 2097152 /* Alias */ && !getDeclarationOfKind(symbolFromSymbolTable, 281 /* ExportSpecifier */);
47061
47077
  symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
47062
- const flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
47078
+ const flags = shouldResolveAlias ? getSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
47063
47079
  if (flags & meaning) {
47064
47080
  qualify = true;
47065
47081
  return true;
@@ -49921,7 +49937,7 @@ function createTypeChecker(host) {
49921
49937
  return !exports ? [] : filter(arrayFrom(exports.values()), (m) => isNamespaceMember(m) && isIdentifierText(m.escapedName, 99 /* ESNext */));
49922
49938
  }
49923
49939
  function isTypeOnlyNamespace(symbol) {
49924
- return every(getNamespaceMembersForSerialization(symbol), (m) => !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* Value */));
49940
+ return every(getNamespaceMembersForSerialization(symbol), (m) => !(getSymbolFlags(resolveSymbol(m)) & 111551 /* Value */));
49925
49941
  }
49926
49942
  function serializeModule(symbol, symbolName2, modifierFlags) {
49927
49943
  const members = getNamespaceMembersForSerialization(symbol);
@@ -52193,7 +52209,7 @@ function createTypeChecker(host) {
52193
52209
  true
52194
52210
  );
52195
52211
  const declaredType = firstDefined(exportSymbol == null ? void 0 : exportSymbol.declarations, (d) => isExportAssignment(d) ? tryGetTypeFromEffectiveTypeNode(d) : void 0);
52196
- links.type = (exportSymbol == null ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType : getAllSymbolFlags(targetSymbol) & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType;
52212
+ links.type = (exportSymbol == null ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType : getSymbolFlags(targetSymbol) & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType;
52197
52213
  }
52198
52214
  return links.type;
52199
52215
  }
@@ -59803,6 +59819,7 @@ function createTypeChecker(host) {
59803
59819
  let errorInfo;
59804
59820
  let relatedInfo;
59805
59821
  let maybeKeys;
59822
+ let maybeKeysSet;
59806
59823
  let sourceStack;
59807
59824
  let targetStack;
59808
59825
  let maybeCount = 0;
@@ -60672,9 +60689,13 @@ function createTypeChecker(host) {
60672
60689
  }
60673
60690
  if (!maybeKeys) {
60674
60691
  maybeKeys = [];
60692
+ maybeKeysSet = /* @__PURE__ */ new Set();
60675
60693
  sourceStack = [];
60676
60694
  targetStack = [];
60677
60695
  } else {
60696
+ if (maybeKeysSet.has(id)) {
60697
+ return 3 /* Maybe */;
60698
+ }
60678
60699
  const broadestEquivalentId = id.startsWith("*") ? getRelationKey(
60679
60700
  source2,
60680
60701
  target2,
@@ -60683,10 +60704,8 @@ function createTypeChecker(host) {
60683
60704
  /*ignoreConstraints*/
60684
60705
  true
60685
60706
  ) : void 0;
60686
- for (let i = 0; i < maybeCount; i++) {
60687
- if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
60688
- return 3 /* Maybe */;
60689
- }
60707
+ if (broadestEquivalentId && maybeKeysSet.has(broadestEquivalentId)) {
60708
+ return 3 /* Maybe */;
60690
60709
  }
60691
60710
  if (sourceDepth === 100 || targetDepth === 100) {
60692
60711
  overflow = true;
@@ -60695,6 +60714,7 @@ function createTypeChecker(host) {
60695
60714
  }
60696
60715
  const maybeStart = maybeCount;
60697
60716
  maybeKeys[maybeCount] = id;
60717
+ maybeKeysSet.add(id);
60698
60718
  maybeCount++;
60699
60719
  const saveExpandingFlags = expandingFlags;
60700
60720
  if (recursionFlags & 1 /* Source */) {
@@ -60747,17 +60767,34 @@ function createTypeChecker(host) {
60747
60767
  if (result2) {
60748
60768
  if (result2 === -1 /* True */ || sourceDepth === 0 && targetDepth === 0) {
60749
60769
  if (result2 === -1 /* True */ || result2 === 3 /* Maybe */) {
60750
- for (let i = maybeStart; i < maybeCount; i++) {
60751
- relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags);
60752
- }
60770
+ resetMaybeStack(
60771
+ /*markAllAsSucceeded*/
60772
+ true
60773
+ );
60774
+ } else {
60775
+ resetMaybeStack(
60776
+ /*markAllAsSucceeded*/
60777
+ false
60778
+ );
60753
60779
  }
60754
- maybeCount = maybeStart;
60755
60780
  }
60756
60781
  } else {
60757
60782
  relation.set(id, (reportErrors2 ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags);
60758
- maybeCount = maybeStart;
60783
+ resetMaybeStack(
60784
+ /*markAllAsSucceeded*/
60785
+ false
60786
+ );
60759
60787
  }
60760
60788
  return result2;
60789
+ function resetMaybeStack(markAllAsSucceeded) {
60790
+ for (let i = maybeStart; i < maybeCount; i++) {
60791
+ maybeKeysSet.delete(maybeKeys[i]);
60792
+ if (markAllAsSucceeded) {
60793
+ relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags);
60794
+ }
60795
+ }
60796
+ maybeCount = maybeStart;
60797
+ }
60761
60798
  }
60762
60799
  function structuredTypeRelatedTo(source2, target2, reportErrors2, intersectionState) {
60763
60800
  const saveErrorInfo = captureErrorCalculationState();
@@ -66201,9 +66238,13 @@ function createTypeChecker(host) {
66201
66238
  symbol,
66202
66239
  /*excludes*/
66203
66240
  111551 /* Value */
66204
- ) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* Value */)) {
66241
+ ) && !isInTypeQuery(location)) {
66205
66242
  const target = resolveAlias(symbol);
66206
- if (getAllSymbolFlags(target) & (111551 /* Value */ | 1048576 /* ExportValue */)) {
66243
+ if (getSymbolFlags(
66244
+ symbol,
66245
+ /*excludeTypeOnlyMeanings*/
66246
+ true
66247
+ ) & (111551 /* Value */ | 1048576 /* ExportValue */)) {
66207
66248
  if (getIsolatedModules(compilerOptions) || shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))) {
66208
66249
  markAliasSymbolAsReferenced(symbol);
66209
66250
  } else {
@@ -77006,9 +77047,6 @@ function createTypeChecker(host) {
77006
77047
  if ((getCombinedNodeFlagsCached(node) & 7 /* BlockScoped */) !== 0 || isParameterDeclaration(node)) {
77007
77048
  return;
77008
77049
  }
77009
- if (node.kind === 260 /* VariableDeclaration */ && !node.initializer) {
77010
- return;
77011
- }
77012
77050
  const symbol = getSymbolOfDeclaration(node);
77013
77051
  if (symbol.flags & 1 /* FunctionScopedVariable */) {
77014
77052
  if (!isIdentifier(node.name))
@@ -79276,10 +79314,22 @@ function createTypeChecker(host) {
79276
79314
  return +expr.text;
79277
79315
  case 217 /* ParenthesizedExpression */:
79278
79316
  return evaluate(expr.expression, location);
79279
- case 80 /* Identifier */:
79280
- if (isInfinityOrNaNString(expr.escapedText)) {
79281
- return +expr.escapedText;
79317
+ case 80 /* Identifier */: {
79318
+ const identifier = expr;
79319
+ if (isInfinityOrNaNString(identifier.escapedText) && resolveEntityName(
79320
+ identifier,
79321
+ 111551 /* Value */,
79322
+ /*ignoreErrors*/
79323
+ true
79324
+ ) === getGlobalSymbol(
79325
+ identifier.escapedText,
79326
+ 111551 /* Value */,
79327
+ /*diagnostic*/
79328
+ void 0
79329
+ )) {
79330
+ return +identifier.escapedText;
79282
79331
  }
79332
+ }
79283
79333
  case 211 /* PropertyAccessExpression */:
79284
79334
  if (isEntityNameExpression(expr)) {
79285
79335
  const symbol = resolveEntityName(
@@ -79618,7 +79668,7 @@ function createTypeChecker(host) {
79618
79668
  }
79619
79669
  return;
79620
79670
  }
79621
- const targetFlags = getAllSymbolFlags(target);
79671
+ const targetFlags = getSymbolFlags(target);
79622
79672
  const excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
79623
79673
  if (targetFlags & excludedMeanings) {
79624
79674
  const message = node.kind === 281 /* ExportSpecifier */ ? Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
@@ -79776,7 +79826,7 @@ function createTypeChecker(host) {
79776
79826
  if (node.moduleReference.kind !== 283 /* ExternalModuleReference */) {
79777
79827
  const target = resolveAlias(getSymbolOfDeclaration(node));
79778
79828
  if (target !== unknownSymbol) {
79779
- const targetFlags = getAllSymbolFlags(target);
79829
+ const targetFlags = getSymbolFlags(target);
79780
79830
  if (targetFlags & 111551 /* Value */) {
79781
79831
  const moduleName = getFirstIdentifier(node.moduleReference);
79782
79832
  if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) {
@@ -79916,7 +79966,7 @@ function createTypeChecker(host) {
79916
79966
  markExportAsReferenced(node);
79917
79967
  }
79918
79968
  const target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
79919
- if (!target || getAllSymbolFlags(target) & 111551 /* Value */) {
79969
+ if (!target || getSymbolFlags(target) & 111551 /* Value */) {
79920
79970
  checkExpressionCached(node.propertyName || node.name);
79921
79971
  }
79922
79972
  }
@@ -79961,7 +80011,7 @@ function createTypeChecker(host) {
79961
80011
  ));
79962
80012
  if (sym) {
79963
80013
  markAliasReferenced(sym, id);
79964
- if (getAllSymbolFlags(sym) & 111551 /* Value */) {
80014
+ if (getSymbolFlags(sym) & 111551 /* Value */) {
79965
80015
  checkExpressionCached(id);
79966
80016
  if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
79967
80017
  error(
@@ -81208,7 +81258,7 @@ function createTypeChecker(host) {
81208
81258
  return symbolLinks2.exportsSomeValue;
81209
81259
  function isValue(s) {
81210
81260
  s = resolveSymbol(s);
81211
- return s && !!(getAllSymbolFlags(s) & 111551 /* Value */);
81261
+ return s && !!(getSymbolFlags(s) & 111551 /* Value */);
81212
81262
  }
81213
81263
  }
81214
81264
  function isNameOfModuleOrEnumDeclaration(node) {
@@ -81338,7 +81388,11 @@ function createTypeChecker(host) {
81338
81388
  case 276 /* ImportSpecifier */:
81339
81389
  case 281 /* ExportSpecifier */:
81340
81390
  const symbol = getSymbolOfDeclaration(node);
81341
- return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* Value */);
81391
+ return !!symbol && isAliasResolvedToValue(
81392
+ symbol,
81393
+ /*excludeTypeOnlyValues*/
81394
+ true
81395
+ );
81342
81396
  case 278 /* ExportDeclaration */:
81343
81397
  const exportClause = node.exportClause;
81344
81398
  return !!exportClause && (isNamespaceExport(exportClause) || some(exportClause.elements, isValueAliasDeclaration));
@@ -81355,7 +81409,7 @@ function createTypeChecker(host) {
81355
81409
  const isValue = isAliasResolvedToValue(getSymbolOfDeclaration(node));
81356
81410
  return isValue && node.moduleReference && !nodeIsMissing(node.moduleReference);
81357
81411
  }
81358
- function isAliasResolvedToValue(symbol) {
81412
+ function isAliasResolvedToValue(symbol, excludeTypeOnlyValues) {
81359
81413
  if (!symbol) {
81360
81414
  return false;
81361
81415
  }
@@ -81363,7 +81417,12 @@ function createTypeChecker(host) {
81363
81417
  if (target === unknownSymbol) {
81364
81418
  return true;
81365
81419
  }
81366
- return !!((getAllSymbolFlags(target) ?? -1) & 111551 /* Value */) && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
81420
+ return !!(getSymbolFlags(
81421
+ symbol,
81422
+ excludeTypeOnlyValues,
81423
+ /*excludeLocalMeanings*/
81424
+ true
81425
+ ) & 111551 /* Value */) && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
81367
81426
  }
81368
81427
  function isConstEnumOrConstEnumOnlyModule(s) {
81369
81428
  return isConstEnumSymbol(s) || !!s.constEnumOnlyModule;
@@ -81377,7 +81436,7 @@ function createTypeChecker(host) {
81377
81436
  return true;
81378
81437
  }
81379
81438
  const target = getSymbolLinks(symbol).aliasTarget;
81380
- if (target && getEffectiveModifierFlags(node) & 1 /* Export */ && getAllSymbolFlags(target) & 111551 /* Value */ && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
81439
+ if (target && getEffectiveModifierFlags(node) & 1 /* Export */ && getSymbolFlags(target) & 111551 /* Value */ && (shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
81381
81440
  return true;
81382
81441
  }
81383
81442
  }