typescript 5.1.0-dev.20230427 → 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.20230427`;
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);
@@ -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
  }
@@ -68811,8 +68813,9 @@ function createTypeChecker(host) {
68811
68813
  addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
68812
68814
  }
68813
68815
  } else {
68814
- if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
68815
- 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);
68816
68819
  }
68817
68820
  checkPropertyNotUsedBeforeDeclaration(prop, node, right);
68818
68821
  markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol));
@@ -79088,19 +79091,17 @@ function createTypeChecker(host) {
79088
79091
  }
79089
79092
  }
79090
79093
  if (isImportSpecifier(node)) {
79091
- const targetSymbol = checkDeprecatedAliasedSymbol(symbol, node);
79092
- if (isDeprecatedAliasedSymbol(targetSymbol) && targetSymbol.declarations) {
79094
+ const targetSymbol = resolveAliasWithDeprecationCheck(symbol, node);
79095
+ if (isDeprecatedSymbol(targetSymbol) && targetSymbol.declarations) {
79093
79096
  addDeprecatedSuggestion(node, targetSymbol.declarations, targetSymbol.escapedName);
79094
79097
  }
79095
79098
  }
79096
79099
  }
79097
79100
  }
79098
- function isDeprecatedAliasedSymbol(symbol) {
79099
- return !!symbol.declarations && every(symbol.declarations, (d) => !!(getCombinedNodeFlags(d) & 268435456 /* Deprecated */));
79100
- }
79101
- function checkDeprecatedAliasedSymbol(symbol, location) {
79102
- if (!(symbol.flags & 2097152 /* Alias */))
79101
+ function resolveAliasWithDeprecationCheck(symbol, location) {
79102
+ if (!(symbol.flags & 2097152 /* Alias */) || isDeprecatedSymbol(symbol) || !getDeclarationOfAliasSymbol(symbol)) {
79103
79103
  return symbol;
79104
+ }
79104
79105
  const targetSymbol = resolveAlias(symbol);
79105
79106
  if (targetSymbol === unknownSymbol)
79106
79107
  return targetSymbol;
@@ -79110,7 +79111,7 @@ function createTypeChecker(host) {
79110
79111
  if (target === targetSymbol)
79111
79112
  break;
79112
79113
  if (target.declarations && length(target.declarations)) {
79113
- if (isDeprecatedAliasedSymbol(target)) {
79114
+ if (isDeprecatedSymbol(target)) {
79114
79115
  addDeprecatedSuggestion(location, target.declarations, target.escapedName);
79115
79116
  break;
79116
79117
  } else {
@@ -101412,12 +101413,56 @@ function transformModule(context) {
101412
101413
  return visitExportDeclaration(node);
101413
101414
  case 276 /* ExportAssignment */:
101414
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) {
101415
101426
  case 242 /* VariableStatement */:
101416
101427
  return visitVariableStatement(node);
101417
101428
  case 261 /* FunctionDeclaration */:
101418
101429
  return visitFunctionDeclaration(node);
101419
101430
  case 262 /* ClassDeclaration */:
101420
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);
101421
101466
  default:
101422
101467
  return visitor(node);
101423
101468
  }
@@ -101428,7 +101473,11 @@ function transformModule(context) {
101428
101473
  }
101429
101474
  switch (node.kind) {
101430
101475
  case 247 /* ForStatement */:
101431
- return visitForStatement(node);
101476
+ return visitForStatement(
101477
+ node,
101478
+ /*isTopLevel*/
101479
+ false
101480
+ );
101432
101481
  case 243 /* ExpressionStatement */:
101433
101482
  return visitExpressionStatement(node);
101434
101483
  case 216 /* ParenthesizedExpression */:
@@ -101513,15 +101562,177 @@ function transformModule(context) {
101513
101562
  }
101514
101563
  return visitEachChild(node, visitor, context);
101515
101564
  }
101516
- 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
+ }
101517
101598
  return factory2.updateForStatement(
101518
101599
  node,
101519
101600
  visitNode(node.initializer, discardedValueVisitor, isForInitializer),
101520
101601
  visitNode(node.condition, visitor, isExpression),
101521
101602
  visitNode(node.incrementor, discardedValueVisitor, isExpression),
101522
- visitIterationBody(node.statement, visitor, context)
101603
+ visitIterationBody(node.statement, isTopLevel ? topLevelNestedVisitor : visitor, context)
101523
101604
  );
101524
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
+ }
101525
101736
  function visitExpressionStatement(node) {
101526
101737
  return factory2.updateExpressionStatement(
101527
101738
  node,
@@ -102314,25 +102525,33 @@ function transformModule(context) {
102314
102525
  return appendExportsOfDeclaration(statements, decl);
102315
102526
  }
102316
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) {
102317
102536
  if (currentModuleInfo.exportEquals) {
102318
102537
  return statements;
102319
102538
  }
102320
- for (const decl of node.declarationList.declarations) {
102321
- statements = appendExportsOfBindingElement(statements, decl);
102539
+ for (const decl of node.declarations) {
102540
+ statements = appendExportsOfBindingElement(statements, decl, isForInOrOfInitializer);
102322
102541
  }
102323
102542
  return statements;
102324
102543
  }
102325
- function appendExportsOfBindingElement(statements, decl) {
102544
+ function appendExportsOfBindingElement(statements, decl, isForInOrOfInitializer) {
102326
102545
  if (currentModuleInfo.exportEquals) {
102327
102546
  return statements;
102328
102547
  }
102329
102548
  if (isBindingPattern(decl.name)) {
102330
102549
  for (const element of decl.name.elements) {
102331
102550
  if (!isOmittedExpression(element)) {
102332
- statements = appendExportsOfBindingElement(statements, element);
102551
+ statements = appendExportsOfBindingElement(statements, element, isForInOrOfInitializer);
102333
102552
  }
102334
102553
  }
102335
- } else if (!isGeneratedIdentifier(decl.name) && (!isVariableDeclaration(decl) || decl.initializer)) {
102554
+ } else if (!isGeneratedIdentifier(decl.name) && (!isVariableDeclaration(decl) || decl.initializer || isForInOrOfInitializer)) {
102336
102555
  statements = appendExportsOfDeclaration(statements, decl);
102337
102556
  }
102338
102557
  return statements;