@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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-insiders.20220420";
92
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220427";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -14691,7 +14691,7 @@ var ts;
14691
14691
  var _a;
14692
14692
  // If we don't need to downlevel and we can reach the original source text using
14693
14693
  // the node's parent reference, then simply get the text as it was originally written.
14694
- if (canUseOriginalText(node, flags)) {
14694
+ if (sourceFile && canUseOriginalText(node, flags)) {
14695
14695
  return getSourceTextOfNodeFromSourceFile(sourceFile, node);
14696
14696
  }
14697
14697
  // If we can't reach the original source text, use the canonical form if it's a number,
@@ -18282,10 +18282,10 @@ var ts;
18282
18282
  return ts.combinePaths(newDirPath, sourceFilePath);
18283
18283
  }
18284
18284
  ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
18285
- function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
18286
- host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
18285
+ function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
18286
+ host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
18287
18287
  diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
18288
- }, sourceFiles);
18288
+ }, sourceFiles, data);
18289
18289
  }
18290
18290
  ts.writeFile = writeFile;
18291
18291
  function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
@@ -34212,7 +34212,7 @@ var ts;
34212
34212
  return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos);
34213
34213
  }
34214
34214
  // It wasn't an assignment or a lambda. This is a conditional expression:
34215
- return parseConditionalExpressionRest(expr, pos, disallowReturnTypeInArrowFunction);
34215
+ return parseConditionalExpressionRest(expr, pos);
34216
34216
  }
34217
34217
  function isYieldExpression() {
34218
34218
  if (token() === 125 /* YieldKeyword */) {
@@ -34287,7 +34287,7 @@ var ts;
34287
34287
  // it out, but don't allow any ambiguity, and return 'undefined' if this could be an
34288
34288
  // expression instead.
34289
34289
  return triState === 1 /* True */ ?
34290
- parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, disallowReturnTypeInArrowFunction) :
34290
+ parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*disallowReturnTypeInArrowFunction*/ false) :
34291
34291
  tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); });
34292
34292
  }
34293
34293
  // True -> We definitely expect a parenthesized arrow function here.
@@ -34502,8 +34502,13 @@ var ts;
34502
34502
  // This is a valid arrow function with "z" as the return type.
34503
34503
  //
34504
34504
  // But, if we're in the true side of a conditional expression, this colon
34505
- // terminates the expression, so we cannot allow a return type, even if we aren't
34505
+ // terminates the expression, so we cannot allow a return type if we aren't
34506
34506
  // certain whether or not the preceding text was parsed as a parameter list.
34507
+ //
34508
+ // For example,
34509
+ // a() ? (b: number, c?: string): void => d() : e
34510
+ // is determined by isParenthesizedArrowFunctionExpression to unambiguously
34511
+ // be an arrow expression, so we allow a return type.
34507
34512
  if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) {
34508
34513
  return undefined;
34509
34514
  }
@@ -34573,7 +34578,7 @@ var ts;
34573
34578
  topLevel = savedTopLevel;
34574
34579
  return node;
34575
34580
  }
34576
- function parseConditionalExpressionRest(leftOperand, pos, disallowReturnTypeInArrowFunction) {
34581
+ function parseConditionalExpressionRest(leftOperand, pos) {
34577
34582
  // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
34578
34583
  var questionToken = parseOptionalToken(57 /* QuestionToken */);
34579
34584
  if (!questionToken) {
@@ -34583,7 +34588,7 @@ var ts;
34583
34588
  // we do not that for the 'whenFalse' part.
34584
34589
  var colonToken;
34585
34590
  return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
34586
- ? parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction) // inherit disallowReturnTypeInArrowFunction in false side
34591
+ ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true)
34587
34592
  : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
34588
34593
  }
34589
34594
  function parseBinaryExpressionOrHigher(precedence) {
@@ -48320,6 +48325,7 @@ var ts;
48320
48325
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
48321
48326
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
48322
48327
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
48328
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
48323
48329
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
48324
48330
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48325
48331
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
@@ -51301,7 +51307,7 @@ var ts;
51301
51307
  }
51302
51308
  }
51303
51309
  function getExportSymbolOfValueSymbolIfExported(symbol) {
51304
- return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol);
51310
+ return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol);
51305
51311
  }
51306
51312
  function symbolIsValue(symbol) {
51307
51313
  return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol));
@@ -58704,7 +58710,7 @@ var ts;
58704
58710
  var typeVariable = getHomomorphicTypeVariable(type);
58705
58711
  if (typeVariable && !type.declaration.nameType) {
58706
58712
  var constraint = getConstraintOfTypeParameter(typeVariable);
58707
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
58713
+ if (constraint && isArrayOrTupleType(constraint)) {
58708
58714
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
58709
58715
  }
58710
58716
  }
@@ -59066,10 +59072,10 @@ var ts;
59066
59072
  }
59067
59073
  function isApplicableIndexType(source, target) {
59068
59074
  // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
59069
- // signature applies to types assignable to 'number' and numeric string literal types.
59075
+ // signature applies to types assignable to 'number', `${number}` and numeric string literal types.
59070
59076
  return isTypeAssignableTo(source, target) ||
59071
59077
  target === stringType && isTypeAssignableTo(source, numberType) ||
59072
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
59078
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value));
59073
59079
  }
59074
59080
  function getIndexInfosOfStructuredType(type) {
59075
59081
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60085,6 +60091,20 @@ var ts;
60085
60091
  constraints = ts.append(constraints, constraint);
60086
60092
  }
60087
60093
  }
60094
+ // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the
60095
+ // template type XXX, K has an added constraint of number | `${number}`.
60096
+ else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) {
60097
+ var mappedType = getTypeFromTypeNode(parent);
60098
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
60099
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
60100
+ if (typeParameter) {
60101
+ var constraint = getConstraintOfTypeParameter(typeParameter);
60102
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
60103
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
60104
+ }
60105
+ }
60106
+ }
60107
+ }
60088
60108
  node = parent;
60089
60109
  }
60090
60110
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -61052,7 +61072,7 @@ var ts;
61052
61072
  while (i > 0) {
61053
61073
  i--;
61054
61074
  var t = types[i];
61055
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61075
+ var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61056
61076
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61057
61077
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61058
61078
  t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
@@ -61211,7 +61231,7 @@ var ts;
61211
61231
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
61212
61232
  return includes & 32768 /* Undefined */ ? undefinedType : nullType;
61213
61233
  }
61214
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61234
+ if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61215
61235
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61216
61236
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61217
61237
  includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
@@ -63095,7 +63115,7 @@ var ts;
63095
63115
  if (!type.declaration.nameType) {
63096
63116
  var constraint = void 0;
63097
63117
  if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
63098
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
63118
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
63099
63119
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
63100
63120
  }
63101
63121
  if (isGenericTupleType(t)) {
@@ -64533,7 +64553,7 @@ var ts;
64533
64553
  }
64534
64554
  return false;
64535
64555
  }
64536
- return isTupleType(target) || isArrayType(target);
64556
+ return isArrayOrTupleType(target);
64537
64557
  }
64538
64558
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
64539
64559
  if (reportErrors) {
@@ -64663,7 +64683,7 @@ var ts;
64663
64683
  // We suppress recursive intersection property checks because they can generate lots of work when relating
64664
64684
  // recursive intersections that are structurally similar but not exactly identical. See #37854.
64665
64685
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
64666
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) {
64686
+ isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) {
64667
64687
  inPropertyCheck = true;
64668
64688
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
64669
64689
  inPropertyCheck = false;
@@ -65290,6 +65310,20 @@ var ts;
65290
65310
  }
65291
65311
  }
65292
65312
  }
65313
+ if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) {
65314
+ // This is a carve-out in comparability to essentially forbid comparing a type parameter
65315
+ // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
65316
+ var constraint = getConstraintOfTypeParameter(source);
65317
+ if (constraint && hasNonCircularBaseConstraint(source)) {
65318
+ while (constraint && constraint.flags & 262144 /* TypeParameter */) {
65319
+ if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) {
65320
+ return result;
65321
+ }
65322
+ constraint = getConstraintOfTypeParameter(constraint);
65323
+ }
65324
+ }
65325
+ return 0 /* False */;
65326
+ }
65293
65327
  }
65294
65328
  else if (targetFlags & 4194304 /* Index */) {
65295
65329
  var targetType_1 = target.type;
@@ -65493,7 +65527,7 @@ var ts;
65493
65527
  if (sourceFlags & 8650752 /* TypeVariable */) {
65494
65528
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65495
65529
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65496
- var constraint = getConstraintOfType(source);
65530
+ var constraint = getConstraintOfType(source) || unknownType;
65497
65531
  if (!strictNullChecks && (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */))) {
65498
65532
  // A type variable with no constraint is not related to the non-primitive object type.
65499
65533
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
@@ -65502,12 +65536,12 @@ var ts;
65502
65536
  }
65503
65537
  }
65504
65538
  // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
65505
- else if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) {
65539
+ else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65506
65540
  resetErrorInfo(saveErrorInfo);
65507
65541
  return result;
65508
65542
  }
65509
65543
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
65510
- else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState))) {
65544
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
65511
65545
  resetErrorInfo(saveErrorInfo);
65512
65546
  return result;
65513
65547
  }
@@ -65651,7 +65685,7 @@ var ts;
65651
65685
  return varianceResult;
65652
65686
  }
65653
65687
  }
65654
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65688
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65655
65689
  if (relation !== identityRelation) {
65656
65690
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
65657
65691
  }
@@ -66027,7 +66061,7 @@ var ts;
66027
66061
  }
66028
66062
  var result = -1 /* True */;
66029
66063
  if (isTupleType(target)) {
66030
- if (isArrayType(source) || isTupleType(source)) {
66064
+ if (isArrayOrTupleType(source)) {
66031
66065
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66032
66066
  return 0 /* False */;
66033
66067
  }
@@ -66988,6 +67022,9 @@ var ts;
66988
67022
  function isReadonlyArrayType(type) {
66989
67023
  return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
66990
67024
  }
67025
+ function isArrayOrTupleType(type) {
67026
+ return isArrayType(type) || isTupleType(type);
67027
+ }
66991
67028
  function isMutableArrayOrTuple(type) {
66992
67029
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
66993
67030
  }
@@ -67439,7 +67476,7 @@ var ts;
67439
67476
  else if (type.flags & 2097152 /* Intersection */) {
67440
67477
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
67441
67478
  }
67442
- else if (isArrayType(type) || isTupleType(type)) {
67479
+ else if (isArrayOrTupleType(type)) {
67443
67480
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
67444
67481
  }
67445
67482
  if (result && context === undefined) {
@@ -67476,7 +67513,7 @@ var ts;
67476
67513
  }
67477
67514
  }
67478
67515
  }
67479
- if (isArrayType(type) || isTupleType(type)) {
67516
+ if (isArrayOrTupleType(type)) {
67480
67517
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
67481
67518
  var t = _c[_b];
67482
67519
  if (reportWideningErrorsInType(t)) {
@@ -68537,7 +68574,7 @@ var ts;
68537
68574
  }
68538
68575
  // Infer from the members of source and target only if the two types are possibly related
68539
68576
  if (!typesDefinitelyUnrelated(source, target)) {
68540
- if (isArrayType(source) || isTupleType(source)) {
68577
+ if (isArrayOrTupleType(source)) {
68541
68578
  if (isTupleType(target)) {
68542
68579
  var sourceArity = getTypeReferenceArity(source);
68543
68580
  var targetArity = getTypeReferenceArity(target);
@@ -73416,6 +73453,7 @@ var ts;
73416
73453
  }
73417
73454
  }
73418
73455
  else {
73456
+ error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
73419
73457
  typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
73420
73458
  }
73421
73459
  }
@@ -75653,6 +75691,7 @@ var ts;
75653
75691
  // decorators are applied to a declaration by the emitter, and not to an expression.
75654
75692
  var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75655
75693
  var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
75694
+ argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75656
75695
  // The following variables are captured and modified by calls to chooseOverload.
75657
75696
  // If overload resolution or type argument inference fails, we want to report the
75658
75697
  // best error possible. The best error is one which says that an argument was not
@@ -75868,7 +75907,7 @@ var ts;
75868
75907
  // If one or more context sensitive arguments were excluded, we start including
75869
75908
  // them now (and keeping do so for any subsequent candidates) and perform a second
75870
75909
  // round of type inference and applicability checking for this particular candidate.
75871
- argCheckMode = 0 /* Normal */;
75910
+ argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75872
75911
  if (inferenceContext) {
75873
75912
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
75874
75913
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -109950,6 +109989,7 @@ var ts;
109950
109989
  else {
109951
109990
  printer.writeFile(sourceFile, writer, sourceMapGenerator);
109952
109991
  }
109992
+ var sourceMapUrlPos;
109953
109993
  if (sourceMapGenerator) {
109954
109994
  if (sourceMapDataList) {
109955
109995
  sourceMapDataList.push({
@@ -109961,6 +110001,7 @@ var ts;
109961
110001
  if (sourceMappingURL) {
109962
110002
  if (!writer.isAtStartOfLine())
109963
110003
  writer.rawWrite(newLine);
110004
+ sourceMapUrlPos = writer.getTextPos();
109964
110005
  writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment
109965
110006
  }
109966
110007
  // Write the source map
@@ -109973,7 +110014,7 @@ var ts;
109973
110014
  writer.writeLine();
109974
110015
  }
109975
110016
  // Write the output file
109976
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
110017
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
109977
110018
  // Reset state
109978
110019
  writer.clear();
109979
110020
  }
@@ -110495,7 +110536,7 @@ var ts;
110495
110536
  setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined);
110496
110537
  }
110497
110538
  function getCurrentLineMap() {
110498
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
110539
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
110499
110540
  }
110500
110541
  function emit(node, parenthesizerRule) {
110501
110542
  if (node === undefined)
@@ -111670,7 +111711,7 @@ var ts;
111670
111711
  increaseIndent();
111671
111712
  }
111672
111713
  var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */;
111673
- var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */;
111714
+ var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */;
111674
111715
  emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine);
111675
111716
  if (indentedFlag) {
111676
111717
  decreaseIndent();
@@ -112026,7 +112067,7 @@ var ts;
112026
112067
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
112027
112068
  // Emit semicolon in non json files
112028
112069
  // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation)
112029
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112070
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112030
112071
  writeTrailingSemicolon();
112031
112072
  }
112032
112073
  }
@@ -112319,7 +112360,7 @@ var ts;
112319
112360
  if (body.multiLine) {
112320
112361
  return false;
112321
112362
  }
112322
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112363
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112323
112364
  return false;
112324
112365
  }
112325
112366
  if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)
@@ -112344,12 +112385,7 @@ var ts;
112344
112385
  var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
112345
112386
  ? emitBlockFunctionBodyOnSingleLine
112346
112387
  : emitBlockFunctionBodyWorker;
112347
- if (emitBodyWithDetachedComments) {
112348
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112349
- }
112350
- else {
112351
- emitBlockFunctionBody(body);
112352
- }
112388
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112353
112389
  decreaseIndent();
112354
112390
  writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body);
112355
112391
  onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
@@ -112746,7 +112782,8 @@ var ts;
112746
112782
  var emitAsSingleStatement = statements.length === 1 &&
112747
112783
  (
112748
112784
  // treat synthesized nodes as located on the same line for emit purposes
112749
- ts.nodeIsSynthesized(parentNode) ||
112785
+ !currentSourceFile ||
112786
+ ts.nodeIsSynthesized(parentNode) ||
112750
112787
  ts.nodeIsSynthesized(statements[0]) ||
112751
112788
  ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
112752
112789
  var format = 163969 /* CaseOrDefaultClauseStatements */;
@@ -112977,16 +113014,14 @@ var ts;
112977
113014
  function emitSourceFile(node) {
112978
113015
  writeLine();
112979
113016
  var statements = node.statements;
112980
- if (emitBodyWithDetachedComments) {
112981
- // Emit detached comment if there are no prologue directives or if the first node is synthesized.
112982
- // The synthesized node will have no leading comment so some comments may be missed.
112983
- var shouldEmitDetachedComment = statements.length === 0 ||
112984
- !ts.isPrologueDirective(statements[0]) ||
112985
- ts.nodeIsSynthesized(statements[0]);
112986
- if (shouldEmitDetachedComment) {
112987
- emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
112988
- return;
112989
- }
113017
+ // Emit detached comment if there are no prologue directives or if the first node is synthesized.
113018
+ // The synthesized node will have no leading comment so some comments may be missed.
113019
+ var shouldEmitDetachedComment = statements.length === 0 ||
113020
+ !ts.isPrologueDirective(statements[0]) ||
113021
+ ts.nodeIsSynthesized(statements[0]);
113022
+ if (shouldEmitDetachedComment) {
113023
+ emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
113024
+ return;
112990
113025
  }
112991
113026
  emitSourceFileWorker(node);
112992
113027
  }
@@ -113375,7 +113410,7 @@ var ts;
113375
113410
  }
113376
113411
  if (isEmpty) {
113377
113412
  // Write a line terminator if the parent node was multi-line
113378
- if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113413
+ if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113379
113414
  writeLine();
113380
113415
  }
113381
113416
  else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) {
@@ -113636,7 +113671,7 @@ var ts;
113636
113671
  }
113637
113672
  var firstChild_1 = children[0];
113638
113673
  if (firstChild_1 === undefined) {
113639
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113674
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113640
113675
  }
113641
113676
  if (firstChild_1.pos === nextListElementPos) {
113642
113677
  // If this child starts at the beginning of a list item in a parent list, its leading
@@ -113660,7 +113695,7 @@ var ts;
113660
113695
  // JsxText will be written with its leading whitespace, so don't add more manually.
113661
113696
  return 0;
113662
113697
  }
113663
- if (parentNode &&
113698
+ if (currentSourceFile && parentNode &&
113664
113699
  !ts.positionIsSynthesized(parentNode.pos) &&
113665
113700
  !ts.nodeIsSynthesized(firstChild_1) &&
113666
113701
  (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -113684,7 +113719,7 @@ var ts;
113684
113719
  // JsxText will be written with its leading whitespace, so don't add more manually.
113685
113720
  return 0;
113686
113721
  }
113687
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113722
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113688
113723
  if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
113689
113724
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
113690
113725
  }
@@ -113716,9 +113751,9 @@ var ts;
113716
113751
  }
113717
113752
  var lastChild = ts.lastOrUndefined(children);
113718
113753
  if (lastChild === undefined) {
113719
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113754
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113720
113755
  }
113721
- if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
113756
+ if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
113722
113757
  if (preserveSourceNewlines) {
113723
113758
  var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
113724
113759
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -113791,7 +113826,7 @@ var ts;
113791
113826
  if (ts.getStartsOnNewLine(node2)) {
113792
113827
  return 1;
113793
113828
  }
113794
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
113829
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
113795
113830
  if (preserveSourceNewlines) {
113796
113831
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
113797
113832
  }
@@ -113801,7 +113836,7 @@ var ts;
113801
113836
  }
113802
113837
  function isEmptyBlock(block) {
113803
113838
  return block.statements.length === 0
113804
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
113839
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
113805
113840
  }
113806
113841
  function skipSynthesizedParentheses(node) {
113807
113842
  while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) {
@@ -113813,16 +113848,23 @@ var ts;
113813
113848
  if (ts.isGeneratedIdentifier(node)) {
113814
113849
  return generateName(node);
113815
113850
  }
113816
- else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
113817
- return ts.idText(node);
113818
- }
113819
- else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
113851
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
113820
113852
  return getTextOfNode(node.textSourceNode, includeTrivia);
113821
113853
  }
113822
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
113823
- return node.text;
113854
+ var sourceFile = currentSourceFile; // const needed for control flow
113855
+ var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
113856
+ if (ts.isMemberName(node)) {
113857
+ if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
113858
+ return ts.idText(node);
113859
+ }
113860
+ }
113861
+ else {
113862
+ ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary
113863
+ if (!canUseSourceFile) {
113864
+ return node.text;
113865
+ }
113824
113866
  }
113825
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
113867
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
113826
113868
  }
113827
113869
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
113828
113870
  if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
@@ -114401,7 +114443,7 @@ var ts;
114401
114443
  return true;
114402
114444
  }
114403
114445
  function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
114404
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114446
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114405
114447
  return;
114406
114448
  if (!hasWrittenComment) {
114407
114449
  ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -114428,7 +114470,7 @@ var ts;
114428
114470
  forEachTrailingCommentToEmit(pos, emitTrailingComment);
114429
114471
  }
114430
114472
  function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114431
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114473
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114432
114474
  return;
114433
114475
  // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
114434
114476
  if (!writer.isAtStartOfLine()) {
@@ -114450,6 +114492,8 @@ var ts;
114450
114492
  exitComment();
114451
114493
  }
114452
114494
  function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
114495
+ if (!currentSourceFile)
114496
+ return;
114453
114497
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114454
114498
  emitPos(commentPos);
114455
114499
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114459,6 +114503,8 @@ var ts;
114459
114503
  }
114460
114504
  }
114461
114505
  function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114506
+ if (!currentSourceFile)
114507
+ return;
114462
114508
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114463
114509
  emitPos(commentPos);
114464
114510
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114491,6 +114537,8 @@ var ts;
114491
114537
  return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
114492
114538
  }
114493
114539
  function forEachLeadingCommentWithoutDetachedComments(cb) {
114540
+ if (!currentSourceFile)
114541
+ return;
114494
114542
  // get the leading comments from detachedPos
114495
114543
  var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
114496
114544
  if (detachedCommentsInfo.length - 1) {
@@ -114502,7 +114550,7 @@ var ts;
114502
114550
  ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos);
114503
114551
  }
114504
114552
  function emitDetachedCommentsAndUpdateCommentsInfo(range) {
114505
- var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
114553
+ var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
114506
114554
  if (currentDetachedCommentInfo) {
114507
114555
  if (detachedCommentsInfo) {
114508
114556
  detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -114513,7 +114561,7 @@ var ts;
114513
114561
  }
114514
114562
  }
114515
114563
  function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
114516
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114564
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114517
114565
  return;
114518
114566
  emitPos(commentPos);
114519
114567
  ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
@@ -114525,7 +114573,7 @@ var ts;
114525
114573
  * @return true if the comment is a triple-slash comment else false
114526
114574
  */
114527
114575
  function isTripleSlashComment(commentPos, commentEnd) {
114528
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114576
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114529
114577
  }
114530
114578
  // Source Maps
114531
114579
  function getParsedSourceMap(node) {
@@ -115440,7 +115488,11 @@ var ts;
115440
115488
  return newValue;
115441
115489
  };
115442
115490
  if (originalWriteFile) {
115443
- host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
115491
+ host.writeFile = function (fileName, data) {
115492
+ var rest = [];
115493
+ for (var _i = 2; _i < arguments.length; _i++) {
115494
+ rest[_i - 2] = arguments[_i];
115495
+ }
115444
115496
  var key = toPath(fileName);
115445
115497
  fileExistsCache.delete(key);
115446
115498
  var value = readFileCache.get(key);
@@ -115454,7 +115506,7 @@ var ts;
115454
115506
  sourceFileCache.delete(key);
115455
115507
  }
115456
115508
  }
115457
- originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
115509
+ originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
115458
115510
  };
115459
115511
  }
115460
115512
  // directoryExists
@@ -116387,6 +116439,7 @@ var ts;
116387
116439
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
116388
116440
  getFileIncludeReasons: function () { return fileReasons; },
116389
116441
  structureIsReused: structureIsReused,
116442
+ writeFile: writeFile,
116390
116443
  };
116391
116444
  onProgramCreateComplete();
116392
116445
  // Add file processingDiagnostics
@@ -116884,7 +116937,7 @@ var ts;
116884
116937
  getProjectReferenceRedirect: getProjectReferenceRedirect,
116885
116938
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
116886
116939
  getSymlinkCache: getSymlinkCache,
116887
- writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
116940
+ writeFile: writeFileCallback || writeFile,
116888
116941
  isEmitBlocked: isEmitBlocked,
116889
116942
  readFile: function (f) { return host.readFile(f); },
116890
116943
  fileExists: function (f) {
@@ -116904,6 +116957,9 @@ var ts;
116904
116957
  getFileIncludeReasons: program.getFileIncludeReasons,
116905
116958
  };
116906
116959
  }
116960
+ function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
116961
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
116962
+ }
116907
116963
  function emitBuildInfo(writeFileCallback) {
116908
116964
  ts.Debug.assert(!ts.outFile(options));
116909
116965
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
@@ -119346,6 +119402,7 @@ var ts;
119346
119402
  }
119347
119403
  }
119348
119404
  }
119405
+ BuilderState.updateExportedModules = updateExportedModules;
119349
119406
  /**
119350
119407
  * Updates the exported modules from cache into state's exported modules map
119351
119408
  * This should be called whenever it is safe to commit the state of the builder
@@ -119769,6 +119826,18 @@ var ts;
119769
119826
  }
119770
119827
  return undefined;
119771
119828
  }
119829
+ function removeDiagnosticsOfLibraryFiles(state) {
119830
+ if (!state.cleanedDiagnosticsOfLibFiles) {
119831
+ state.cleanedDiagnosticsOfLibFiles = true;
119832
+ var program_1 = ts.Debug.checkDefined(state.program);
119833
+ var options_2 = program_1.getCompilerOptions();
119834
+ ts.forEach(program_1.getSourceFiles(), function (f) {
119835
+ return program_1.isSourceFileDefaultLibrary(f) &&
119836
+ !ts.skipTypeChecking(f, options_2, program_1) &&
119837
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
119838
+ });
119839
+ }
119840
+ }
119772
119841
  /**
119773
119842
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119774
119843
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
@@ -119778,28 +119847,17 @@ var ts;
119778
119847
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119779
119848
  // If affected files is everything except default library, then nothing more to do
119780
119849
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
119781
- if (!state.cleanedDiagnosticsOfLibFiles) {
119782
- state.cleanedDiagnosticsOfLibFiles = true;
119783
- var program_1 = ts.Debug.checkDefined(state.program);
119784
- var options_2 = program_1.getCompilerOptions();
119785
- ts.forEach(program_1.getSourceFiles(), function (f) {
119786
- return program_1.isSourceFileDefaultLibrary(f) &&
119787
- !ts.skipTypeChecking(f, options_2, program_1) &&
119788
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
119789
- });
119790
- }
119850
+ removeDiagnosticsOfLibraryFiles(state);
119791
119851
  // When a change affects the global scope, all files are considered to be affected without updating their signature
119792
119852
  // That means when affected file is handled, its signature can be out of date
119793
119853
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
119794
119854
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
119795
119855
  return;
119796
119856
  }
119797
- else {
119798
- 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);
119799
- }
119800
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
119801
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
119802
- }
119857
+ 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);
119858
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
119859
+ return;
119860
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
119803
119861
  }
119804
119862
  /**
119805
119863
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
@@ -119841,16 +119899,41 @@ var ts;
119841
119899
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
119842
119900
  return newSignature !== oldSignature;
119843
119901
  }
119902
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
119903
+ // Go through exported modules from cache first
119904
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
119905
+ var result = keys && ts.forEachKey(keys, fn);
119906
+ if (result)
119907
+ return result;
119908
+ // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
119909
+ keys = state.exportedModulesMap.getKeys(filePath);
119910
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
119911
+ var _a;
119912
+ // If the cache had an updated value, skip
119913
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
119914
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
119915
+ fn(exportedFromPath) :
119916
+ undefined;
119917
+ });
119918
+ }
119919
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
119920
+ var _a;
119921
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
119922
+ return false;
119923
+ // Every file needs to be handled
119924
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
119925
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
119926
+ removeDiagnosticsOfLibraryFiles(state);
119927
+ return true;
119928
+ }
119844
119929
  /**
119845
- * Iterate on referencing modules that export entities from affected file
119930
+ * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
119846
119931
  */
119847
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
119848
- var _a, _b;
119932
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
119849
119933
  // If there was change in signature (dts output) for the changed file,
119850
119934
  // then only we need to handle pending file emit
119851
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
119935
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
119852
119936
  return;
119853
- }
119854
119937
  if (!isChangedSignature(state, affectedFile.resolvedPath))
119855
119938
  return;
119856
119939
  // Since isolated modules dont change js files, files affected by change in signature is itself
@@ -119863,7 +119946,9 @@ var ts;
119863
119946
  var currentPath = queue.pop();
119864
119947
  if (!seenFileNamesMap.has(currentPath)) {
119865
119948
  seenFileNamesMap.set(currentPath, true);
119866
- fn(state, currentPath);
119949
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
119950
+ return;
119951
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
119867
119952
  if (isChangedSignature(state, currentPath)) {
119868
119953
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
119869
119954
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -119875,56 +119960,38 @@ var ts;
119875
119960
  var seenFileAndExportsOfFile = new ts.Set();
119876
119961
  // Go through exported modules from cache first
119877
119962
  // If exported modules has path, all files referencing file exported from are affected
119878
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
119879
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119880
- });
119881
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
119882
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
119883
- var _a;
119884
- // If the cache had an updated value, skip
119885
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
119886
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
119887
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119963
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
119964
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
119965
+ return true;
119966
+ var references = state.referencedMap.getKeys(exportedFromPath);
119967
+ return references && ts.forEachKey(references, function (filePath) {
119968
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
119969
+ });
119888
119970
  });
119889
119971
  }
119890
119972
  /**
119891
- * Iterate on files referencing referencedPath
119973
+ * handle dts and semantic diagnostics on file and iterate on anything that exports this file
119974
+ * return true when all work is done and we can exit handling dts emit and semantic diagnostics
119892
119975
  */
119893
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
119976
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
119894
119977
  var _a;
119895
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
119896
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
119897
- });
119898
- }
119899
- /**
119900
- * fn on file and iterate on anything that exports this file
119901
- */
119902
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
119903
- var _a, _b, _c;
119904
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
119905
- return;
119906
- }
119907
- fn(state, filePath);
119978
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
119979
+ return undefined;
119980
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
119981
+ return true;
119982
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
119908
119983
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
119909
- // Go through exported modules from cache first
119910
119984
  // If exported modules has path, all files referencing file exported from are affected
119911
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
119912
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119913
- });
119914
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
119915
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
119916
- var _a;
119917
- // If the cache had an updated value, skip
119918
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
119919
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
119920
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119985
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
119986
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
119921
119987
  });
119922
119988
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
119923
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
119989
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
119924
119990
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
119925
- fn(state, referencingFilePath);
119926
- } // Dont add to seen since this is not yet done with the export removal
119927
- );
119991
+ handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
119992
+ state, referencingFilePath, cancellationToken, computeHash, host);
119993
+ });
119994
+ return undefined;
119928
119995
  }
119929
119996
  /**
119930
119997
  * This is called after completing operation on the next affected file.
@@ -120300,7 +120367,43 @@ var ts;
120300
120367
  return toAffectedFileEmitResult(state,
120301
120368
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
120302
120369
  // Otherwise just affected file
120303
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120370
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120371
+ getWriteFileUpdatingSignatureCallback(writeFile) :
120372
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120373
+ }
120374
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
120375
+ return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
120376
+ var _a;
120377
+ if (ts.isDeclarationFileName(fileName)) {
120378
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120379
+ var file = sourceFiles[0];
120380
+ var info = state.fileInfos.get(file.resolvedPath);
120381
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
120382
+ if (signature === file.version) {
120383
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
120384
+ if (newSignature !== file.version) { // Update it
120385
+ if (host.storeFilesChangingSignatureDuringEmit)
120386
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120387
+ if (state.exportedModulesMap)
120388
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
120389
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
120390
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
120391
+ }
120392
+ else {
120393
+ info.signature = newSignature;
120394
+ if (state.exportedModulesMap)
120395
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120396
+ }
120397
+ }
120398
+ }
120399
+ }
120400
+ if (writeFile)
120401
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120402
+ else if (host.writeFile)
120403
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120404
+ else
120405
+ state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120406
+ };
120304
120407
  }
120305
120408
  /**
120306
120409
  * Emits the JavaScript and declaration files.
@@ -120357,7 +120460,9 @@ var ts;
120357
120460
  }
120358
120461
  }
120359
120462
  }
120360
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120463
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120464
+ getWriteFileUpdatingSignatureCallback(writeFile) :
120465
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120361
120466
  }
120362
120467
  /**
120363
120468
  * Return the semantic diagnostics for the next affected file or undefined if iteration is complete
@@ -122549,6 +122654,7 @@ var ts;
122549
122654
  createHash: ts.maybeBind(host, host.createHash),
122550
122655
  readDirectory: ts.maybeBind(host, host.readDirectory),
122551
122656
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
122657
+ storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
122552
122658
  };
122553
122659
  function writeFile(fileName, text, writeByteOrderMark, onError) {
122554
122660
  try {
@@ -122608,6 +122714,7 @@ var ts;
122608
122714
  createHash: ts.maybeBind(system, system.createHash),
122609
122715
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
122610
122716
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
122717
+ storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
122611
122718
  };
122612
122719
  }
122613
122720
  ts.createProgramHost = createProgramHost;
@@ -122696,6 +122803,7 @@ var ts;
122696
122803
  var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system);
122697
122804
  host.createHash = ts.maybeBind(system, system.createHash);
122698
122805
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
122806
+ host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
122699
122807
  ts.setGetSourceFileAsHashVersioned(host, system);
122700
122808
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
122701
122809
  return host;