@typescript-deploys/pr-build 4.7.0-pr-48791-5 → 4.7.0-pr-48861-16

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 :
@@ -6057,6 +6057,7 @@ var ts;
6057
6057
  This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."),
6058
6058
  A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"),
6059
6059
  Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."),
6060
+ Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."),
6060
6061
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
6061
6062
  Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."),
6062
6063
  Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."),
@@ -11209,7 +11210,7 @@ var ts;
11209
11210
  ts.getScriptTargetFeatures = getScriptTargetFeatures;
11210
11211
  function getLiteralText(node, sourceFile, flags) {
11211
11212
  var _a;
11212
- if (canUseOriginalText(node, flags)) {
11213
+ if (sourceFile && canUseOriginalText(node, flags)) {
11213
11214
  return getSourceTextOfNodeFromSourceFile(sourceFile, node);
11214
11215
  }
11215
11216
  switch (node.kind) {
@@ -14324,10 +14325,10 @@ var ts;
14324
14325
  return ts.combinePaths(newDirPath, sourceFilePath);
14325
14326
  }
14326
14327
  ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
14327
- function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
14328
- host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
14328
+ function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
14329
+ host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
14329
14330
  diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
14330
- }, sourceFiles);
14331
+ }, sourceFiles, data);
14331
14332
  }
14332
14333
  ts.writeFile = writeFile;
14333
14334
  function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
@@ -27638,7 +27639,7 @@ var ts;
27638
27639
  return undefined;
27639
27640
  }
27640
27641
  return triState === 1 ?
27641
- parseParenthesizedArrowFunctionExpression(true, disallowReturnTypeInArrowFunction) :
27642
+ parseParenthesizedArrowFunctionExpression(true, false) :
27642
27643
  tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); });
27643
27644
  }
27644
27645
  function isParenthesizedArrowFunctionExpression() {
@@ -30687,7 +30688,8 @@ var ts;
30687
30688
  if (!comment) {
30688
30689
  comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
30689
30690
  }
30690
- return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
30691
+ var end = comment !== undefined ? getNodePos() : typeExpression.end;
30692
+ return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
30691
30693
  }
30692
30694
  function escapedTextsEqual(a, b) {
30693
30695
  while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
@@ -39568,6 +39570,7 @@ var ts;
39568
39570
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
39569
39571
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
39570
39572
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
39573
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]);
39571
39574
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; });
39572
39575
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; });
39573
39576
  var uniqueLiteralType = createIntrinsicType(131072, "never");
@@ -42162,7 +42165,7 @@ var ts;
42162
42165
  }
42163
42166
  }
42164
42167
  function getExportSymbolOfValueSymbolIfExported(symbol) {
42165
- return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol);
42168
+ return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 && symbol.exportSymbol || symbol);
42166
42169
  }
42167
42170
  function symbolIsValue(symbol) {
42168
42171
  return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol));
@@ -48557,7 +48560,7 @@ var ts;
48557
48560
  var typeVariable = getHomomorphicTypeVariable(type);
48558
48561
  if (typeVariable && !type.declaration.nameType) {
48559
48562
  var constraint = getConstraintOfTypeParameter(typeVariable);
48560
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
48563
+ if (constraint && isArrayOrTupleType(constraint)) {
48561
48564
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
48562
48565
  }
48563
48566
  }
@@ -48866,7 +48869,7 @@ var ts;
48866
48869
  function isApplicableIndexType(source, target) {
48867
48870
  return isTypeAssignableTo(source, target) ||
48868
48871
  target === stringType && isTypeAssignableTo(source, numberType) ||
48869
- target === numberType && !!(source.flags & 128) && ts.isNumericLiteralName(source.value);
48872
+ target === numberType && (source === numericStringType || !!(source.flags & 128) && ts.isNumericLiteralName(source.value));
48870
48873
  }
48871
48874
  function getIndexInfosOfStructuredType(type) {
48872
48875
  if (type.flags & 3670016) {
@@ -49772,6 +49775,18 @@ var ts;
49772
49775
  constraints = ts.append(constraints, constraint);
49773
49776
  }
49774
49777
  }
49778
+ else if (type.flags & 262144 && parent.kind === 195 && node === parent.type) {
49779
+ var mappedType = getTypeFromTypeNode(parent);
49780
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
49781
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
49782
+ if (typeParameter) {
49783
+ var constraint = getConstraintOfTypeParameter(typeParameter);
49784
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
49785
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
49786
+ }
49787
+ }
49788
+ }
49789
+ }
49775
49790
  node = parent;
49776
49791
  }
49777
49792
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -50658,7 +50673,7 @@ var ts;
50658
50673
  while (i > 0) {
50659
50674
  i--;
50660
50675
  var t = types[i];
50661
- var remove = t.flags & 4 && includes & 128 ||
50676
+ var remove = t.flags & 4 && includes & (128 | 134217728 | 268435456) ||
50662
50677
  t.flags & 8 && includes & 256 ||
50663
50678
  t.flags & 64 && includes & 2048 ||
50664
50679
  t.flags & 4096 && includes & 8192;
@@ -50781,7 +50796,7 @@ var ts;
50781
50796
  if (!strictNullChecks && includes & 98304) {
50782
50797
  return includes & 32768 ? undefinedType : nullType;
50783
50798
  }
50784
- if (includes & 4 && includes & 128 ||
50799
+ if (includes & 4 && includes & (128 | 134217728 | 268435456) ||
50785
50800
  includes & 8 && includes & 256 ||
50786
50801
  includes & 64 && includes & 2048 ||
50787
50802
  includes & 4096 && includes & 8192) {
@@ -52449,7 +52464,7 @@ var ts;
52449
52464
  if (!type.declaration.nameType) {
52450
52465
  var constraint = void 0;
52451
52466
  if (isArrayType(t) || t.flags & 1 && findResolutionCycleStartIndex(typeVariable, 4) < 0 &&
52452
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
52467
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
52453
52468
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
52454
52469
  }
52455
52470
  if (isGenericTupleType(t)) {
@@ -53744,7 +53759,7 @@ var ts;
53744
53759
  }
53745
53760
  return false;
53746
53761
  }
53747
- return isTupleType(target) || isArrayType(target);
53762
+ return isArrayOrTupleType(target);
53748
53763
  }
53749
53764
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
53750
53765
  if (reportErrors) {
@@ -53840,7 +53855,7 @@ var ts;
53840
53855
  unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
53841
53856
  recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
53842
53857
  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); }))) {
53858
+ isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144); }))) {
53844
53859
  inPropertyCheck = true;
53845
53860
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4, recursionFlags);
53846
53861
  inPropertyCheck = false;
@@ -54375,6 +54390,18 @@ var ts;
54375
54390
  }
54376
54391
  }
54377
54392
  }
54393
+ if (relation === comparableRelation && sourceFlags & 262144) {
54394
+ var constraint = getConstraintOfTypeParameter(source);
54395
+ if (constraint && hasNonCircularBaseConstraint(source)) {
54396
+ while (constraint && constraint.flags & 262144) {
54397
+ if (result = isRelatedTo(constraint, target, 1, false)) {
54398
+ return result;
54399
+ }
54400
+ constraint = getConstraintOfTypeParameter(constraint);
54401
+ }
54402
+ }
54403
+ return 0;
54404
+ }
54378
54405
  }
54379
54406
  else if (targetFlags & 4194304) {
54380
54407
  var targetType_1 = target.type;
@@ -54525,18 +54552,18 @@ var ts;
54525
54552
  }
54526
54553
  if (sourceFlags & 8650752) {
54527
54554
  if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
54528
- var constraint = getConstraintOfType(source);
54529
- if (!strictNullChecks && (!constraint || (sourceFlags & 262144 && constraint.flags & 1))) {
54555
+ var constraint = getConstraintOfType(source) || unknownType;
54556
+ if (!strictNullChecks && (!getConstraintOfType(source) || (sourceFlags & 262144 && constraint.flags & 1))) {
54530
54557
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) {
54531
54558
  resetErrorInfo(saveErrorInfo);
54532
54559
  return result;
54533
54560
  }
54534
54561
  }
54535
- else if (constraint && (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState))) {
54562
+ if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
54536
54563
  resetErrorInfo(saveErrorInfo);
54537
54564
  return result;
54538
54565
  }
54539
- else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState))) {
54566
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) {
54540
54567
  resetErrorInfo(saveErrorInfo);
54541
54568
  return result;
54542
54569
  }
@@ -54659,7 +54686,7 @@ var ts;
54659
54686
  return varianceResult;
54660
54687
  }
54661
54688
  }
54662
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
54689
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
54663
54690
  if (relation !== identityRelation) {
54664
54691
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3, reportErrors);
54665
54692
  }
@@ -54953,7 +54980,7 @@ var ts;
54953
54980
  }
54954
54981
  var result = -1;
54955
54982
  if (isTupleType(target)) {
54956
- if (isArrayType(source) || isTupleType(source)) {
54983
+ if (isArrayOrTupleType(source)) {
54957
54984
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
54958
54985
  return 0;
54959
54986
  }
@@ -55800,6 +55827,9 @@ var ts;
55800
55827
  function isReadonlyArrayType(type) {
55801
55828
  return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType;
55802
55829
  }
55830
+ function isArrayOrTupleType(type) {
55831
+ return isArrayType(type) || isTupleType(type);
55832
+ }
55803
55833
  function isMutableArrayOrTuple(type) {
55804
55834
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
55805
55835
  }
@@ -56197,7 +56227,7 @@ var ts;
56197
56227
  else if (type.flags & 2097152) {
56198
56228
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
56199
56229
  }
56200
- else if (isArrayType(type) || isTupleType(type)) {
56230
+ else if (isArrayOrTupleType(type)) {
56201
56231
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
56202
56232
  }
56203
56233
  if (result && context === undefined) {
@@ -56223,7 +56253,7 @@ var ts;
56223
56253
  }
56224
56254
  }
56225
56255
  }
56226
- if (isArrayType(type) || isTupleType(type)) {
56256
+ if (isArrayOrTupleType(type)) {
56227
56257
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
56228
56258
  var t = _c[_b];
56229
56259
  if (reportWideningErrorsInType(t)) {
@@ -57125,7 +57155,7 @@ var ts;
57125
57155
  }
57126
57156
  }
57127
57157
  if (!typesDefinitelyUnrelated(source, target)) {
57128
- if (isArrayType(source) || isTupleType(source)) {
57158
+ if (isArrayOrTupleType(source)) {
57129
57159
  if (isTupleType(target)) {
57130
57160
  var sourceArity = getTypeReferenceArity(source);
57131
57161
  var targetArity = getTypeReferenceArity(target);
@@ -61316,6 +61346,7 @@ var ts;
61316
61346
  }
61317
61347
  }
61318
61348
  else {
61349
+ error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
61319
61350
  typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
61320
61351
  }
61321
61352
  }
@@ -63129,8 +63160,14 @@ var ts;
63129
63160
  var parameterRange = hasRestParameter ? min
63130
63161
  : min < max ? min + "-" + max
63131
63162
  : min;
63132
- var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
63133
- : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
63163
+ var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node);
63164
+ if (isVoidPromiseError && ts.isInJSFile(node)) {
63165
+ return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments);
63166
+ }
63167
+ var error = hasRestParameter
63168
+ ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
63169
+ : isVoidPromiseError
63170
+ ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
63134
63171
  : ts.Diagnostics.Expected_0_arguments_but_got_1;
63135
63172
  if (min < args.length && args.length < max) {
63136
63173
  return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove);
@@ -63206,6 +63243,7 @@ var ts;
63206
63243
  var args = getEffectiveCallArguments(node);
63207
63244
  var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
63208
63245
  var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
63246
+ argCheckMode |= checkMode & 32;
63209
63247
  var candidatesForArgumentError;
63210
63248
  var candidateForArgumentArityError;
63211
63249
  var candidateForTypeArgumentError;
@@ -63376,7 +63414,7 @@ var ts;
63376
63414
  continue;
63377
63415
  }
63378
63416
  if (argCheckMode) {
63379
- argCheckMode = 0;
63417
+ argCheckMode = checkMode & 32;
63380
63418
  if (inferenceContext) {
63381
63419
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
63382
63420
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -90213,6 +90251,7 @@ var ts;
90213
90251
  else {
90214
90252
  printer.writeFile(sourceFile, writer, sourceMapGenerator);
90215
90253
  }
90254
+ var sourceMapUrlPos;
90216
90255
  if (sourceMapGenerator) {
90217
90256
  if (sourceMapDataList) {
90218
90257
  sourceMapDataList.push({
@@ -90224,6 +90263,7 @@ var ts;
90224
90263
  if (sourceMappingURL) {
90225
90264
  if (!writer.isAtStartOfLine())
90226
90265
  writer.rawWrite(newLine);
90266
+ sourceMapUrlPos = writer.getTextPos();
90227
90267
  writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
90228
90268
  }
90229
90269
  if (sourceMapFilePath) {
@@ -90234,7 +90274,7 @@ var ts;
90234
90274
  else {
90235
90275
  writer.writeLine();
90236
90276
  }
90237
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
90277
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
90238
90278
  writer.clear();
90239
90279
  }
90240
90280
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -90718,7 +90758,7 @@ var ts;
90718
90758
  setWriter(undefined, undefined);
90719
90759
  }
90720
90760
  function getCurrentLineMap() {
90721
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
90761
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
90722
90762
  }
90723
90763
  function emit(node, parenthesizerRule) {
90724
90764
  if (node === undefined)
@@ -91802,7 +91842,7 @@ var ts;
91802
91842
  increaseIndent();
91803
91843
  }
91804
91844
  var preferNewLine = node.multiLine ? 65536 : 0;
91805
- var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
91845
+ var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
91806
91846
  emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
91807
91847
  if (indentedFlag) {
91808
91848
  decreaseIndent();
@@ -92129,7 +92169,7 @@ var ts;
92129
92169
  }
92130
92170
  function emitExpressionStatement(node) {
92131
92171
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
92132
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
92172
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
92133
92173
  writeTrailingSemicolon();
92134
92174
  }
92135
92175
  }
@@ -92408,7 +92448,7 @@ var ts;
92408
92448
  if (body.multiLine) {
92409
92449
  return false;
92410
92450
  }
92411
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
92451
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
92412
92452
  return false;
92413
92453
  }
92414
92454
  if (getLeadingLineTerminatorCount(body, body.statements, 2)
@@ -92433,12 +92473,7 @@ var ts;
92433
92473
  var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
92434
92474
  ? emitBlockFunctionBodyOnSingleLine
92435
92475
  : emitBlockFunctionBodyWorker;
92436
- if (emitBodyWithDetachedComments) {
92437
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
92438
- }
92439
- else {
92440
- emitBlockFunctionBody(body);
92441
- }
92476
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
92442
92477
  decreaseIndent();
92443
92478
  writeToken(19, body.statements.end, writePunctuation, body);
92444
92479
  onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
@@ -92822,7 +92857,8 @@ var ts;
92822
92857
  }
92823
92858
  function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
92824
92859
  var emitAsSingleStatement = statements.length === 1 &&
92825
- (ts.nodeIsSynthesized(parentNode) ||
92860
+ (!currentSourceFile ||
92861
+ ts.nodeIsSynthesized(parentNode) ||
92826
92862
  ts.nodeIsSynthesized(statements[0]) ||
92827
92863
  ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
92828
92864
  var format = 163969;
@@ -93034,14 +93070,12 @@ var ts;
93034
93070
  function emitSourceFile(node) {
93035
93071
  writeLine();
93036
93072
  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
- }
93073
+ var shouldEmitDetachedComment = statements.length === 0 ||
93074
+ !ts.isPrologueDirective(statements[0]) ||
93075
+ ts.nodeIsSynthesized(statements[0]);
93076
+ if (shouldEmitDetachedComment) {
93077
+ emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
93078
+ return;
93045
93079
  }
93046
93080
  emitSourceFileWorker(node);
93047
93081
  }
@@ -93419,7 +93453,7 @@ var ts;
93419
93453
  onBeforeEmitNodeArray(children);
93420
93454
  }
93421
93455
  if (isEmpty) {
93422
- if (format & 1 && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
93456
+ if (format & 1 && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
93423
93457
  writeLine();
93424
93458
  }
93425
93459
  else if (format & 256 && !(format & 524288)) {
@@ -93650,7 +93684,7 @@ var ts;
93650
93684
  }
93651
93685
  var firstChild_1 = children[0];
93652
93686
  if (firstChild_1 === undefined) {
93653
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93687
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93654
93688
  }
93655
93689
  if (firstChild_1.pos === nextListElementPos) {
93656
93690
  return 0;
@@ -93658,7 +93692,7 @@ var ts;
93658
93692
  if (firstChild_1.kind === 11) {
93659
93693
  return 0;
93660
93694
  }
93661
- if (parentNode &&
93695
+ if (currentSourceFile && parentNode &&
93662
93696
  !ts.positionIsSynthesized(parentNode.pos) &&
93663
93697
  !ts.nodeIsSynthesized(firstChild_1) &&
93664
93698
  (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -93681,7 +93715,7 @@ var ts;
93681
93715
  if (nextNode.kind === 11) {
93682
93716
  return 0;
93683
93717
  }
93684
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
93718
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
93685
93719
  if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
93686
93720
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
93687
93721
  }
@@ -93706,9 +93740,9 @@ var ts;
93706
93740
  }
93707
93741
  var lastChild = ts.lastOrUndefined(children);
93708
93742
  if (lastChild === undefined) {
93709
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93743
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
93710
93744
  }
93711
- if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
93745
+ if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
93712
93746
  if (preserveSourceNewlines) {
93713
93747
  var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
93714
93748
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -93765,7 +93799,7 @@ var ts;
93765
93799
  if (ts.getStartsOnNewLine(node2)) {
93766
93800
  return 1;
93767
93801
  }
93768
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
93802
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
93769
93803
  if (preserveSourceNewlines) {
93770
93804
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
93771
93805
  }
@@ -93775,7 +93809,7 @@ var ts;
93775
93809
  }
93776
93810
  function isEmptyBlock(block) {
93777
93811
  return block.statements.length === 0
93778
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
93812
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
93779
93813
  }
93780
93814
  function skipSynthesizedParentheses(node) {
93781
93815
  while (node.kind === 212 && ts.nodeIsSynthesized(node)) {
@@ -93787,16 +93821,23 @@ var ts;
93787
93821
  if (ts.isGeneratedIdentifier(node)) {
93788
93822
  return generateName(node);
93789
93823
  }
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) {
93824
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
93794
93825
  return getTextOfNode(node.textSourceNode, includeTrivia);
93795
93826
  }
93796
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
93797
- return node.text;
93827
+ var sourceFile = currentSourceFile;
93828
+ var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
93829
+ if (ts.isMemberName(node)) {
93830
+ if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
93831
+ return ts.idText(node);
93832
+ }
93798
93833
  }
93799
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
93834
+ else {
93835
+ ts.Debug.assertNode(node, ts.isLiteralExpression);
93836
+ if (!canUseSourceFile) {
93837
+ return node.text;
93838
+ }
93839
+ }
93840
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
93800
93841
  }
93801
93842
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
93802
93843
  if (node.kind === 10 && node.textSourceNode) {
@@ -94287,7 +94328,7 @@ var ts;
94287
94328
  return true;
94288
94329
  }
94289
94330
  function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
94290
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94331
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94291
94332
  return;
94292
94333
  if (!hasWrittenComment) {
94293
94334
  ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -94313,7 +94354,7 @@ var ts;
94313
94354
  forEachTrailingCommentToEmit(pos, emitTrailingComment);
94314
94355
  }
94315
94356
  function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
94316
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94357
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94317
94358
  return;
94318
94359
  if (!writer.isAtStartOfLine()) {
94319
94360
  writer.writeSpace(" ");
@@ -94334,6 +94375,8 @@ var ts;
94334
94375
  exitComment();
94335
94376
  }
94336
94377
  function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
94378
+ if (!currentSourceFile)
94379
+ return;
94337
94380
  emitPos(commentPos);
94338
94381
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
94339
94382
  emitPos(commentEnd);
@@ -94342,6 +94385,8 @@ var ts;
94342
94385
  }
94343
94386
  }
94344
94387
  function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
94388
+ if (!currentSourceFile)
94389
+ return;
94345
94390
  emitPos(commentPos);
94346
94391
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
94347
94392
  emitPos(commentEnd);
@@ -94371,6 +94416,8 @@ var ts;
94371
94416
  return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
94372
94417
  }
94373
94418
  function forEachLeadingCommentWithoutDetachedComments(cb) {
94419
+ if (!currentSourceFile)
94420
+ return;
94374
94421
  var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
94375
94422
  if (detachedCommentsInfo.length - 1) {
94376
94423
  detachedCommentsInfo.pop();
@@ -94381,7 +94428,7 @@ var ts;
94381
94428
  ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
94382
94429
  }
94383
94430
  function emitDetachedCommentsAndUpdateCommentsInfo(range) {
94384
- var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
94431
+ var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
94385
94432
  if (currentDetachedCommentInfo) {
94386
94433
  if (detachedCommentsInfo) {
94387
94434
  detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -94392,14 +94439,14 @@ var ts;
94392
94439
  }
94393
94440
  }
94394
94441
  function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
94395
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
94442
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
94396
94443
  return;
94397
94444
  emitPos(commentPos);
94398
94445
  ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
94399
94446
  emitPos(commentEnd);
94400
94447
  }
94401
94448
  function isTripleSlashComment(commentPos, commentEnd) {
94402
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
94449
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
94403
94450
  }
94404
94451
  function getParsedSourceMap(node) {
94405
94452
  if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
@@ -95206,7 +95253,11 @@ var ts;
95206
95253
  return newValue;
95207
95254
  };
95208
95255
  if (originalWriteFile) {
95209
- host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
95256
+ host.writeFile = function (fileName, data) {
95257
+ var rest = [];
95258
+ for (var _i = 2; _i < arguments.length; _i++) {
95259
+ rest[_i - 2] = arguments[_i];
95260
+ }
95210
95261
  var key = toPath(fileName);
95211
95262
  fileExistsCache.delete(key);
95212
95263
  var value = readFileCache.get(key);
@@ -95220,7 +95271,7 @@ var ts;
95220
95271
  sourceFileCache.delete(key);
95221
95272
  }
95222
95273
  }
95223
- originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
95274
+ originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
95224
95275
  };
95225
95276
  }
95226
95277
  if (originalDirectoryExists && originalCreateDirectory) {
@@ -96042,6 +96093,7 @@ var ts;
96042
96093
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
96043
96094
  getFileIncludeReasons: function () { return fileReasons; },
96044
96095
  structureIsReused: structureIsReused,
96096
+ writeFile: writeFile,
96045
96097
  };
96046
96098
  onProgramCreateComplete();
96047
96099
  fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) {
@@ -96445,7 +96497,7 @@ var ts;
96445
96497
  getProjectReferenceRedirect: getProjectReferenceRedirect,
96446
96498
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
96447
96499
  getSymlinkCache: getSymlinkCache,
96448
- writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
96500
+ writeFile: writeFileCallback || writeFile,
96449
96501
  isEmitBlocked: isEmitBlocked,
96450
96502
  readFile: function (f) { return host.readFile(f); },
96451
96503
  fileExists: function (f) {
@@ -96463,6 +96515,9 @@ var ts;
96463
96515
  getFileIncludeReasons: program.getFileIncludeReasons,
96464
96516
  };
96465
96517
  }
96518
+ function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
96519
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
96520
+ }
96466
96521
  function emitBuildInfo(writeFileCallback) {
96467
96522
  ts.Debug.assert(!ts.outFile(options));
96468
96523
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitBuildInfo", {}, true);
@@ -98640,6 +98695,7 @@ var ts;
98640
98695
  }
98641
98696
  }
98642
98697
  }
98698
+ BuilderState.updateExportedModules = updateExportedModules;
98643
98699
  function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
98644
98700
  var _a;
98645
98701
  if (exportedModulesMapCache) {
@@ -98966,29 +99022,30 @@ var ts;
98966
99022
  }
98967
99023
  return undefined;
98968
99024
  }
99025
+ function removeDiagnosticsOfLibraryFiles(state) {
99026
+ if (!state.cleanedDiagnosticsOfLibFiles) {
99027
+ state.cleanedDiagnosticsOfLibFiles = true;
99028
+ var program_1 = ts.Debug.checkDefined(state.program);
99029
+ var options_2 = program_1.getCompilerOptions();
99030
+ ts.forEach(program_1.getSourceFiles(), function (f) {
99031
+ return program_1.isSourceFileDefaultLibrary(f) &&
99032
+ !ts.skipTypeChecking(f, options_2, program_1) &&
99033
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
99034
+ });
99035
+ }
99036
+ }
98969
99037
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
98970
99038
  var _a;
98971
99039
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
98972
99040
  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
- }
99041
+ removeDiagnosticsOfLibraryFiles(state);
98983
99042
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
98984
99043
  return;
98985
99044
  }
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
- }
99045
+ 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);
99046
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
99047
+ return;
99048
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
98992
99049
  }
98993
99050
  function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
98994
99051
  removeSemanticDiagnosticsOf(state, path);
@@ -99016,11 +99073,32 @@ var ts;
99016
99073
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
99017
99074
  return newSignature !== oldSignature;
99018
99075
  }
99019
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
99020
- var _a, _b;
99021
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
99076
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
99077
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
99078
+ var result = keys && ts.forEachKey(keys, fn);
99079
+ if (result)
99080
+ return result;
99081
+ keys = state.exportedModulesMap.getKeys(filePath);
99082
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
99083
+ var _a;
99084
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99085
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
99086
+ fn(exportedFromPath) :
99087
+ undefined;
99088
+ });
99089
+ }
99090
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
99091
+ var _a;
99092
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
99093
+ return false;
99094
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
99095
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
99096
+ removeDiagnosticsOfLibraryFiles(state);
99097
+ return true;
99098
+ }
99099
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
99100
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
99022
99101
  return;
99023
- }
99024
99102
  if (!isChangedSignature(state, affectedFile.resolvedPath))
99025
99103
  return;
99026
99104
  if (state.compilerOptions.isolatedModules) {
@@ -99031,7 +99109,9 @@ var ts;
99031
99109
  var currentPath = queue.pop();
99032
99110
  if (!seenFileNamesMap.has(currentPath)) {
99033
99111
  seenFileNamesMap.set(currentPath, true);
99034
- fn(state, currentPath);
99112
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
99113
+ return;
99114
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
99035
99115
  if (isChangedSignature(state, currentPath)) {
99036
99116
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
99037
99117
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -99041,42 +99121,31 @@ var ts;
99041
99121
  }
99042
99122
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
99043
99123
  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);
99124
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
99125
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
99126
+ return true;
99127
+ var references = state.referencedMap.getKeys(exportedFromPath);
99128
+ return references && ts.forEachKey(references, function (filePath) {
99129
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99130
+ });
99052
99131
  });
99053
99132
  }
99054
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
99133
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
99055
99134
  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);
99135
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
99136
+ return undefined;
99137
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
99138
+ return true;
99139
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
99066
99140
  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);
99141
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
99142
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99069
99143
  });
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) {
99144
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
99077
99145
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
99078
- fn(state, referencingFilePath);
99146
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, host);
99079
99147
  });
99148
+ return undefined;
99080
99149
  }
99081
99150
  function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
99082
99151
  if (isBuildInfoEmit) {
@@ -99398,7 +99467,43 @@ var ts;
99398
99467
  affected = program;
99399
99468
  }
99400
99469
  }
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);
99470
+ return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
99471
+ getWriteFileUpdatingSignatureCallback(writeFile) :
99472
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile);
99473
+ }
99474
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
99475
+ return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
99476
+ var _a;
99477
+ if (ts.isDeclarationFileName(fileName)) {
99478
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
99479
+ var file = sourceFiles[0];
99480
+ var info = state.fileInfos.get(file.resolvedPath);
99481
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
99482
+ if (signature === file.version) {
99483
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
99484
+ if (newSignature !== file.version) {
99485
+ if (host.storeFilesChangingSignatureDuringEmit)
99486
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
99487
+ if (state.exportedModulesMap)
99488
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
99489
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
99490
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
99491
+ }
99492
+ else {
99493
+ info.signature = newSignature;
99494
+ if (state.exportedModulesMap)
99495
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
99496
+ }
99497
+ }
99498
+ }
99499
+ }
99500
+ if (writeFile)
99501
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99502
+ else if (host.writeFile)
99503
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99504
+ else
99505
+ state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99506
+ };
99402
99507
  }
99403
99508
  function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
99404
99509
  var _a;
@@ -99439,7 +99544,9 @@ var ts;
99439
99544
  }
99440
99545
  }
99441
99546
  }
99442
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
99547
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
99548
+ getWriteFileUpdatingSignatureCallback(writeFile) :
99549
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
99443
99550
  }
99444
99551
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
99445
99552
  while (true) {
@@ -101362,6 +101469,7 @@ var ts;
101362
101469
  createHash: ts.maybeBind(host, host.createHash),
101363
101470
  readDirectory: ts.maybeBind(host, host.readDirectory),
101364
101471
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
101472
+ storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
101365
101473
  };
101366
101474
  function writeFile(fileName, text, writeByteOrderMark, onError) {
101367
101475
  try {
@@ -101415,6 +101523,7 @@ var ts;
101415
101523
  createHash: ts.maybeBind(system, system.createHash),
101416
101524
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
101417
101525
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
101526
+ storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
101418
101527
  };
101419
101528
  }
101420
101529
  ts.createProgramHost = createProgramHost;
@@ -101491,6 +101600,7 @@ var ts;
101491
101600
  var host = ts.createCompilerHostWorker(options, undefined, system);
101492
101601
  host.createHash = ts.maybeBind(system, system.createHash);
101493
101602
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
101603
+ host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
101494
101604
  ts.setGetSourceFileAsHashVersioned(host, system);
101495
101605
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
101496
101606
  return host;