typescript 5.1.0-dev.20230426 → 5.1.0-dev.20230428

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.1";
21
- var version = `${versionMajorMinor}.0-dev.20230426`;
21
+ var version = `${versionMajorMinor}.0-dev.20230428`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -13734,6 +13734,7 @@ function canHaveJSDoc(node) {
13734
13734
  case 171 /* PropertyDeclaration */:
13735
13735
  case 170 /* PropertySignature */:
13736
13736
  case 252 /* ReturnStatement */:
13737
+ case 239 /* SemicolonClassElement */:
13737
13738
  case 177 /* SetAccessor */:
13738
13739
  case 303 /* ShorthandPropertyAssignment */:
13739
13740
  case 304 /* SpreadAssignment */:
@@ -31102,11 +31103,11 @@ var Parser;
31102
31103
  }
31103
31104
  function parseClassElement() {
31104
31105
  const pos = getNodePos();
31106
+ const hasJSDoc = hasPrecedingJSDocComment();
31105
31107
  if (token() === 27 /* SemicolonToken */) {
31106
31108
  nextToken();
31107
- return finishNode(factory2.createSemicolonClassElement(), pos);
31109
+ return withJSDoc(finishNode(factory2.createSemicolonClassElement(), pos), hasJSDoc);
31108
31110
  }
31109
- const hasJSDoc = hasPrecedingJSDocComment();
31110
31111
  const modifiers = parseModifiers(
31111
31112
  /*allowDecorators*/
31112
31113
  true,
@@ -43641,13 +43642,14 @@ function createTypeChecker(host) {
43641
43642
  return diagnostic;
43642
43643
  }
43643
43644
  function isDeprecatedSymbol(symbol) {
43644
- if (length(symbol.declarations) > 1) {
43645
- const parentSymbol = getParentOfSymbol(symbol);
43646
- if (parentSymbol && parentSymbol.flags & 64 /* Interface */) {
43647
- return some(symbol.declarations, (d) => !!(getCombinedNodeFlags(d) & 268435456 /* Deprecated */));
43648
- }
43645
+ const parentSymbol = getParentOfSymbol(symbol);
43646
+ if (parentSymbol && length(symbol.declarations) > 1) {
43647
+ return parentSymbol.flags & 64 /* Interface */ ? some(symbol.declarations, isDeprecatedDeclaration) : every(symbol.declarations, isDeprecatedDeclaration);
43649
43648
  }
43650
- return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
43649
+ return !!symbol.valueDeclaration && isDeprecatedDeclaration(symbol.valueDeclaration) || length(symbol.declarations) && every(symbol.declarations, isDeprecatedDeclaration);
43650
+ }
43651
+ function isDeprecatedDeclaration(declaration) {
43652
+ return !!(getCombinedNodeFlags(declaration) & 268435456 /* Deprecated */);
43651
43653
  }
43652
43654
  function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
43653
43655
  const diagnostic = createDiagnosticForNode(location, Diagnostics._0_is_deprecated, deprecatedEntity);
@@ -54540,16 +54542,16 @@ function createTypeChecker(host) {
54540
54542
  if (declaration.kind === 175 /* Constructor */) {
54541
54543
  return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
54542
54544
  }
54545
+ const typeNode = getEffectiveReturnTypeNode(declaration);
54543
54546
  if (isJSDocSignature(declaration)) {
54544
54547
  const root = getJSDocRoot(declaration);
54545
- if (root && isConstructorDeclaration(root.parent)) {
54548
+ if (root && isConstructorDeclaration(root.parent) && !typeNode) {
54546
54549
  return getDeclaredTypeOfClassOrInterface(getMergedSymbol(root.parent.parent.symbol));
54547
54550
  }
54548
54551
  }
54549
54552
  if (isJSDocConstructSignature(declaration)) {
54550
54553
  return getTypeFromTypeNode(declaration.parameters[0].type);
54551
54554
  }
54552
- const typeNode = getEffectiveReturnTypeNode(declaration);
54553
54555
  if (typeNode) {
54554
54556
  return getTypeFromTypeNode(typeNode);
54555
54557
  }
@@ -65807,7 +65809,7 @@ function createTypeChecker(host) {
65807
65809
  markAliasReferenced(symbol, node);
65808
65810
  }
65809
65811
  const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
65810
- const targetSymbol = checkDeprecatedAliasedSymbol(localOrExportSymbol, node);
65812
+ const targetSymbol = resolveAliasWithDeprecationCheck(localOrExportSymbol, node);
65811
65813
  if (isDeprecatedSymbol(targetSymbol) && isUncalledFunctionReference(node, targetSymbol) && targetSymbol.declarations) {
65812
65814
  addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText);
65813
65815
  }
@@ -66976,6 +66978,7 @@ function createTypeChecker(host) {
66976
66978
  );
66977
66979
  }
66978
66980
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
66981
+ const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
66979
66982
  return discriminateTypeByDiscriminableItems(
66980
66983
  contextualType,
66981
66984
  concatenate(
@@ -66986,7 +66989,14 @@ function createTypeChecker(host) {
66986
66989
  map(
66987
66990
  filter(getPropertiesOfType(contextualType), (s) => {
66988
66991
  var _a;
66989
- return !!(s.flags & 16777216 /* Optional */) && !!((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
66992
+ if (!(s.flags & 16777216 /* Optional */) || !((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members)) {
66993
+ return false;
66994
+ }
66995
+ const element = node.parent.parent;
66996
+ if (s.escapedName === jsxChildrenPropertyName && isJsxElement(element) && getSemanticJsxChildren(element.children).length) {
66997
+ return false;
66998
+ }
66999
+ return !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
66990
67000
  }),
66991
67001
  (s) => [() => undefinedType, s.escapedName]
66992
67002
  )
@@ -68803,8 +68813,9 @@ function createTypeChecker(host) {
68803
68813
  addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
68804
68814
  }
68805
68815
  } else {
68806
- if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
68807
- addDeprecatedSuggestion(right, prop.declarations, right.escapedText);
68816
+ const targetPropSymbol = resolveAliasWithDeprecationCheck(prop, right);
68817
+ if (isDeprecatedSymbol(targetPropSymbol) && isUncalledFunctionReference(node, targetPropSymbol) && targetPropSymbol.declarations) {
68818
+ addDeprecatedSuggestion(right, targetPropSymbol.declarations, right.escapedText);
68808
68819
  }
68809
68820
  checkPropertyNotUsedBeforeDeclaration(prop, node, right);
68810
68821
  markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol));
@@ -79080,19 +79091,17 @@ function createTypeChecker(host) {
79080
79091
  }
79081
79092
  }
79082
79093
  if (isImportSpecifier(node)) {
79083
- const targetSymbol = checkDeprecatedAliasedSymbol(symbol, node);
79084
- if (isDeprecatedAliasedSymbol(targetSymbol) && targetSymbol.declarations) {
79094
+ const targetSymbol = resolveAliasWithDeprecationCheck(symbol, node);
79095
+ if (isDeprecatedSymbol(targetSymbol) && targetSymbol.declarations) {
79085
79096
  addDeprecatedSuggestion(node, targetSymbol.declarations, targetSymbol.escapedName);
79086
79097
  }
79087
79098
  }
79088
79099
  }
79089
79100
  }
79090
- function isDeprecatedAliasedSymbol(symbol) {
79091
- return !!symbol.declarations && every(symbol.declarations, (d) => !!(getCombinedNodeFlags(d) & 268435456 /* Deprecated */));
79092
- }
79093
- function checkDeprecatedAliasedSymbol(symbol, location) {
79094
- if (!(symbol.flags & 2097152 /* Alias */))
79101
+ function resolveAliasWithDeprecationCheck(symbol, location) {
79102
+ if (!(symbol.flags & 2097152 /* Alias */) || isDeprecatedSymbol(symbol) || !getDeclarationOfAliasSymbol(symbol)) {
79095
79103
  return symbol;
79104
+ }
79096
79105
  const targetSymbol = resolveAlias(symbol);
79097
79106
  if (targetSymbol === unknownSymbol)
79098
79107
  return targetSymbol;
@@ -79102,7 +79111,7 @@ function createTypeChecker(host) {
79102
79111
  if (target === targetSymbol)
79103
79112
  break;
79104
79113
  if (target.declarations && length(target.declarations)) {
79105
- if (isDeprecatedAliasedSymbol(target)) {
79114
+ if (isDeprecatedSymbol(target)) {
79106
79115
  addDeprecatedSuggestion(location, target.declarations, target.escapedName);
79107
79116
  break;
79108
79117
  } else {
@@ -101404,12 +101413,56 @@ function transformModule(context) {
101404
101413
  return visitExportDeclaration(node);
101405
101414
  case 276 /* ExportAssignment */:
101406
101415
  return visitExportAssignment(node);
101416
+ case 261 /* FunctionDeclaration */:
101417
+ return visitFunctionDeclaration(node);
101418
+ case 262 /* ClassDeclaration */:
101419
+ return visitClassDeclaration(node);
101420
+ default:
101421
+ return topLevelNestedVisitor(node);
101422
+ }
101423
+ }
101424
+ function topLevelNestedVisitor(node) {
101425
+ switch (node.kind) {
101407
101426
  case 242 /* VariableStatement */:
101408
101427
  return visitVariableStatement(node);
101409
101428
  case 261 /* FunctionDeclaration */:
101410
101429
  return visitFunctionDeclaration(node);
101411
101430
  case 262 /* ClassDeclaration */:
101412
101431
  return visitClassDeclaration(node);
101432
+ case 247 /* ForStatement */:
101433
+ return visitForStatement(
101434
+ node,
101435
+ /*isTopLevel*/
101436
+ true
101437
+ );
101438
+ case 248 /* ForInStatement */:
101439
+ return visitForInStatement(node);
101440
+ case 249 /* ForOfStatement */:
101441
+ return visitForOfStatement(node);
101442
+ case 245 /* DoStatement */:
101443
+ return visitDoStatement(node);
101444
+ case 246 /* WhileStatement */:
101445
+ return visitWhileStatement(node);
101446
+ case 255 /* LabeledStatement */:
101447
+ return visitLabeledStatement(node);
101448
+ case 253 /* WithStatement */:
101449
+ return visitWithStatement(node);
101450
+ case 244 /* IfStatement */:
101451
+ return visitIfStatement(node);
101452
+ case 254 /* SwitchStatement */:
101453
+ return visitSwitchStatement(node);
101454
+ case 268 /* CaseBlock */:
101455
+ return visitCaseBlock(node);
101456
+ case 295 /* CaseClause */:
101457
+ return visitCaseClause(node);
101458
+ case 296 /* DefaultClause */:
101459
+ return visitDefaultClause(node);
101460
+ case 257 /* TryStatement */:
101461
+ return visitTryStatement(node);
101462
+ case 298 /* CatchClause */:
101463
+ return visitCatchClause(node);
101464
+ case 240 /* Block */:
101465
+ return visitBlock(node);
101413
101466
  default:
101414
101467
  return visitor(node);
101415
101468
  }
@@ -101420,7 +101473,11 @@ function transformModule(context) {
101420
101473
  }
101421
101474
  switch (node.kind) {
101422
101475
  case 247 /* ForStatement */:
101423
- return visitForStatement(node);
101476
+ return visitForStatement(
101477
+ node,
101478
+ /*isTopLevel*/
101479
+ false
101480
+ );
101424
101481
  case 243 /* ExpressionStatement */:
101425
101482
  return visitExpressionStatement(node);
101426
101483
  case 216 /* ParenthesizedExpression */:
@@ -101505,15 +101562,177 @@ function transformModule(context) {
101505
101562
  }
101506
101563
  return visitEachChild(node, visitor, context);
101507
101564
  }
101508
- function visitForStatement(node) {
101565
+ function visitForStatement(node, isTopLevel) {
101566
+ if (isTopLevel && node.initializer && isVariableDeclarationList(node.initializer) && !(node.initializer.flags & 3 /* BlockScoped */)) {
101567
+ const exportStatements = appendExportsOfVariableDeclarationList(
101568
+ /*statements*/
101569
+ void 0,
101570
+ node.initializer,
101571
+ /*isForInOrOfInitializer*/
101572
+ false
101573
+ );
101574
+ if (exportStatements) {
101575
+ const statements = [];
101576
+ const varDeclList = visitNode(node.initializer, discardedValueVisitor, isVariableDeclarationList);
101577
+ const varStatement = factory2.createVariableStatement(
101578
+ /*modifiers*/
101579
+ void 0,
101580
+ varDeclList
101581
+ );
101582
+ statements.push(varStatement);
101583
+ addRange(statements, exportStatements);
101584
+ const condition = visitNode(node.condition, visitor, isExpression);
101585
+ const incrementor = visitNode(node.incrementor, discardedValueVisitor, isExpression);
101586
+ const body = visitIterationBody(node.statement, isTopLevel ? topLevelNestedVisitor : visitor, context);
101587
+ statements.push(factory2.updateForStatement(
101588
+ node,
101589
+ /*initializer*/
101590
+ void 0,
101591
+ condition,
101592
+ incrementor,
101593
+ body
101594
+ ));
101595
+ return statements;
101596
+ }
101597
+ }
101509
101598
  return factory2.updateForStatement(
101510
101599
  node,
101511
101600
  visitNode(node.initializer, discardedValueVisitor, isForInitializer),
101512
101601
  visitNode(node.condition, visitor, isExpression),
101513
101602
  visitNode(node.incrementor, discardedValueVisitor, isExpression),
101514
- visitIterationBody(node.statement, visitor, context)
101603
+ visitIterationBody(node.statement, isTopLevel ? topLevelNestedVisitor : visitor, context)
101515
101604
  );
101516
101605
  }
101606
+ function visitForInStatement(node) {
101607
+ if (isVariableDeclarationList(node.initializer) && !(node.initializer.flags & 3 /* BlockScoped */)) {
101608
+ const exportStatements = appendExportsOfVariableDeclarationList(
101609
+ /*statements*/
101610
+ void 0,
101611
+ node.initializer,
101612
+ /*isForInOrOfInitializer*/
101613
+ true
101614
+ );
101615
+ if (some(exportStatements)) {
101616
+ const initializer = visitNode(node.initializer, discardedValueVisitor, isForInitializer);
101617
+ const expression = visitNode(node.expression, visitor, isExpression);
101618
+ const body = visitIterationBody(node.statement, topLevelNestedVisitor, context);
101619
+ const mergedBody = isBlock(body) ? factory2.updateBlock(body, [...exportStatements, ...body.statements]) : factory2.createBlock(
101620
+ [...exportStatements, body],
101621
+ /*multiLine*/
101622
+ true
101623
+ );
101624
+ return factory2.updateForInStatement(node, initializer, expression, mergedBody);
101625
+ }
101626
+ }
101627
+ return factory2.updateForInStatement(
101628
+ node,
101629
+ visitNode(node.initializer, discardedValueVisitor, isForInitializer),
101630
+ visitNode(node.expression, visitor, isExpression),
101631
+ visitIterationBody(node.statement, topLevelNestedVisitor, context)
101632
+ );
101633
+ }
101634
+ function visitForOfStatement(node) {
101635
+ if (isVariableDeclarationList(node.initializer) && !(node.initializer.flags & 3 /* BlockScoped */)) {
101636
+ const exportStatements = appendExportsOfVariableDeclarationList(
101637
+ /*statements*/
101638
+ void 0,
101639
+ node.initializer,
101640
+ /*isForInOrOfInitializer*/
101641
+ true
101642
+ );
101643
+ const initializer = visitNode(node.initializer, discardedValueVisitor, isForInitializer);
101644
+ const expression = visitNode(node.expression, visitor, isExpression);
101645
+ let body = visitIterationBody(node.statement, topLevelNestedVisitor, context);
101646
+ if (some(exportStatements)) {
101647
+ body = isBlock(body) ? factory2.updateBlock(body, [...exportStatements, ...body.statements]) : factory2.createBlock(
101648
+ [...exportStatements, body],
101649
+ /*multiLine*/
101650
+ true
101651
+ );
101652
+ }
101653
+ return factory2.updateForOfStatement(node, node.awaitModifier, initializer, expression, body);
101654
+ }
101655
+ return factory2.updateForOfStatement(
101656
+ node,
101657
+ node.awaitModifier,
101658
+ visitNode(node.initializer, discardedValueVisitor, isForInitializer),
101659
+ visitNode(node.expression, visitor, isExpression),
101660
+ visitIterationBody(node.statement, topLevelNestedVisitor, context)
101661
+ );
101662
+ }
101663
+ function visitDoStatement(node) {
101664
+ return factory2.updateDoStatement(
101665
+ node,
101666
+ visitIterationBody(node.statement, topLevelNestedVisitor, context),
101667
+ visitNode(node.expression, visitor, isExpression)
101668
+ );
101669
+ }
101670
+ function visitWhileStatement(node) {
101671
+ return factory2.updateWhileStatement(
101672
+ node,
101673
+ visitNode(node.expression, visitor, isExpression),
101674
+ visitIterationBody(node.statement, topLevelNestedVisitor, context)
101675
+ );
101676
+ }
101677
+ function visitLabeledStatement(node) {
101678
+ return factory2.updateLabeledStatement(
101679
+ node,
101680
+ node.label,
101681
+ Debug.checkDefined(visitNode(node.statement, topLevelNestedVisitor, isStatement, factory2.liftToBlock))
101682
+ );
101683
+ }
101684
+ function visitWithStatement(node) {
101685
+ return factory2.updateWithStatement(
101686
+ node,
101687
+ visitNode(node.expression, visitor, isExpression),
101688
+ Debug.checkDefined(visitNode(node.statement, topLevelNestedVisitor, isStatement, factory2.liftToBlock))
101689
+ );
101690
+ }
101691
+ function visitIfStatement(node) {
101692
+ return factory2.updateIfStatement(
101693
+ node,
101694
+ visitNode(node.expression, visitor, isExpression),
101695
+ Debug.checkDefined(visitNode(node.thenStatement, topLevelNestedVisitor, isStatement, factory2.liftToBlock)),
101696
+ visitNode(node.elseStatement, topLevelNestedVisitor, isStatement, factory2.liftToBlock)
101697
+ );
101698
+ }
101699
+ function visitSwitchStatement(node) {
101700
+ return factory2.updateSwitchStatement(
101701
+ node,
101702
+ visitNode(node.expression, visitor, isExpression),
101703
+ Debug.checkDefined(visitNode(node.caseBlock, topLevelNestedVisitor, isCaseBlock))
101704
+ );
101705
+ }
101706
+ function visitCaseBlock(node) {
101707
+ return factory2.updateCaseBlock(
101708
+ node,
101709
+ visitNodes2(node.clauses, topLevelNestedVisitor, isCaseOrDefaultClause)
101710
+ );
101711
+ }
101712
+ function visitCaseClause(node) {
101713
+ return factory2.updateCaseClause(
101714
+ node,
101715
+ visitNode(node.expression, visitor, isExpression),
101716
+ visitNodes2(node.statements, topLevelNestedVisitor, isStatement)
101717
+ );
101718
+ }
101719
+ function visitDefaultClause(node) {
101720
+ return visitEachChild(node, topLevelNestedVisitor, context);
101721
+ }
101722
+ function visitTryStatement(node) {
101723
+ return visitEachChild(node, topLevelNestedVisitor, context);
101724
+ }
101725
+ function visitCatchClause(node) {
101726
+ return factory2.updateCatchClause(
101727
+ node,
101728
+ node.variableDeclaration,
101729
+ Debug.checkDefined(visitNode(node.block, topLevelNestedVisitor, isBlock))
101730
+ );
101731
+ }
101732
+ function visitBlock(node) {
101733
+ node = visitEachChild(node, topLevelNestedVisitor, context);
101734
+ return node;
101735
+ }
101517
101736
  function visitExpressionStatement(node) {
101518
101737
  return factory2.updateExpressionStatement(
101519
101738
  node,
@@ -102306,25 +102525,33 @@ function transformModule(context) {
102306
102525
  return appendExportsOfDeclaration(statements, decl);
102307
102526
  }
102308
102527
  function appendExportsOfVariableStatement(statements, node) {
102528
+ return appendExportsOfVariableDeclarationList(
102529
+ statements,
102530
+ node.declarationList,
102531
+ /*isForInOrOfInitializer*/
102532
+ false
102533
+ );
102534
+ }
102535
+ function appendExportsOfVariableDeclarationList(statements, node, isForInOrOfInitializer) {
102309
102536
  if (currentModuleInfo.exportEquals) {
102310
102537
  return statements;
102311
102538
  }
102312
- for (const decl of node.declarationList.declarations) {
102313
- statements = appendExportsOfBindingElement(statements, decl);
102539
+ for (const decl of node.declarations) {
102540
+ statements = appendExportsOfBindingElement(statements, decl, isForInOrOfInitializer);
102314
102541
  }
102315
102542
  return statements;
102316
102543
  }
102317
- function appendExportsOfBindingElement(statements, decl) {
102544
+ function appendExportsOfBindingElement(statements, decl, isForInOrOfInitializer) {
102318
102545
  if (currentModuleInfo.exportEquals) {
102319
102546
  return statements;
102320
102547
  }
102321
102548
  if (isBindingPattern(decl.name)) {
102322
102549
  for (const element of decl.name.elements) {
102323
102550
  if (!isOmittedExpression(element)) {
102324
- statements = appendExportsOfBindingElement(statements, element);
102551
+ statements = appendExportsOfBindingElement(statements, element, isForInOrOfInitializer);
102325
102552
  }
102326
102553
  }
102327
- } else if (!isGeneratedIdentifier(decl.name) && (!isVariableDeclaration(decl) || decl.initializer)) {
102554
+ } else if (!isGeneratedIdentifier(decl.name) && (!isVariableDeclaration(decl) || decl.initializer || isForInOrOfInitializer)) {
102328
102555
  statements = appendExportsOfDeclaration(statements, decl);
102329
102556
  }
102330
102557
  return statements;
@@ -119633,7 +119860,9 @@ var WatchType = {
119633
119860
  MissingSourceMapFile: "Missing source map file",
119634
119861
  NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root",
119635
119862
  MissingGeneratedFile: "Missing generated file",
119636
- NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation"
119863
+ NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation",
119864
+ TypingInstallerLocationFile: "File location for typing installer",
119865
+ TypingInstallerLocationDirectory: "Directory location for typing installer"
119637
119866
  };
119638
119867
  function createWatchFactory(host, options) {
119639
119868
  const watchLogLevel = host.trace ? options.extendedDiagnostics ? 2 /* Verbose */ : options.diagnostics ? 1 /* TriggerOnly */ : 0 /* None */ : 0 /* None */;