typescript 4.7.0-dev.20220420 → 4.7.0-dev.20220423

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.20220420";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220423";
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) {
@@ -14324,10 +14324,10 @@ var ts;
14324
14324
  return ts.combinePaths(newDirPath, sourceFilePath);
14325
14325
  }
14326
14326
  ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
14327
- function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
14328
- host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
14327
+ function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
14328
+ host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
14329
14329
  diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
14330
- }, sourceFiles);
14330
+ }, sourceFiles, data);
14331
14331
  }
14332
14332
  ts.writeFile = writeFile;
14333
14333
  function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
@@ -61316,6 +61316,7 @@ var ts;
61316
61316
  }
61317
61317
  }
61318
61318
  else {
61319
+ error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
61319
61320
  typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
61320
61321
  }
61321
61322
  }
@@ -63206,6 +63207,7 @@ var ts;
63206
63207
  var args = getEffectiveCallArguments(node);
63207
63208
  var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
63208
63209
  var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
63210
+ argCheckMode |= checkMode & 32;
63209
63211
  var candidatesForArgumentError;
63210
63212
  var candidateForArgumentArityError;
63211
63213
  var candidateForTypeArgumentError;
@@ -63376,7 +63378,7 @@ var ts;
63376
63378
  continue;
63377
63379
  }
63378
63380
  if (argCheckMode) {
63379
- argCheckMode = 0;
63381
+ argCheckMode = checkMode & 32;
63380
63382
  if (inferenceContext) {
63381
63383
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
63382
63384
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -79085,7 +79087,7 @@ var ts;
79085
79087
  }
79086
79088
  resumeLexicalEnvironment();
79087
79089
  var needsSyntheticConstructor = !constructor && isDerivedClass;
79088
- var indexOfFirstStatementAfterSuper = 0;
79090
+ var indexOfFirstStatementAfterSuperAndPrologue = 0;
79089
79091
  var prologueStatementCount = 0;
79090
79092
  var superStatementIndex = -1;
79091
79093
  var statements = [];
@@ -79093,8 +79095,11 @@ var ts;
79093
79095
  prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, false, visitor);
79094
79096
  superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
79095
79097
  if (superStatementIndex >= 0) {
79096
- indexOfFirstStatementAfterSuper = superStatementIndex + 1;
79097
- statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
79098
+ indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
79099
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
79100
+ }
79101
+ else if (prologueStatementCount >= 0) {
79102
+ indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
79098
79103
  }
79099
79104
  }
79100
79105
  if (needsSyntheticConstructor) {
@@ -79113,19 +79118,17 @@ var ts;
79113
79118
  }
79114
79119
  }
79115
79120
  if (parameterPropertyDeclarationCount > 0) {
79116
- var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
79121
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
79117
79122
  if (superStatementIndex >= 0) {
79118
79123
  ts.addRange(statements, parameterProperties);
79119
79124
  }
79120
- else if (needsSyntheticConstructor) {
79121
- statements = __spreadArray(__spreadArray([
79122
- statements[0]
79123
- ], parameterProperties, true), statements.slice(1), true);
79124
- }
79125
79125
  else {
79126
- statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
79126
+ var superAndPrologueStatementCount = prologueStatementCount;
79127
+ if (needsSyntheticConstructor)
79128
+ superAndPrologueStatementCount++;
79129
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
79127
79130
  }
79128
- indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
79131
+ indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
79129
79132
  }
79130
79133
  }
79131
79134
  }
@@ -79133,7 +79136,7 @@ var ts;
79133
79136
  addMethodStatements(statements, privateMethodsAndAccessors, receiver);
79134
79137
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
79135
79138
  if (constructor) {
79136
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
79139
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
79137
79140
  }
79138
79141
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
79139
79142
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
@@ -90212,6 +90215,7 @@ var ts;
90212
90215
  else {
90213
90216
  printer.writeFile(sourceFile, writer, sourceMapGenerator);
90214
90217
  }
90218
+ var sourceMapUrlPos;
90215
90219
  if (sourceMapGenerator) {
90216
90220
  if (sourceMapDataList) {
90217
90221
  sourceMapDataList.push({
@@ -90223,6 +90227,7 @@ var ts;
90223
90227
  if (sourceMappingURL) {
90224
90228
  if (!writer.isAtStartOfLine())
90225
90229
  writer.rawWrite(newLine);
90230
+ sourceMapUrlPos = writer.getTextPos();
90226
90231
  writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
90227
90232
  }
90228
90233
  if (sourceMapFilePath) {
@@ -90233,7 +90238,7 @@ var ts;
90233
90238
  else {
90234
90239
  writer.writeLine();
90235
90240
  }
90236
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
90241
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
90237
90242
  writer.clear();
90238
90243
  }
90239
90244
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -90717,7 +90722,7 @@ var ts;
90717
90722
  setWriter(undefined, undefined);
90718
90723
  }
90719
90724
  function getCurrentLineMap() {
90720
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
90725
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
90721
90726
  }
90722
90727
  function emit(node, parenthesizerRule) {
90723
90728
  if (node === undefined)
@@ -91801,7 +91806,7 @@ var ts;
91801
91806
  increaseIndent();
91802
91807
  }
91803
91808
  var preferNewLine = node.multiLine ? 65536 : 0;
91804
- var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
91809
+ var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
91805
91810
  emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
91806
91811
  if (indentedFlag) {
91807
91812
  decreaseIndent();
@@ -92128,7 +92133,7 @@ var ts;
92128
92133
  }
92129
92134
  function emitExpressionStatement(node) {
92130
92135
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
92131
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
92136
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
92132
92137
  writeTrailingSemicolon();
92133
92138
  }
92134
92139
  }
@@ -92407,7 +92412,7 @@ var ts;
92407
92412
  if (body.multiLine) {
92408
92413
  return false;
92409
92414
  }
92410
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
92415
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
92411
92416
  return false;
92412
92417
  }
92413
92418
  if (getLeadingLineTerminatorCount(body, body.statements, 2)
@@ -92432,12 +92437,7 @@ var ts;
92432
92437
  var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
92433
92438
  ? emitBlockFunctionBodyOnSingleLine
92434
92439
  : emitBlockFunctionBodyWorker;
92435
- if (emitBodyWithDetachedComments) {
92436
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
92437
- }
92438
- else {
92439
- emitBlockFunctionBody(body);
92440
- }
92440
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
92441
92441
  decreaseIndent();
92442
92442
  writeToken(19, body.statements.end, writePunctuation, body);
92443
92443
  onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
@@ -92821,7 +92821,8 @@ var ts;
92821
92821
  }
92822
92822
  function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
92823
92823
  var emitAsSingleStatement = statements.length === 1 &&
92824
- (ts.nodeIsSynthesized(parentNode) ||
92824
+ (!currentSourceFile ||
92825
+ ts.nodeIsSynthesized(parentNode) ||
92825
92826
  ts.nodeIsSynthesized(statements[0]) ||
92826
92827
  ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
92827
92828
  var format = 163969;
@@ -93033,14 +93034,12 @@ var ts;
93033
93034
  function emitSourceFile(node) {
93034
93035
  writeLine();
93035
93036
  var statements = node.statements;
93036
- if (emitBodyWithDetachedComments) {
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;
93043
- }
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;
93044
93043
  }
93045
93044
  emitSourceFileWorker(node);
93046
93045
  }
@@ -93418,7 +93417,7 @@ var ts;
93418
93417
  onBeforeEmitNodeArray(children);
93419
93418
  }
93420
93419
  if (isEmpty) {
93421
- if (format & 1 && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
93420
+ if (format & 1 && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
93422
93421
  writeLine();
93423
93422
  }
93424
93423
  else if (format & 256 && !(format & 524288)) {
@@ -93649,7 +93648,7 @@ var ts;
93649
93648
  }
93650
93649
  var firstChild_1 = children[0];
93651
93650
  if (firstChild_1 === undefined) {
93652
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93651
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93653
93652
  }
93654
93653
  if (firstChild_1.pos === nextListElementPos) {
93655
93654
  return 0;
@@ -93657,7 +93656,7 @@ var ts;
93657
93656
  if (firstChild_1.kind === 11) {
93658
93657
  return 0;
93659
93658
  }
93660
- if (parentNode &&
93659
+ if (currentSourceFile && parentNode &&
93661
93660
  !ts.positionIsSynthesized(parentNode.pos) &&
93662
93661
  !ts.nodeIsSynthesized(firstChild_1) &&
93663
93662
  (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -93680,7 +93679,7 @@ var ts;
93680
93679
  if (nextNode.kind === 11) {
93681
93680
  return 0;
93682
93681
  }
93683
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
93682
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
93684
93683
  if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
93685
93684
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
93686
93685
  }
@@ -93705,9 +93704,9 @@ var ts;
93705
93704
  }
93706
93705
  var lastChild = ts.lastOrUndefined(children);
93707
93706
  if (lastChild === undefined) {
93708
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93707
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93709
93708
  }
93710
- 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)) {
93711
93710
  if (preserveSourceNewlines) {
93712
93711
  var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
93713
93712
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -93764,7 +93763,7 @@ var ts;
93764
93763
  if (ts.getStartsOnNewLine(node2)) {
93765
93764
  return 1;
93766
93765
  }
93767
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
93766
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
93768
93767
  if (preserveSourceNewlines) {
93769
93768
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
93770
93769
  }
@@ -93774,7 +93773,7 @@ var ts;
93774
93773
  }
93775
93774
  function isEmptyBlock(block) {
93776
93775
  return block.statements.length === 0
93777
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
93776
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
93778
93777
  }
93779
93778
  function skipSynthesizedParentheses(node) {
93780
93779
  while (node.kind === 212 && ts.nodeIsSynthesized(node)) {
@@ -93786,16 +93785,23 @@ var ts;
93786
93785
  if (ts.isGeneratedIdentifier(node)) {
93787
93786
  return generateName(node);
93788
93787
  }
93789
- else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
93790
- return ts.idText(node);
93791
- }
93792
- else if (node.kind === 10 && node.textSourceNode) {
93788
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
93793
93789
  return getTextOfNode(node.textSourceNode, includeTrivia);
93794
93790
  }
93795
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
93796
- 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
+ }
93797
+ }
93798
+ else {
93799
+ ts.Debug.assertNode(node, ts.isLiteralExpression);
93800
+ if (!canUseSourceFile) {
93801
+ return node.text;
93802
+ }
93797
93803
  }
93798
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
93804
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
93799
93805
  }
93800
93806
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
93801
93807
  if (node.kind === 10 && node.textSourceNode) {
@@ -94286,7 +94292,7 @@ var ts;
94286
94292
  return true;
94287
94293
  }
94288
94294
  function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
94289
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94295
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94290
94296
  return;
94291
94297
  if (!hasWrittenComment) {
94292
94298
  ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -94312,7 +94318,7 @@ var ts;
94312
94318
  forEachTrailingCommentToEmit(pos, emitTrailingComment);
94313
94319
  }
94314
94320
  function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
94315
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94321
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94316
94322
  return;
94317
94323
  if (!writer.isAtStartOfLine()) {
94318
94324
  writer.writeSpace(" ");
@@ -94333,6 +94339,8 @@ var ts;
94333
94339
  exitComment();
94334
94340
  }
94335
94341
  function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
94342
+ if (!currentSourceFile)
94343
+ return;
94336
94344
  emitPos(commentPos);
94337
94345
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
94338
94346
  emitPos(commentEnd);
@@ -94341,6 +94349,8 @@ var ts;
94341
94349
  }
94342
94350
  }
94343
94351
  function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
94352
+ if (!currentSourceFile)
94353
+ return;
94344
94354
  emitPos(commentPos);
94345
94355
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
94346
94356
  emitPos(commentEnd);
@@ -94370,6 +94380,8 @@ var ts;
94370
94380
  return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
94371
94381
  }
94372
94382
  function forEachLeadingCommentWithoutDetachedComments(cb) {
94383
+ if (!currentSourceFile)
94384
+ return;
94373
94385
  var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
94374
94386
  if (detachedCommentsInfo.length - 1) {
94375
94387
  detachedCommentsInfo.pop();
@@ -94380,7 +94392,7 @@ var ts;
94380
94392
  ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
94381
94393
  }
94382
94394
  function emitDetachedCommentsAndUpdateCommentsInfo(range) {
94383
- 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);
94384
94396
  if (currentDetachedCommentInfo) {
94385
94397
  if (detachedCommentsInfo) {
94386
94398
  detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -94391,14 +94403,14 @@ var ts;
94391
94403
  }
94392
94404
  }
94393
94405
  function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
94394
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94406
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94395
94407
  return;
94396
94408
  emitPos(commentPos);
94397
94409
  ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
94398
94410
  emitPos(commentEnd);
94399
94411
  }
94400
94412
  function isTripleSlashComment(commentPos, commentEnd) {
94401
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
94413
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
94402
94414
  }
94403
94415
  function getParsedSourceMap(node) {
94404
94416
  if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
@@ -95205,7 +95217,11 @@ var ts;
95205
95217
  return newValue;
95206
95218
  };
95207
95219
  if (originalWriteFile) {
95208
- host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
95220
+ host.writeFile = function (fileName, data) {
95221
+ var rest = [];
95222
+ for (var _i = 2; _i < arguments.length; _i++) {
95223
+ rest[_i - 2] = arguments[_i];
95224
+ }
95209
95225
  var key = toPath(fileName);
95210
95226
  fileExistsCache.delete(key);
95211
95227
  var value = readFileCache.get(key);
@@ -95219,7 +95235,7 @@ var ts;
95219
95235
  sourceFileCache.delete(key);
95220
95236
  }
95221
95237
  }
95222
- originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
95238
+ originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
95223
95239
  };
95224
95240
  }
95225
95241
  if (originalDirectoryExists && originalCreateDirectory) {
@@ -96041,6 +96057,7 @@ var ts;
96041
96057
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
96042
96058
  getFileIncludeReasons: function () { return fileReasons; },
96043
96059
  structureIsReused: structureIsReused,
96060
+ writeFile: writeFile,
96044
96061
  };
96045
96062
  onProgramCreateComplete();
96046
96063
  fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) {
@@ -96444,7 +96461,7 @@ var ts;
96444
96461
  getProjectReferenceRedirect: getProjectReferenceRedirect,
96445
96462
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
96446
96463
  getSymlinkCache: getSymlinkCache,
96447
- writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
96464
+ writeFile: writeFileCallback || writeFile,
96448
96465
  isEmitBlocked: isEmitBlocked,
96449
96466
  readFile: function (f) { return host.readFile(f); },
96450
96467
  fileExists: function (f) {
@@ -96462,6 +96479,9 @@ var ts;
96462
96479
  getFileIncludeReasons: program.getFileIncludeReasons,
96463
96480
  };
96464
96481
  }
96482
+ function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
96483
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
96484
+ }
96465
96485
  function emitBuildInfo(writeFileCallback) {
96466
96486
  ts.Debug.assert(!ts.outFile(options));
96467
96487
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitBuildInfo", {}, true);
@@ -98639,6 +98659,7 @@ var ts;
98639
98659
  }
98640
98660
  }
98641
98661
  }
98662
+ BuilderState.updateExportedModules = updateExportedModules;
98642
98663
  function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
98643
98664
  var _a;
98644
98665
  if (exportedModulesMapCache) {
@@ -98965,29 +98986,30 @@ var ts;
98965
98986
  }
98966
98987
  return undefined;
98967
98988
  }
98989
+ function removeDiagnosticsOfLibraryFiles(state) {
98990
+ if (!state.cleanedDiagnosticsOfLibFiles) {
98991
+ state.cleanedDiagnosticsOfLibFiles = true;
98992
+ var program_1 = ts.Debug.checkDefined(state.program);
98993
+ var options_2 = program_1.getCompilerOptions();
98994
+ ts.forEach(program_1.getSourceFiles(), function (f) {
98995
+ return program_1.isSourceFileDefaultLibrary(f) &&
98996
+ !ts.skipTypeChecking(f, options_2, program_1) &&
98997
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
98998
+ });
98999
+ }
99000
+ }
98968
99001
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
98969
99002
  var _a;
98970
99003
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
98971
99004
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
98972
- if (!state.cleanedDiagnosticsOfLibFiles) {
98973
- state.cleanedDiagnosticsOfLibFiles = true;
98974
- var program_1 = ts.Debug.checkDefined(state.program);
98975
- var options_2 = program_1.getCompilerOptions();
98976
- ts.forEach(program_1.getSourceFiles(), function (f) {
98977
- return program_1.isSourceFileDefaultLibrary(f) &&
98978
- !ts.skipTypeChecking(f, options_2, program_1) &&
98979
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
98980
- });
98981
- }
99005
+ removeDiagnosticsOfLibraryFiles(state);
98982
99006
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
98983
99007
  return;
98984
99008
  }
98985
- else {
98986
- ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
98987
- }
98988
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
98989
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
98990
- }
99009
+ ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
99010
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
99011
+ return;
99012
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
98991
99013
  }
98992
99014
  function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
98993
99015
  removeSemanticDiagnosticsOf(state, path);
@@ -99015,11 +99037,32 @@ var ts;
99015
99037
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
99016
99038
  return newSignature !== oldSignature;
99017
99039
  }
99018
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
99019
- var _a, _b;
99020
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
99040
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
99041
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
99042
+ var result = keys && ts.forEachKey(keys, fn);
99043
+ if (result)
99044
+ return result;
99045
+ keys = state.exportedModulesMap.getKeys(filePath);
99046
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
99047
+ var _a;
99048
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99049
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
99050
+ fn(exportedFromPath) :
99051
+ undefined;
99052
+ });
99053
+ }
99054
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
99055
+ var _a;
99056
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
99057
+ return false;
99058
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
99059
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
99060
+ removeDiagnosticsOfLibraryFiles(state);
99061
+ return true;
99062
+ }
99063
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
99064
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
99021
99065
  return;
99022
- }
99023
99066
  if (!isChangedSignature(state, affectedFile.resolvedPath))
99024
99067
  return;
99025
99068
  if (state.compilerOptions.isolatedModules) {
@@ -99030,7 +99073,9 @@ var ts;
99030
99073
  var currentPath = queue.pop();
99031
99074
  if (!seenFileNamesMap.has(currentPath)) {
99032
99075
  seenFileNamesMap.set(currentPath, true);
99033
- fn(state, currentPath);
99076
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
99077
+ return;
99078
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
99034
99079
  if (isChangedSignature(state, currentPath)) {
99035
99080
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
99036
99081
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -99040,42 +99085,31 @@ var ts;
99040
99085
  }
99041
99086
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
99042
99087
  var seenFileAndExportsOfFile = new ts.Set();
99043
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
99044
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99045
- });
99046
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
99047
- var _a;
99048
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99049
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
99050
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99088
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
99089
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
99090
+ return true;
99091
+ var references = state.referencedMap.getKeys(exportedFromPath);
99092
+ return references && ts.forEachKey(references, function (filePath) {
99093
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99094
+ });
99051
99095
  });
99052
99096
  }
99053
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
99097
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
99054
99098
  var _a;
99055
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
99056
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
99057
- });
99058
- }
99059
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
99060
- var _a, _b, _c;
99061
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
99062
- return;
99063
- }
99064
- fn(state, filePath);
99099
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
99100
+ return undefined;
99101
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
99102
+ return true;
99103
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
99065
99104
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
99066
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
99067
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99105
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
99106
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99068
99107
  });
99069
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
99070
- var _a;
99071
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99072
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
99073
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99074
- });
99075
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
99108
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
99076
99109
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
99077
- fn(state, referencingFilePath);
99110
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, host);
99078
99111
  });
99112
+ return undefined;
99079
99113
  }
99080
99114
  function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
99081
99115
  if (isBuildInfoEmit) {
@@ -99397,7 +99431,43 @@ var ts;
99397
99431
  affected = program;
99398
99432
  }
99399
99433
  }
99400
- return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile);
99434
+ return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
99435
+ getWriteFileUpdatingSignatureCallback(writeFile) :
99436
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile);
99437
+ }
99438
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
99439
+ return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
99440
+ var _a;
99441
+ if (ts.isDeclarationFileName(fileName)) {
99442
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
99443
+ var file = sourceFiles[0];
99444
+ var info = state.fileInfos.get(file.resolvedPath);
99445
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
99446
+ if (signature === file.version) {
99447
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
99448
+ if (newSignature !== file.version) {
99449
+ if (host.storeFilesChangingSignatureDuringEmit)
99450
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
99451
+ if (state.exportedModulesMap)
99452
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
99453
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
99454
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
99455
+ }
99456
+ else {
99457
+ info.signature = newSignature;
99458
+ if (state.exportedModulesMap)
99459
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
99460
+ }
99461
+ }
99462
+ }
99463
+ }
99464
+ if (writeFile)
99465
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99466
+ else if (host.writeFile)
99467
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99468
+ else
99469
+ state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99470
+ };
99401
99471
  }
99402
99472
  function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
99403
99473
  var _a;
@@ -99438,7 +99508,9 @@ var ts;
99438
99508
  }
99439
99509
  }
99440
99510
  }
99441
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
99511
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
99512
+ getWriteFileUpdatingSignatureCallback(writeFile) :
99513
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
99442
99514
  }
99443
99515
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
99444
99516
  while (true) {
@@ -101361,6 +101433,7 @@ var ts;
101361
101433
  createHash: ts.maybeBind(host, host.createHash),
101362
101434
  readDirectory: ts.maybeBind(host, host.readDirectory),
101363
101435
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
101436
+ storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
101364
101437
  };
101365
101438
  function writeFile(fileName, text, writeByteOrderMark, onError) {
101366
101439
  try {
@@ -101414,6 +101487,7 @@ var ts;
101414
101487
  createHash: ts.maybeBind(system, system.createHash),
101415
101488
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
101416
101489
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
101490
+ storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
101417
101491
  };
101418
101492
  }
101419
101493
  ts.createProgramHost = createProgramHost;
@@ -101490,6 +101564,7 @@ var ts;
101490
101564
  var host = ts.createCompilerHostWorker(options, undefined, system);
101491
101565
  host.createHash = ts.maybeBind(system, system.createHash);
101492
101566
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
101567
+ host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
101493
101568
  ts.setGetSourceFileAsHashVersioned(host, system);
101494
101569
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
101495
101570
  return host;