typescript 4.7.0-dev.20220422 → 4.7.0-dev.20220425

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
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220422";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220425";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -11209,7 +11209,7 @@ var ts;
11209
11209
  ts.getScriptTargetFeatures = getScriptTargetFeatures;
11210
11210
  function getLiteralText(node, sourceFile, flags) {
11211
11211
  var _a;
11212
- if (canUseOriginalText(node, flags)) {
11212
+ if (sourceFile && canUseOriginalText(node, flags)) {
11213
11213
  return getSourceTextOfNodeFromSourceFile(sourceFile, node);
11214
11214
  }
11215
11215
  switch (node.kind) {
@@ -63207,6 +63207,7 @@ var ts;
63207
63207
  var args = getEffectiveCallArguments(node);
63208
63208
  var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
63209
63209
  var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
63210
+ argCheckMode |= checkMode & 32;
63210
63211
  var candidatesForArgumentError;
63211
63212
  var candidateForArgumentArityError;
63212
63213
  var candidateForTypeArgumentError;
@@ -63377,7 +63378,7 @@ var ts;
63377
63378
  continue;
63378
63379
  }
63379
63380
  if (argCheckMode) {
63380
- argCheckMode = 0;
63381
+ argCheckMode = checkMode & 32;
63381
63382
  if (inferenceContext) {
63382
63383
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
63383
63384
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -90721,7 +90722,7 @@ var ts;
90721
90722
  setWriter(undefined, undefined);
90722
90723
  }
90723
90724
  function getCurrentLineMap() {
90724
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
90725
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
90725
90726
  }
90726
90727
  function emit(node, parenthesizerRule) {
90727
90728
  if (node === undefined)
@@ -91805,7 +91806,7 @@ var ts;
91805
91806
  increaseIndent();
91806
91807
  }
91807
91808
  var preferNewLine = node.multiLine ? 65536 : 0;
91808
- var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
91809
+ var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
91809
91810
  emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
91810
91811
  if (indentedFlag) {
91811
91812
  decreaseIndent();
@@ -92132,7 +92133,7 @@ var ts;
92132
92133
  }
92133
92134
  function emitExpressionStatement(node) {
92134
92135
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
92135
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
92136
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
92136
92137
  writeTrailingSemicolon();
92137
92138
  }
92138
92139
  }
@@ -92411,7 +92412,7 @@ var ts;
92411
92412
  if (body.multiLine) {
92412
92413
  return false;
92413
92414
  }
92414
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
92415
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
92415
92416
  return false;
92416
92417
  }
92417
92418
  if (getLeadingLineTerminatorCount(body, body.statements, 2)
@@ -92436,12 +92437,7 @@ var ts;
92436
92437
  var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
92437
92438
  ? emitBlockFunctionBodyOnSingleLine
92438
92439
  : emitBlockFunctionBodyWorker;
92439
- if (emitBodyWithDetachedComments) {
92440
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
92441
- }
92442
- else {
92443
- emitBlockFunctionBody(body);
92444
- }
92440
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
92445
92441
  decreaseIndent();
92446
92442
  writeToken(19, body.statements.end, writePunctuation, body);
92447
92443
  onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
@@ -92825,7 +92821,8 @@ var ts;
92825
92821
  }
92826
92822
  function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
92827
92823
  var emitAsSingleStatement = statements.length === 1 &&
92828
- (ts.nodeIsSynthesized(parentNode) ||
92824
+ (!currentSourceFile ||
92825
+ ts.nodeIsSynthesized(parentNode) ||
92829
92826
  ts.nodeIsSynthesized(statements[0]) ||
92830
92827
  ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
92831
92828
  var format = 163969;
@@ -93037,14 +93034,12 @@ var ts;
93037
93034
  function emitSourceFile(node) {
93038
93035
  writeLine();
93039
93036
  var statements = node.statements;
93040
- if (emitBodyWithDetachedComments) {
93041
- var shouldEmitDetachedComment = statements.length === 0 ||
93042
- !ts.isPrologueDirective(statements[0]) ||
93043
- ts.nodeIsSynthesized(statements[0]);
93044
- if (shouldEmitDetachedComment) {
93045
- emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
93046
- return;
93047
- }
93037
+ var shouldEmitDetachedComment = statements.length === 0 ||
93038
+ !ts.isPrologueDirective(statements[0]) ||
93039
+ ts.nodeIsSynthesized(statements[0]);
93040
+ if (shouldEmitDetachedComment) {
93041
+ emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
93042
+ return;
93048
93043
  }
93049
93044
  emitSourceFileWorker(node);
93050
93045
  }
@@ -93422,7 +93417,7 @@ var ts;
93422
93417
  onBeforeEmitNodeArray(children);
93423
93418
  }
93424
93419
  if (isEmpty) {
93425
- if (format & 1 && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
93420
+ if (format & 1 && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
93426
93421
  writeLine();
93427
93422
  }
93428
93423
  else if (format & 256 && !(format & 524288)) {
@@ -93653,7 +93648,7 @@ var ts;
93653
93648
  }
93654
93649
  var firstChild_1 = children[0];
93655
93650
  if (firstChild_1 === undefined) {
93656
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93651
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93657
93652
  }
93658
93653
  if (firstChild_1.pos === nextListElementPos) {
93659
93654
  return 0;
@@ -93661,7 +93656,7 @@ var ts;
93661
93656
  if (firstChild_1.kind === 11) {
93662
93657
  return 0;
93663
93658
  }
93664
- if (parentNode &&
93659
+ if (currentSourceFile && parentNode &&
93665
93660
  !ts.positionIsSynthesized(parentNode.pos) &&
93666
93661
  !ts.nodeIsSynthesized(firstChild_1) &&
93667
93662
  (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -93684,7 +93679,7 @@ var ts;
93684
93679
  if (nextNode.kind === 11) {
93685
93680
  return 0;
93686
93681
  }
93687
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
93682
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
93688
93683
  if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
93689
93684
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
93690
93685
  }
@@ -93709,9 +93704,9 @@ var ts;
93709
93704
  }
93710
93705
  var lastChild = ts.lastOrUndefined(children);
93711
93706
  if (lastChild === undefined) {
93712
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93707
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93713
93708
  }
93714
- if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
93709
+ if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
93715
93710
  if (preserveSourceNewlines) {
93716
93711
  var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
93717
93712
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -93768,7 +93763,7 @@ var ts;
93768
93763
  if (ts.getStartsOnNewLine(node2)) {
93769
93764
  return 1;
93770
93765
  }
93771
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
93766
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
93772
93767
  if (preserveSourceNewlines) {
93773
93768
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
93774
93769
  }
@@ -93778,7 +93773,7 @@ var ts;
93778
93773
  }
93779
93774
  function isEmptyBlock(block) {
93780
93775
  return block.statements.length === 0
93781
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
93776
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
93782
93777
  }
93783
93778
  function skipSynthesizedParentheses(node) {
93784
93779
  while (node.kind === 212 && ts.nodeIsSynthesized(node)) {
@@ -93790,16 +93785,23 @@ var ts;
93790
93785
  if (ts.isGeneratedIdentifier(node)) {
93791
93786
  return generateName(node);
93792
93787
  }
93793
- else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
93794
- return ts.idText(node);
93795
- }
93796
- else if (node.kind === 10 && node.textSourceNode) {
93788
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
93797
93789
  return getTextOfNode(node.textSourceNode, includeTrivia);
93798
93790
  }
93799
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
93800
- return node.text;
93791
+ var sourceFile = currentSourceFile;
93792
+ var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
93793
+ if (ts.isMemberName(node)) {
93794
+ if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
93795
+ return ts.idText(node);
93796
+ }
93801
93797
  }
93802
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
93798
+ else {
93799
+ ts.Debug.assertNode(node, ts.isLiteralExpression);
93800
+ if (!canUseSourceFile) {
93801
+ return node.text;
93802
+ }
93803
+ }
93804
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
93803
93805
  }
93804
93806
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
93805
93807
  if (node.kind === 10 && node.textSourceNode) {
@@ -94290,7 +94292,7 @@ var ts;
94290
94292
  return true;
94291
94293
  }
94292
94294
  function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
94293
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94295
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94294
94296
  return;
94295
94297
  if (!hasWrittenComment) {
94296
94298
  ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -94316,7 +94318,7 @@ var ts;
94316
94318
  forEachTrailingCommentToEmit(pos, emitTrailingComment);
94317
94319
  }
94318
94320
  function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
94319
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94321
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94320
94322
  return;
94321
94323
  if (!writer.isAtStartOfLine()) {
94322
94324
  writer.writeSpace(" ");
@@ -94337,6 +94339,8 @@ var ts;
94337
94339
  exitComment();
94338
94340
  }
94339
94341
  function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
94342
+ if (!currentSourceFile)
94343
+ return;
94340
94344
  emitPos(commentPos);
94341
94345
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
94342
94346
  emitPos(commentEnd);
@@ -94345,6 +94349,8 @@ var ts;
94345
94349
  }
94346
94350
  }
94347
94351
  function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
94352
+ if (!currentSourceFile)
94353
+ return;
94348
94354
  emitPos(commentPos);
94349
94355
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
94350
94356
  emitPos(commentEnd);
@@ -94374,6 +94380,8 @@ var ts;
94374
94380
  return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
94375
94381
  }
94376
94382
  function forEachLeadingCommentWithoutDetachedComments(cb) {
94383
+ if (!currentSourceFile)
94384
+ return;
94377
94385
  var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
94378
94386
  if (detachedCommentsInfo.length - 1) {
94379
94387
  detachedCommentsInfo.pop();
@@ -94384,7 +94392,7 @@ var ts;
94384
94392
  ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
94385
94393
  }
94386
94394
  function emitDetachedCommentsAndUpdateCommentsInfo(range) {
94387
- var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
94395
+ var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
94388
94396
  if (currentDetachedCommentInfo) {
94389
94397
  if (detachedCommentsInfo) {
94390
94398
  detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -94395,14 +94403,14 @@ var ts;
94395
94403
  }
94396
94404
  }
94397
94405
  function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
94398
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94406
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94399
94407
  return;
94400
94408
  emitPos(commentPos);
94401
94409
  ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
94402
94410
  emitPos(commentEnd);
94403
94411
  }
94404
94412
  function isTripleSlashComment(commentPos, commentEnd) {
94405
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
94413
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
94406
94414
  }
94407
94415
  function getParsedSourceMap(node) {
94408
94416
  if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {