typescript 4.7.0-dev.20220406 → 4.7.0-dev.20220416

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-dev.20220406";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220416";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -4649,7 +4649,6 @@ var ts;
4649
4649
  NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
4650
4650
  NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
4651
4651
  NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
4652
- NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
4653
4652
  // Error handling
4654
4653
  NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
4655
4654
  NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
@@ -8706,6 +8705,7 @@ var ts;
8706
8705
  _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
8707
8706
  Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
8708
8707
  Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."),
8708
+ Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."),
8709
8709
  Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
8710
8710
  A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
8711
8711
  Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
@@ -14954,6 +14954,10 @@ var ts;
14954
14954
  }
14955
14955
  }
14956
14956
  ts.isAnyImportSyntax = isAnyImportSyntax;
14957
+ function isAnyImportOrBareOrAccessedRequire(node) {
14958
+ return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
14959
+ }
14960
+ ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
14957
14961
  function isLateVisibilityPaintedStatement(node) {
14958
14962
  switch (node.kind) {
14959
14963
  case 266 /* ImportDeclaration */:
@@ -16314,17 +16318,13 @@ var ts;
16314
16318
  if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
16315
16319
  return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
16316
16320
  }
16317
- if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
16321
+ if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
16318
16322
  (initializer.expression.kind === 108 /* ThisKeyword */ ||
16319
16323
  ts.isIdentifier(initializer.expression) &&
16320
16324
  (initializer.expression.escapedText === "window" ||
16321
16325
  initializer.expression.escapedText === "self" ||
16322
16326
  initializer.expression.escapedText === "global"))) {
16323
- var nameOrArgument = getNameOrArgument(initializer);
16324
- if (ts.isPrivateIdentifier(nameOrArgument)) {
16325
- ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
16326
- }
16327
- return isSameEntityName(name, nameOrArgument);
16327
+ return isSameEntityName(name, getNameOrArgument(initializer));
16328
16328
  }
16329
16329
  if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
16330
16330
  return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
@@ -16532,14 +16532,14 @@ var ts;
16532
16532
  }
16533
16533
  ts.isFunctionSymbol = isFunctionSymbol;
16534
16534
  function tryGetModuleSpecifierFromDeclaration(node) {
16535
- var _a, _b, _c;
16535
+ var _a, _b;
16536
16536
  switch (node.kind) {
16537
16537
  case 254 /* VariableDeclaration */:
16538
- return node.initializer.arguments[0].text;
16538
+ return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
16539
16539
  case 266 /* ImportDeclaration */:
16540
- return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text;
16540
+ return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
16541
16541
  case 265 /* ImportEqualsDeclaration */:
16542
- return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text;
16542
+ return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
16543
16543
  default:
16544
16544
  ts.Debug.assertNever(node);
16545
16545
  }
@@ -17054,7 +17054,10 @@ var ts;
17054
17054
  return parent.propertyName === node;
17055
17055
  case 275 /* ExportSpecifier */:
17056
17056
  case 285 /* JsxAttribute */:
17057
- // Any name in an export specifier or JSX Attribute
17057
+ case 279 /* JsxSelfClosingElement */:
17058
+ case 280 /* JsxOpeningElement */:
17059
+ case 281 /* JsxClosingElement */:
17060
+ // Any name in an export specifier or JSX Attribute or Jsx Element
17058
17061
  return true;
17059
17062
  }
17060
17063
  return false;
@@ -17070,21 +17073,28 @@ var ts;
17070
17073
  // export = <EntityNameExpression>
17071
17074
  // export default <EntityNameExpression>
17072
17075
  // module.exports = <EntityNameExpression>
17073
- // {<Identifier>}
17074
- // {name: <EntityNameExpression>}
17076
+ // module.exports.x = <EntityNameExpression>
17077
+ // const x = require("...")
17078
+ // const { x } = require("...")
17079
+ // const x = require("...").y
17080
+ // const { x } = require("...").y
17075
17081
  function isAliasSymbolDeclaration(node) {
17076
- return node.kind === 265 /* ImportEqualsDeclaration */ ||
17082
+ if (node.kind === 265 /* ImportEqualsDeclaration */ ||
17077
17083
  node.kind === 264 /* NamespaceExportDeclaration */ ||
17078
17084
  node.kind === 267 /* ImportClause */ && !!node.name ||
17079
17085
  node.kind === 268 /* NamespaceImport */ ||
17080
17086
  node.kind === 274 /* NamespaceExport */ ||
17081
17087
  node.kind === 270 /* ImportSpecifier */ ||
17082
17088
  node.kind === 275 /* ExportSpecifier */ ||
17083
- node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
17084
- ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17085
- ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) ||
17086
- node.kind === 297 /* ShorthandPropertyAssignment */ ||
17087
- node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer);
17089
+ node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
17090
+ return true;
17091
+ }
17092
+ return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17093
+ ts.isPropertyAccessExpression(node)
17094
+ && ts.isBinaryExpression(node.parent)
17095
+ && node.parent.left === node
17096
+ && node.parent.operatorToken.kind === 63 /* EqualsToken */
17097
+ && isAliasableExpression(node.parent.right));
17088
17098
  }
17089
17099
  ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
