@typescript-deploys/pr-build 4.7.0-pr-48792-5 → 4.7.0-pr-48861-7

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-insiders.20220420";
72
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220427";
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) {
@@ -27596,7 +27596,7 @@ var ts;
27596
27596
  if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
27597
27597
  return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos);
27598
27598
  }
27599
- return parseConditionalExpressionRest(expr, pos, disallowReturnTypeInArrowFunction);
27599
+ return parseConditionalExpressionRest(expr, pos);
27600
27600
  }
27601
27601
  function isYieldExpression() {
27602
27602
  if (token() === 125) {
@@ -27638,7 +27638,7 @@ var ts;
27638
27638
  return undefined;
27639
27639
  }
27640
27640
  return triState === 1 ?
27641
- parseParenthesizedArrowFunctionExpression(true, disallowReturnTypeInArrowFunction) :
27641
+ parseParenthesizedArrowFunctionExpression(true, false) :
27642
27642
  tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); });
27643
27643
  }
27644
27644
  function isParenthesizedArrowFunctionExpression() {
@@ -27838,14 +27838,14 @@ var ts;
27838
27838
  topLevel = savedTopLevel;
27839
27839
  return node;
27840
27840
  }
27841
- function parseConditionalExpressionRest(leftOperand, pos, disallowReturnTypeInArrowFunction) {
27841
+ function parseConditionalExpressionRest(leftOperand, pos) {
27842
27842
  var questionToken = parseOptionalToken(57);
27843
27843
  if (!questionToken) {
27844
27844
  return leftOperand;
27845
27845
  }
27846
27846
  var colonToken;
27847
27847
  return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(true); }), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken)
27848
- ? parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction)
27848
+ ? parseAssignmentExpressionOrHigher(true)
27849
27849
  : createMissingNode(79, false, ts.Diagnostics._0_expected, ts.tokenToString(58))), pos);
27850
27850
  }
27851
27851
  function parseBinaryExpressionOrHigher(precedence) {
@@ -39568,6 +39568,7 @@ var ts;
39568
39568
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
39569
39569
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
39570
39570
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
39571
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]);
39571
39572
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; });
39572
39573
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; });
39573
39574
  var uniqueLiteralType = createIntrinsicType(131072, "never");
@@ -42162,7 +42163,7 @@ var ts;
42162
42163
  }
42163
42164
  }
42164
42165
  function getExportSymbolOfValueSymbolIfExported(symbol) {
42165
- return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol);
42166
+ return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 && symbol.exportSymbol || symbol);
42166
42167
  }
42167
42168
  function symbolIsValue(symbol) {
42168
42169
  return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol));
@@ -48557,7 +48558,7 @@ var ts;
48557
48558
  var typeVariable = getHomomorphicTypeVariable(type);
48558
48559
  if (typeVariable && !type.declaration.nameType) {
48559
48560
  var constraint = getConstraintOfTypeParameter(typeVariable);
48560
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
48561
+ if (constraint && isArrayOrTupleType(constraint)) {
48561
48562
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
48562
48563
  }
48563
48564
  }
@@ -48866,7 +48867,7 @@ var ts;
48866
48867
  function isApplicableIndexType(source, target) {
48867
48868
  return isTypeAssignableTo(source, target) ||
48868
48869
  target === stringType && isTypeAssignableTo(source, numberType) ||
48869
- target === numberType && !!(source.flags & 128) && ts.isNumericLiteralName(source.value);
48870
+ target === numberType && (source === numericStringType || !!(source.flags & 128) && ts.isNumericLiteralName(source.value));
48870
48871
  }
48871
48872
  function getIndexInfosOfStructuredType(type) {
48872
48873
  if (type.flags & 3670016) {
@@ -49772,6 +49773,18 @@ var ts;
49772
49773
  constraints = ts.append(constraints, constraint);
49773
49774
  }
49774
49775
  }
49776
+ else if (type.flags & 262144 && parent.kind === 195 && node === parent.type) {
49777
+ var mappedType = getTypeFromTypeNode(parent);
49778
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
49779
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
49780
+ if (typeParameter) {
49781
+ var constraint = getConstraintOfTypeParameter(typeParameter);
49782
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
49783
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
49784
+ }
49785
+ }
49786
+ }
49787
+ }
49775
49788
  node = parent;
49776
49789
  }
49777
49790
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -50658,7 +50671,7 @@ var ts;
50658
50671
  while (i > 0) {
50659
50672
  i--;
50660
50673
  var t = types[i];
50661
- var remove = t.flags & 4 && includes & 128 ||
50674
+ var remove = t.flags & 4 && includes & (128 | 134217728 | 268435456) ||
50662
50675
  t.flags & 8 && includes & 256 ||
50663
50676
  t.flags & 64 && includes & 2048 ||
50664
50677
  t.flags & 4096 && includes & 8192;
@@ -50781,7 +50794,7 @@ var ts;
50781
50794
  if (!strictNullChecks && includes & 98304) {
50782
50795
  return includes & 32768 ? undefinedType : nullType;
50783
50796
  }
50784
- if (includes & 4 && includes & 128 ||
50797
+ if (includes & 4 && includes & (128 | 134217728 | 268435456) ||
50785
50798
  includes & 8 && includes & 256 ||
50786
50799
  includes & 64 && includes & 2048 ||
50787
50800
  includes & 4096 && includes & 8192) {
@@ -52449,7 +52462,7 @@ var ts;
52449
52462
  if (!type.declaration.nameType) {
52450
52463
  var constraint = void 0;
52451
52464
  if (isArrayType(t) || t.flags & 1 && findResolutionCycleStartIndex(typeVariable, 4) < 0 &&
52452
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
52465
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
52453
52466
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
52454
52467
  }
52455
52468
  if (isGenericTupleType(t)) {
@@ -53744,7 +53757,7 @@ var ts;
53744
53757
  }
53745
53758
  return false;
53746
53759
  }
53747
- return isTupleType(target) || isArrayType(target);
53760
+ return isArrayOrTupleType(target);
53748
53761
  }
53749
53762
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
53750
53763
  if (reportErrors) {
@@ -53840,7 +53853,7 @@ var ts;
53840
53853
  unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
53841
53854
  recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
53842
53855
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
53843
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144); }))) {
53856
+ isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144); }))) {
53844
53857
  inPropertyCheck = true;
53845
53858
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4, recursionFlags);
53846
53859
  inPropertyCheck = false;
@@ -54375,6 +54388,18 @@ var ts;
54375
54388
  }
54376
54389
  }
54377
54390
  }
54391
+ if (relation === comparableRelation && sourceFlags & 262144) {
54392
+ var constraint = getConstraintOfTypeParameter(source);
54393
+ if (constraint && hasNonCircularBaseConstraint(source)) {
54394
+ while (constraint && constraint.flags & 262144) {
54395
+ if (result = isRelatedTo(constraint, target, 1, false)) {
54396
+ return result;
54397
+ }
54398
+ constraint = getConstraintOfTypeParameter(constraint);
54399
+ }
54400
+ }
54401
+ return 0;
54402
+ }
54378
54403
  }
54379
54404
  else if (targetFlags & 4194304) {
54380
54405
  var targetType_1 = target.type;
@@ -54525,18 +54550,18 @@ var ts;
54525
54550
  }
54526
54551
  if (sourceFlags & 8650752) {
54527
54552
  if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
54528
- var constraint = getConstraintOfType(source);
54553
+ var constraint = getConstraintOfType(source) || unknownType;
54529
54554
  if (!strictNullChecks && (!constraint || (sourceFlags & 262144 && constraint.flags & 1))) {
54530
54555
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) {
54531
54556
  resetErrorInfo(saveErrorInfo);
54532
54557
  return result;
54533
54558
  }
54534
54559
  }
54535
- else if (constraint && (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState))) {
54560
+ else if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
54536
54561
  resetErrorInfo(saveErrorInfo);
54537
54562
  return result;
54538
54563
  }
54539
- else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState))) {
54564
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) {
54540
54565
  resetErrorInfo(saveErrorInfo);
54541
54566
  return result;
54542
54567
  }
@@ -54659,7 +54684,7 @@ var ts;
54659
54684
  return varianceResult;
54660
54685
  }
54661
54686
  }
54662
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
54687
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
54663
54688
  if (relation !== identityRelation) {
54664
54689
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3, reportErrors);
54665
54690
  }
@@ -54953,7 +54978,7 @@ var ts;
54953
54978
  }
54954
54979
  var result = -1;
54955
54980
  if (isTupleType(target)) {
54956
- if (isArrayType(source) || isTupleType(source)) {
54981
+ if (isArrayOrTupleType(source)) {
54957
54982
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
54958
54983
  return 0;
54959
54984
  }
@@ -55800,6 +55825,9 @@ var ts;
55800
55825
  function isReadonlyArrayType(type) {
55801
55826
  return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType;
55802
55827
  }
55828
+ function isArrayOrTupleType(type) {
55829
+ return isArrayType(type) || isTupleType(type);
55830
+ }
55803
55831
  function isMutableArrayOrTuple(type) {
55804
55832
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
55805
55833
  }
@@ -56197,7 +56225,7 @@ var ts;
56197
56225
  else if (type.flags & 2097152) {
56198
56226
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
56199
56227
  }
56200
- else if (isArrayType(type) || isTupleType(type)) {
56228
+ else if (isArrayOrTupleType(type)) {
56201
56229
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
56202
56230
  }
56203
56231
  if (result && context === undefined) {
@@ -56223,7 +56251,7 @@ var ts;
56223
56251
  }
56224
56252
  }
56225
56253
  }
56226
- if (isArrayType(type) || isTupleType(type)) {
56254
+ if (isArrayOrTupleType(type)) {
56227
56255
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
56228
56256
  var t = _c[_b];
56229
56257
  if (reportWideningErrorsInType(t)) {
@@ -57125,7 +57153,7 @@ var ts;
57125
57153
  }
57126
57154
  }
57127
57155
  if (!typesDefinitelyUnrelated(source, target)) {
57128
- if (isArrayType(source) || isTupleType(source)) {
57156
+ if (isArrayOrTupleType(source)) {
57129
57157
  if (isTupleType(target)) {
57130
57158
  var sourceArity = getTypeReferenceArity(source);
57131
57159
  var targetArity = getTypeReferenceArity(target);
@@ -61316,6 +61344,7 @@ var ts;
61316
61344
  }
61317
61345
  }
61318
61346
  else {
61347
+ error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
61319
61348
  typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
61320
61349
  }
61321
61350
  }
@@ -63206,6 +63235,7 @@ var ts;
63206
63235
  var args = getEffectiveCallArguments(node);
63207
63236
  var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
63208
63237
  var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
63238
+ argCheckMode |= checkMode & 32;
63209
63239
  var candidatesForArgumentError;
63210
63240
  var candidateForArgumentArityError;
63211
63241
  var candidateForTypeArgumentError;
@@ -63376,7 +63406,7 @@ var ts;
63376
63406
  continue;
63377
63407
  }
63378
63408
  if (argCheckMode) {
63379
- argCheckMode = 0;
63409
+ argCheckMode = checkMode & 32;
63380
63410
  if (inferenceContext) {
63381
63411
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
63382
63412
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -90213,6 +90243,7 @@ var ts;
90213
90243
  else {
90214
90244
  printer.writeFile(sourceFile, writer, sourceMapGenerator);
90215
90245
  }
90246
+ var sourceMapUrlPos;
90216
90247
  if (sourceMapGenerator) {
90217
90248
  if (sourceMapDataList) {
90218
90249
  sourceMapDataList.push({
@@ -90224,6 +90255,7 @@ var ts;
90224
90255
  if (sourceMappingURL) {
90225
90256
  if (!writer.isAtStartOfLine())
90226
90257
  writer.rawWrite(newLine);
90258
+ sourceMapUrlPos = writer.getTextPos();
90227
90259
  writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
90228
90260
  }
90229
90261
  if (sourceMapFilePath) {
@@ -90234,7 +90266,7 @@ var ts;
90234
90266
  else {
90235
90267
  writer.writeLine();
90236
90268
  }
90237
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
90269
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
90238
90270
  writer.clear();
90239
90271
  }
90240
90272
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -90718,7 +90750,7 @@ var ts;
90718
90750
  setWriter(undefined, undefined);
90719
90751
  }
90720
90752
  function getCurrentLineMap() {
90721
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
90753
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
90722
90754
  }
90723
90755
  function emit(node, parenthesizerRule) {
90724
90756
  if (node === undefined)
@@ -91802,7 +91834,7 @@ var ts;
91802
91834
  increaseIndent();
91803
91835
  }
91804
91836
  var preferNewLine = node.multiLine ? 65536 : 0;
91805
- var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
91837
+ var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
91806
91838
  emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
91807
91839
  if (indentedFlag) {
91808
91840
  decreaseIndent();
@@ -92129,7 +92161,7 @@ var ts;
92129
92161
  }
92130
92162
  function emitExpressionStatement(node) {
92131
92163
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
92132
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
92164
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
92133
92165
  writeTrailingSemicolon();
92134
92166
  }
92135
92167
  }
@@ -92408,7 +92440,7 @@ var ts;
92408
92440
  if (body.multiLine) {
92409
92441
  return false;
92410
92442
  }
92411
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
92443
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
92412
92444
  return false;
92413
92445
  }
92414
92446
  if (getLeadingLineTerminatorCount(body, body.statements, 2)
@@ -92433,12 +92465,7 @@ var ts;
92433
92465
  var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
92434
92466
  ? emitBlockFunctionBodyOnSingleLine
92435
92467
  : emitBlockFunctionBodyWorker;
92436
- if (emitBodyWithDetachedComments) {
92437
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
92438
- }
92439
- else {
92440
- emitBlockFunctionBody(body);
92441
- }
92468
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
92442
92469
  decreaseIndent();
92443
92470
  writeToken(19, body.statements.end, writePunctuation, body);
92444
92471
  onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
@@ -92822,7 +92849,8 @@ var ts;
92822
92849
  }
92823
92850
  function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
92824
92851
  var emitAsSingleStatement = statements.length === 1 &&
92825
- (ts.nodeIsSynthesized(parentNode) ||
92852
+ (!currentSourceFile ||
92853
+ ts.nodeIsSynthesized(parentNode) ||
92826
92854
  ts.nodeIsSynthesized(statements[0]) ||
92827
92855
  ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
92828
92856
  var format = 163969;
@@ -93034,14 +93062,12 @@ var ts;
93034
93062
  function emitSourceFile(node) {
93035
93063
  writeLine();
93036
93064
  var statements = node.statements;
93037
- if (emitBodyWithDetachedComments) {
93038
- var shouldEmitDetachedComment = statements.length === 0 ||
93039
- !ts.isPrologueDirective(statements[0]) ||
93040
- ts.nodeIsSynthesized(statements[0]);
93041
- if (shouldEmitDetachedComment) {
93042
- emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
93043
- return;
93044
- }
93065
+ var shouldEmitDetachedComment = statements.length === 0 ||
93066
+ !ts.isPrologueDirective(statements[0]) ||
93067
+ ts.nodeIsSynthesized(statements[0]);
93068
+ if (shouldEmitDetachedComment) {
93069
+ emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
93070
+ return;
93045
93071
  }
93046
93072
  emitSourceFileWorker(node);
93047
93073
  }
@@ -93419,7 +93445,7 @@ var ts;
93419
93445
  onBeforeEmitNodeArray(children);
93420
93446
  }
93421
93447
  if (isEmpty) {
93422
- if (format & 1 && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
93448
+ if (format & 1 && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
93423
93449
  writeLine();
93424
93450
  }
93425
93451
  else if (format & 256 && !(format & 524288)) {
@@ -93650,7 +93676,7 @@ var ts;
93650
93676
  }
93651
93677
  var firstChild_1 = children[0];
93652
93678
  if (firstChild_1 === undefined) {
93653
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93679
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93654
93680
  }
93655
93681
  if (firstChild_1.pos === nextListElementPos) {
93656
93682
  return 0;
@@ -93658,7 +93684,7 @@ var ts;
93658
93684
  if (firstChild_1.kind === 11) {
93659
93685
  return 0;
93660
93686
  }
93661
- if (parentNode &&
93687
+ if (currentSourceFile && parentNode &&
93662
93688
  !ts.positionIsSynthesized(parentNode.pos) &&
93663
93689
  !ts.nodeIsSynthesized(firstChild_1) &&
93664
93690
  (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -93681,7 +93707,7 @@ var ts;
93681
93707
  if (nextNode.kind === 11) {
93682
93708
  return 0;
93683
93709
  }
93684
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
93710
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
93685
93711
  if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
93686
93712
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
93687
93713
  }
@@ -93706,9 +93732,9 @@ var ts;
93706
93732
  }
93707
93733
  var lastChild = ts.lastOrUndefined(children);
93708
93734
  if (lastChild === undefined) {
93709
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93735
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93710
93736
  }
93711
- if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
93737
+ if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
93712
93738
  if (preserveSourceNewlines) {
93713
93739
  var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
93714
93740
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -93765,7 +93791,7 @@ var ts;
93765
93791
  if (ts.getStartsOnNewLine(node2)) {
93766
93792
  return 1;
93767
93793
  }
93768
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
93794
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
93769
93795
  if (preserveSourceNewlines) {
93770
93796
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
93771
93797
  }
@@ -93775,7 +93801,7 @@ var ts;
93775
93801
  }
93776
93802
  function isEmptyBlock(block) {
93777
93803
  return block.statements.length === 0
93778
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
93804
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
93779
93805
  }
93780
93806
  function skipSynthesizedParentheses(node) {
93781
93807
  while (node.kind === 212 && ts.nodeIsSynthesized(node)) {
@@ -93787,16 +93813,23 @@ var ts;
93787
93813
  if (ts.isGeneratedIdentifier(node)) {
93788
93814
  return generateName(node);
93789
93815
  }
93790
- else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
93791
- return ts.idText(node);
93792
- }
93793
- else if (node.kind === 10 && node.textSourceNode) {
93816
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
93794
93817
  return getTextOfNode(node.textSourceNode, includeTrivia);
93795
93818
  }
93796
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
93797
- return node.text;
93819
+ var sourceFile = currentSourceFile;
93820
+ var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
93821
+ if (ts.isMemberName(node)) {
93822
+ if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
93823
+ return ts.idText(node);
93824
+ }
93798
93825
  }
93799
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
93826
+ else {
93827
+ ts.Debug.assertNode(node, ts.isLiteralExpression);
93828
+ if (!canUseSourceFile) {
93829
+ return node.text;
93830
+ }
93831
+ }
93832
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
93800
93833
  }
93801
93834
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
93802
93835
  if (node.kind === 10 && node.textSourceNode) {
@@ -94287,7 +94320,7 @@ var ts;
94287
94320
  return true;
94288
94321
  }
94289
94322
  function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
94290
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94323
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94291
94324
  return;
94292
94325
  if (!hasWrittenComment) {
94293
94326
  ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -94313,7 +94346,7 @@ var ts;
94313
94346
  forEachTrailingCommentToEmit(pos, emitTrailingComment);
94314
94347
  }
94315
94348
  function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
94316
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94349
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94317
94350
  return;
94318
94351
  if (!writer.isAtStartOfLine()) {
94319
94352
  writer.writeSpace(" ");
@@ -94334,6 +94367,8 @@ var ts;
94334
94367
  exitComment();
94335
94368
  }
94336
94369
  function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
94370
+ if (!currentSourceFile)
94371
+ return;
94337
94372
  emitPos(commentPos);
94338
94373
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
94339
94374
  emitPos(commentEnd);
@@ -94342,6 +94377,8 @@ var ts;
94342
94377
  }
94343
94378
  }
94344
94379
  function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
94380
+ if (!currentSourceFile)
94381
+ return;
94345
94382
  emitPos(commentPos);
94346
94383
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
94347
94384
  emitPos(commentEnd);
@@ -94371,6 +94408,8 @@ var ts;
94371
94408
  return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
94372
94409
  }
94373
94410
  function forEachLeadingCommentWithoutDetachedComments(cb) {
94411
+ if (!currentSourceFile)
94412
+ return;
94374
94413
  var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
94375
94414
  if (detachedCommentsInfo.length - 1) {
94376
94415
  detachedCommentsInfo.pop();
@@ -94381,7 +94420,7 @@ var ts;
94381
94420
  ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
94382
94421
  }
94383
94422
  function emitDetachedCommentsAndUpdateCommentsInfo(range) {
94384
- var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
94423
+ var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
94385
94424
  if (currentDetachedCommentInfo) {
94386
94425
  if (detachedCommentsInfo) {
94387
94426
  detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -94392,14 +94431,14 @@ var ts;
94392
94431
  }
94393
94432
  }
94394
94433
  function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
94395
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94434
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94396
94435
  return;
94397
94436
  emitPos(commentPos);
94398
94437
  ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
94399
94438
  emitPos(commentEnd);
94400
94439
  }
94401
94440
  function isTripleSlashComment(commentPos, commentEnd) {
94402
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
94441
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
94403
94442
  }
94404
94443
  function getParsedSourceMap(node) {
94405
94444
  if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
@@ -95206,7 +95245,11 @@ var ts;
95206
95245
  return newValue;
95207
95246
  };
95208
95247
  if (originalWriteFile) {
95209
- host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
95248
+ host.writeFile = function (fileName, data) {
95249
+ var rest = [];
95250
+ for (var _i = 2; _i < arguments.length; _i++) {
95251
+ rest[_i - 2] = arguments[_i];
95252
+ }
95210
95253
  var key = toPath(fileName);
95211
95254
  fileExistsCache.delete(key);
95212
95255
  var value = readFileCache.get(key);
@@ -95220,7 +95263,7 @@ var ts;
95220
95263
  sourceFileCache.delete(key);
95221
95264
  }
95222
95265
  }
95223
- originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
95266
+ originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
95224
95267
  };
95225
95268
  }
95226
95269
  if (originalDirectoryExists && originalCreateDirectory) {
@@ -96042,6 +96085,7 @@ var ts;
96042
96085
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
96043
96086
  getFileIncludeReasons: function () { return fileReasons; },
96044
96087
  structureIsReused: structureIsReused,
96088
+ writeFile: writeFile,
96045
96089
  };
96046
96090
  onProgramCreateComplete();
96047
96091
  fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) {
@@ -96445,7 +96489,7 @@ var ts;
96445
96489
  getProjectReferenceRedirect: getProjectReferenceRedirect,
96446
96490
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
96447
96491
  getSymlinkCache: getSymlinkCache,
96448
- writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
96492
+ writeFile: writeFileCallback || writeFile,
96449
96493
  isEmitBlocked: isEmitBlocked,
96450
96494
  readFile: function (f) { return host.readFile(f); },
96451
96495
  fileExists: function (f) {
@@ -96463,6 +96507,9 @@ var ts;
96463
96507
  getFileIncludeReasons: program.getFileIncludeReasons,
96464
96508
  };
96465
96509
  }
96510
+ function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
96511
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
96512
+ }
96466
96513
  function emitBuildInfo(writeFileCallback) {
96467
96514
  ts.Debug.assert(!ts.outFile(options));
96468
96515
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitBuildInfo", {}, true);
@@ -98640,6 +98687,7 @@ var ts;
98640
98687
  }
98641
98688
  }
98642
98689
  }
98690
+ BuilderState.updateExportedModules = updateExportedModules;
98643
98691
  function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
98644
98692
  var _a;
98645
98693
  if (exportedModulesMapCache) {
@@ -98966,29 +99014,30 @@ var ts;
98966
99014
  }
98967
99015
  return undefined;
98968
99016
  }
99017
+ function removeDiagnosticsOfLibraryFiles(state) {
99018
+ if (!state.cleanedDiagnosticsOfLibFiles) {
99019
+ state.cleanedDiagnosticsOfLibFiles = true;
99020
+ var program_1 = ts.Debug.checkDefined(state.program);
99021
+ var options_2 = program_1.getCompilerOptions();
99022
+ ts.forEach(program_1.getSourceFiles(), function (f) {
99023
+ return program_1.isSourceFileDefaultLibrary(f) &&
99024
+ !ts.skipTypeChecking(f, options_2, program_1) &&
99025
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
99026
+ });
99027
+ }
99028
+ }
98969
99029
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
98970
99030
  var _a;
98971
99031
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
98972
99032
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
98973
- if (!state.cleanedDiagnosticsOfLibFiles) {
98974
- state.cleanedDiagnosticsOfLibFiles = true;
98975
- var program_1 = ts.Debug.checkDefined(state.program);
98976
- var options_2 = program_1.getCompilerOptions();
98977
- ts.forEach(program_1.getSourceFiles(), function (f) {
98978
- return program_1.isSourceFileDefaultLibrary(f) &&
98979
- !ts.skipTypeChecking(f, options_2, program_1) &&
98980
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
98981
- });
98982
- }
99033
+ removeDiagnosticsOfLibraryFiles(state);
98983
99034
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
98984
99035
  return;
98985
99036
  }
98986
- else {
98987
- 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);
98988
- }
98989
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
98990
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
98991
- }
99037
+ 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);
99038
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
99039
+ return;
99040
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
98992
99041
  }
98993
99042
  function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
98994
99043
  removeSemanticDiagnosticsOf(state, path);
@@ -99016,11 +99065,32 @@ var ts;
99016
99065
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
99017
99066
  return newSignature !== oldSignature;
99018
99067
  }
99019
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
99020
- var _a, _b;
99021
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
99068
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
99069
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
99070
+ var result = keys && ts.forEachKey(keys, fn);
99071
+ if (result)
99072
+ return result;
99073
+ keys = state.exportedModulesMap.getKeys(filePath);
99074
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
99075
+ var _a;
99076
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99077
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
99078
+ fn(exportedFromPath) :
99079
+ undefined;
99080
+ });
99081
+ }
99082
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
99083
+ var _a;
99084
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
99085
+ return false;
99086
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
99087
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
99088
+ removeDiagnosticsOfLibraryFiles(state);
99089
+ return true;
99090
+ }
99091
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
99092
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
99022
99093
  return;
99023
- }
99024
99094
  if (!isChangedSignature(state, affectedFile.resolvedPath))
99025
99095
  return;
99026
99096
  if (state.compilerOptions.isolatedModules) {
@@ -99031,7 +99101,9 @@ var ts;
99031
99101
  var currentPath = queue.pop();
99032
99102
  if (!seenFileNamesMap.has(currentPath)) {
99033
99103
  seenFileNamesMap.set(currentPath, true);
99034
- fn(state, currentPath);
99104
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
99105
+ return;
99106
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
99035
99107
  if (isChangedSignature(state, currentPath)) {
99036
99108
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
99037
99109
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -99041,42 +99113,31 @@ var ts;
99041
99113
  }
99042
99114
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
99043
99115
  var seenFileAndExportsOfFile = new ts.Set();
99044
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
99045
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99046
- });
99047
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
99048
- var _a;
99049
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99050
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
99051
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99116
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
99117
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
99118
+ return true;
99119
+ var references = state.referencedMap.getKeys(exportedFromPath);
99120
+ return references && ts.forEachKey(references, function (filePath) {
99121
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99122
+ });
99052
99123
  });
99053
99124
  }
99054
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
99125
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
99055
99126
  var _a;
99056
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
99057
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
99058
- });
99059
- }
99060
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
99061
- var _a, _b, _c;
99062
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
99063
- return;
99064
- }
99065
- fn(state, filePath);
99127
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
99128
+ return undefined;
99129
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
99130
+ return true;
99131
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
99066
99132
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
99067
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
99068
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99133
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
99134
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99069
99135
  });
99070
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
99071
- var _a;
99072
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99073
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
99074
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99075
- });
99076
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
99136
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
99077
99137
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
99078
- fn(state, referencingFilePath);
99138
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, host);
99079
99139
  });
99140
+ return undefined;
99080
99141
  }
99081
99142
  function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
99082
99143
  if (isBuildInfoEmit) {
@@ -99398,7 +99459,43 @@ var ts;
99398
99459
  affected = program;
99399
99460
  }
99400
99461
  }
99401
- 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);
99462
+ return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
99463
+ getWriteFileUpdatingSignatureCallback(writeFile) :
99464
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile);
99465
+ }
99466
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
99467
+ return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
99468
+ var _a;
99469
+ if (ts.isDeclarationFileName(fileName)) {
99470
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
99471
+ var file = sourceFiles[0];
99472
+ var info = state.fileInfos.get(file.resolvedPath);
99473
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
99474
+ if (signature === file.version) {
99475
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
99476
+ if (newSignature !== file.version) {
99477
+ if (host.storeFilesChangingSignatureDuringEmit)
99478
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
99479
+ if (state.exportedModulesMap)
99480
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
99481
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
99482
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
99483
+ }
99484
+ else {
99485
+ info.signature = newSignature;
99486
+ if (state.exportedModulesMap)
99487
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
99488
+ }
99489
+ }
99490
+ }
99491
+ }
99492
+ if (writeFile)
99493
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99494
+ else if (host.writeFile)
99495
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99496
+ else
99497
+ state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99498
+ };
99402
99499
  }
99403
99500
  function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
99404
99501
  var _a;
@@ -99439,7 +99536,9 @@ var ts;
99439
99536
  }
99440
99537
  }
99441
99538
  }
99442
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
99539
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
99540
+ getWriteFileUpdatingSignatureCallback(writeFile) :
99541
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
99443
99542
  }
99444
99543
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
99445
99544
  while (true) {
@@ -101362,6 +101461,7 @@ var ts;
101362
101461
  createHash: ts.maybeBind(host, host.createHash),
101363
101462
  readDirectory: ts.maybeBind(host, host.readDirectory),
101364
101463
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
101464
+ storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
101365
101465
  };
101366
101466
  function writeFile(fileName, text, writeByteOrderMark, onError) {
101367
101467
  try {
@@ -101415,6 +101515,7 @@ var ts;
101415
101515
  createHash: ts.maybeBind(system, system.createHash),
101416
101516
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
101417
101517
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
101518
+ storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
101418
101519
  };
101419
101520
  }
101420
101521
  ts.createProgramHost = createProgramHost;
@@ -101491,6 +101592,7 @@ var ts;
101491
101592
  var host = ts.createCompilerHostWorker(options, undefined, system);
101492
101593
  host.createHash = ts.maybeBind(system, system.createHash);
101493
101594
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
101595
+ host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
101494
101596
  ts.setGetSourceFileAsHashVersioned(host, system);
101495
101597
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
101496
101598
  return host;