typescript 4.6.0-dev.20211123 → 4.6.0-dev.20211130

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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20211123";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20211130";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -83444,9 +83444,8 @@ var ts;
83444
83444
  var enclosingFile = ts.getSourceFileOfNode(node);
83445
83445
  var links = getNodeLinks(enclosingFile);
83446
83446
  if (!(links.flags & 1 /* TypeChecked */)) {
83447
- links.deferredNodes = links.deferredNodes || new ts.Map();
83448
- var id = getNodeId(node);
83449
- links.deferredNodes.set(id, node);
83447
+ links.deferredNodes || (links.deferredNodes = new ts.Set());
83448
+ links.deferredNodes.add(node);
83450
83449
  }
83451
83450
  }
83452
83451
  function checkDeferredNodes(context) {
@@ -90900,11 +90899,10 @@ var ts;
90900
90899
  // we can safely elide the parentheses here, as a new synthetic
90901
90900
  // ParenthesizedExpression will be inserted if we remove parentheses too
90902
90901
  // aggressively.
90903
- // HOWEVER - if there are leading comments on the expression itself, to handle ASI
90904
- // correctly for return and throw, we must keep the parenthesis
90905
- if (ts.length(ts.getLeadingCommentRangesOfNode(expression, currentSourceFile))) {
90906
- return factory.updateParenthesizedExpression(node, expression);
90907
- }
90902
+ //
90903
+ // If there are leading comments on the expression itself, the emitter will handle ASI
90904
+ // for return, throw, and yield by re-introducing parenthesis during emit on an as-need
90905
+ // basis.
90908
90906
  return factory.createPartiallyEmittedExpression(expression, node);
90909
90907
  }
90910
90908
  return ts.visitEachChild(node, visitor, context);
@@ -94852,11 +94850,11 @@ var ts;
94852
94850
  }
94853
94851
  function visitOptionalExpression(node, captureThisArg, isDelete) {
94854
94852
  var _a = flattenChain(node), expression = _a.expression, chain = _a.chain;
94855
- var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0]), /*isDelete*/ false);
94853
+ var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false);
94856
94854
  var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined;
94857
- var leftExpression = ts.isSyntheticReference(left) ? left.expression : left;
94858
- var capturedLeft = leftExpression;
94859
- if (!ts.isSimpleCopiableExpression(leftExpression)) {
94855
+ var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left;
94856
+ var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */);
94857
+ if (!ts.isSimpleCopiableExpression(capturedLeft)) {
94860
94858
  capturedLeft = factory.createTempVariable(hoistVariableDeclaration);
94861
94859
  leftExpression = factory.createAssignment(capturedLeft, leftExpression);
94862
94860
  }
@@ -94882,6 +94880,10 @@ var ts;
94882
94880
  break;
94883
94881
  case 207 /* CallExpression */:
94884
94882
  if (i === 0 && leftThisArg) {
94883
+ if (!ts.isGeneratedIdentifier(leftThisArg)) {
94884
+ leftThisArg = factory.cloneNode(leftThisArg);
94885
+ ts.addEmitFlags(leftThisArg, 1536 /* NoComments */);
94886
+ }
94885
94887
  rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
94886
94888
  }
94887
94889
  else {
@@ -109664,7 +109666,7 @@ var ts;
109664
109666
  function emitYieldExpression(node) {
109665
109667
  emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node);
109666
109668
  emit(node.asteriskToken);
109667
- emitExpressionWithLeadingSpace(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma);
109669
+ emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma);
109668
109670
  }
109669
109671
  function emitSpreadElement(node) {
109670
109672
  emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node);
@@ -109861,9 +109863,49 @@ var ts;
109861
109863
  }
109862
109864
  return pos;
109863
109865
  }