17090
17100
  function getAliasDeclarationFromName(node) {
@@ -17095,6 +17105,7 @@ var ts;
17095
17105
  case 275 /* ExportSpecifier */:
17096
17106
  case 271 /* ExportAssignment */:
17097
17107
  case 265 /* ImportEqualsDeclaration */:
17108
+ case 274 /* NamespaceExport */:
17098
17109
  return node.parent;
17099
17110
  case 161 /* QualifiedName */:
17100
17111
  do {
@@ -18921,6 +18932,11 @@ var ts;
18921
18932
  (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
18922
18933
  }
18923
18934
  ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
18935
+ function isRightSideOfAccessExpression(node) {
18936
+ return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
18937
+ || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
18938
+ }
18939
+ ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression;
18924
18940
  function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
18925
18941
  return ts.isQualifiedName(node.parent) && node.parent.right === node
18926
18942
  || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
@@ -19572,6 +19588,41 @@ var ts;
19572
19588
  return expr;
19573
19589
  }
19574
19590
  ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
19591
+ function forEachNameInAccessChainWalkingLeft(name, action) {
19592
+ if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
19593
+ return walkAccessExpression(name.parent);
19594
+ }
19595
+ function walkAccessExpression(access) {
19596
+ if (access.kind === 206 /* PropertyAccessExpression */) {
19597
+ var res = action(access.name);
19598
+ if (res !== undefined) {
19599
+ return res;
19600
+ }
19601
+ }
19602
+ else if (access.kind === 207 /* ElementAccessExpression */) {
19603
+ if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) {
19604
+ var res = action(access.argumentExpression);
19605
+ if (res !== undefined) {
19606
+ return res;
19607
+ }
19608
+ }
19609
+ else {
19610
+ // Chain interrupted by non-static-name access 'x[expr()].y.z'
19611
+ return undefined;
19612
+ }
19613
+ }
19614
+ if (isAccessExpression(access.expression)) {
19615
+ return walkAccessExpression(access.expression);
19616
+ }
19617
+ if (ts.isIdentifier(access.expression)) {
19618
+ // End of chain at Identifier 'x.y.z'
19619
+ return action(access.expression);
19620
+ }
19621
+ // End of chain at non-Identifier 'x().y.z'
19622
+ return undefined;
19623
+ }
19624
+ }
19625
+ ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft;
19575
19626
  function getLeftmostExpression(node, stopAtCallExpressions) {
19576
19627
  while (true) {
19577
19628
  switch (node.kind) {
@@ -20519,6 +20570,7 @@ var ts;
20519
20570
  ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
20520
20571
  var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]];
20521
20572
  var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
20573
+ ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
20522
20574
  function getSupportedExtensions(options, extraFileExtensions) {
20523
20575
  var needJsExtensions = options && getAllowJSCompilerOption(options);
20524
20576
  if (!extraFileExtensions || extraFileExtensions.length === 0) {
@@ -21207,6 +21259,11 @@ var ts;
21207
21259
  return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
21208
21260
  }
21209
21261
  ts.getNodeModulePathParts = getNodeModulePathParts;
21262
+ function getParameterTypeNode(parameter) {
21263
+ var _a;
21264
+ return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
21265
+ }
21266
+ ts.getParameterTypeNode = getParameterTypeNode;
21210
21267
  })(ts || (ts = {}));
21211
21268
  /* @internal */
21212
21269
  var ts;
@@ -35360,34 +35417,10 @@ var ts;
35360
35417
  case 20 /* OpenParenToken */: // foo<x>(
35361
35418
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35362
35419
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35363
- // These tokens can't follow in a call expression, nor can they start an
35364
- // expression. So, consider the type argument list part of an instantiation
35365
- // expression.
35366
- // falls through
35367
- case 27 /* CommaToken */: // foo<x>,
35368
- case 24 /* DotToken */: // foo<x>.
35369
- case 28 /* QuestionDotToken */: // foo<x>?.
35370
- case 21 /* CloseParenToken */: // foo<x>)
35371
- case 23 /* CloseBracketToken */: // foo<x>]
35372
- case 58 /* ColonToken */: // foo<x>:
35373
- case 26 /* SemicolonToken */: // foo<x>;
35374
- case 57 /* QuestionToken */: // foo<x>?
35375
- case 34 /* EqualsEqualsToken */: // foo<x> ==
35376
- case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
35377
- case 35 /* ExclamationEqualsToken */: // foo<x> !=
35378
- case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
35379
- case 55 /* AmpersandAmpersandToken */: // foo<x> &&
35380
- case 56 /* BarBarToken */: // foo<x> ||
35381
- case 60 /* QuestionQuestionToken */: // foo<x> ??
35382
- case 52 /* CaretToken */: // foo<x> ^
35383
- case 50 /* AmpersandToken */: // foo<x> &
35384
- case 51 /* BarToken */: // foo<x> |
35385
- case 19 /* CloseBraceToken */: // foo<x> }
35386
- case 1 /* EndOfFileToken */: // foo<x>
35387
35420
  return true;
35388
35421
  }
35389
- // Treat anything else as an expression.
35390
- return false;
35422
+ // Consider something a type argument list only if the following token can't start an expression.
35423
+ return !isStartOfExpression();
35391
35424
  }
35392
35425
  function parsePrimaryExpression() {
35393
35426
  switch (token()) {
@@ -38605,7 +38638,7 @@ var ts;
38605
38638
  })(IncrementalParser || (IncrementalParser = {}));
38606
38639
  /** @internal */
38607
38640
  function isDeclarationFileName(fileName) {
38608
- return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
38641
+ return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
38609
38642
  }
38610
38643
  ts.isDeclarationFileName = isDeclarationFileName;
38611
38644
  function parseResolutionMode(mode, pos, end, reportDiagnostic) {
@@ -42113,7 +42146,8 @@ var ts;
42113
42146
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
42114
42147
  Extensions[Extensions["Json"] = 2] = "Json";
42115
42148
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
42116
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
42149
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
42150
+ Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
42117
42151
  })(Extensions || (Extensions = {}));
42118
42152
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
42119
42153
  function resolvedTypeScriptOnly(resolved) {
@@ -43058,7 +43092,21 @@ var ts;
43058
43092
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43059
43093
  }
43060
43094
  function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
43061
- return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
43095
+ var extensions;
43096
+ if (lookupConfig) {
43097
+ extensions = tsconfigExtensions;
43098
+ }
43099
+ else if (compilerOptions.noDtsResolution) {
43100
+ extensions = [Extensions.TsOnly];
43101
+ if (compilerOptions.allowJs)
43102
+ extensions.push(Extensions.JavaScript);
43103
+ if (compilerOptions.resolveJsonModule)
43104
+ extensions.push(Extensions.Json);
43105
+ }
43106
+ else {
43107
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
43108
+ }
43109
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
43062
43110
  }
43063
43111
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
43064
43112
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -43067,6 +43115,10 @@ var ts;
43067
43115
  var failedLookupLocations = [];
43068
43116
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
43069
43117
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43118
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
43119
+ if (compilerOptions.noDtsResolution) {
43120
+ conditions.pop();
43121
+ }
43070
43122
  var state = {
43071
43123
  compilerOptions: compilerOptions,
43072
43124
  host: host,
@@ -43074,7 +43126,7 @@ var ts;
43074
43126
  failedLookupLocations: failedLookupLocations,
43075
43127
  packageJsonInfoCache: cache,
43076
43128
  features: features,
43077
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
43129
+ conditions: conditions,
43078
43130
  };
43079
43131
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43080
43132
  return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
@@ -43250,9 +43302,9 @@ var ts;
43250
43302
  }
43251
43303
  }
43252
43304
  function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
43253
- if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) {
43305
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
43254
43306
  var result = tryFile(candidate, onlyRecordFailures, state);
43255
- return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43307
+ return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43256
43308
  }
43257
43309
  return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
43258
43310
  }
@@ -43282,20 +43334,22 @@ var ts;
43282
43334
  default: return tryExtension(".d.ts" /* Dts */);
43283
43335
  }
43284
43336
  case Extensions.TypeScript:
43337
+ case Extensions.TsOnly:
43338
+ var useDts = extensions === Extensions.TypeScript;
43285
43339
  switch (originalExtension) {
43286
43340
  case ".mjs" /* Mjs */:
43287
43341
  case ".mts" /* Mts */:
43288
43342
  case ".d.mts" /* Dmts */:
43289
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43343
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
43290
43344
  case ".cjs" /* Cjs */:
43291
43345
  case ".cts" /* Cts */:
43292
43346
  case ".d.cts" /* Dcts */:
43293
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43347
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
43294
43348
  case ".json" /* Json */:
43295
43349
  candidate += ".json" /* Json */;
43296
- return tryExtension(".d.ts" /* Dts */);
43350
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
43297
43351
  default:
43298
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
43352
+ return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
43299
43353
  }
43300
43354
  case Extensions.JavaScript:
43301
43355
  switch (originalExtension) {
@@ -43522,6 +43576,7 @@ var ts;
43522
43576
  switch (extensions) {
43523
43577
  case Extensions.JavaScript:
43524
43578
  case Extensions.Json:
43579
+ case Extensions.TsOnly:
43525
43580
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43526
43581
  break;
43527
43582
  case Extensions.TypeScript:
@@ -43594,14 +43649,16 @@ var ts;
43594
43649
  function extensionIsOk(extensions, extension) {
43595
43650
  switch (extensions) {
43596
43651
  case Extensions.JavaScript:
43597
- return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
43652
+ return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
43598
43653
  case Extensions.TSConfig:
43599
43654
  case Extensions.Json:
43600
43655
  return extension === ".json" /* Json */;
43601
43656
  case Extensions.TypeScript:
43602
- return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43657
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
43658
+ case Extensions.TsOnly:
43659
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
43603
43660
  case Extensions.DtsOnly:
43604
- return extension === ".d.ts" /* Dts */;
43661
+ return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
43605
43662
  }
43606
43663
  }
43607
43664
  /* @internal */
@@ -45761,6 +45818,7 @@ var ts;
45761
45818
  case 261 /* ModuleDeclaration */:
45762
45819
  case 259 /* TypeAliasDeclaration */:
45763
45820
  case 195 /* MappedType */:
45821
+ case 176 /* IndexSignature */:
45764
45822
  return 1 /* IsContainer */ | 32 /* HasLocals */;
45765
45823
  case 305 /* SourceFile */:
45766
45824
  return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
@@ -45779,7 +45837,6 @@ var ts;
45779
45837
  case 317 /* JSDocFunctionType */:
45780
45838
  case 179 /* FunctionType */:
45781
45839
  case 175 /* ConstructSignature */:
45782
- case 176 /* IndexSignature */:
45783
45840
  case 180 /* ConstructorType */:
45784
45841
  case 170 /* ClassStaticBlockDeclaration */:
45785
45842
  return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
@@ -50357,27 +50414,27 @@ var ts;
50357
50414
  function resolveAlias(symbol) {
50358
50415
  ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
50359
50416
  var links = getSymbolLinks(symbol);
50360
- if (!links.target) {
50361
- links.target = resolvingSymbol;
50417
+ if (!links.aliasTarget) {
50418
+ links.aliasTarget = resolvingSymbol;
50362
50419
  var node = getDeclarationOfAliasSymbol(symbol);
50363
50420
  if (!node)
50364
50421
  return ts.Debug.fail();
50365
50422
  var target = getTargetOfAliasDeclaration(node);
50366
- if (links.target === resolvingSymbol) {
50367
- links.target = target || unknownSymbol;
50423
+ if (links.aliasTarget === resolvingSymbol) {
50424
+ links.aliasTarget = target || unknownSymbol;
50368
50425
  }
50369
50426
  else {
50370
50427
  error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
50371
50428
  }
50372
50429
  }
50373
- else if (links.target === resolvingSymbol) {
50374
- links.target = unknownSymbol;
50430
+ else if (links.aliasTarget === resolvingSymbol) {
50431
+ links.aliasTarget = unknownSymbol;
50375
50432
  }
50376
- return links.target;
50433
+ return links.aliasTarget;
50377
50434
  }
50378
50435
  function tryResolveAlias(symbol) {
50379
50436
  var links = getSymbolLinks(symbol);
50380
- if (links.target !== resolvingSymbol) {
50437
+ if (links.aliasTarget !== resolvingSymbol) {
50381
50438
  return resolveAlias(symbol);
50382
50439
  }
50383
50440
  return undefined;
@@ -52174,13 +52231,37 @@ var ts;
52174
52231
  return ts.Debug.fail("Should be unreachable.");
52175
52232
  function conditionalTypeToTypeNode(type) {
52176
52233
  var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
52234
+ context.approximateLength += 15;
52235
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) {
52236
+ var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
52237
+ var name = typeParameterToName(newParam, context);
52238
+ var newTypeVariable = ts.factory.createTypeReferenceNode(name);
52239
+ context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
52240
+ var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
52241
+ var saveInferTypeParameters_1 = context.inferTypeParameters;
52242
+ context.inferTypeParameters = type.root.inferTypeParameters;
52243
+ var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
52244
+ context.inferTypeParameters = saveInferTypeParameters_1;
52245
+ var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
52246
+ var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
52247
+ // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
52248
+ // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
52249
+ // inner conditional runs the check the user provided on the check type (distributively) and returns the result
52250
+ // checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
52251
+ // this is potentially simplifiable to
52252
+ // checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
52253
+ // but that may confuse users who read the output more.
52254
+ // On the other hand,
52255
+ // checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
52256
+ // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
52257
+ return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
52258
+ }
52177
52259
  var saveInferTypeParameters = context.inferTypeParameters;
52178
52260
  context.inferTypeParameters = type.root.inferTypeParameters;
52179
52261
  var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
52180
52262
  context.inferTypeParameters = saveInferTypeParameters;
52181
52263
  var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
52182
52264
  var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
52183
- context.approximateLength += 15;
52184
52265
  return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
52185
52266
  }
52186
52267
  function typeToTypeNodeOrCircularityElision(type) {
@@ -52879,9 +52960,6 @@ var ts;
52879
52960
  if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
52880
52961
  parameterType = getOptionalType(parameterType);
52881
52962
  }
52882
- if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
52883
- parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
52884
- }
52885
52963
  var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
52886
52964
  var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
52887
52965
  var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
@@ -53440,7 +53518,7 @@ var ts;
53440
53518
  if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
53441
53519
  // try to reuse the existing annotation
53442
53520
  var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
53443
- if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53521
+ if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53444
53522
  var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
53445
53523
  if (result_6) {
53446
53524
  return result_6;
@@ -53457,6 +53535,16 @@ var ts;
53457
53535
  context.flags = oldFlags;
53458
53536
  return result;
53459
53537
  }
53538
+ function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
53539
+ var typeFromTypeNode = getTypeFromTypeNode(typeNode);
53540
+ if (typeFromTypeNode === type) {
53541
+ return true;
53542
+ }
53543
+ if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
53544
+ return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
53545
+ }
53546
+ return false;
53547
+ }
53460
53548
  function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
53461
53549
  if (!isErrorType(type) && context.enclosingDeclaration) {
53462
53550
  var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
@@ -55728,7 +55816,7 @@ var ts;
55728
55816
  }
55729
55817
  }
55730
55818
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55731
- type = getUnionType(sourceTypes, 2 /* Subtype */);
55819
+ type = getUnionType(sourceTypes);
55732
55820
  }
55733
55821
  }
55734
55822
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -58477,8 +58565,9 @@ var ts;
58477
58565
  // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
58478
58566
  // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
58479
58567
  // nesting, so it is effectively just a safety stop.
58480
- if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) {
58481
- stack.push(t);
58568
+ var identity_1 = getRecursionIdentity(t);
58569
+ if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
58570
+ stack.push(identity_1);
58482
58571
  result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
58483
58572
  stack.pop();
58484
58573
  }
@@ -66676,12 +66765,12 @@ var ts;
66676
66765
  function isDeeplyNestedType(type, stack, depth, maxDepth) {
66677
66766
  if (maxDepth === void 0) { maxDepth = 3; }
66678
66767
  if (depth >= maxDepth) {
66679
- var identity_1 = getRecursionIdentity(type);
66768
+ var identity_2 = getRecursionIdentity(type);
66680
66769
  var count = 0;
66681
66770
  var lastTypeId = 0;
66682
66771
  for (var i = 0; i < depth; i++) {
66683
66772
  var t = stack[i];
66684
- if (getRecursionIdentity(t) === identity_1) {
66773
+ if (getRecursionIdentity(t) === identity_2) {
66685
66774
  // We only count occurrences with a higher type id than the previous occurrence, since higher
66686
66775
  // type ids are an indicator of newer instantiations caused by recursion.
66687
66776
  if (t.id >= lastTypeId) {
@@ -76683,7 +76772,7 @@ var ts;
76683
76772
  var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
76684
76773
  newSymbol.parent = originalSymbol;
76685
76774
  newSymbol.nameType = getStringLiteralType("default");
76686
- newSymbol.target = resolveSymbol(symbol);
76775
+ newSymbol.aliasTarget = resolveSymbol(symbol);
76687
76776
  memberTable.set("default" /* Default */, newSymbol);
76688
76777
  return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
76689
76778
  }
@@ -79495,19 +79584,28 @@ var ts;
79495
79584
  if (constraintType && defaultType) {
79496
79585
  checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
79497
79586
  }
79498
- if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) {
79587
+ checkNodeDeferred(node);
79588
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79589
+ }
79590
+ function checkTypeParameterDeferred(node) {
79591
+ if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
79592
+ var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
79499
79593
  var modifiers = getVarianceModifiers(typeParameter);
79500
- if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
79594
+ if (modifiers) {
79501
79595
  var symbol = getSymbolOfNode(node.parent);
79502
- var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
79503
- var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
79504
- var saveVarianceTypeParameter = typeParameter;
79505
- varianceTypeParameter = typeParameter;
79506
- checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
79507
- varianceTypeParameter = saveVarianceTypeParameter;
79596
+ if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
79597
+ error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
79598
+ }
79599
+ else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
79600
+ var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
79601
+ var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
79602
+ var saveVarianceTypeParameter = typeParameter;
79603
+ varianceTypeParameter = typeParameter;
79604
+ checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
79605
+ varianceTypeParameter = saveVarianceTypeParameter;
79606
+ }
79508
79607
  }
79509
79608
  }
79510
- addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79511
79609
  }
79512
79610
  function checkParameter(node) {
79513
79611
  // Grammar checking
@@ -79997,7 +80095,7 @@ var ts;
79997
80095
  superCallStatement = statement;
79998
80096
  break;
79999
80097
  }
80000
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
80098
+ if (nodeImmediatelyReferencesSuperOrThis(statement)) {
80001
80099
  break;
80002
80100
  }
80003
80101
  }
@@ -85350,6 +85448,9 @@ var ts;
85350
85448
  case 226 /* ClassExpression */:
85351
85449
  checkClassExpressionDeferred(node);
85352
85450
  break;
85451
+ case 163 /* TypeParameter */:
85452
+ checkTypeParameterDeferred(node);
85453
+ break;
85353
85454
  case 279 /* JsxSelfClosingElement */:
85354
85455
  checkJsxSelfClosingElementDeferred(node);
85355
85456
  break;
@@ -86164,11 +86265,11 @@ var ts;
86164
86265
  var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
86165
86266
  return leftSpread ? [leftSpread, rightSpread]
86166
86267
  : syntheticOrigin ? [syntheticOrigin]
86167
- : ts.singleElementArray(tryGetAliasTarget(symbol));
86268
+ : ts.singleElementArray(tryGetTarget(symbol));
86168
86269
  }
86169
86270
  return undefined;
86170
86271
  }
86171
- function tryGetAliasTarget(symbol) {
86272
+ function tryGetTarget(symbol) {
86172
86273
  var target;
86173
86274
  var next = symbol;
86174
86275
  while (next = getSymbolLinks(next).target) {
@@ -86398,7 +86499,7 @@ var ts;
86398
86499
  if (links === null || links === void 0 ? void 0 : links.referenced) {
86399
86500
  return true;
86400
86501
  }
86401
- var target = getSymbolLinks(symbol).target; // TODO: GH#18217
86502
+ var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
86402
86503
  if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
86403
86504
  target.flags & 111551 /* Value */ &&
86404
86505
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
@@ -86446,11 +86547,6 @@ var ts;
86446
86547
  !parameter.initializer &&
86447
86548
  ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
86448
86549
  }
86449
- function isOptionalUninitializedParameter(parameter) {
86450
- return !!strictNullChecks &&
86451
- isOptionalParameter(parameter) &&
86452
- !parameter.initializer;
86453
- }
86454
86550
  function isExpandoFunctionDeclaration(node) {
86455
86551
  var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
86456
86552
  if (!declaration) {
@@ -87367,8 +87463,7 @@ var ts;
87367
87463
  case 144 /* OutKeyword */:
87368
87464
  var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
87369
87465
  var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
87370
- if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ &&
87371
- node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
87466
+ if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
87372
87467
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
87373
87468
  }
87374
87469
  if (flags & inOutFlag) {
@@ -92602,11 +92697,11 @@ var ts;
92602
92697
  }
92603
92698
  var statements = [];
92604
92699
  resumeLexicalEnvironment();
92605
- var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92606
- var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
92700
+ var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92701
+ var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
92607
92702
  // If there was a super call, visit existing statements up to and including it
92608
92703
  if (superStatementIndex >= 0) {
92609
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
92704
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
92610
92705
  }
92611
92706
  // Transform parameters into property assignments. Transforms this:
92612
92707
  //
@@ -92625,12 +92720,12 @@ var ts;
92625
92720
  if (superStatementIndex >= 0) {
92626
92721
  ts.addRange(statements, parameterPropertyAssignments);
92627
92722
  }
92628
- // Since there was no super() call, parameter properties are the first statements in the constructor
92723
+ // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
92629
92724
  else {
92630
- statements = ts.addRange(parameterPropertyAssignments, statements);
92725
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
92631
92726
  }
92632
- // Add remaining statements from the body, skipping the super() call if it was found
92633
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
92727
+ // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
92728
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
92634
92729
  // End the lexical environment.
92635
92730
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
92636
92731
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
@@ -108394,6 +108489,10 @@ var ts;
108394
108489
  return factory.updateModifiers(statement, modifiers);
108395
108490
  }
108396
108491
  function transformTopLevelDeclaration(input) {
108492
+ if (lateMarkedStatements) {
108493
+ while (ts.orderedRemoveItem(lateMarkedStatements, input))
108494
+ ;
108495
+ }
108397
108496
  if (shouldStripInternal(input))
108398
108497
  return;
108399
108498
  switch (input.kind) {
@@ -109525,7 +109624,7 @@ var ts;
109525
109624
  addOutput(buildInfoPath);
109526
109625
  }
109527
109626
  function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
109528
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109627
+ if (ts.isDeclarationFileName(inputFileName))
109529
109628
  return;
109530
109629
  var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109531
109630
  addOutput(js);
@@ -109570,7 +109669,7 @@ var ts;
109570
109669
  /*@internal*/
109571
109670
  function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
109572
109671
  var options = _a.options, fileNames = _a.fileNames;
109573
- return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
109672
+ return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
109574
109673
  }
109575
109674
  ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
109576
109675
  /*@internal*/
@@ -109612,7 +109711,7 @@ var ts;
109612
109711
  var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
109613
109712
  for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
109614
109713
  var inputFileName = _b[_a];
109615
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109714
+ if (ts.isDeclarationFileName(inputFileName))
109616
109715
  continue;
109617
109716
  var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109618
109717
  if (jsFilePath)
@@ -114962,7 +115061,7 @@ var ts;
114962
115061
  if (ts.outFile(options) || options.outDir)
114963
115062
  return false;
114964
115063
  // File if emitted next to input needs to be ignored
114965
- if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) {
115064
+ if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
114966
115065
  // If its declaration directory: its not ignored if not excluded by config
114967
115066
  if (options.declarationDir)
114968
115067
  return false;
@@ -116135,7 +116234,7 @@ var ts;
116135
116234
  var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
116136
116235
  for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
116137
116236
  var fileName = _c[_b];
116138
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
116237
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
116139
116238
  processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
116140
116239
  }
116141
116240
  }
@@ -116326,7 +116425,7 @@ var ts;
116326
116425
  }
116327
116426
  function getRedirectReferenceForResolution(file) {
116328
116427
  var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
116329
- if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]))
116428
+ if (redirect || !ts.isDeclarationFileName(file.originalFileName))
116330
116429
  return redirect;
116331
116430
  // The originalFileName could not be actual source file name if file found was d.ts from referecned project
116332
116431
  // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
@@ -117717,7 +117816,7 @@ var ts;
117717
117816
  }
117718
117817
  function getProjectReferenceRedirectProject(fileName) {
117719
117818
  // Ignore dts or any json files
117720
- if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117819
+ if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117721
117820
  return undefined;
117722
117821
  }
117723
117822
  // If this file is produced by a referenced project, we need to rewrite it to
@@ -117766,7 +117865,7 @@ var ts;
117766
117865
  else {
117767
117866
  var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
117768
117867
  ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
117769
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117868
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117770
117869
  var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
117771
117870
  mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
117772
117871
  }
@@ -118567,7 +118666,7 @@ var ts;
118567
118666
  if (options.outDir) {
118568
118667
  return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
118569
118668
  }
118570
- if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
118669
+ if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
118571
118670
  // Otherwise just check if sourceFile with the name exists
118572
118671
  var filePathWithoutExtension = ts.removeFileExtension(filePath);
118573
118672
  return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
@@ -118900,13 +118999,9 @@ var ts;
118900
118999
  ts.getFileEmitOutput = getFileEmitOutput;
118901
119000
  var BuilderState;
118902
119001
  (function (BuilderState) {
118903
- var manyToManyPathMapCount = 0;
118904
119002
  function createManyToManyPathMap() {
118905
119003
  function create(forward, reverse, deleted) {
118906
- var version = 0;
118907
119004
  var map = {
118908
- id: manyToManyPathMapCount++,
118909
- version: function () { return version; },
118910
119005
  clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
118911
119006
  forEach: function (fn) { return forward.forEach(fn); },
118912
119007
  getKeys: function (v) { return reverse.get(v); },
@@ -118922,30 +119017,29 @@ var ts;
118922
119017
  }
118923
119018
  set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); });
118924
119019
  forward.delete(k);
118925
- version++;
118926
119020
  return true;
118927
119021
  },
118928
119022
  set: function (k, vSet) {
118929
- var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k));
119023
+ deleted === null || deleted === void 0 ? void 0 : deleted.delete(k);
118930
119024
  var existingVSet = forward.get(k);
118931
119025
  forward.set(k, vSet);
118932
119026
  existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) {
118933
119027
  if (!vSet.has(v)) {
118934
- changed = true;
118935
119028
  deleteFromMultimap(reverse, v, k);
118936
119029
  }
118937
119030
  });
118938
119031
  vSet.forEach(function (v) {
118939
119032
  if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) {
118940
- changed = true;
118941
119033
  addToMultimap(reverse, v, k);
118942
119034
  }
118943
119035
  });
118944
- if (changed) {
118945
- version++;
118946
- }
118947
119036
  return map;
118948
119037
  },
119038
+ clear: function () {
119039
+ forward.clear();
119040
+ reverse.clear();
119041
+ deleted === null || deleted === void 0 ? void 0 : deleted.clear();
119042
+ }
118949
119043
  };
118950
119044
  return map;
118951
119045
  }
@@ -118960,11 +119054,10 @@ var ts;
118960
119054
  }
118961
119055
  set.add(v);
118962
119056
  }
118963
- function deleteFromMultimap(map, k, v, removeEmpty) {
118964
- if (removeEmpty === void 0) { removeEmpty = true; }
119057
+ function deleteFromMultimap(map, k, v) {
118965
119058
  var set = map.get(k);
118966
119059
  if (set === null || set === void 0 ? void 0 : set.delete(v)) {
118967
- if (removeEmpty && !set.size) {
119060
+ if (!set.size) {
118968
119061
  map.delete(k);
118969
119062
  }
118970
119063
  return true;
@@ -119193,7 +119286,7 @@ var ts;
119193
119286
  /*forceDtsEmit*/ true);
119194
119287
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
119195
119288
  if (firstDts_1) {
119196
- ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
119289
+ ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
119197
119290
  latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
119198
119291
  if (exportedModulesMapCache && latestSignature !== prevSignature) {
119199
119292
  updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
@@ -119251,20 +119344,6 @@ var ts;
119251
119344
  var _a;
119252
119345
  if (exportedModulesMapCache) {
119253
119346
  ts.Debug.assert(!!state.exportedModulesMap);
119254
- var cacheId = exportedModulesMapCache.id;
119255
- var cacheVersion = exportedModulesMapCache.version();
119256
- if (state.previousCache) {
119257
- if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) {
119258
- // If this is the same cache at the same version as last time this BuilderState
119259
- // was updated, there's no need to update again
119260
- return;
119261
- }
119262
- state.previousCache.id = cacheId;
119263
- state.previousCache.version = cacheVersion;
119264
- }
119265
- else {
119266
- state.previousCache = { id: cacheId, version: cacheVersion };
119267
- }
119268
119347
  (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
119269
119348
  exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
119270
119349
  }
@@ -119598,7 +119677,8 @@ var ts;
119598
119677
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
119599
119678
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
119600
119679
  */
119601
- function getNextAffectedFile(state, cancellationToken, computeHash) {
119680
+ function getNextAffectedFile(state, cancellationToken, computeHash, host) {
119681
+ var _a;
119602
119682
  while (true) {
119603
119683
  var affectedFiles = state.affectedFiles;
119604
119684
  if (affectedFiles) {
@@ -119609,7 +119689,7 @@ var ts;
119609
119689
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
119610
119690
  // Set the next affected file as seen and remove the cached semantic diagnostics
119611
119691
  state.affectedFilesIndex = affectedFilesIndex;
119612
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
119692
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
119613
119693
  return affectedFile;
119614
119694
  }
119615
119695
  affectedFilesIndex++;
@@ -119621,6 +119701,7 @@ var ts;
119621
119701
  ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
119622
119702
  state.currentAffectedFilesSignatures.clear();
119623
119703
  ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
119704
+ (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
119624
119705
  state.affectedFiles = undefined;
119625
119706
  }
119626
119707
  // Get next changed file
@@ -119650,6 +119731,11 @@ var ts;
119650
119731
  state.seenAffectedFiles = new ts.Set();
119651
119732
  }
119652
119733
  }
119734
+ function clearAffectedFilesPendingEmit(state) {
119735
+ state.affectedFilesPendingEmit = undefined;
119736
+ state.affectedFilesPendingEmitKind = undefined;
119737
+ state.affectedFilesPendingEmitIndex = undefined;
119738
+ }
119653
119739
  /**
119654
119740
  * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
119655
119741
  */
@@ -119669,9 +119755,7 @@ var ts;
119669
119755
  }
119670
119756
  }
119671
119757
  }
119672
- state.affectedFilesPendingEmit = undefined;
119673
- state.affectedFilesPendingEmitKind = undefined;
119674
- state.affectedFilesPendingEmitIndex = undefined;
119758
+ clearAffectedFilesPendingEmit(state);
119675
119759
  }
119676
119760
  return undefined;
119677
119761
  }
@@ -119679,7 +119763,7 @@ var ts;
119679
119763
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119680
119764
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
119681
119765
  */
119682
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
119766
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
119683
119767
  var _a;
119684
119768
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119685
119769
  // If affected files is everything except default library, then nothing more to do
@@ -119704,14 +119788,14 @@ var ts;
119704
119788
  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);
119705
119789
  }
119706
119790
  if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
119707
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
119791
+ forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
119708
119792
  }
119709
119793
  }
119710
119794
  /**
119711
119795
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
119712
119796
  * Also we need to make sure signature is updated for these files
119713
119797
  */
119714
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
119798
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
119715
119799
  removeSemanticDiagnosticsOf(state, path);
119716
119800
  if (!state.changedFilesSet.has(path)) {
119717
119801
  var program = ts.Debug.checkDefined(state.program);
@@ -119722,8 +119806,7 @@ var ts;
119722
119806
  // This ensures that we dont later during incremental builds considering wrong signature.
119723
119807
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
119724
119808
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
119725
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
119726
- /* useFileVersionAsSignature */ true);
119809
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
119727
119810
  // If not dts emit, nothing more to do
119728
119811
  if (ts.getEmitDeclarations(state.compilerOptions)) {
119729
119812
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -119920,13 +120003,18 @@ var ts;
119920
120003
  var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
119921
120004
  var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
119922
120005
  return value.version === actualSignature ?
119923
- value.affectsGlobalScope ?
119924
- { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
120006
+ value.affectsGlobalScope || value.impliedFormat ?
120007
+ // If file version is same as signature, dont serialize signature
120008
+ { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120009
+ // If file info only contains version and signature and both are same we can just write string
119925
120010
  value.version :
119926
- actualSignature !== undefined ?
120011
+ actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
119927
120012
  signature === undefined ?
120013
+ // If we havent computed signature, use fileInfo as is
119928
120014
  value :
120015
+ // Serialize fileInfo with new updated signature
119929
120016
  { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120017
+ // Signature of the FileInfo is undefined, serialize it as false
119930
120018
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
119931
120019
  });
119932
120020
  var referencedMap;
@@ -120171,7 +120259,7 @@ var ts;
120171
120259
  * in that order would be used to write the files
120172
120260
  */
120173
120261
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
120174
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120262
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
120175
120263
  var emitKind = 1 /* Full */;
120176
120264
  var isPendingEmitFile = false;
120177
120265
  if (!affected) {
@@ -120216,54 +120304,48 @@ var ts;
120216
120304
  * in that order would be used to write the files
120217
120305
  */
120218
120306
  function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
120219
- var restorePendingEmitOnHandlingNoEmitSuccess = false;
120220
- var savedAffectedFilesPendingEmit;
120221
- var savedAffectedFilesPendingEmitKind;
120222
- var savedAffectedFilesPendingEmitIndex;
120223
- // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors
120224
- // This ensures pending files to emit is updated in tsbuildinfo
120225
- // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit)
120226
- if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
120227
- !targetSourceFile &&
120228
- !ts.outFile(state.compilerOptions) &&
120229
- !state.compilerOptions.noEmit &&
120230
- state.compilerOptions.noEmitOnError) {
120231
- restorePendingEmitOnHandlingNoEmitSuccess = true;
120232
- savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120233
- savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120234
- savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120235
- }
120307
+ var _a;
120236
120308
  if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120237
120309
  assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
120238
120310
  }
120239
120311
  var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
120240
120312
  if (result)
120241
120313
  return result;
120242
- if (restorePendingEmitOnHandlingNoEmitSuccess) {
120243
- state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
120244
- state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
120245
- state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
120246
- }
120247
120314
  // Emit only affected files if using builder for emit
120248
- if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120249
- // Emit and report any errors we ran into.
120250
- var sourceMaps = [];
120251
- var emitSkipped = false;
120252
- var diagnostics = void 0;
120253
- var emittedFiles = [];
120254
- var affectedEmitResult = void 0;
120255
- while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
120256
- emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
120257
- diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
120258
- emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
120259
- sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120315
+ if (!targetSourceFile) {
120316
+ if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120317
+ // Emit and report any errors we ran into.
120318
+ var sourceMaps = [];
120319
+ var emitSkipped = false;
120320
+ var diagnostics = void 0;
120321
+ var emittedFiles = [];
120322
+ var affectedEmitResult = void 0;
120323
+ while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
120324
+ emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
120325
+ diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
120326
+ emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
120327
+ sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120328
+ }
120329
+ return {
120330
+ emitSkipped: emitSkipped,
120331
+ diagnostics: diagnostics || ts.emptyArray,
120332
+ emittedFiles: emittedFiles,
120333
+ sourceMaps: sourceMaps
120334
+ };
120335
+ }
120336
+ // In non Emit builder, clear affected files pending emit
120337
+ else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
120338
+ ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
120339
+ // State can clear affected files pending emit if
120340
+ if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
120341
+ // If every file pending emit is pending on only dts emit
120342
+ || ts.every(state.affectedFilesPendingEmit, function (path, index) {
120343
+ return index < state.affectedFilesPendingEmitIndex ||
120344
+ state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
120345
+ })) {
120346
+ clearAffectedFilesPendingEmit(state);
120347
+ }
120260
120348
  }
120261
- return {
120262
- emitSkipped: emitSkipped,
120263
- diagnostics: diagnostics || ts.emptyArray,
120264
- emittedFiles: emittedFiles,
120265
- sourceMaps: sourceMaps
120266
- };
120267
120349
  }
120268
120350
  return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120269
120351
  }
@@ -120273,7 +120355,7 @@ var ts;
120273
120355
  */
120274
120356
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
120275
120357
  while (true) {
120276
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120358
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
120277
120359
  if (!affected) {
120278
120360
  // Done
120279
120361
  return undefined;
@@ -123393,9 +123475,6 @@ var ts;
123393
123475
  function newer(date1, date2) {
123394
123476
  return date2 > date1 ? date2 : date1;
123395
123477
  }
123396
- function isDeclarationFile(fileName) {
123397
- return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
123398
- }
123399
123478
  /*@internal*/
123400
123479
  function isCircularBuildOrder(buildOrder) {
123401
123480
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -123958,7 +124037,7 @@ var ts;
123958
124037
  outputFiles.forEach(function (_a) {
123959
124038
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
123960
124039
  var priorChangeTime;
123961
- if (!anyDtsChanged && isDeclarationFile(name)) {
124040
+ if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
123962
124041
  // Check for unchanged .d.ts files
123963
124042
  if (host.fileExists(name) && state.readFileWithCache(name) === text) {
123964
124043
  priorChangeTime = host.getModifiedTime(name);
@@ -124299,7 +124378,7 @@ var ts;
124299
124378
  // In addition to file timestamps, we also keep track of when a .d.ts file
124300
124379
  // had its file touched but not had its contents changed - this allows us
124301
124380
  // to skip a downstream typecheck
124302
- if (isDeclarationFile(output)) {
124381
+ if (ts.isDeclarationFileName(output)) {
124303
124382
  var outputModifiedTime = ts.getModifiedTime(host, output);
124304
124383
  newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
124305
124384
  }
@@ -124453,7 +124532,7 @@ var ts;
124453
124532
  reportVerbose = false;
124454
124533
  reportStatus(state, verboseMessage, proj.options.configFilePath);
124455
124534
  }
124456
- if (isDeclarationFile(file)) {
124535
+ if (ts.isDeclarationFileName(file)) {
124457
124536
  priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
124458
124537
  }
124459
124538
  host.setModifiedTime(file, now);