typescript 5.1.0-dev.20230427 → 5.1.0-dev.20230429

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.20230429`;
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 {
@@ -90413,6 +90414,19 @@ function transformLegacyDecorators(context) {
90413
90414
  let members = visitNodes2(node.members, visitor, isClassElement);
90414
90415
  let decorationStatements = [];
90415
90416
  ({ members, decorationStatements } = transformDecoratorsOfClassElements(node, members));
90417
+ const assignClassAliasInStaticBlock = languageVersion >= 9 /* ES2022 */ && !!classAlias && some(members, (member) => isPropertyDeclaration(member) && hasSyntacticModifier(member, 32 /* Static */) || isClassStaticBlockDeclaration(member));
90418
+ if (assignClassAliasInStaticBlock) {
90419
+ members = setTextRange(factory2.createNodeArray([
90420
+ factory2.createClassStaticBlockDeclaration(
90421
+ factory2.createBlock([
90422
+ factory2.createExpressionStatement(
90423
+ factory2.createAssignment(classAlias, factory2.createThis())
90424
+ )
90425
+ ])
90426
+ ),
90427
+ ...members
90428
+ ]), members);
90429
+ }
90416
90430
  const classExpression = factory2.createClassExpression(
90417
90431
  modifiers,
90418
90432
  name && isGeneratedIdentifier(name) ? void 0 : name,
@@ -90429,7 +90443,7 @@ function transformLegacyDecorators(context) {
90429
90443
  void 0,
90430
90444
  /*type*/
90431
90445
  void 0,
90432
- classAlias ? factory2.createAssignment(classAlias, classExpression) : classExpression
90446
+ classAlias && !assignClassAliasInStaticBlock ? factory2.createAssignment(classAlias, classExpression) : classExpression
90433
90447
  );
90434
90448
  setOriginalNode(varDecl, node);
90435
90449
  let varModifiers;
@@ -101412,12 +101426,56 @@ function transformModule(context) {
101412
101426
  return visitExportDeclaration(node);
101413
101427
  case 276 /* ExportAssignment */:
101414
101428
  return visitExportAssignment(node);
101429
+ case 261 /* FunctionDeclaration */:
101430
+ return visitFunctionDeclaration(node);
101431
+ case 262 /* ClassDeclaration */:
101432
+ return visitClassDeclaration(node);
101433
+ default:
101434
+ return topLevelNestedVisitor(node);
101435
+ }
101436
+ }
101437
+ function topLevelNestedVisitor(node) {
101438
+ switch (node.kind) {
101415
101439
  case 242 /* VariableStatement */:
101416
101440
  return visitVariableStatement(node);
101417
101441
  case 261 /* FunctionDeclaration */:
101418
101442
  return visitFunctionDeclaration(node);
101419
101443
  case 262 /* ClassDeclaration */:
101420
101444
  return visitClassDeclaration(node);
101445
+ case 247 /* ForStatement */:
101446
+ return visitForStatement(
101447
+ node,
101448
+ /*isTopLevel*/
101449
+ true
101450
+ );
101451
+ case 248 /* ForInStatement */:
101452
+ return visitForInStatement(node);
101453
+ case 249 /* ForOfStatement */:
101454
+ return visitForOfStatement(node);
101455
+ case 245 /* DoStatement */:
101456
+ return visitDoStatement(node);
101457
+ case 246 /* WhileStatement */:
101458
+ return visitWhileStatement(node);
101459
+ case 255 /* LabeledStatement */:
101460
+ return visitLabeledStatement(node);
101461
+ case 253 /* WithStatement */:
101462
+ return visitWithStatement(node);
101463
+ case 244 /* IfStatement */:
101464
+ return visitIfStatement(node);
101465
+ case 254 /* SwitchStatement */:
101466
+ return visitSwitchStatement(node);
101467
+ case 268 /* CaseBlock */:
101468
+ return visitCaseBlock(node);
101469
+ case 295 /* CaseClause */:
101470
+ return visitCaseClause(node);
101471
+ case 296 /* DefaultClause */:
101472
+ return visitDefaultClause(node);
101473
+ case 257 /* TryStatement */:
101474
+ return visitTryStatement(node);
101475
+ case 298 /* CatchClause */:
101476
+ return visitCatchClause(node);
101477
+ case 240 /* Block */:
101478
+ return visitBlock(node);
101421
101479
  default:
101422
101480
  return visitor(node);
101423
101481
  }
@@ -101428,7 +101486,11 @@ function transformModule(context) {
101428
101486
  }
101429
101487
  switch (node.kind) {
101430
101488
  case 247 /* ForStatement */:
101431
- return visitForStatement(node);
101489
+ return visitForStatement(
101490
+ node,
101491
+ /*isTopLevel*/
101492
+ false
101493
+ );
101432
101494
  case 243 /* ExpressionStatement */:
101433
101495
  return visitExpressionStatement(node);
101434
101496
  case 216 /* ParenthesizedExpression */:
@@ -101513,15 +101575,177 @@ function transformModule(context) {
101513
101575
  }
101514
101576
  return visitEachChild(node, visitor, context);
101515
101577
  }
101516
- function visitForStatement(node) {
101578
+ function visitForStatement(node, isTopLevel) {
101579
+ if (isTopLevel && node.initializer && isVariableDeclarationList(node.initializer) && !(node.initializer.flags & 3 /* BlockScoped */)) {
101580
+ const exportStatements = appendExportsOfVariableDeclarationList(
101581
+ /*statements*/
101582
+ void 0,
101583
+ node.initializer,
101584
+ /*isForInOrOfInitializer*/
101585
+ false
101586
+ );
101587
+ if (exportStatements) {
101588
+ const statements = [];
101589
+ const varDeclList = visitNode(node.initializer, discardedValueVisitor, isVariableDeclarationList);
101590
+ const varStatement = factory2.createVariableStatement(
101591
+ /*modifiers*/
101592
+ void 0,
101593
+ varDeclList
101594
+ );
101595
+ statements.push(varStatement);
101596
+ addRange(statements, exportStatements);
101597
+ const condition = visitNode(node.condition, visitor, isExpression);
101598
+ const incrementor = visitNode(node.incrementor, discardedValueVisitor, isExpression);
101599
+ const body = visitIterationBody(node.statement, isTopLevel ? topLevelNestedVisitor : visitor, context);
101600
+ statements.push(factory2.updateForStatement(
101601
+ node,
101602
+ /*initializer*/
101603
+ void 0,
101604
+ condition,
101605
+ incrementor,
101606
+ body
101607
+ ));
101608
+ return statements;
101609
+ }
101610
+ }
101517
101611
  return factory2.updateForStatement(
101518
101612
  node,
101519
101613
  visitNode(node.initializer, discardedValueVisitor, isForInitializer),
101520
101614
  visitNode(node.condition, visitor, isExpression),
101521
101615
  visitNode(node.incrementor, discardedValueVisitor, isExpression),
101522
- visitIterationBody(node.statement, visitor, context)
101616
+ visitIterationBody(node.statement, isTopLevel ? topLevelNestedVisitor : visitor, context)
101617
+ );
101618
+ }
101619
+ function visitForInStatement(node) {
101620
+ if (isVariableDeclarationList(node.initializer) && !(node.initializer.flags & 3 /* BlockScoped */)) {
101621
+ const exportStatements = appendExportsOfVariableDeclarationList(
101622
+ /*statements*/
101623
+ void 0,
101624
+ node.initializer,
101625
+ /*isForInOrOfInitializer*/
101626
+ true
101627
+ );
101628
+ if (some(exportStatements)) {
101629
+ const initializer = visitNode(node.initializer, discardedValueVisitor, isForInitializer);
101630
+ const expression = visitNode(node.expression, visitor, isExpression);
101631
+ const body = visitIterationBody(node.statement, topLevelNestedVisitor, context);
101632
+ const mergedBody = isBlock(body) ? factory2.updateBlock(body, [...exportStatements, ...body.statements]) : factory2.createBlock(
101633
+ [...exportStatements, body],
101634
+ /*multiLine*/
101635
+ true
101636
+ );
101637
+ return factory2.updateForInStatement(node, initializer, expression, mergedBody);
101638
+ }
101639
+ }
101640
+ return factory2.updateForInStatement(
101641
+ node,
101642
+ visitNode(node.initializer, discardedValueVisitor, isForInitializer),
101643
+ visitNode(node.expression, visitor, isExpression),
101644
+ visitIterationBody(node.statement, topLevelNestedVisitor, context)
101645
+ );
101646
+ }
101647
+ function visitForOfStatement(node) {
101648
+ if (isVariableDeclarationList(node.initializer) && !(node.initializer.flags & 3 /* BlockScoped */)) {
101649
+ const exportStatements = appendExportsOfVariableDeclarationList(
101650
+ /*statements*/
101651
+ void 0,
101652
+ node.initializer,
101653
+ /*isForInOrOfInitializer*/
101654
+ true
101655
+ );
101656
+ const initializer = visitNode(node.initializer, discardedValueVisitor, isForInitializer);
101657
+ const expression = visitNode(node.expression, visitor, isExpression);
101658
+ let body = visitIterationBody(node.statement, topLevelNestedVisitor, context);
101659
+ if (some(exportStatements)) {
101660
+ body = isBlock(body) ? factory2.updateBlock(body, [...exportStatements, ...body.statements]) : factory2.createBlock(
101661
+ [...exportStatements, body],
101662
+ /*multiLine*/
101663
+ true
101664
+ );
101665
+ }
101666
+ return factory2.updateForOfStatement(node, node.awaitModifier, initializer, expression, body);
101667
+ }
101668
+ return factory2.updateForOfStatement(
101669
+ node,
101670
+ node.awaitModifier,
101671
+ visitNode(node.initializer, discardedValueVisitor, isForInitializer),
101672
+ visitNode(node.expression, visitor, isExpression),
101673
+ visitIterationBody(node.statement, topLevelNestedVisitor, context)
101674
+ );
101675
+ }
101676
+ function visitDoStatement(node) {
101677
+ return factory2.updateDoStatement(
101678
+ node,
101679
+ visitIterationBody(node.statement, topLevelNestedVisitor, context),
101680
+ visitNode(node.expression, visitor, isExpression)
101523
101681
  );
101524
101682
  }
101683
+ function visitWhileStatement(node) {
101684
+ return factory2.updateWhileStatement(
101685
+ node,
101686
+ visitNode(node.expression, visitor, isExpression),
101687
+ visitIterationBody(node.statement, topLevelNestedVisitor, context)
101688
+ );
101689
+ }
101690
+ function visitLabeledStatement(node) {
101691
+ return factory2.updateLabeledStatement(
101692
+ node,
101693
+ node.label,
101694
+ Debug.checkDefined(visitNode(node.statement, topLevelNestedVisitor, isStatement, factory2.liftToBlock))
101695
+ );
101696
+ }
101697
+ function visitWithStatement(node) {
101698
+ return factory2.updateWithStatement(
101699
+ node,
101700
+ visitNode(node.expression, visitor, isExpression),
101701
+ Debug.checkDefined(visitNode(node.statement, topLevelNestedVisitor, isStatement, factory2.liftToBlock))
101702
+ );
101703
+ }
101704
+ function visitIfStatement(node) {
101705
+ return factory2.updateIfStatement(
101706
+ node,
101707
+ visitNode(node.expression, visitor, isExpression),
101708
+ Debug.checkDefined(visitNode(node.thenStatement, topLevelNestedVisitor, isStatement, factory2.liftToBlock)),
101709
+ visitNode(node.elseStatement, topLevelNestedVisitor, isStatement, factory2.liftToBlock)
101710
+ );
101711
+ }
101712
+ function visitSwitchStatement(node) {
101713
+ return factory2.updateSwitchStatement(
101714
+ node,
101715
+ visitNode(node.expression, visitor, isExpression),
101716
+ Debug.checkDefined(visitNode(node.caseBlock, topLevelNestedVisitor, isCaseBlock))
101717
+ );
101718
+ }
101719
+ function visitCaseBlock(node) {
101720
+ return factory2.updateCaseBlock(
101721
+ node,
101722
+ visitNodes2(node.clauses, topLevelNestedVisitor, isCaseOrDefaultClause)
101723
+ );
101724
+ }
101725
+ function visitCaseClause(node) {
101726
+ return factory2.updateCaseClause(
101727
+ node,
101728
+ visitNode(node.expression, visitor, isExpression),
101729
+ visitNodes2(node.statements, topLevelNestedVisitor, isStatement)
101730
+ );
101731
+ }
101732
+ function visitDefaultClause(node) {
101733
+ return visitEachChild(node, topLevelNestedVisitor, context);
101734
+ }
101735
+ function visitTryStatement(node) {
101736
+ return visitEachChild(node, topLevelNestedVisitor, context);
101737
+ }
101738
+ function visitCatchClause(node) {
101739
+ return factory2.updateCatchClause(
101740
+ node,
101741
+ node.variableDeclaration,
101742
+ Debug.checkDefined(visitNode(node.block, topLevelNestedVisitor, isBlock))
101743
+ );
101744
+ }
101745
+ function visitBlock(node) {
101746
+ node = visitEachChild(node, topLevelNestedVisitor, context);
101747
+ return node;
101748
+ }
101525
101749
  function visitExpressionStatement(node) {
101526
101750
  return factory2.updateExpressionStatement(
101527
101751
  node,
@@ -102314,25 +102538,33 @@ function transformModule(context) {
102314
102538
  return appendExportsOfDeclaration(statements, decl);
102315
102539
  }
102316
102540
  function appendExportsOfVariableStatement(statements, node) {
102541
+ return appendExportsOfVariableDeclarationList(
102542
+ statements,
102543
+ node.declarationList,
102544
+ /*isForInOrOfInitializer*/
102545
+ false
102546
+ );
102547
+ }
102548
+ function appendExportsOfVariableDeclarationList(statements, node, isForInOrOfInitializer) {
102317
102549
  if (currentModuleInfo.exportEquals) {
102318
102550
  return statements;
102319
102551
  }
102320
- for (const decl of node.declarationList.declarations) {
102321
- statements = appendExportsOfBindingElement(statements, decl);
102552
+ for (const decl of node.declarations) {
102553
+ statements = appendExportsOfBindingElement(statements, decl, isForInOrOfInitializer);
102322
102554
  }
102323
102555
  return statements;
102324
102556
  }
102325
- function appendExportsOfBindingElement(statements, decl) {
102557
+ function appendExportsOfBindingElement(statements, decl, isForInOrOfInitializer) {
102326
102558
  if (currentModuleInfo.exportEquals) {
102327
102559
  return statements;
102328
102560
  }
102329
102561
  if (isBindingPattern(decl.name)) {
102330
102562
  for (const element of decl.name.elements) {
102331
102563
  if (!isOmittedExpression(element)) {
102332
- statements = appendExportsOfBindingElement(statements, element);
102564
+ statements = appendExportsOfBindingElement(statements, element, isForInOrOfInitializer);
102333
102565
  }
102334
102566
  }
102335
- } else if (!isGeneratedIdentifier(decl.name) && (!isVariableDeclaration(decl) || decl.initializer)) {
102567
+ } else if (!isGeneratedIdentifier(decl.name) && (!isVariableDeclaration(decl) || decl.initializer || isForInOrOfInitializer)) {
102336
102568
  statements = appendExportsOfDeclaration(statements, decl);
102337
102569
  }
102338
102570
  return statements;