typescript 4.7.0-dev.20220309 → 4.7.0-dev.20220312

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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220309";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220312";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -1662,6 +1662,159 @@ var ts;
1662
1662
  return createMultiMap();
1663
1663
  }
1664
1664
  ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap;
1665
+ /**
1666
+ * Creates a Set with custom equality and hash code functionality. This is useful when you
1667
+ * want to use something looser than object identity - e.g. "has the same span".
1668
+ *
1669
+ * If `equals(a, b)`, it must be the case that `getHashCode(a) === getHashCode(b)`.
1670
+ * The converse is not required.
1671
+ *
1672
+ * To facilitate a perf optimization (lazy allocation of bucket arrays), `TElement` is
1673
+ * assumed not to be an array type.
1674
+ */
1675
+ function createSet(getHashCode, equals) {
1676
+ var multiMap = new ts.Map();
1677
+ var size = 0;
1678
+ function getElementIterator() {
1679
+ var valueIt = multiMap.values();
1680
+ var arrayIt;
1681
+ return {
1682
+ next: function () {
1683
+ while (true) {
1684
+ if (arrayIt) {
1685
+ var n = arrayIt.next();
1686
+ if (!n.done) {
1687
+ return { value: n.value };
1688
+ }
1689
+ arrayIt = undefined;
1690
+ }
1691
+ else {
1692
+ var n = valueIt.next();
1693
+ if (n.done) {
1694
+ return { value: undefined, done: true };
1695
+ }
1696
+ if (!isArray(n.value)) {
1697
+ return { value: n.value };
1698
+ }
1699
+ arrayIt = arrayIterator(n.value);
1700
+ }
1701
+ }
1702
+ }
1703
+ };
1704
+ }
1705
+ var set = {
1706
+ has: function (element) {
1707
+ var hash = getHashCode(element);
1708
+ if (!multiMap.has(hash))
1709
+ return false;
1710
+ var candidates = multiMap.get(hash);
1711
+ if (!isArray(candidates))
1712
+ return equals(candidates, element);
1713
+ for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
1714
+ var candidate = candidates_1[_i];
1715
+ if (equals(candidate, element)) {
1716
+ return true;
1717
+ }
1718
+ }
1719
+ return false;
1720
+ },
1721
+ add: function (element) {
1722
+ var hash = getHashCode(element);
1723
+ if (multiMap.has(hash)) {
1724
+ var values = multiMap.get(hash);
1725
+ if (isArray(values)) {
1726
+ if (!contains(values, element, equals)) {
1727
+ values.push(element);
1728
+ size++;
1729
+ }
1730
+ }
1731
+ else {
1732
+ var value = values;
1733
+ if (!equals(value, element)) {
1734
+ multiMap.set(hash, [value, element]);
1735
+ size++;
1736
+ }
1737
+ }
1738
+ }
1739
+ else {
1740
+ multiMap.set(hash, element);
1741
+ size++;
1742
+ }
1743
+ return this;
1744
+ },
1745
+ delete: function (element) {
1746
+ var hash = getHashCode(element);
1747
+ if (!multiMap.has(hash))
1748
+ return false;
1749
+ var candidates = multiMap.get(hash);
1750
+ if (isArray(candidates)) {
1751
+ for (var i = 0; i < candidates.length; i++) {
1752
+ if (equals(candidates[i], element)) {
1753
+ if (candidates.length === 1) {
1754
+ multiMap.delete(hash);
1755
+ }
1756
+ else if (candidates.length === 2) {
1757
+ multiMap.set(hash, candidates[1 - i]);
1758
+ }
1759
+ else {
1760
+ unorderedRemoveItemAt(candidates, i);
1761
+ }
1762
+ size--;
1763
+ return true;
1764
+ }
1765
+ }
1766
+ }
1767
+ else {
1768
+ var candidate = candidates;
1769
+ if (equals(candidate, element)) {
1770
+ multiMap.delete(hash);
1771
+ size--;
1772
+ return true;
1773
+ }
1774
+ }
1775
+ return false;
1776
+ },
1777
+ clear: function () {
1778
+ multiMap.clear();
1779
+ size = 0;
1780
+ },
1781
+ get size() {
1782
+ return size;
1783
+ },
1784
+ forEach: function (action) {
1785
+ for (var _i = 0, _a = arrayFrom(multiMap.values()); _i < _a.length; _i++) {
1786
+ var elements = _a[_i];
1787
+ if (isArray(elements)) {
1788
+ for (var _b = 0, elements_1 = elements; _b < elements_1.length; _b++) {
1789
+ var element = elements_1[_b];
1790
+ action(element, element);
1791
+ }
1792
+ }
1793
+ else {
1794
+ var element = elements;
1795
+ action(element, element);
1796
+ }
1797
+ }
1798
+ },
1799
+ keys: function () {
1800
+ return getElementIterator();
1801
+ },
1802
+ values: function () {
1803
+ return getElementIterator();
1804
+ },
1805
+ entries: function () {
1806
+ var it = getElementIterator();
1807
+ return {
1808
+ next: function () {
1809
+ var n = it.next();
1810
+ return n.done ? n : { value: [n.value, n.value] };
1811
+ }
1812
+ };
1813
+ },
1814
+ };
1815
+ return set;
1816
+ }
1817
+ ts.createSet = createSet;
1665
1818
  /**
1666
1819
  * Tests whether a value is an array.
1667
1820
  */
@@ -2055,8 +2208,8 @@ var ts;
2055
2208
  var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
2056
2209
  var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
2057
2210
  var bestCandidate;
2058
- for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
2059
- var candidate = candidates_1[_i];
2211
+ for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
2212
+ var candidate = candidates_2[_i];
2060
2213
  var candidateName = getName(candidate);
2061
2214
  if (candidateName !== undefined && Math.abs(candidateName.length - name.length) <= maximumLengthDifference) {
2062
2215
  if (candidateName === name) {
@@ -2293,13 +2446,15 @@ var ts;
2293
2446
  for (var _i = 0; _i < arguments.length; _i++) {
2294
2447
  args[_i] = arguments[_i];
2295
2448
  }
2449
+ var lastResult;
2296
2450
  for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
2297
2451
  var f = fs_1[_a];
2298
- if (f.apply(void 0, args)) {
2299
- return true;
2452
+ lastResult = f.apply(void 0, args);
2453
+ if (lastResult) {
2454
+ return lastResult;
2300
2455
  }
2301
2456
  }
2302
- return false;
2457
+ return lastResult;
2303
2458
  };
2304
2459
  }
2305
2460
  ts.or = or;
@@ -4358,6 +4513,7 @@ var ts;
4358
4513
  SyntaxKind[SyntaxKind["JSDocFunctionType"] = 316] = "JSDocFunctionType";
4359
4514
  SyntaxKind[SyntaxKind["JSDocVariadicType"] = 317] = "JSDocVariadicType";
4360
4515
  SyntaxKind[SyntaxKind["JSDocNamepathType"] = 318] = "JSDocNamepathType";
4516
+ /** @deprecated Use SyntaxKind.JSDoc */
4361
4517
  SyntaxKind[SyntaxKind["JSDocComment"] = 319] = "JSDocComment";
4362
4518
  SyntaxKind[SyntaxKind["JSDocText"] = 320] = "JSDocText";
4363
4519
  SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 321] = "JSDocTypeLiteral";
@@ -4431,6 +4587,7 @@ var ts;
4431
4587
  SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 346] = "LastJSDocTagNode";
4432
4588
  /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
4433
4589
  /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 159] = "LastContextualKeyword";
4590
+ SyntaxKind[SyntaxKind["JSDoc"] = 319] = "JSDoc";
4434
4591
  })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
4435
4592
  var NodeFlags;
4436
4593
  (function (NodeFlags) {
@@ -5317,6 +5474,21 @@ var ts;
5317
5474
  ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12";
5318
5475
  ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext";
5319
5476
  })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
5477
+ var ModuleDetectionKind;
5478
+ (function (ModuleDetectionKind) {
5479
+ /**
5480
+ * Files with imports, exports and/or import.meta are considered modules
5481
+ */
5482
+ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy";
5483
+ /**
5484
+ * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+
5485
+ */
5486
+ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto";
5487
+ /**
5488
+ * Consider all non-declaration files modules, regardless of present syntax
5489
+ */
5490
+ ModuleDetectionKind[ModuleDetectionKind["Force"] = 3] = "Force";
5491
+ })(ModuleDetectionKind = ts.ModuleDetectionKind || (ts.ModuleDetectionKind = {}));
5320
5492
  var WatchFileKind;
5321
5493
  (function (WatchFileKind) {
5322
5494
  WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
@@ -8414,6 +8586,8 @@ var ts;
8414
8586
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8415
8587
  An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."),
8416
8588
  An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."),
8589
+ Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."),
8590
+ auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules."),
8417
8591
  The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
8418
8592
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
8419
8593
  Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
@@ -13027,7 +13201,7 @@ var ts;
13027
13201
  return ts.emptyArray;
13028
13202
  }
13029
13203
  if (ts.isJSDocTypeAlias(node)) {
13030
- ts.Debug.assert(node.parent.kind === 319 /* JSDocComment */);
13204
+ ts.Debug.assert(node.parent.kind === 319 /* JSDoc */);
13031
13205
  return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
13032
13206
  }
13033
13207
  if (node.typeParameters) {
@@ -13974,7 +14148,7 @@ var ts;
13974
14148
  ts.isJSDocNode = isJSDocNode;
13975
14149
  /** True if node is of a kind that may contain comment text. */
13976
14150
  function isJSDocCommentContainingNode(node) {
13977
- return node.kind === 319 /* JSDocComment */
14151
+ return node.kind === 319 /* JSDoc */
13978
14152
  || node.kind === 318 /* JSDocNamepathType */
13979
14153
  || node.kind === 320 /* JSDocText */
13980
14154
  || isJSDocLinkLike(node)
@@ -15539,10 +15713,23 @@ var ts;
15539
15713
  && node.parent.parent.kind === 236 /* VariableStatement */;
15540
15714
  }
15541
15715
  ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
15716
+ function isCommonJsExportedExpression(node) {
15717
+ if (!isInJSFile(node))
15718
+ return false;
15719
+ return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) ||
15720
+ isCommonJsExportPropertyAssignment(node.parent);
15721
+ }
15722
+ ts.isCommonJsExportedExpression = isCommonJsExportedExpression;
15723
+ function isCommonJsExportPropertyAssignment(node) {
15724
+ if (!isInJSFile(node))
15725
+ return false;
15726
+ return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */);
15727
+ }
15728
+ ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment;
15542
15729
  function isValidESSymbolDeclaration(node) {
15543
- return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
15730
+ return (ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
15544
15731
  ts.isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
15545
- ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node);
15732
+ ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node)) || isCommonJsExportPropertyAssignment(node);
15546
15733
  }
15547
15734
  ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
15548
15735
  function introducesArgumentsExoticObject(node) {
@@ -18436,7 +18623,7 @@ var ts;
18436
18623
  ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
18437
18624
  /** template tags are only available when a typedef isn't already using them */
18438
18625
  function isNonTypeAliasTemplate(tag) {
18439
- return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 319 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias));
18626
+ return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 319 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias));
18440
18627
  }
18441
18628
  /**
18442
18629
  * Gets the effective type annotation of the value parameter of a set accessor. If the node
@@ -19910,6 +20097,61 @@ var ts;
19910
20097
  return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */;
19911
20098
  }
19912
20099
  ts.getLanguageVariant = getLanguageVariant;
20100
+ /**
20101
+ * This is a somewhat unavoidable full tree walk to locate a JSX tag - `import.meta` requires the same,
20102
+ * but we avoid that walk (or parts of it) if at all possible using the `PossiblyContainsImportMeta` node flag.
20103
+ * Unfortunately, there's no `NodeFlag` space to do the same for JSX.
20104
+ */
20105
+ function walkTreeForJSXTags(node) {
20106
+ if (!(node.transformFlags & 2 /* ContainsJsx */))
20107
+ return undefined;
20108
+ return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags);
20109
+ }
20110
+ function isFileModuleFromUsingJSXTag(file) {
20111
+ // Excludes declaration files - they still require an explicit `export {}` or the like
20112
+ // for back compat purposes. (not that declaration files should contain JSX tags!)
20113
+ return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined;
20114
+ }
20115
+ /**
20116
+ * Note that this requires file.impliedNodeFormat be set already; meaning it must be set very early on
20117
+ * in SourceFile construction.
20118
+ */
20119
+ function isFileForcedToBeModuleByFormat(file) {
20120
+ // Excludes declaration files - they still require an explicit `export {}` or the like
20121
+ // for back compat purposes.
20122
+ return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20123
+ }
20124
+ function getSetExternalModuleIndicator(options) {
20125
+ // TODO: Should this callback be cached?
20126
+ switch (getEmitModuleDetectionKind(options)) {
20127
+ case ts.ModuleDetectionKind.Force:
20128
+ // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20129
+ return function (file) {
20130
+ file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20131
+ };
20132
+ case ts.ModuleDetectionKind.Legacy:
20133
+ // Files are modules if they have imports, exports, or import.meta
20134
+ return function (file) {
20135
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file);
20136
+ };
20137
+ case ts.ModuleDetectionKind.Auto:
20138
+ // If module is nodenext or node12, all esm format files are modules
20139
+ // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness
20140
+ // otherwise, the presence of import or export statments (or import.meta) implies module-ness
20141
+ var checks = [ts.isFileProbablyExternalModule];
20142
+ if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
20143
+ checks.push(isFileModuleFromUsingJSXTag);
20144
+ }
20145
+ var moduleKind = getEmitModuleKind(options);
20146
+ if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
20147
+ checks.push(isFileForcedToBeModuleByFormat);
20148
+ }
20149
+ var combined_1 = ts.or.apply(void 0, checks);
20150
+ var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
20151
+ return callback;
20152
+ }
20153
+ }
20154
+ ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator;
19913
20155
  function getEmitScriptTarget(compilerOptions) {
19914
20156
  return compilerOptions.target ||
19915
20157
  (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) ||
@@ -19944,6 +20186,10 @@ var ts;
19944
20186
  return moduleResolution;
19945
20187
  }
19946
20188
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20189
+ function getEmitModuleDetectionKind(options) {
20190
+ return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20191
+ }
20192
+ ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
19947
20193
  function hasJsonModuleEmitEnabled(options) {
19948
20194
  switch (getEmitModuleKind(options)) {
19949
20195
  case ts.ModuleKind.CommonJS:
@@ -25413,7 +25659,7 @@ var ts;
25413
25659
  }
25414
25660
  // @api
25415
25661
  function createJSDocComment(comment, tags) {
25416
- var node = createBaseNode(319 /* JSDocComment */);
25662
+ var node = createBaseNode(319 /* JSDoc */);
25417
25663
  node.comment = comment;
25418
25664
  node.tags = asNodeArray(tags);
25419
25665
  return node;
@@ -28922,7 +29168,7 @@ var ts;
28922
29168
  }
28923
29169
  ts.isJSDocNamepathType = isJSDocNamepathType;
28924
29170
  function isJSDoc(node) {
28925
- return node.kind === 319 /* JSDocComment */;
29171
+ return node.kind === 319 /* JSDoc */;
28926
29172
  }
28927
29173
  ts.isJSDoc = isJSDoc;
28928
29174
  function isJSDocTypeLiteral(node) {
@@ -30114,6 +30360,36 @@ var ts;
30114
30360
  text.charCodeAt(start + 3) !== 47 /* slash */;
30115
30361
  }
30116
30362
  ts.isJSDocLikeText = isJSDocLikeText;
30363
+ /*@internal*/
30364
+ function isFileProbablyExternalModule(sourceFile) {
30365
+ // Try to use the first top-level import/export when available, then
30366
+ // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
30367
+ return ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
30368
+ getImportMetaIfNecessary(sourceFile);
30369
+ }
30370
+ ts.isFileProbablyExternalModule = isFileProbablyExternalModule;
30371
+ function isAnExternalModuleIndicatorNode(node) {
30372
+ return hasModifierOfKind(node, 93 /* ExportKeyword */)
30373
+ || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
30374
+ || ts.isImportDeclaration(node)
30375
+ || ts.isExportAssignment(node)
30376
+ || ts.isExportDeclaration(node) ? node : undefined;
30377
+ }
30378
+ function getImportMetaIfNecessary(sourceFile) {
30379
+ return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
30380
+ walkTreeForImportMeta(sourceFile) :
30381
+ undefined;
30382
+ }
30383
+ function walkTreeForImportMeta(node) {
30384
+ return isImportMeta(node) ? node : forEachChild(node, walkTreeForImportMeta);
30385
+ }
30386
+ /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
30387
+ function hasModifierOfKind(node, kind) {
30388
+ return ts.some(node.modifiers, function (m) { return m.kind === kind; });
30389
+ }
30390
+ function isImportMeta(node) {
30391
+ return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta";
30392
+ }
30117
30393
  /**
30118
30394
  * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
30119
30395
  * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
@@ -30547,7 +30823,7 @@ var ts;
30547
30823
  case 316 /* JSDocFunctionType */:
30548
30824
  return visitNodes(cbNode, cbNodes, node.parameters) ||
30549
30825
  visitNode(cbNode, node.type);
30550
- case 319 /* JSDocComment */:
30826
+ case 319 /* JSDoc */:
30551
30827
  return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))
30552
30828
  || visitNodes(cbNode, cbNodes, node.tags);
30553
30829
  case 345 /* JSDocSeeTag */:
@@ -30695,17 +30971,25 @@ var ts;
30695
30971
  children.unshift(n);
30696
30972
  }
30697
30973
  }
30698
- function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
30974
+ function setExternalModuleIndicator(sourceFile) {
30975
+ sourceFile.externalModuleIndicator = isFileProbablyExternalModule(sourceFile);
30976
+ }
30977
+ function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) {
30699
30978
  if (setParentNodes === void 0) { setParentNodes = false; }
30700
30979
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
30701
30980
  ts.performance.mark("beforeParse");
30702
30981
  var result;
30703
30982
  ts.perfLogger.logStartParseSourceFile(fileName);
30983
+ var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat;
30704
30984
  if (languageVersion === 100 /* JSON */) {
30705
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */);
30985
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop);
30706
30986
  }
30707
30987
  else {
30708
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind);
30988
+ var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) {
30989
+ file.impliedNodeFormat = format;
30990
+ return (overrideSetExternalModuleIndicator || setExternalModuleIndicator)(file);
30991
+ };
30992
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind, setIndicator);
30709
30993
  }
30710
30994
  ts.perfLogger.logStopParseSourceFile();
30711
30995
  ts.performance.mark("afterParse");
@@ -30891,7 +31175,7 @@ var ts;
30891
31175
  // Note: any errors at the end of the file that do not precede a regular node, should get
30892
31176
  // attached to the EOF token.
30893
31177
  var parseErrorBeforeNextFinishedNode = false;
30894
- function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
31178
+ function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind, setExternalModuleIndicatorOverride) {
30895
31179
  var _a;
30896
31180
  if (setParentNodes === void 0) { setParentNodes = false; }
30897
31181
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
@@ -30907,7 +31191,7 @@ var ts;
30907
31191
  return result_3;
30908
31192
  }
30909
31193
  initializeState(fileName, sourceText, languageVersion, syntaxCursor, scriptKind);
30910
- var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind);
31194
+ var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicatorOverride || setExternalModuleIndicator);
30911
31195
  clearState();
30912
31196
  return result;
30913
31197
  }
@@ -30991,7 +31275,7 @@ var ts;
30991
31275
  endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token);
30992
31276
  }
30993
31277
  // Set source file so that errors will be reported with this file name
30994
- var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags);
31278
+ var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop);
30995
31279
  if (setParentNodes) {
30996
31280
  fixupParentReferences(sourceFile);
30997
31281
  }
@@ -31065,7 +31349,7 @@ var ts;
31065
31349
  notParenthesizedArrow = undefined;
31066
31350
  topLevel = true;
31067
31351
  }
31068
- function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
31352
+ function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
31069
31353
  var isDeclarationFile = isDeclarationFileName(fileName);
31070
31354
  if (isDeclarationFile) {
31071
31355
  contextFlags |= 8388608 /* Ambient */;
@@ -31076,7 +31360,7 @@ var ts;
31076
31360
  var statements = parseList(0 /* SourceElements */, parseStatement);
31077
31361
  ts.Debug.assert(token() === 1 /* EndOfFileToken */);
31078
31362
  var endOfFileToken = addJSDocComment(parseTokenNode());
31079
- var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags);
31363
+ var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
31080
31364
  // A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
31081
31365
  processCommentPragmas(sourceFile, sourceText);
31082
31366
  processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
@@ -31213,25 +31497,30 @@ var ts;
31213
31497
  ts.setParentRecursive(rootNode, /*incremental*/ true);
31214
31498
  }
31215
31499
  Parser.fixupParentReferences = fixupParentReferences;
31216
- function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags) {
31500
+ function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags, setExternalModuleIndicator) {
31217
31501
  // code from createNode is inlined here so createNode won't have to deal with special case of creating source files
31218
31502
  // this is quite rare comparing to other nodes and createNode should be as fast as possible
31219
31503
  var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
31220
31504
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
31221
- setExternalModuleIndicator(sourceFile);
31505
+ setFields(sourceFile);
31222
31506
  // If we parsed this as an external module, it may contain top-level await
31223
31507
  if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
31224
31508
  sourceFile = reparseTopLevelAwait(sourceFile);
31509
+ setFields(sourceFile);
31225
31510
  }
31226
- sourceFile.text = sourceText;
31227
- sourceFile.bindDiagnostics = [];
31228
- sourceFile.bindSuggestionDiagnostics = undefined;
31229
- sourceFile.languageVersion = languageVersion;
31230
- sourceFile.fileName = fileName;
31231
- sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
31232
- sourceFile.isDeclarationFile = isDeclarationFile;
31233
- sourceFile.scriptKind = scriptKind;
31234
31511
  return sourceFile;
31512
+ function setFields(sourceFile) {
31513
+ sourceFile.text = sourceText;
31514
+ sourceFile.bindDiagnostics = [];
31515
+ sourceFile.bindSuggestionDiagnostics = undefined;
31516
+ sourceFile.languageVersion = languageVersion;
31517
+ sourceFile.fileName = fileName;
31518
+ sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
31519
+ sourceFile.isDeclarationFile = isDeclarationFile;
31520
+ sourceFile.scriptKind = scriptKind;
31521
+ setExternalModuleIndicator(sourceFile);
31522
+ sourceFile.setExternalModuleIndicator = setExternalModuleIndicator;
31523
+ }
31235
31524
  }
31236
31525
  function setContextFlag(val, flag) {
31237
31526
  if (val) {
@@ -36714,35 +37003,6 @@ var ts;
36714
37003
  var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
36715
37004
  return withJSDoc(finishNode(node, pos), hasJSDoc);
36716
37005
  }
36717
- function setExternalModuleIndicator(sourceFile) {
36718
- // Try to use the first top-level import/export when available, then
36719
- // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
36720
- sourceFile.externalModuleIndicator =
36721
- ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
36722
- getImportMetaIfNecessary(sourceFile);
36723
- }
36724
- function isAnExternalModuleIndicatorNode(node) {
36725
- return hasModifierOfKind(node, 93 /* ExportKeyword */)
36726
- || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
36727
- || ts.isImportDeclaration(node)
36728
- || ts.isExportAssignment(node)
36729
- || ts.isExportDeclaration(node) ? node : undefined;
36730
- }
36731
- function getImportMetaIfNecessary(sourceFile) {
36732
- return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
36733
- walkTreeForExternalModuleIndicators(sourceFile) :
36734
- undefined;
36735
- }
36736
- function walkTreeForExternalModuleIndicators(node) {
36737
- return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
36738
- }
36739
- /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
36740
- function hasModifierOfKind(node, kind) {
36741
- return ts.some(node.modifiers, function (m) { return m.kind === kind; });
36742
- }
36743
- function isImportMeta(node) {
36744
- return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta";
36745
- }
36746
37006
  var ParsingContext;
36747
37007
  (function (ParsingContext) {
36748
37008
  ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements";
@@ -36785,7 +37045,7 @@ var ts;
36785
37045
  scanner.setText(content, start, length);
36786
37046
  currentToken = scanner.scan();
36787
37047
  var jsDocTypeExpression = parseJSDocTypeExpression();
36788
- var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */);
37048
+ var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop);
36789
37049
  var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
36790
37050
  if (jsDocDiagnostics) {
36791
37051
  sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
@@ -37746,7 +38006,7 @@ var ts;
37746
38006
  if (sourceFile.statements.length === 0) {
37747
38007
  // If we don't have any statements in the current source file, then there's no real
37748
38008
  // way to incrementally parse. So just do a full parse instead.
37749
- return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind);
38009
+ return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
37750
38010
  }
37751
38011
  // Make sure we're not trying to incrementally update a source file more than once. Once
37752
38012
  // we do an update the original source file is considered unusable from that point onwards.
@@ -37803,7 +38063,7 @@ var ts;
37803
38063
  // inconsistent tree. Setting the parents on the new tree should be very fast. We
37804
38064
  // will immediately bail out of walking any subtrees when we can see that their parents
37805
38065
  // are already correct.
37806
- var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
38066
+ var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
37807
38067
  result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
37808
38068
  result.impliedNodeFormat = sourceFile.impliedNodeFormat;
37809
38069
  return result;
@@ -39719,6 +39979,18 @@ var ts;
39719
39979
  description: ts.Diagnostics.Specify_a_list_of_language_service_plugins_to_include,
39720
39980
  category: ts.Diagnostics.Editor_Support,
39721
39981
  },
39982
+ {
39983
+ name: "moduleDetection",
39984
+ type: new ts.Map(ts.getEntries({
39985
+ auto: ts.ModuleDetectionKind.Auto,
39986
+ legacy: ts.ModuleDetectionKind.Legacy,
39987
+ force: ts.ModuleDetectionKind.Force,
39988
+ })),
39989
+ affectsModuleResolution: true,
39990
+ description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files,
39991
+ category: ts.Diagnostics.Language_and_Environment,
39992
+ defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules,
39993
+ }
39722
39994
  ];
39723
39995
  /* @internal */
39724
39996
  ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild, true), commandOptionsWithoutBuild, true);
@@ -47861,6 +48133,8 @@ var ts;
47861
48133
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
47862
48134
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
47863
48135
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48136
+ var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
48137
+ var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints)
47864
48138
  var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
47865
48139
  var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
47866
48140
  emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */;
@@ -48799,7 +49073,7 @@ var ts;
48799
49073
  // - parameters are only in the scope of function body
48800
49074
  // This restriction does not apply to JSDoc comment types because they are parented
48801
49075
  // at a higher level than type parameters would normally be
48802
- if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 319 /* JSDocComment */) {
49076
+ if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 319 /* JSDoc */) {
48803
49077
  useResult = result.flags & 262144 /* TypeParameter */
48804
49078
  // type parameters are visible in parameter list, return type and type parameter list
48805
49079
  ? lastLocation === location.type ||
@@ -51765,10 +52039,16 @@ var ts;
51765
52039
  var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
51766
52040
  var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined;
51767
52041
  var appropriateConstraintTypeNode;
52042
+ var newTypeVariable;
51768
52043
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
51769
52044
  // We have a { [P in keyof T]: X }
51770
52045
  // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
51771
- appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
52046
+ if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
52047
+ var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
52048
+ var name = typeParameterToName(newParam, context);
52049
+ newTypeVariable = ts.factory.createTypeReferenceNode(name);
52050
+ }
52051
+ appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
51772
52052
  }
51773
52053
  else {
51774
52054
  appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
@@ -51778,7 +52058,14 @@ var ts;
51778
52058
  var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context);
51779
52059
  var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
51780
52060
  context.approximateLength += 10;
51781
- return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
52061
+ var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
52062
+ if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
52063
+ // homomorphic mapped type with a non-homomorphic naive inlining
52064
+ // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
52065
+ // type stays homomorphic
52066
+ return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
52067
+ }
52068
+ return result;
51782
52069
  }
51783
52070
  function createAnonymousTypeNode(type) {
51784
52071
  var _a;
@@ -53399,7 +53686,7 @@ var ts;
53399
53686
  // If it's a class/interface/function: emit a class/interface/function with a `default` modifier
53400
53687
  // These forms can merge, eg (`export default 12; export default interface A {}`)
53401
53688
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
53402
- var _a, _b;
53689
+ var _a, _b, _c, _d;
53403
53690
  var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
53404
53691
  var isDefault = symbol.escapedName === "default" /* Default */;
53405
53692
  if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
@@ -53450,17 +53737,21 @@ var ts;
53450
53737
  else {
53451
53738
  // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_
53452
53739
  // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property`
53453
- var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined
53454
- : isConstVariable(symbol) ? 2 /* Const */
53740
+ var flags = !(symbol.flags & 2 /* BlockScopedVariable */)
53741
+ ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration)
53742
+ ? 2 /* Const */
53743
+ : undefined
53744
+ : isConstVariable(symbol)
53745
+ ? 2 /* Const */
53455
53746
  : 1 /* Let */;
53456
53747
  var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol);
53457
53748
  var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
53458
53749
  if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
53459
53750
  textRange = textRange.parent.parent;
53460
53751
  }
53461
- var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression);
53752
+ var propertyAccessRequire = (_c = symbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isPropertyAccessExpression);
53462
53753
  if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right)
53463
- && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
53754
+ && ((_d = type.symbol) === null || _d === void 0 ? void 0 : _d.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
53464
53755
  var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right;
53465
53756
  addResult(ts.factory.createExportDeclaration(
53466
53757
  /*decorators*/ undefined,
@@ -53540,8 +53831,8 @@ var ts;
53540
53831
  // synthesize export * from "moduleReference"
53541
53832
  // Straightforward - only one thing to do - make an export declaration
53542
53833
  if (symbol.declarations) {
53543
- for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) {
53544
- var node = _c[_i];
53834
+ for (var _i = 0, _e = symbol.declarations; _i < _e.length; _i++) {
53835
+ var node = _e[_i];
53545
53836
  var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
53546
53837
  if (!resolvedModule)
53547
53838
  continue;
@@ -55347,7 +55638,10 @@ var ts;
55347
55638
  if (containsSameNamedThisProperty(expression.left, expression.right)) {
55348
55639
  return anyType;
55349
55640
  }
55350
- var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
55641
+ var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression)));
55642
+ var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol)
55643
+ : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right))
55644
+ : getWidenedLiteralType(checkExpressionCached(expression.right));
55351
55645
  if (type.flags & 524288 /* Object */ &&
55352
55646
  kind === 2 /* ModuleExports */ &&
55353
55647
  symbol.escapedName === "export=" /* ExportEquals */) {
@@ -56091,7 +56385,7 @@ var ts;
56091
56385
  node = paramSymbol.valueDeclaration;
56092
56386
  }
56093
56387
  break;
56094
- case 319 /* JSDocComment */: {
56388
+ case 319 /* JSDoc */: {
56095
56389
  var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
56096
56390
  return node.tags
56097
56391
  ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; }))
@@ -58352,10 +58646,10 @@ var ts;
58352
58646
  else if (type !== firstType) {
58353
58647
  checkFlags |= 64 /* HasNonUniformType */;
58354
58648
  }
58355
- if (isLiteralType(type) || isPatternLiteralType(type)) {
58649
+ if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
58356
58650
  checkFlags |= 128 /* HasLiteralType */;
58357
58651
  }
58358
- if (type.flags & 131072 /* Never */) {
58652
+ if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
58359
58653
  checkFlags |= 131072 /* HasNeverType */;
58360
58654
  }
58361
58655
  propTypes.push(type);
@@ -59540,7 +59834,7 @@ var ts;
59540
59834
  function getConditionalFlowTypeOfType(type, node) {
59541
59835
  var constraints;
59542
59836
  var covariant = true;
59543
- while (node && !ts.isStatement(node) && node.kind !== 319 /* JSDocComment */) {
59837
+ while (node && !ts.isStatement(node) && node.kind !== 319 /* JSDoc */) {
59544
59838
  var parent = node.parent;
59545
59839
  // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but
59546
59840
  // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax
@@ -60896,10 +61190,24 @@ var ts;
60896
61190
  return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
60897
61191
  /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
60898
61192
  }
61193
+ /**
61194
+ * A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
61195
+ * must be kept generic, as that instantiation information needs to flow through the type system. By replacing all
61196
+ * type parameters in the union with a special never type that is treated as a literal in `getReducedType`, we can cause the `getReducedType` logic
61197
+ * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
61198
+ */
61199
+ function isPossiblyReducibleByInstantiation(type) {
61200
+ return ts.some(type.types, function (t) {
61201
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
61202
+ return getReducedType(uniqueFilled) !== uniqueFilled;
61203
+ });
61204
+ }
60899
61205
  function getIndexType(type, stringsOnly, noIndexSignatures) {
60900
61206
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
60901
61207
  type = getReducedType(type);
60902
- return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
61208
+ return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
61209
+ ? getIndexTypeForGenericType(type, stringsOnly)
61210
+ : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60903
61211
  type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60904
61212
  type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
60905
61213
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
@@ -61527,6 +61835,10 @@ var ts;
61527
61835
  }
61528
61836
  return type;
61529
61837
  }
61838
+ function maybeCloneTypeParameter(p) {
61839
+ var constraint = getConstraintOfTypeParameter(p);
61840
+ return constraint && (isGenericObjectType(constraint) || isGenericIndexType(constraint)) ? cloneTypeParameter(p) : p;
61841
+ }
61530
61842
  function isTypicalNondistributiveConditional(root) {
61531
61843
  return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
61532
61844
  }
@@ -61545,37 +61857,65 @@ var ts;
61545
61857
  var result;
61546
61858
  var extraTypes;
61547
61859
  var tailCount = 0;
61548
- // We loop here for an immediately nested conditional type in the false position, effectively treating
61549
- // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
61550
- // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
61551
- // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
61552
- // cases we increment the tail recursion counter and stop after 1000 iterations.
61553
- while (true) {
61860
+ var _loop_18 = function () {
61554
61861
  if (tailCount === 1000) {
61555
61862
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
61556
61863
  result = errorType;
61557
- break;
61864
+ return "break";
61558
61865
  }
61559
61866
  var isUnwrapped = isTypicalNondistributiveConditional(root);
61560
61867
  var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
61561
61868
  var checkTypeInstantiable = isGenericType(checkType);
61562
61869
  var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
61563
61870
  if (checkType === wildcardType || extendsType === wildcardType) {
61564
- return wildcardType;
61871
+ return { value: wildcardType };
61565
61872
  }
61566
61873
  var combinedMapper = void 0;
61567
61874
  if (root.inferTypeParameters) {
61568
- var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */);
61569
- if (!checkTypeInstantiable) {
61875
+ // When we're looking at making an inference for an infer type, when we get its constraint, it'll automagically be
61876
+ // instantiated with the context, so it doesn't need the mapper for the inference contex - however the constraint
61877
+ // may refer to another _root_, _uncloned_ `infer` type parameter [1], or to something mapped by `mapper` [2].
61878
+ // [1] Eg, if we have `Foo<T, U extends T>` and `Foo<number, infer B>` - `B` is constrained to `T`, which, in turn, has been instantiated
61879
+ // as `number`
61880
+ // Conversely, if we have `Foo<infer A, infer B>`, `B` is still constrained to `T` and `T` is instantiated as `A`
61881
+ // [2] Eg, if we have `Foo<T, U extends T>` and `Foo<Q, infer B>` where `Q` is mapped by `mapper` into `number` - `B` is constrained to `T`
61882
+ // which is in turn instantiated as `Q`, which is in turn instantiated as `number`.
61883
+ // So we need to:
61884
+ // * Clone the type parameters so their constraints can be instantiated in the context of `mapper` (otherwise theyd only get inference context information)
61885
+ // * Set the clones to both map the conditional's enclosing `mapper` and the original params
61886
+ // * instantiate the extends type with the clones
61887
+ // * incorporate all of the component mappers into the combined mapper for the true and false members
61888
+ // This means we have three mappers that need applying:
61889
+ // * The original `mapper` used to create this conditional
61890
+ // * The mapper that maps the old root type parameter to the clone (`freshMapper`)
61891
+ // * The mapper that maps the clone to its inference result (`context.mapper`)
61892
+ var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
61893
+ var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined;
61894
+ var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */);
61895
+ if (freshMapper) {
61896
+ var freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
61897
+ for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) {
61898
+ var p = freshParams_1[_i];
61899
+ if (root.inferTypeParameters.indexOf(p) === -1) {
61900
+ p.mapper = freshCombinedMapper;
61901
+ }
61902
+ }
61903
+ }
61904
+ // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
61905
+ // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
61906
+ // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
61907
+ // so in those cases we refain from performing inference and retain the uninfered type parameter
61908
+ if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
61570
61909
  // We don't want inferences from constraints as they may cause us to eagerly resolve the
61571
61910
  // conditional type instead of deferring resolution. Also, we always want strict function
61572
61911
  // types rules (i.e. proper contravariance) for inferences.
61573
- inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
61912
+ inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
61574
61913
  }
61914
+ var innerMapper = combineTypeMappers(freshMapper, context.mapper);
61575
61915
  // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the
61576
61916
  // those type parameters are used in type references (see getInferredTypeParameterConstraint). For
61577
61917
  // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples.
61578
- combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper;
61918
+ combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
61579
61919
  }
61580
61920
  // Instantiate the extends type including inferences for 'infer T' type parameters
61581
61921
  var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType;
@@ -61597,14 +61937,14 @@ var ts;
61597
61937
  var newRoot = falseType_1.root;
61598
61938
  if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
61599
61939
  root = newRoot;
61600
- continue;
61940
+ return "continue";
61601
61941
  }
61602
61942
  if (canTailRecurse(falseType_1, mapper)) {
61603
- continue;
61943
+ return "continue";
61604
61944
  }
61605
61945
  }
61606
61946
  result = instantiateType(falseType_1, mapper);
61607
- break;
61947
+ return "break";
61608
61948
  }
61609
61949
  // Return trueType for a definitely true extends check. We check instantiations of the two
61610
61950
  // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
@@ -61615,10 +61955,10 @@ var ts;
61615
61955
  var trueType_1 = getTypeFromTypeNode(root.node.trueType);
61616
61956
  var trueMapper = combinedMapper || mapper;
61617
61957
  if (canTailRecurse(trueType_1, trueMapper)) {
61618
- continue;
61958
+ return "continue";
61619
61959
  }
61620
61960
  result = instantiateType(trueType_1, trueMapper);
61621
- break;
61961
+ return "break";
61622
61962
  }
61623
61963
  }
61624
61964
  // Return a deferred type for a check that is neither definitely true nor definitely false
@@ -61630,7 +61970,19 @@ var ts;
61630
61970
  result.combinedMapper = combinedMapper;
61631
61971
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
61632
61972
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
61633
- break;
61973
+ return "break";
61974
+ };
61975
+ // We loop here for an immediately nested conditional type in the false position, effectively treating
61976
+ // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
61977
+ // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
61978
+ // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
61979
+ // cases we increment the tail recursion counter and stop after 1000 iterations.
61980
+ while (true) {
61981
+ var state_5 = _loop_18();
61982
+ if (typeof state_5 === "object")
61983
+ return state_5.value;
61984
+ if (state_5 === "break")
61985
+ break;
61634
61986
  }
61635
61987
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
61636
61988
  // We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
@@ -62052,9 +62404,11 @@ var ts;
62052
62404
  }
62053
62405
  function getESSymbolLikeTypeForNode(node) {
62054
62406
  if (ts.isValidESSymbolDeclaration(node)) {
62055
- var symbol = getSymbolOfNode(node);
62056
- var links = getSymbolLinks(symbol);
62057
- return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
62407
+ var symbol = ts.isCommonJsExportPropertyAssignment(node) ? getSymbolOfNode(node.left) : getSymbolOfNode(node);
62408
+ if (symbol) {
62409
+ var links = getSymbolLinks(symbol);
62410
+ return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
62411
+ }
62058
62412
  }
62059
62413
  return esSymbolType;
62060
62414
  }
@@ -62698,6 +63052,10 @@ var ts;
62698
63052
  }
62699
63053
  return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable
62700
63054
  }
63055
+ function getUniqueLiteralFilledInstantiation(type) {
63056
+ return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
63057
+ type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper));
63058
+ }
62701
63059
  function getPermissiveInstantiation(type) {
62702
63060
  return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
62703
63061
  type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
@@ -63586,7 +63944,8 @@ var ts;
63586
63944
  return true;
63587
63945
  }
63588
63946
  }
63589
- else {
63947
+ else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
63948
+ // We have excluded types that may simplify to other forms, so types must have identical flags
63590
63949
  if (source.flags !== target.flags)
63591
63950
  return false;
63592
63951
  if (source.flags & 67358815 /* Singleton */)
@@ -64157,7 +64516,7 @@ var ts;
64157
64516
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
64158
64517
  checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
64159
64518
  }
64160
- var _loop_18 = function (prop) {
64519
+ var _loop_19 = function (prop) {
64161
64520
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
64162
64521
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
64163
64522
  if (reportErrors) {
@@ -64220,9 +64579,9 @@ var ts;
64220
64579
  };
64221
64580
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
64222
64581
  var prop = _b[_i];
64223
- var state_5 = _loop_18(prop);
64224
- if (typeof state_5 === "object")
64225
- return state_5.value;
64582
+ var state_6 = _loop_19(prop);
64583
+ if (typeof state_6 === "object")
64584
+ return state_6.value;
64226
64585
  }
64227
64586
  return false;
64228
64587
  }
@@ -65212,11 +65571,11 @@ var ts;
65212
65571
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
65213
65572
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
65214
65573
  var matchingTypes = [];
65215
- var _loop_19 = function (combination) {
65574
+ var _loop_20 = function (combination) {
65216
65575
  var hasMatch = false;
65217
65576
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
65218
65577
  var type = _d[_c];
65219
- var _loop_20 = function (i) {
65578
+ var _loop_21 = function (i) {
65220
65579
  var sourceProperty = sourcePropertiesFiltered[i];
65221
65580
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
65222
65581
  if (!targetProperty)
@@ -65232,8 +65591,8 @@ var ts;
65232
65591
  }
65233
65592
  };
65234
65593
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
65235
- var state_7 = _loop_20(i);
65236
- switch (state_7) {
65594
+ var state_8 = _loop_21(i);
65595
+ switch (state_8) {
65237
65596
  case "continue-outer": continue outer;
65238
65597
  }
65239
65598
  }
@@ -65246,9 +65605,9 @@ var ts;
65246
65605
  };
65247
65606
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
65248
65607
  var combination = discriminantCombinations_1[_a];
65249
- var state_6 = _loop_19(combination);
65250
- if (typeof state_6 === "object")
65251
- return state_6.value;
65608
+ var state_7 = _loop_20(combination);
65609
+ if (typeof state_7 === "object")
65610
+ return state_7.value;
65252
65611
  }
65253
65612
  // Compare the remaining non-discriminant properties of each match.
65254
65613
  var result = -1 /* True */;
@@ -65961,7 +66320,7 @@ var ts;
65961
66320
  // The emptyArray singleton is used to signal a recursive invocation.
65962
66321
  cache.variances = ts.emptyArray;
65963
66322
  variances = [];
65964
- var _loop_21 = function (tp) {
66323
+ var _loop_22 = function (tp) {
65965
66324
  var unmeasurable = false;
65966
66325
  var unreliable = false;
65967
66326
  var oldHandler = outofbandVarianceMarkerHandler;
@@ -65993,7 +66352,7 @@ var ts;
65993
66352
  };
65994
66353
  for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
65995
66354
  var tp = typeParameters_1[_i];
65996
- _loop_21(tp);
66355
+ _loop_22(tp);
65997
66356
  }
65998
66357
  cache.variances = variances;
65999
66358
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -68364,7 +68723,7 @@ var ts;
68364
68723
  function mapTypesByKeyProperty(types, name) {
68365
68724
  var map = new ts.Map();
68366
68725
  var count = 0;
68367
- var _loop_22 = function (type) {
68726
+ var _loop_23 = function (type) {
68368
68727
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
68369
68728
  var discriminant = getTypeOfPropertyOfType(type, name);
68370
68729
  if (discriminant) {
@@ -68390,9 +68749,9 @@ var ts;
68390
68749
  };
68391
68750
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
68392
68751
  var type = types_16[_i];
68393
- var state_8 = _loop_22(type);
68394
- if (typeof state_8 === "object")
68395
- return state_8.value;
68752
+ var state_9 = _loop_23(type);
68753
+ if (typeof state_9 === "object")
68754
+ return state_9.value;
68396
68755
  }
68397
68756
  return count >= 10 && count * 2 >= types.length ? map : undefined;
68398
68757
  }
@@ -69662,7 +70021,7 @@ var ts;
69662
70021
  return result;
69663
70022
  }
69664
70023
  function getCandidateDiscriminantPropertyAccess(expr) {
69665
- if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
70024
+ if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference) || ts.isObjectLiteralMethod(reference)) {
69666
70025
  // When the reference is a binding pattern or function or arrow expression, we are narrowing a pesudo-reference in
69667
70026
  // getNarrowedTypeOfSymbol. An identifier for a destructuring variable declared in the same binding pattern or
69668
70027
  // parameter declared in the same parameter list is a candidate.
@@ -74723,7 +75082,7 @@ var ts;
74723
75082
  if (spreadIndex >= 0) {
74724
75083
  // Create synthetic arguments from spreads of tuple types.
74725
75084
  var effectiveArgs_1 = args.slice(0, spreadIndex);
74726
- var _loop_23 = function (i) {
75085
+ var _loop_24 = function (i) {
74727
75086
  var arg = args[i];
74728
75087
  // We can call checkExpressionCached because spread expressions never have a contextual type.
74729
75088
  var spreadType = arg.kind === 224 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -74740,7 +75099,7 @@ var ts;
74740
75099
  }
74741
75100
  };
74742
75101
  for (var i = spreadIndex; i < args.length; i++) {
74743
- _loop_23(i);
75102
+ _loop_24(i);
74744
75103
  }
74745
75104
  return effectiveArgs_1;
74746
75105
  }
@@ -75053,7 +75412,7 @@ var ts;
75053
75412
  var min_3 = Number.MAX_VALUE;
75054
75413
  var minIndex = 0;
75055
75414
  var i_1 = 0;
75056
- var _loop_24 = function (c) {
75415
+ var _loop_25 = function (c) {
75057
75416
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
75058
75417
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
75059
75418
  if (diags_2) {
@@ -75071,7 +75430,7 @@ var ts;
75071
75430
  };
75072
75431
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
75073
75432
  var c = candidatesForArgumentError_1[_a];
75074
- _loop_24(c);
75433
+ _loop_25(c);
75075
75434
  }
75076
75435
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
75077
75436
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -75229,7 +75588,7 @@ var ts;
75229
75588
  }
75230
75589
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
75231
75590
  var parameters = [];
75232
- var _loop_25 = function (i) {
75591
+ var _loop_26 = function (i) {
75233
75592
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
75234
75593
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
75235
75594
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -75237,7 +75596,7 @@ var ts;
75237
75596
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
75238
75597
  };
75239
75598
  for (var i = 0; i < maxNonRestParam; i++) {
75240
- _loop_25(i);
75599
+ _loop_26(i);
75241
75600
  }
75242
75601
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
75243
75602
  var flags = 0 /* None */;
@@ -76634,6 +76993,9 @@ var ts;
76634
76993
  assignBindingElementTypes(declaration.name, links.type);
76635
76994
  }
76636
76995
  }
76996
+ else if (type) {
76997
+ ts.Debug.assertEqual(links.type, type, "Parameter symbol already has a cached type which differs from newly assigned type");
76998
+ }
76637
76999
  }
76638
77000
  // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
76639
77001
  // the destructured type into the contained binding elements.
@@ -78464,7 +78826,7 @@ var ts;
78464
78826
  }
78465
78827
  function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
78466
78828
  var type = checkExpression(node, checkMode, forceTuple);
78467
- return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
78829
+ return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
78468
78830
  isTypeAssertion(node) ? type :
78469
78831
  getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
78470
78832
  }
@@ -79233,7 +79595,7 @@ var ts;
79233
79595
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
79234
79596
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
79235
79597
  var indexSignatureMap_1 = new ts.Map();
79236
- var _loop_26 = function (declaration) {
79598
+ var _loop_27 = function (declaration) {
79237
79599
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
79238
79600
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
79239
79601
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -79248,7 +79610,7 @@ var ts;
79248
79610
  };
79249
79611
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
79250
79612
  var declaration = _a[_i];
79251
- _loop_26(declaration);
79613
+ _loop_27(declaration);
79252
79614
  }
79253
79615
  indexSignatureMap_1.forEach(function (entry) {
79254
79616
  if (entry.declarations.length > 1) {
@@ -82627,7 +82989,7 @@ var ts;
82627
82989
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
82628
82990
  var localPropDeclaration = declaration && declaration.kind === 220 /* BinaryExpression */ ||
82629
82991
  name && name.kind === 161 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
82630
- var _loop_27 = function (info) {
82992
+ var _loop_28 = function (info) {
82631
82993
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
82632
82994
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
82633
82995
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -82640,7 +83002,7 @@ var ts;
82640
83002
  };
82641
83003
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
82642
83004
  var info = indexInfos_9[_i];
82643
- _loop_27(info);
83005
+ _loop_28(info);
82644
83006
  }
82645
83007
  }
82646
83008
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -82648,7 +83010,7 @@ var ts;
82648
83010
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
82649
83011
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
82650
83012
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
82651
- var _loop_28 = function (info) {
83013
+ var _loop_29 = function (info) {
82652
83014
  if (info === checkInfo)
82653
83015
  return "continue";
82654
83016
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -82663,7 +83025,7 @@ var ts;
82663
83025
  };
82664
83026
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
82665
83027
  var info = indexInfos_10[_i];
82666
- _loop_28(info);
83028
+ _loop_29(info);
82667
83029
  }
82668
83030
  }
82669
83031
  function checkTypeNameIsReserved(name, message) {
@@ -82974,7 +83336,7 @@ var ts;
82974
83336
  var baseTypes = baseTypeNode && getBaseTypes(type);
82975
83337
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
82976
83338
  var baseStaticType = getBaseConstructorTypeOfClass(type);
82977
- var _loop_29 = function (member) {
83339
+ var _loop_30 = function (member) {
82978
83340
  if (ts.hasAmbientModifier(member)) {
82979
83341
  return "continue";
82980
83342
  }
@@ -82991,7 +83353,7 @@ var ts;
82991
83353
  };
82992
83354
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
82993
83355
  var member = _a[_i];
82994
- _loop_29(member);
83356
+ _loop_30(member);
82995
83357
  }
82996
83358
  }
82997
83359
  /**
@@ -83079,7 +83441,7 @@ var ts;
83079
83441
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
83080
83442
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
83081
83443
  var issuedMemberError = false;
83082
- var _loop_30 = function (member) {
83444
+ var _loop_31 = function (member) {
83083
83445
  if (ts.isStatic(member)) {
83084
83446
  return "continue";
83085
83447
  }
@@ -83098,7 +83460,7 @@ var ts;
83098
83460
  };
83099
83461
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
83100
83462
  var member = _a[_i];
83101
- _loop_30(member);
83463
+ _loop_31(member);
83102
83464
  }
83103
83465
  if (!issuedMemberError) {
83104
83466
  // check again with diagnostics to generate a less-specific error
@@ -87526,8 +87888,8 @@ var ts;
87526
87888
  }
87527
87889
  else {
87528
87890
  var elements = name.elements;
87529
- for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
87530
- var element = elements_1[_i];
87891
+ for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
87892
+ var element = elements_2[_i];
87531
87893
  if (!ts.isOmittedExpression(element)) {
87532
87894
  return checkESModuleMarker(element.name);
87533
87895
  }
@@ -87543,8 +87905,8 @@ var ts;
87543
87905
  }
87544
87906
  else {
87545
87907
  var elements = name.elements;
87546
- for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
87547
- var element = elements_2[_i];
87908
+ for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
87909
+ var element = elements_3[_i];
87548
87910
  if (!ts.isOmittedExpression(element)) {
87549
87911
  checkGrammarNameInLetOrConstDeclarations(element.name);
87550
87912
  }
@@ -89798,8 +90160,8 @@ var ts;
89798
90160
  }
89799
90161
  function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
89800
90162
  var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
89801
- for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
89802
- var element = elements_3[_i];
90163
+ for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
90164
+ var element = elements_4[_i];
89803
90165
  if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
89804
90166
  return true;
89805
90167
  }
@@ -95417,8 +95779,8 @@ var ts;
95417
95779
  function chunkObjectLiteralElements(elements) {
95418
95780
  var chunkObject;
95419
95781
  var objects = [];
95420
- for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
95421
- var e = elements_4[_i];
95782
+ for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) {
95783
+ var e = elements_5[_i];
95422
95784
  if (e.kind === 297 /* SpreadAssignment */) {
95423
95785
  if (chunkObject) {
95424
95786
  objects.push(factory.createObjectLiteralExpression(chunkObject));
@@ -110063,7 +110425,7 @@ var ts;
110063
110425
  return emitRestOrJSDocVariadicType(node);
110064
110426
  case 318 /* JSDocNamepathType */:
110065
110427
  return;
110066
- case 319 /* JSDocComment */:
110428
+ case 319 /* JSDoc */:
110067
110429
  return emitJSDoc(node);
110068
110430
  case 321 /* JSDocTypeLiteral */:
110069
110431
  return emitJSDocTypeLiteral(node);
@@ -114439,7 +114801,7 @@ var ts;
114439
114801
  var existingDirectories = new ts.Map();
114440
114802
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
114441
114803
  var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
114442
- function getSourceFile(fileName, languageVersion, onError) {
114804
+ function getSourceFile(fileName, languageVersionOrOptions, onError) {
114443
114805
  var text;
114444
114806
  try {
114445
114807
  ts.performance.mark("beforeIORead");
@@ -114453,7 +114815,7 @@ var ts;
114453
114815
  }
114454
114816
  text = "";
114455
114817
  }
114456
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
114818
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions, setParentNodes) : undefined;
114457
114819
  }
114458
114820
  function directoryExists(directoryPath) {
114459
114821
  if (existingDirectories.has(directoryPath)) {
@@ -115859,8 +116221,8 @@ var ts;
115859
116221
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
115860
116222
  var oldSourceFile = oldSourceFiles_2[_i];
115861
116223
  var newSourceFile = host.getSourceFileByPath
115862
- ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
115863
- : host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
116224
+ ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile)
116225
+ : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
115864
116226
  if (!newSourceFile) {
115865
116227
  return 0 /* Not */;
115866
116228
  }
@@ -115891,7 +116253,6 @@ var ts;
115891
116253
  newSourceFile.originalFileName = oldSourceFile.originalFileName;
115892
116254
  newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
115893
116255
  newSourceFile.fileName = oldSourceFile.fileName;
115894
- newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
115895
116256
  var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
115896
116257
  if (packageName !== undefined) {
115897
116258
  // If there are 2 different source files for the same package name and at least one of them changes,
@@ -116810,6 +117171,17 @@ var ts;
116810
117171
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
116811
117172
  return result;
116812
117173
  }
117174
+ function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
117175
+ // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
117176
+ // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
117177
+ // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
117178
+ var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
117179
+ return {
117180
+ languageVersion: ts.getEmitScriptTarget(options),
117181
+ impliedNodeFormat: impliedNodeFormat,
117182
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
117183
+ };
117184
+ }
116813
117185
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
116814
117186
  var path = toPath(fileName);
116815
117187
  if (useSourceOfProjectReferenceRedirect) {
@@ -116897,7 +117269,7 @@ var ts;
116897
117269
  }
116898
117270
  }
116899
117271
  // We haven't looked for this file, do so now and cache result
116900
- var file = host.getSourceFile(fileName, ts.getEmitScriptTarget(options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
117272
+ var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
116901
117273
  if (packageId) {
116902
117274
  var packageIdKey = ts.packageIdToString(packageId);
116903
117275
  var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
@@ -116925,10 +117297,6 @@ var ts;
116925
117297
  file.path = path;
116926
117298
  file.resolvedPath = toPath(fileName);
116927
117299
  file.originalFileName = originalFileName;
116928
- // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
116929
- // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
116930
- // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
116931
- file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
116932
117300
  addFileIncludeReason(file, reason);
116933
117301
  if (host.useCaseSensitiveFileNames()) {
116934
117302
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -117430,7 +117798,7 @@ var ts;
117430
117798
  }
117431
117799
  else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
117432
117800
  // We cannot use createDiagnosticFromNode because nodes do not have parents yet
117433
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117801
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117434
117802
  programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
117435
117803
  }
117436
117804
  // Cannot specify module gen that isn't amd or system with --out
@@ -117439,7 +117807,7 @@ var ts;
117439
117807
  createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
117440
117808
  }
117441
117809
  else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
117442
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117810
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117443
117811
  programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
117444
117812
  }
117445
117813
  }
@@ -120885,7 +121253,7 @@ var ts;
120885
121253
  });
120886
121254
  // Sort by paths closest to importing file Name directory
120887
121255
  var sortedPaths = [];
120888
- var _loop_31 = function (directory) {
121256
+ var _loop_32 = function (directory) {
120889
121257
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
120890
121258
  var pathsInDirectory;
120891
121259
  allFileNames.forEach(function (_a, fileName) {
@@ -120909,9 +121277,9 @@ var ts;
120909
121277
  };
120910
121278
  var out_directory_1;
120911
121279
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
120912
- var state_9 = _loop_31(directory);
121280
+ var state_10 = _loop_32(directory);
120913
121281
  directory = out_directory_1;
120914
- if (state_9 === "break")
121282
+ if (state_10 === "break")
120915
121283
  break;
120916
121284
  }
120917
121285
  if (allFileNames.size) {
@@ -121701,7 +122069,7 @@ var ts;
121701
122069
  var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
121702
122070
  var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
121703
122071
  return {
121704
- getSourceFile: function (fileName, languageVersion, onError) {
122072
+ getSourceFile: function (fileName, languageVersionOrOptions, onError) {
121705
122073
  var text;
121706
122074
  try {
121707
122075
  ts.performance.mark("beforeIORead");
@@ -121715,7 +122083,7 @@ var ts;
121715
122083
  }
121716
122084
  text = "";
121717
122085
  }
121718
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
122086
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions) : undefined;
121719
122087
  },
121720
122088
  getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
121721
122089
  getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
@@ -122183,7 +122551,7 @@ var ts;
122183
122551
  }
122184
122552
  return directoryStructureHost.fileExists(fileName);
122185
122553
  }
122186
- function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
122554
+ function getVersionedSourceFileByPath(fileName, path, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
122187
122555
  var hostSourceFile = sourceFilesCache.get(path);
122188
122556
  // No source file on the host
122189
122557
  if (isFileMissingOnHost(hostSourceFile)) {
@@ -122191,7 +122559,7 @@ var ts;
122191
122559
  }
122192
122560
  // Create new source file if requested or the versions dont match
122193
122561
  if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
122194
- var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
122562
+ var sourceFile = getNewSourceFile(fileName, languageVersionOrOptions, onError);
122195
122563
  if (hostSourceFile) {
122196
122564
  if (sourceFile) {
122197
122565
  // Set the source file and create file watcher now that file was present on the disk
@@ -134296,9 +134664,15 @@ var ts;
134296
134664
  });
134297
134665
  return JSON.stringify(bucketInfoArray, undefined, 2);
134298
134666
  }
134667
+ function getCompilationSettings(settingsOrHost) {
134668
+ if (typeof settingsOrHost.getCompilationSettings === "function") {
134669
+ return settingsOrHost.getCompilationSettings();
134670
+ }
134671
+ return settingsOrHost;
134672
+ }
134299
134673
  function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
134300
134674
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
134301
- var key = getKeyForCompilationSettings(compilationSettings);
134675
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
134302
134676
  return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
134303
134677
  }
134304
134678
  function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
@@ -134306,20 +134680,28 @@ var ts;
134306
134680
  }
134307
134681
  function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
134308
134682
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
134309
- var key = getKeyForCompilationSettings(compilationSettings);
134683
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
134310
134684
  return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
134311
134685
  }
134312
134686
  function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
134313
- return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
134687
+ return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
134314
134688
  }
134315
134689
  function getDocumentRegistryEntry(bucketEntry, scriptKind) {
134316
134690
  var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided"));
134317
134691
  ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry);
134318
134692
  return entry;
134319
134693
  }
134320
- function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
134694
+ function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
134695
+ var _a, _b, _c, _d;
134321
134696
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
134697
+ var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
134698
+ var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
134322
134699
  var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
134700
+ var sourceFileOptions = {
134701
+ languageVersion: scriptTarget,
134702
+ impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings),
134703
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
134704
+ };
134323
134705
  var oldBucketCount = buckets.size;
134324
134706
  var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
134325
134707
  if (ts.tracing) {
@@ -134353,7 +134735,7 @@ var ts;
134353
134735
  }
134354
134736
  if (!entry) {
134355
134737
  // Have never seen this file with these settings. Create a new source file for it.
134356
- var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind);
134738
+ var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
134357
134739
  if (externalCache) {
134358
134740
  externalCache.setDocument(key, path, sourceFile);
134359
134741
  }
@@ -142797,7 +143179,7 @@ var ts;
142797
143179
  continue;
142798
143180
  var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, moduleSpecifier));
142799
143181
  var resolvedFile = module_1 && program.getSourceFile(module_1.resolvedFileName);
142800
- if (resolvedFile && resolvedFile.externalModuleIndicator && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
143182
+ if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
142801
143183
  diags.push(ts.createDiagnosticForNode(name, ts.Diagnostics.Import_may_be_converted_to_a_default_import));
142802
143184
  }
142803
143185
  }
@@ -143713,19 +144095,7 @@ var ts;
143713
144095
  options.suppressOutputPathCheck = true;
143714
144096
  // Filename can be non-ts file.
143715
144097
  options.allowNonTsExtensions = true;
143716
- // if jsx is specified then treat file as .tsx
143717
- var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
143718
- var sourceFile = ts.createSourceFile(inputFileName, input, ts.getEmitScriptTarget(options));
143719
- if (transpileOptions.moduleName) {
143720
- sourceFile.moduleName = transpileOptions.moduleName;
143721
- }
143722
- if (transpileOptions.renamedDependencies) {
143723
- sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
143724
- }
143725
144098
  var newLine = ts.getNewLineCharacter(options);
143726
- // Output
143727
- var outputText;
143728
- var sourceMapText;
143729
144099
  // Create a compilerHost object to allow the compiler to read and write files
143730
144100
  var compilerHost = {
143731
144101
  getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; },
@@ -143749,6 +144119,22 @@ var ts;
143749
144119
  directoryExists: function () { return true; },
143750
144120
  getDirectories: function () { return []; }
143751
144121
  };
144122
+ // if jsx is specified then treat file as .tsx
144123
+ var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
144124
+ var sourceFile = ts.createSourceFile(inputFileName, input, {
144125
+ languageVersion: ts.getEmitScriptTarget(options),
144126
+ impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(inputFileName, "", compilerHost.getCanonicalFileName), /*cache*/ undefined, compilerHost, options),
144127
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
144128
+ });
144129
+ if (transpileOptions.moduleName) {
144130
+ sourceFile.moduleName = transpileOptions.moduleName;
144131
+ }
144132
+ if (transpileOptions.renamedDependencies) {
144133
+ sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
144134
+ }
144135
+ // Output
144136
+ var outputText;
144137
+ var sourceMapText;
143752
144138
  var program = ts.createProgram([inputFileName], options, compilerHost);
143753
144139
  if (transpileOptions.reportDiagnostics) {
143754
144140
  ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
@@ -160261,7 +160647,7 @@ var ts;
160261
160647
  for (var i = 1;; i++) {
160262
160648
  var name = ts.combinePaths(inDirectory, newModuleName + extension);
160263
160649
  if (!host.fileExists(name))
160264
- return newModuleName; // TODO: GH#18217
160650
+ return newModuleName;
160265
160651
  newModuleName = moduleName + "." + i;
160266
160652
  }
160267
160653
  }
@@ -162621,6 +163007,7 @@ var ts;
162621
163007
  this.host = host;
162622
163008
  }
162623
163009
  SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) {
163010
+ var _a, _b, _c, _d, _e, _f, _g, _h;
162624
163011
  var scriptSnapshot = this.host.getScriptSnapshot(fileName);
162625
163012
  if (!scriptSnapshot) {
162626
163013
  // The host does not know about this file.
@@ -162631,7 +163018,12 @@ var ts;
162631
163018
  var sourceFile;
162632
163019
  if (this.currentFileName !== fileName) {
162633
163020
  // This is a new file, just parse it
162634
- sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 99 /* Latest */, version, /*setNodeParents*/ true, scriptKind);
163021
+ var options = {
163022
+ languageVersion: 99 /* Latest */,
163023
+ impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()),
163024
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings())
163025
+ };
163026
+ sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, scriptKind);
162635
163027
  }
162636
163028
  else if (this.currentFileVersion !== version) {
162637
163029
  // This is the same file, just a newer version. Incrementally parse the file.
@@ -162653,8 +163045,8 @@ var ts;
162653
163045
  sourceFile.version = version;
162654
163046
  sourceFile.scriptSnapshot = scriptSnapshot;
162655
163047
  }
162656
- function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) {
162657
- var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTarget, setNodeParents, scriptKind);
163048
+ function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTargetOrOptions, version, setNodeParents, scriptKind) {
163049
+ var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTargetOrOptions, setNodeParents, scriptKind);
162658
163050
  setSourceFileFields(sourceFile, scriptSnapshot, version);
162659
163051
  return sourceFile;
162660
163052
  }
@@ -162702,8 +163094,13 @@ var ts;
162702
163094
  return newSourceFile;
162703
163095
  }
162704
163096
  }
163097
+ var options = {
163098
+ languageVersion: sourceFile.languageVersion,
163099
+ impliedNodeFormat: sourceFile.impliedNodeFormat,
163100
+ setExternalModuleIndicator: sourceFile.setExternalModuleIndicator,
163101
+ };
162705
163102
  // Otherwise, just create a new source file.
162706
- return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind);
163103
+ return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, sourceFile.scriptKind);
162707
163104
  }
162708
163105
  ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile;
162709
163106
  var NoopCancellationToken = {
@@ -163047,7 +163444,7 @@ var ts;
163047
163444
  // file's script kind, i.e. in one project some file is treated as ".ts"
163048
163445
  // and in another as ".js"
163049
163446
  if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
163050
- return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
163447
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
163051
163448
  }
163052
163449
  else {
163053
163450
  // Release old source file and fall through to aquire new file with new script kind
@@ -163057,7 +163454,7 @@ var ts;
163057
163454
  // We didn't already have the file. Fall through and acquire it from the registry.
163058
163455
  }
163059
163456
  // Could not find this file in the old program, create a new SourceFile for it.
163060
- return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
163457
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
163061
163458
  }
163062
163459
  }
163063
163460
  // TODO: GH#18217 frequently asserted as defined
@@ -168187,6 +168584,10 @@ var ts;
168187
168584
  this.packageJsonsForAutoImport = new ts.Set(packageJsons.map(function (p) { return p.fileName; }));
168188
168585
  return packageJsons;
168189
168586
  };
168587
+ /* @internal */
168588
+ Project.prototype.getPackageJsonCache = function () {
168589
+ return this.projectService.packageJsonCache;
168590
+ };
168190
168591
  /*@internal*/
168191
168592
  Project.prototype.getCachedExportInfoMap = function () {
168192
168593
  return this.exportMapCache || (this.exportMapCache = ts.createCacheableExportInfoMap(this));
@@ -172625,15 +173026,23 @@ var ts;
172625
173026
  return ts.deduplicate(outputs, ts.equateValues);
172626
173027
  }
172627
173028
  ;
173029
+ function createDocumentSpanSet() {
173030
+ return ts.createSet(function (_a) {
173031
+ var textSpan = _a.textSpan;
173032
+ return textSpan.start + 100003 * textSpan.length;
173033
+ }, ts.documentSpansEqual);
173034
+ }
172628
173035
  function combineProjectOutputForRenameLocations(projects, defaultProject, initialLocation, findInStrings, findInComments, _a) {
172629
173036
  var providePrefixAndSuffixTextForRename = _a.providePrefixAndSuffixTextForRename;
172630
173037
  var outputs = [];
173038
+ var seen = createDocumentSpanSet();
172631
173039
  combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, tryAddToTodo) {
172632
173040
  var projectOutputs = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename);
172633
173041
  if (projectOutputs) {
172634
173042
  for (var _i = 0, projectOutputs_1 = projectOutputs; _i < projectOutputs_1.length; _i++) {
172635
173043
  var output = projectOutputs_1[_i];
172636
- if (!ts.contains(outputs, output, ts.documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(output))) {
173044
+ if (!seen.has(output) && !tryAddToTodo(project, documentSpanLocation(output))) {
173045
+ seen.add(output);
172637
173046
  outputs.push(output);
172638
173047
  }
172639
173048
  }
@@ -174017,6 +174426,7 @@ var ts;
174017
174426
  var projects = this.getProjects(args);
174018
174427
  var fileName = args.file;
174019
174428
  var references = [];
174429
+ var seen = createDocumentSpanSet();
174020
174430
  forEachProjectInProjects(projects, /*path*/ undefined, function (project) {
174021
174431
  if (project.getCancellationToken().isCancellationRequested())
174022
174432
  return;
@@ -174024,8 +174434,9 @@ var ts;
174024
174434
  if (projectOutputs) {
174025
174435
  for (var _i = 0, projectOutputs_3 = projectOutputs; _i < projectOutputs_3.length; _i++) {
174026
174436
  var referenceEntry = projectOutputs_3[_i];
174027
- if (!ts.contains(references, referenceEntry, ts.documentSpansEqual)) {
174437
+ if (!seen.has(referenceEntry)) {
174028
174438
  references.push(referenceEntry);
174439
+ seen.add(referenceEntry);
174029
174440
  }
174030
174441
  }
174031
174442
  }