109866
+ function commentWillEmitNewLine(node) {
109867
+ return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine;
109868
+ }
109869
+ function willEmitLeadingNewLine(node) {
109870
+ if (!currentSourceFile)
109871
+ return false;
109872
+ if (ts.some(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), commentWillEmitNewLine))
109873
+ return true;
109874
+ if (ts.some(ts.getSyntheticLeadingComments(node), commentWillEmitNewLine))
109875
+ return true;
109876
+ if (ts.isPartiallyEmittedExpression(node)) {
109877
+ if (node.pos !== node.expression.pos) {
109878
+ if (ts.some(ts.getTrailingCommentRanges(currentSourceFile.text, node.expression.pos), commentWillEmitNewLine))
109879
+ return true;
109880
+ }
109881
+ return willEmitLeadingNewLine(node.expression);
109882
+ }
109883
+ return false;
109884
+ }
109885
+ /**
109886
+ * Wraps an expression in parens if we would emit a leading comment that would introduce a line separator
109887
+ * between the node and its parent.
109888
+ */
109889
+ function parenthesizeExpressionForNoAsi(node) {
109890
+ if (!commentsDisabled && ts.isPartiallyEmittedExpression(node) && willEmitLeadingNewLine(node)) {
109891
+ var parseNode = ts.getParseTreeNode(node);
109892
+ if (parseNode && ts.isParenthesizedExpression(parseNode)) {
109893
+ // If the original node was a parenthesized expression, restore it to preserve comment and source map emit
109894
+ var parens = ts.factory.createParenthesizedExpression(node.expression);
109895
+ ts.setOriginalNode(parens, node);
109896
+ ts.setTextRange(parens, parseNode);
109897
+ return parens;
109898
+ }
109899
+ return ts.factory.createParenthesizedExpression(node);
109900
+ }
109901
+ return node;
109902
+ }
109903
+ function parenthesizeExpressionForNoAsiAndDisallowedComma(node) {
109904
+ return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node));
109905
+ }
109864
109906
  function emitReturnStatement(node) {
109865
109907
  emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node);
109866
- emitExpressionWithLeadingSpace(node.expression);
109908
+ emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi);
109867
109909
  writeTrailingSemicolon();
109868
109910
  }
109869
109911
  function emitWithStatement(node) {
@@ -109891,7 +109933,7 @@ var ts;
109891
109933
  }
109892
109934
  function emitThrowStatement(node) {
109893
109935
  emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node);
109894
- emitExpressionWithLeadingSpace(node.expression);
109936
+ emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi);
109895
109937
  writeTrailingSemicolon();
109896
109938
  }
109897
109939
  function emitTryStatement(node) {
@@ -110735,7 +110777,14 @@ var ts;
110735
110777
  }
110736
110778
  // Transformation nodes
110737
110779
  function emitPartiallyEmittedExpression(node) {
110780
+ var emitFlags = ts.getEmitFlags(node);
110781
+ if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) {
110782
+ emitTrailingCommentsOfPosition(node.expression.pos);
110783
+ }
110738
110784
  emitExpression(node.expression);
110785
+ if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) {
110786
+ emitLeadingCommentsOfPosition(node.expression.end);
110787
+ }
110739
110788
  }
110740
110789
  function emitCommaList(node) {
110741
110790
  emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined);
@@ -111099,10 +111148,8 @@ var ts;
111099
111148
  // Emit this child.
111100
111149
  previousSourceFileTextKind = recordBundleFileInternalSectionStart(child);
111101
111150
  if (shouldEmitInterveningComments) {
111102
- if (emitTrailingCommentsOfPosition) {
111103
- var commentRange = ts.getCommentRange(child);
111104
- emitTrailingCommentsOfPosition(commentRange.pos);
111105
- }
111151
+ var commentRange = ts.getCommentRange(child);
111152
+ emitTrailingCommentsOfPosition(commentRange.pos);
111106
111153
  }
111107
111154
  else {
111108
111155
  shouldEmitInterveningComments = mayEmitInterveningComments;
@@ -111423,7 +111470,7 @@ var ts;
111423
111470
  function writeLineSeparatorsAndIndentBefore(node, parent) {
111424
111471
  var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* None */);
111425
111472
  if (leadingNewlines) {
111426
- writeLinesAndIndent(leadingNewlines, /*writeLinesIfNotIndenting*/ false);
111473
+ writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false);
111427
111474
  }
111428
111475
  return !!leadingNewlines;
111429
111476
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.6.0-dev.20211123",
5
+ "version": "4.6.0-dev.20211130",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [