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.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220309";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220312";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -1468,6 +1468,159 @@ var ts;
1468
1468
  return createMultiMap();
1469
1469
  }
1470
1470
  ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap;
1471
+ /**
1472
+ * Creates a Set with custom equality and hash code functionality. This is useful when you
1473
+ * want to use something looser than object identity - e.g. "has the same span".
1474
+ *
1475
+ * If `equals(a, b)`, it must be the case that `getHashCode(a) === getHashCode(b)`.
1476
+ * The converse is not required.
1477
+ *
1478
+ * To facilitate a perf optimization (lazy allocation of bucket arrays), `TElement` is
1479
+ * assumed not to be an array type.
1480
+ */
1481
+ function createSet(getHashCode, equals) {
1482
+ var multiMap = new ts.Map();
1483
+ var size = 0;
1484
+ function getElementIterator() {
1485
+ var valueIt = multiMap.values();
1486
+ var arrayIt;
1487
+ return {
1488
+ next: function () {
1489
+ while (true) {
1490
+ if (arrayIt) {
1491
+ var n = arrayIt.next();
1492
+ if (!n.done) {
1493
+ return { value: n.value };
1494
+ }
1495
+ arrayIt = undefined;
1496
+ }
1497
+ else {
1498
+ var n = valueIt.next();
1499
+ if (n.done) {
1500
+ return { value: undefined, done: true };
1501
+ }
1502
+ if (!isArray(n.value)) {
1503
+ return { value: n.value };
1504
+ }
1505
+ arrayIt = arrayIterator(n.value);
1506
+ }
1507
+ }
1508
+ }
1509
+ };
1510
+ }
1511
+ var set = {
1512
+ has: function (element) {
1513
+ var hash = getHashCode(element);
1514
+ if (!multiMap.has(hash))
1515
+ return false;
1516
+ var candidates = multiMap.get(hash);
1517
+ if (!isArray(candidates))
1518
+ return equals(candidates, element);
1519
+ for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
1520
+ var candidate = candidates_1[_i];
1521
+ if (equals(candidate, element)) {
1522
+ return true;
1523
+ }
1524
+ }
1525
+ return false;
1526
+ },
1527
+ add: function (element) {
1528
+ var hash = getHashCode(element);
1529
+ if (multiMap.has(hash)) {
1530
+ var values = multiMap.get(hash);
1531
+ if (isArray(values)) {
1532
+ if (!contains(values, element, equals)) {
1533
+ values.push(element);
1534
+ size++;
1535
+ }
1536
+ }
1537
+ else {
1538
+ var value = values;
1539
+ if (!equals(value, element)) {
1540
+ multiMap.set(hash, [value, element]);
1541
+ size++;
1542
+ }
1543
+ }
1544
+ }
1545
+ else {
1546
+ multiMap.set(hash, element);
1547
+ size++;
1548
+ }
1549
+ return this;
1550
+ },
1551
+ delete: function (element) {
1552
+ var hash = getHashCode(element);
1553
+ if (!multiMap.has(hash))
1554
+ return false;
1555
+ var candidates = multiMap.get(hash);
1556
+ if (isArray(candidates)) {
1557
+ for (var i = 0; i < candidates.length; i++) {
1558
+ if (equals(candidates[i], element)) {
1559
+ if (candidates.length === 1) {
1560
+ multiMap.delete(hash);
1561
+ }
1562
+ else if (candidates.length === 2) {
1563
+ multiMap.set(hash, candidates[1 - i]);
1564
+ }
1565
+ else {
1566
+ unorderedRemoveItemAt(candidates, i);
1567
+ }
1568
+ size--;
1569
+ return true;
1570
+ }
1571
+ }
1572
+ }
1573
+ else {
1574
+ var candidate = candidates;
1575
+ if (equals(candidate, element)) {
1576
+ multiMap.delete(hash);
1577
+ size--;
1578
+ return true;
1579
+ }
1580
+ }
1581
+ return false;
1582
+ },
1583
+ clear: function () {
1584
+ multiMap.clear();
1585
+ size = 0;
1586
+ },
1587
+ get size() {
1588
+ return size;
1589
+ },
1590
+ forEach: function (action) {
1591
+ for (var _i = 0, _a = arrayFrom(multiMap.values()); _i < _a.length; _i++) {
1592
+ var elements = _a[_i];
1593
+ if (isArray(elements)) {
1594
+ for (var _b = 0, elements_1 = elements; _b < elements_1.length; _b++) {
1595
+ var element = elements_1[_b];
1596
+ action(element, element);
1597
+ }
1598
+ }
1599
+ else {
1600
+ var element = elements;
1601
+ action(element, element);
1602
+ }
1603
+ }
1604
+ },
1605
+ keys: function () {
1606
+ return getElementIterator();
1607
+ },
1608
+ values: function () {
1609
+ return getElementIterator();
1610
+ },
1611
+ entries: function () {
1612
+ var it = getElementIterator();
1613
+ return {
1614
+ next: function () {
1615
+ var n = it.next();
1616
+ return n.done ? n : { value: [n.value, n.value] };
1617
+ }
1618
+ };
1619
+ },
1620
+ };
1621
+ return set;
1622
+ }
1623
+ ts.createSet = createSet;
1471
1624
  /**
1472
1625
  * Tests whether a value is an array.
1473
1626
  */
@@ -1861,8 +2014,8 @@ var ts;
1861
2014
  var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
1862
2015
  var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
1863
2016
  var bestCandidate;
1864
- for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
1865
- var candidate = candidates_1[_i];
2017
+ for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
2018
+ var candidate = candidates_2[_i];
1866
2019
  var candidateName = getName(candidate);
1867
2020
  if (candidateName !== undefined && Math.abs(candidateName.length - name.length) <= maximumLengthDifference) {
1868
2021
  if (candidateName === name) {
@@ -2099,13 +2252,15 @@ var ts;
2099
2252
  for (var _i = 0; _i < arguments.length; _i++) {
2100
2253
  args[_i] = arguments[_i];
2101
2254
  }
2255
+ var lastResult;
2102
2256
  for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
2103
2257
  var f = fs_1[_a];
2104
- if (f.apply(void 0, args)) {
2105
- return true;
2258
+ lastResult = f.apply(void 0, args);
2259
+ if (lastResult) {
2260
+ return lastResult;
2106
2261
  }
2107
2262
  }
2108
- return false;
2263
+ return lastResult;
2109
2264
  };
2110
2265
  }
2111
2266
  ts.or = or;
@@ -4164,6 +4319,7 @@ var ts;
4164
4319
  SyntaxKind[SyntaxKind["JSDocFunctionType"] = 316] = "JSDocFunctionType";
4165
4320
  SyntaxKind[SyntaxKind["JSDocVariadicType"] = 317] = "JSDocVariadicType";
4166
4321
  SyntaxKind[SyntaxKind["JSDocNamepathType"] = 318] = "JSDocNamepathType";
4322
+ /** @deprecated Use SyntaxKind.JSDoc */
4167
4323
  SyntaxKind[SyntaxKind["JSDocComment"] = 319] = "JSDocComment";
4168
4324
  SyntaxKind[SyntaxKind["JSDocText"] = 320] = "JSDocText";
4169
4325
  SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 321] = "JSDocTypeLiteral";
@@ -4237,6 +4393,7 @@ var ts;
4237
4393
  SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 346] = "LastJSDocTagNode";
4238
4394
  /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
4239
4395
  /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 159] = "LastContextualKeyword";
4396
+ SyntaxKind[SyntaxKind["JSDoc"] = 319] = "JSDoc";
4240
4397
  })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
4241
4398
  var NodeFlags;
4242
4399
  (function (NodeFlags) {
@@ -5123,6 +5280,21 @@ var ts;
5123
5280
  ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12";
5124
5281
  ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext";
5125
5282
  })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
5283
+ var ModuleDetectionKind;
5284
+ (function (ModuleDetectionKind) {
5285
+ /**
5286
+ * Files with imports, exports and/or import.meta are considered modules
5287
+ */
5288
+ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy";
5289
+ /**
5290
+ * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+
5291
+ */
5292
+ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto";
5293
+ /**
5294
+ * Consider all non-declaration files modules, regardless of present syntax
5295
+ */
5296
+ ModuleDetectionKind[ModuleDetectionKind["Force"] = 3] = "Force";
5297
+ })(ModuleDetectionKind = ts.ModuleDetectionKind || (ts.ModuleDetectionKind = {}));
5126
5298
  var WatchFileKind;
5127
5299
  (function (WatchFileKind) {
5128
5300
  WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
@@ -8220,6 +8392,8 @@ var ts;
8220
8392
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8221
8393
  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."),
8222
8394
  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."),
8395
+ 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."),
8396
+ 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."),
8223
8397
  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."),
8224
8398
  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."),
8225
8399
  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),
@@ -12833,7 +13007,7 @@ var ts;
12833
13007
  return ts.emptyArray;
12834
13008
  }
12835
13009
  if (ts.isJSDocTypeAlias(node)) {
12836
- ts.Debug.assert(node.parent.kind === 319 /* JSDocComment */);
13010
+ ts.Debug.assert(node.parent.kind === 319 /* JSDoc */);
12837
13011
  return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
12838
13012
  }
12839
13013
  if (node.typeParameters) {
@@ -13780,7 +13954,7 @@ var ts;
13780
13954
  ts.isJSDocNode = isJSDocNode;
13781
13955
  /** True if node is of a kind that may contain comment text. */
13782
13956
  function isJSDocCommentContainingNode(node) {
13783
- return node.kind === 319 /* JSDocComment */
13957
+ return node.kind === 319 /* JSDoc */
13784
13958
  || node.kind === 318 /* JSDocNamepathType */
13785
13959
  || node.kind === 320 /* JSDocText */
13786
13960
  || isJSDocLinkLike(node)
@@ -15345,10 +15519,23 @@ var ts;
15345
15519
  && node.parent.parent.kind === 236 /* VariableStatement */;
15346
15520
  }
15347
15521
  ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
15522
+ function isCommonJsExportedExpression(node) {
15523
+ if (!isInJSFile(node))
15524
+ return false;
15525
+ return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) ||
15526
+ isCommonJsExportPropertyAssignment(node.parent);
15527
+ }
15528
+ ts.isCommonJsExportedExpression = isCommonJsExportedExpression;
15529
+ function isCommonJsExportPropertyAssignment(node) {
15530
+ if (!isInJSFile(node))
15531
+ return false;
15532
+ return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */);
15533
+ }
15534
+ ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment;
15348
15535
  function isValidESSymbolDeclaration(node) {
15349
- return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
15536
+ return (ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
15350
15537
  ts.isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
15351
- ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node);
15538
+ ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node)) || isCommonJsExportPropertyAssignment(node);
15352
15539
  }
15353
15540
  ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
15354
15541
  function introducesArgumentsExoticObject(node) {
@@ -18242,7 +18429,7 @@ var ts;
18242
18429
  ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
18243
18430
  /** template tags are only available when a typedef isn't already using them */
18244
18431
  function isNonTypeAliasTemplate(tag) {
18245
- return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 319 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias));
18432
+ return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 319 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias));
18246
18433
  }
18247
18434
  /**
18248
18435
  * Gets the effective type annotation of the value parameter of a set accessor. If the node
@@ -19716,6 +19903,61 @@ var ts;
19716
19903
  return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */;
19717
19904
  }
19718
19905
  ts.getLanguageVariant = getLanguageVariant;
19906
+ /**
19907
+ * This is a somewhat unavoidable full tree walk to locate a JSX tag - `import.meta` requires the same,
19908
+ * but we avoid that walk (or parts of it) if at all possible using the `PossiblyContainsImportMeta` node flag.
19909
+ * Unfortunately, there's no `NodeFlag` space to do the same for JSX.
19910
+ */
19911
+ function walkTreeForJSXTags(node) {
19912
+ if (!(node.transformFlags & 2 /* ContainsJsx */))
19913
+ return undefined;
19914
+ return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags);
19915
+ }
19916
+ function isFileModuleFromUsingJSXTag(file) {
19917
+ // Excludes declaration files - they still require an explicit `export {}` or the like
19918
+ // for back compat purposes. (not that declaration files should contain JSX tags!)
19919
+ return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined;
19920
+ }
19921
+ /**
19922
+ * Note that this requires file.impliedNodeFormat be set already; meaning it must be set very early on
19923
+ * in SourceFile construction.
19924
+ */
19925
+ function isFileForcedToBeModuleByFormat(file) {
19926
+ // Excludes declaration files - they still require an explicit `export {}` or the like
19927
+ // for back compat purposes.
19928
+ return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
19929
+ }
19930
+ function getSetExternalModuleIndicator(options) {
19931
+ // TODO: Should this callback be cached?
19932
+ switch (getEmitModuleDetectionKind(options)) {
19933
+ case ts.ModuleDetectionKind.Force:
19934
+ // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
19935
+ return function (file) {
19936
+ file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
19937
+ };
19938
+ case ts.ModuleDetectionKind.Legacy:
19939
+ // Files are modules if they have imports, exports, or import.meta
19940
+ return function (file) {
19941
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file);
19942
+ };
19943
+ case ts.ModuleDetectionKind.Auto:
19944
+ // If module is nodenext or node12, all esm format files are modules
19945
+ // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness
19946
+ // otherwise, the presence of import or export statments (or import.meta) implies module-ness
19947
+ var checks = [ts.isFileProbablyExternalModule];
19948
+ if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
19949
+ checks.push(isFileModuleFromUsingJSXTag);
19950
+ }
19951
+ var moduleKind = getEmitModuleKind(options);
19952
+ if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
19953
+ checks.push(isFileForcedToBeModuleByFormat);
19954
+ }
19955
+ var combined_1 = ts.or.apply(void 0, checks);
19956
+ var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
19957
+ return callback;
19958
+ }
19959
+ }
19960
+ ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator;
19719
19961
  function getEmitScriptTarget(compilerOptions) {
19720
19962
  return compilerOptions.target ||
19721
19963
  (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) ||
@@ -19750,6 +19992,10 @@ var ts;
19750
19992
  return moduleResolution;
19751
19993
  }
19752
19994
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
19995
+ function getEmitModuleDetectionKind(options) {
19996
+ return options.moduleDetection || ts.ModuleDetectionKind.Auto;
19997
+ }
19998
+ ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
19753
19999
  function hasJsonModuleEmitEnabled(options) {
19754
20000
  switch (getEmitModuleKind(options)) {
19755
20001
  case ts.ModuleKind.CommonJS:
@@ -25219,7 +25465,7 @@ var ts;
25219
25465
  }
25220
25466
  // @api
25221
25467
  function createJSDocComment(comment, tags) {
25222
- var node = createBaseNode(319 /* JSDocComment */);
25468
+ var node = createBaseNode(319 /* JSDoc */);
25223
25469
  node.comment = comment;
25224
25470
  node.tags = asNodeArray(tags);
25225
25471
  return node;
@@ -28728,7 +28974,7 @@ var ts;
28728
28974
  }
28729
28975
  ts.isJSDocNamepathType = isJSDocNamepathType;
28730
28976
  function isJSDoc(node) {
28731
- return node.kind === 319 /* JSDocComment */;
28977
+ return node.kind === 319 /* JSDoc */;
28732
28978
  }
28733
28979
  ts.isJSDoc = isJSDoc;
28734
28980
  function isJSDocTypeLiteral(node) {
@@ -29920,6 +30166,36 @@ var ts;
29920
30166
  text.charCodeAt(start + 3) !== 47 /* slash */;
29921
30167
  }
29922
30168
  ts.isJSDocLikeText = isJSDocLikeText;
30169
+ /*@internal*/
30170
+ function isFileProbablyExternalModule(sourceFile) {
30171
+ // Try to use the first top-level import/export when available, then
30172
+ // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
30173
+ return ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
30174
+ getImportMetaIfNecessary(sourceFile);
30175
+ }
30176
+ ts.isFileProbablyExternalModule = isFileProbablyExternalModule;
30177
+ function isAnExternalModuleIndicatorNode(node) {
30178
+ return hasModifierOfKind(node, 93 /* ExportKeyword */)
30179
+ || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
30180
+ || ts.isImportDeclaration(node)
30181
+ || ts.isExportAssignment(node)
30182
+ || ts.isExportDeclaration(node) ? node : undefined;
30183
+ }
30184
+ function getImportMetaIfNecessary(sourceFile) {
30185
+ return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
30186
+ walkTreeForImportMeta(sourceFile) :
30187
+ undefined;
30188
+ }
30189
+ function walkTreeForImportMeta(node) {
30190
+ return isImportMeta(node) ? node : forEachChild(node, walkTreeForImportMeta);
30191
+ }
30192
+ /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
30193
+ function hasModifierOfKind(node, kind) {
30194
+ return ts.some(node.modifiers, function (m) { return m.kind === kind; });
30195
+ }
30196
+ function isImportMeta(node) {
30197
+ return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta";
30198
+ }
29923
30199
  /**
29924
30200
  * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
29925
30201
  * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
@@ -30353,7 +30629,7 @@ var ts;
30353
30629
  case 316 /* JSDocFunctionType */:
30354
30630
  return visitNodes(cbNode, cbNodes, node.parameters) ||
30355
30631
  visitNode(cbNode, node.type);
30356
- case 319 /* JSDocComment */:
30632
+ case 319 /* JSDoc */:
30357
30633
  return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))
30358
30634
  || visitNodes(cbNode, cbNodes, node.tags);
30359
30635
  case 345 /* JSDocSeeTag */:
@@ -30501,17 +30777,25 @@ var ts;
30501
30777
  children.unshift(n);
30502
30778
  }
30503
30779
  }
30504
- function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
30780
+ function setExternalModuleIndicator(sourceFile) {
30781
+ sourceFile.externalModuleIndicator = isFileProbablyExternalModule(sourceFile);
30782
+ }
30783
+ function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) {
30505
30784
  if (setParentNodes === void 0) { setParentNodes = false; }
30506
30785
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
30507
30786
  ts.performance.mark("beforeParse");
30508
30787
  var result;
30509
30788
  ts.perfLogger.logStartParseSourceFile(fileName);
30789
+ var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat;
30510
30790
  if (languageVersion === 100 /* JSON */) {
30511
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */);
30791
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop);
30512
30792
  }
30513
30793
  else {
30514
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind);
30794
+ var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) {
30795
+ file.impliedNodeFormat = format;
30796
+ return (overrideSetExternalModuleIndicator || setExternalModuleIndicator)(file);
30797
+ };
30798
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind, setIndicator);
30515
30799
  }
30516
30800
  ts.perfLogger.logStopParseSourceFile();
30517
30801
  ts.performance.mark("afterParse");
@@ -30697,7 +30981,7 @@ var ts;
30697
30981
  // Note: any errors at the end of the file that do not precede a regular node, should get
30698
30982
  // attached to the EOF token.
30699
30983
  var parseErrorBeforeNextFinishedNode = false;
30700
- function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
30984
+ function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind, setExternalModuleIndicatorOverride) {
30701
30985
  var _a;
30702
30986
  if (setParentNodes === void 0) { setParentNodes = false; }
30703
30987
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
@@ -30713,7 +30997,7 @@ var ts;
30713
30997
  return result_3;
30714
30998
  }
30715
30999
  initializeState(fileName, sourceText, languageVersion, syntaxCursor, scriptKind);
30716
- var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind);
31000
+ var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicatorOverride || setExternalModuleIndicator);
30717
31001
  clearState();
30718
31002
  return result;
30719
31003
  }
@@ -30797,7 +31081,7 @@ var ts;
30797
31081
  endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token);
30798
31082
  }
30799
31083
  // Set source file so that errors will be reported with this file name
30800
- var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags);
31084
+ var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop);
30801
31085
  if (setParentNodes) {
30802
31086
  fixupParentReferences(sourceFile);
30803
31087
  }
@@ -30871,7 +31155,7 @@ var ts;
30871
31155
  notParenthesizedArrow = undefined;
30872
31156
  topLevel = true;
30873
31157
  }
30874
- function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
31158
+ function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
30875
31159
  var isDeclarationFile = isDeclarationFileName(fileName);
30876
31160
  if (isDeclarationFile) {
30877
31161
  contextFlags |= 8388608 /* Ambient */;
@@ -30882,7 +31166,7 @@ var ts;
30882
31166
  var statements = parseList(0 /* SourceElements */, parseStatement);
30883
31167
  ts.Debug.assert(token() === 1 /* EndOfFileToken */);
30884
31168
  var endOfFileToken = addJSDocComment(parseTokenNode());
30885
- var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags);
31169
+ var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
30886
31170
  // 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
30887
31171
  processCommentPragmas(sourceFile, sourceText);
30888
31172
  processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
@@ -31019,25 +31303,30 @@ var ts;
31019
31303
  ts.setParentRecursive(rootNode, /*incremental*/ true);
31020
31304
  }
31021
31305
  Parser.fixupParentReferences = fixupParentReferences;
31022
- function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags) {
31306
+ function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags, setExternalModuleIndicator) {
31023
31307
  // code from createNode is inlined here so createNode won't have to deal with special case of creating source files
31024
31308
  // this is quite rare comparing to other nodes and createNode should be as fast as possible
31025
31309
  var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
31026
31310
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
31027
- setExternalModuleIndicator(sourceFile);
31311
+ setFields(sourceFile);
31028
31312
  // If we parsed this as an external module, it may contain top-level await
31029
31313
  if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
31030
31314
  sourceFile = reparseTopLevelAwait(sourceFile);
31315
+ setFields(sourceFile);
31031
31316
  }
31032
- sourceFile.text = sourceText;
31033
- sourceFile.bindDiagnostics = [];
31034
- sourceFile.bindSuggestionDiagnostics = undefined;
31035
- sourceFile.languageVersion = languageVersion;
31036
- sourceFile.fileName = fileName;
31037
- sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
31038
- sourceFile.isDeclarationFile = isDeclarationFile;
31039
- sourceFile.scriptKind = scriptKind;
31040
31317
  return sourceFile;
31318
+ function setFields(sourceFile) {
31319
+ sourceFile.text = sourceText;
31320
+ sourceFile.bindDiagnostics = [];
31321
+ sourceFile.bindSuggestionDiagnostics = undefined;
31322
+ sourceFile.languageVersion = languageVersion;
31323
+ sourceFile.fileName = fileName;
31324
+ sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
31325
+ sourceFile.isDeclarationFile = isDeclarationFile;
31326
+ sourceFile.scriptKind = scriptKind;
31327
+ setExternalModuleIndicator(sourceFile);
31328
+ sourceFile.setExternalModuleIndicator = setExternalModuleIndicator;
31329
+ }
31041
31330
  }
31042
31331
  function setContextFlag(val, flag) {
31043
31332
  if (val) {
@@ -36520,35 +36809,6 @@ var ts;
36520
36809
  var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
36521
36810
  return withJSDoc(finishNode(node, pos), hasJSDoc);
36522
36811
  }
36523
- function setExternalModuleIndicator(sourceFile) {
36524
- // Try to use the first top-level import/export when available, then
36525
- // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
36526
- sourceFile.externalModuleIndicator =
36527
- ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
36528
- getImportMetaIfNecessary(sourceFile);
36529
- }
36530
- function isAnExternalModuleIndicatorNode(node) {
36531
- return hasModifierOfKind(node, 93 /* ExportKeyword */)
36532
- || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
36533
- || ts.isImportDeclaration(node)
36534
- || ts.isExportAssignment(node)
36535
- || ts.isExportDeclaration(node) ? node : undefined;
36536
- }
36537
- function getImportMetaIfNecessary(sourceFile) {
36538
- return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
36539
- walkTreeForExternalModuleIndicators(sourceFile) :
36540
- undefined;
36541
- }
36542
- function walkTreeForExternalModuleIndicators(node) {
36543
- return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
36544
- }
36545
- /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
36546
- function hasModifierOfKind(node, kind) {
36547
- return ts.some(node.modifiers, function (m) { return m.kind === kind; });
36548
- }
36549
- function isImportMeta(node) {
36550
- return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta";
36551
- }
36552
36812
  var ParsingContext;
36553
36813
  (function (ParsingContext) {
36554
36814
  ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements";
@@ -36591,7 +36851,7 @@ var ts;
36591
36851
  scanner.setText(content, start, length);
36592
36852
  currentToken = scanner.scan();
36593
36853
  var jsDocTypeExpression = parseJSDocTypeExpression();
36594
- var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */);
36854
+ var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop);
36595
36855
  var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
36596
36856
  if (jsDocDiagnostics) {
36597
36857
  sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
@@ -37552,7 +37812,7 @@ var ts;
37552
37812
  if (sourceFile.statements.length === 0) {
37553
37813
  // If we don't have any statements in the current source file, then there's no real
37554
37814
  // way to incrementally parse. So just do a full parse instead.
37555
- return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind);
37815
+ return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
37556
37816
  }
37557
37817
  // Make sure we're not trying to incrementally update a source file more than once. Once
37558
37818
  // we do an update the original source file is considered unusable from that point onwards.
@@ -37609,7 +37869,7 @@ var ts;
37609
37869
  // inconsistent tree. Setting the parents on the new tree should be very fast. We
37610
37870
  // will immediately bail out of walking any subtrees when we can see that their parents
37611
37871
  // are already correct.
37612
- var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
37872
+ var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
37613
37873
  result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
37614
37874
  result.impliedNodeFormat = sourceFile.impliedNodeFormat;
37615
37875
  return result;
@@ -39525,6 +39785,18 @@ var ts;
39525
39785
  description: ts.Diagnostics.Specify_a_list_of_language_service_plugins_to_include,
39526
39786
  category: ts.Diagnostics.Editor_Support,
39527
39787
  },
39788
+ {
39789
+ name: "moduleDetection",
39790
+ type: new ts.Map(ts.getEntries({
39791
+ auto: ts.ModuleDetectionKind.Auto,
39792
+ legacy: ts.ModuleDetectionKind.Legacy,
39793
+ force: ts.ModuleDetectionKind.Force,
39794
+ })),
39795
+ affectsModuleResolution: true,
39796
+ description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files,
39797
+ category: ts.Diagnostics.Language_and_Environment,
39798
+ 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,
39799
+ }
39528
39800
  ];
39529
39801
  /* @internal */
39530
39802
  ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild, true), commandOptionsWithoutBuild, true);
@@ -47667,6 +47939,8 @@ var ts;
47667
47939
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
47668
47940
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
47669
47941
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
47942
+ var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
47943
+ var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints)
47670
47944
  var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
47671
47945
  var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
47672
47946
  emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */;
@@ -48605,7 +48879,7 @@ var ts;
48605
48879
  // - parameters are only in the scope of function body
48606
48880
  // This restriction does not apply to JSDoc comment types because they are parented
48607
48881
  // at a higher level than type parameters would normally be
48608
- if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 319 /* JSDocComment */) {
48882
+ if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 319 /* JSDoc */) {
48609
48883
  useResult = result.flags & 262144 /* TypeParameter */
48610
48884
  // type parameters are visible in parameter list, return type and type parameter list
48611
48885
  ? lastLocation === location.type ||
@@ -51571,10 +51845,16 @@ var ts;
51571
51845
  var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
51572
51846
  var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined;
51573
51847
  var appropriateConstraintTypeNode;
51848
+ var newTypeVariable;
51574
51849
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
51575
51850
  // We have a { [P in keyof T]: X }
51576
51851
  // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
51577
- appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
51852
+ if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
51853
+ var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
51854
+ var name = typeParameterToName(newParam, context);
51855
+ newTypeVariable = ts.factory.createTypeReferenceNode(name);
51856
+ }
51857
+ appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
51578
51858
  }
51579
51859
  else {
51580
51860
  appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
@@ -51584,7 +51864,14 @@ var ts;
51584
51864
  var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context);
51585
51865
  var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
51586
51866
  context.approximateLength += 10;
51587
- return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
51867
+ var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
51868
+ if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
51869
+ // homomorphic mapped type with a non-homomorphic naive inlining
51870
+ // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
51871
+ // type stays homomorphic
51872
+ 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 */));
51873
+ }
51874
+ return result;
51588
51875
  }
51589
51876
  function createAnonymousTypeNode(type) {
51590
51877
  var _a;
@@ -53205,7 +53492,7 @@ var ts;
53205
53492
  // If it's a class/interface/function: emit a class/interface/function with a `default` modifier
53206
53493
  // These forms can merge, eg (`export default 12; export default interface A {}`)
53207
53494
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
53208
- var _a, _b;
53495
+ var _a, _b, _c, _d;
53209
53496
  var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
53210
53497
  var isDefault = symbol.escapedName === "default" /* Default */;
53211
53498
  if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
@@ -53256,17 +53543,21 @@ var ts;
53256
53543
  else {
53257
53544
  // 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!_
53258
53545
  // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property`
53259
- var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined
53260
- : isConstVariable(symbol) ? 2 /* Const */
53546
+ var flags = !(symbol.flags & 2 /* BlockScopedVariable */)
53547
+ ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration)
53548
+ ? 2 /* Const */
53549
+ : undefined
53550
+ : isConstVariable(symbol)
53551
+ ? 2 /* Const */
53261
53552
  : 1 /* Let */;
53262
53553
  var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol);
53263
53554
  var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
53264
53555
  if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
53265
53556
  textRange = textRange.parent.parent;
53266
53557
  }
53267
- var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression);
53558
+ var propertyAccessRequire = (_c = symbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isPropertyAccessExpression);
53268
53559
  if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right)
53269
- && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
53560
+ && ((_d = type.symbol) === null || _d === void 0 ? void 0 : _d.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
53270
53561
  var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right;
53271
53562
  addResult(ts.factory.createExportDeclaration(
53272
53563
  /*decorators*/ undefined,
@@ -53346,8 +53637,8 @@ var ts;
53346
53637
  // synthesize export * from "moduleReference"
53347
53638
  // Straightforward - only one thing to do - make an export declaration
53348
53639
  if (symbol.declarations) {
53349
- for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) {
53350
- var node = _c[_i];
53640
+ for (var _i = 0, _e = symbol.declarations; _i < _e.length; _i++) {
53641
+ var node = _e[_i];
53351
53642
  var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
53352
53643
  if (!resolvedModule)
53353
53644
  continue;
@@ -55153,7 +55444,10 @@ var ts;
55153
55444
  if (containsSameNamedThisProperty(expression.left, expression.right)) {
55154
55445
  return anyType;
55155
55446
  }
55156
- var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
55447
+ 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)));
55448
+ var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol)
55449
+ : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right))
55450
+ : getWidenedLiteralType(checkExpressionCached(expression.right));
55157
55451
  if (type.flags & 524288 /* Object */ &&
55158
55452
  kind === 2 /* ModuleExports */ &&
55159
55453
  symbol.escapedName === "export=" /* ExportEquals */) {
@@ -55897,7 +56191,7 @@ var ts;
55897
56191
  node = paramSymbol.valueDeclaration;
55898
56192
  }
55899
56193
  break;
55900
- case 319 /* JSDocComment */: {
56194
+ case 319 /* JSDoc */: {
55901
56195
  var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
55902
56196
  return node.tags
55903
56197
  ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; }))
@@ -58158,10 +58452,10 @@ var ts;
58158
58452
  else if (type !== firstType) {
58159
58453
  checkFlags |= 64 /* HasNonUniformType */;
58160
58454
  }
58161
- if (isLiteralType(type) || isPatternLiteralType(type)) {
58455
+ if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
58162
58456
  checkFlags |= 128 /* HasLiteralType */;
58163
58457
  }
58164
- if (type.flags & 131072 /* Never */) {
58458
+ if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
58165
58459
  checkFlags |= 131072 /* HasNeverType */;
58166
58460
  }
58167
58461
  propTypes.push(type);
@@ -59346,7 +59640,7 @@ var ts;
59346
59640
  function getConditionalFlowTypeOfType(type, node) {
59347
59641
  var constraints;
59348
59642
  var covariant = true;
59349
- while (node && !ts.isStatement(node) && node.kind !== 319 /* JSDocComment */) {
59643
+ while (node && !ts.isStatement(node) && node.kind !== 319 /* JSDoc */) {
59350
59644
  var parent = node.parent;
59351
59645
  // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but
59352
59646
  // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax
@@ -60702,10 +60996,24 @@ var ts;
60702
60996
  return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
60703
60997
  /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
60704
60998
  }
60999
+ /**
61000
+ * A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
61001
+ * must be kept generic, as that instantiation information needs to flow through the type system. By replacing all
61002
+ * type parameters in the union with a special never type that is treated as a literal in `getReducedType`, we can cause the `getReducedType` logic
61003
+ * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
61004
+ */
61005
+ function isPossiblyReducibleByInstantiation(type) {
61006
+ return ts.some(type.types, function (t) {
61007
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
61008
+ return getReducedType(uniqueFilled) !== uniqueFilled;
61009
+ });
61010
+ }
60705
61011
  function getIndexType(type, stringsOnly, noIndexSignatures) {
60706
61012
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
60707
61013
  type = getReducedType(type);
60708
- return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
61014
+ return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
61015
+ ? getIndexTypeForGenericType(type, stringsOnly)
61016
+ : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60709
61017
  type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60710
61018
  type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
60711
61019
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
@@ -61333,6 +61641,10 @@ var ts;
61333
61641
  }
61334
61642
  return type;
61335
61643
  }
61644
+ function maybeCloneTypeParameter(p) {
61645
+ var constraint = getConstraintOfTypeParameter(p);
61646
+ return constraint && (isGenericObjectType(constraint) || isGenericIndexType(constraint)) ? cloneTypeParameter(p) : p;
61647
+ }
61336
61648
  function isTypicalNondistributiveConditional(root) {
61337
61649
  return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
61338
61650
  }
@@ -61351,37 +61663,65 @@ var ts;
61351
61663
  var result;
61352
61664
  var extraTypes;
61353
61665
  var tailCount = 0;
61354
- // We loop here for an immediately nested conditional type in the false position, effectively treating
61355
- // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
61356
- // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
61357
- // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
61358
- // cases we increment the tail recursion counter and stop after 1000 iterations.
61359
- while (true) {
61666
+ var _loop_18 = function () {
61360
61667
  if (tailCount === 1000) {
61361
61668
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
61362
61669
  result = errorType;
61363
- break;
61670
+ return "break";
61364
61671
  }
61365
61672
  var isUnwrapped = isTypicalNondistributiveConditional(root);
61366
61673
  var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
61367
61674
  var checkTypeInstantiable = isGenericType(checkType);
61368
61675
  var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
61369
61676
  if (checkType === wildcardType || extendsType === wildcardType) {
61370
- return wildcardType;
61677
+ return { value: wildcardType };
61371
61678
  }
61372
61679
  var combinedMapper = void 0;
61373
61680
  if (root.inferTypeParameters) {
61374
- var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */);
61375
- if (!checkTypeInstantiable) {
61681
+ // When we're looking at making an inference for an infer type, when we get its constraint, it'll automagically be
61682
+ // instantiated with the context, so it doesn't need the mapper for the inference contex - however the constraint
61683
+ // may refer to another _root_, _uncloned_ `infer` type parameter [1], or to something mapped by `mapper` [2].
61684
+ // [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
61685
+ // as `number`
61686
+ // Conversely, if we have `Foo<infer A, infer B>`, `B` is still constrained to `T` and `T` is instantiated as `A`
61687
+ // [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`
61688
+ // which is in turn instantiated as `Q`, which is in turn instantiated as `number`.
61689
+ // So we need to:
61690
+ // * Clone the type parameters so their constraints can be instantiated in the context of `mapper` (otherwise theyd only get inference context information)
61691
+ // * Set the clones to both map the conditional's enclosing `mapper` and the original params
61692
+ // * instantiate the extends type with the clones
61693
+ // * incorporate all of the component mappers into the combined mapper for the true and false members
61694
+ // This means we have three mappers that need applying:
61695
+ // * The original `mapper` used to create this conditional
61696
+ // * The mapper that maps the old root type parameter to the clone (`freshMapper`)
61697
+ // * The mapper that maps the clone to its inference result (`context.mapper`)
61698
+ var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
61699
+ var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined;
61700
+ var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */);
61701
+ if (freshMapper) {
61702
+ var freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
61703
+ for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) {
61704
+ var p = freshParams_1[_i];
61705
+ if (root.inferTypeParameters.indexOf(p) === -1) {
61706
+ p.mapper = freshCombinedMapper;
61707
+ }
61708
+ }
61709
+ }
61710
+ // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
61711
+ // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
61712
+ // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
61713
+ // so in those cases we refain from performing inference and retain the uninfered type parameter
61714
+ if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
61376
61715
  // We don't want inferences from constraints as they may cause us to eagerly resolve the
61377
61716
  // conditional type instead of deferring resolution. Also, we always want strict function
61378
61717
  // types rules (i.e. proper contravariance) for inferences.
61379
- inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
61718
+ inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
61380
61719
  }
61720
+ var innerMapper = combineTypeMappers(freshMapper, context.mapper);
61381
61721
  // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the
61382
61722
  // those type parameters are used in type references (see getInferredTypeParameterConstraint). For
61383
61723
  // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples.
61384
- combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper;
61724
+ combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
61385
61725
  }
61386
61726
  // Instantiate the extends type including inferences for 'infer T' type parameters
61387
61727
  var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType;
@@ -61403,14 +61743,14 @@ var ts;
61403
61743
  var newRoot = falseType_1.root;
61404
61744
  if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
61405
61745
  root = newRoot;
61406
- continue;
61746
+ return "continue";
61407
61747
  }
61408
61748
  if (canTailRecurse(falseType_1, mapper)) {
61409
- continue;
61749
+ return "continue";
61410
61750
  }
61411
61751
  }
61412
61752
  result = instantiateType(falseType_1, mapper);
61413
- break;
61753
+ return "break";
61414
61754
  }
61415
61755
  // Return trueType for a definitely true extends check. We check instantiations of the two
61416
61756
  // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
@@ -61421,10 +61761,10 @@ var ts;
61421
61761
  var trueType_1 = getTypeFromTypeNode(root.node.trueType);
61422
61762
  var trueMapper = combinedMapper || mapper;
61423
61763
  if (canTailRecurse(trueType_1, trueMapper)) {
61424
- continue;
61764
+ return "continue";
61425
61765
  }
61426
61766
  result = instantiateType(trueType_1, trueMapper);
61427
- break;
61767
+ return "break";
61428
61768
  }
61429
61769
  }
61430
61770
  // Return a deferred type for a check that is neither definitely true nor definitely false
@@ -61436,7 +61776,19 @@ var ts;
61436
61776
  result.combinedMapper = combinedMapper;
61437
61777
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
61438
61778
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
61439
- break;
61779
+ return "break";
61780
+ };
61781
+ // We loop here for an immediately nested conditional type in the false position, effectively treating
61782
+ // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
61783
+ // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
61784
+ // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
61785
+ // cases we increment the tail recursion counter and stop after 1000 iterations.
61786
+ while (true) {
61787
+ var state_5 = _loop_18();
61788
+ if (typeof state_5 === "object")
61789
+ return state_5.value;
61790
+ if (state_5 === "break")
61791
+ break;
61440
61792
  }
61441
61793
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
61442
61794
  // We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
@@ -61858,9 +62210,11 @@ var ts;
61858
62210
  }
61859
62211
  function getESSymbolLikeTypeForNode(node) {
61860
62212
  if (ts.isValidESSymbolDeclaration(node)) {
61861
- var symbol = getSymbolOfNode(node);
61862
- var links = getSymbolLinks(symbol);
61863
- return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
62213
+ var symbol = ts.isCommonJsExportPropertyAssignment(node) ? getSymbolOfNode(node.left) : getSymbolOfNode(node);
62214
+ if (symbol) {
62215
+ var links = getSymbolLinks(symbol);
62216
+ return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
62217
+ }
61864
62218
  }
61865
62219
  return esSymbolType;
61866
62220
  }
@@ -62504,6 +62858,10 @@ var ts;
62504
62858
  }
62505
62859
  return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable
62506
62860
  }
62861
+ function getUniqueLiteralFilledInstantiation(type) {
62862
+ return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
62863
+ type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper));
62864
+ }
62507
62865
  function getPermissiveInstantiation(type) {
62508
62866
  return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
62509
62867
  type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
@@ -63392,7 +63750,8 @@ var ts;
63392
63750
  return true;
63393
63751
  }
63394
63752
  }
63395
- else {
63753
+ else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
63754
+ // We have excluded types that may simplify to other forms, so types must have identical flags
63396
63755
  if (source.flags !== target.flags)
63397
63756
  return false;
63398
63757
  if (source.flags & 67358815 /* Singleton */)
@@ -63963,7 +64322,7 @@ var ts;
63963
64322
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
63964
64323
  checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
63965
64324
  }
63966
- var _loop_18 = function (prop) {
64325
+ var _loop_19 = function (prop) {
63967
64326
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
63968
64327
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
63969
64328
  if (reportErrors) {
@@ -64026,9 +64385,9 @@ var ts;
64026
64385
  };
64027
64386
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
64028
64387
  var prop = _b[_i];
64029
- var state_5 = _loop_18(prop);
64030
- if (typeof state_5 === "object")
64031
- return state_5.value;
64388
+ var state_6 = _loop_19(prop);
64389
+ if (typeof state_6 === "object")
64390
+ return state_6.value;
64032
64391
  }
64033
64392
  return false;
64034
64393
  }
@@ -65018,11 +65377,11 @@ var ts;
65018
65377
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
65019
65378
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
65020
65379
  var matchingTypes = [];
65021
- var _loop_19 = function (combination) {
65380
+ var _loop_20 = function (combination) {
65022
65381
  var hasMatch = false;
65023
65382
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
65024
65383
  var type = _d[_c];
65025
- var _loop_20 = function (i) {
65384
+ var _loop_21 = function (i) {
65026
65385
  var sourceProperty = sourcePropertiesFiltered[i];
65027
65386
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
65028
65387
  if (!targetProperty)
@@ -65038,8 +65397,8 @@ var ts;
65038
65397
  }
65039
65398
  };
65040
65399
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
65041
- var state_7 = _loop_20(i);
65042
- switch (state_7) {
65400
+ var state_8 = _loop_21(i);
65401
+ switch (state_8) {
65043
65402
  case "continue-outer": continue outer;
65044
65403
  }
65045
65404
  }
@@ -65052,9 +65411,9 @@ var ts;
65052
65411
  };
65053
65412
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
65054
65413
  var combination = discriminantCombinations_1[_a];
65055
- var state_6 = _loop_19(combination);
65056
- if (typeof state_6 === "object")
65057
- return state_6.value;
65414
+ var state_7 = _loop_20(combination);
65415
+ if (typeof state_7 === "object")
65416
+ return state_7.value;
65058
65417
  }
65059
65418
  // Compare the remaining non-discriminant properties of each match.
65060
65419
  var result = -1 /* True */;
@@ -65767,7 +66126,7 @@ var ts;
65767
66126
  // The emptyArray singleton is used to signal a recursive invocation.
65768
66127
  cache.variances = ts.emptyArray;
65769
66128
  variances = [];
65770
- var _loop_21 = function (tp) {
66129
+ var _loop_22 = function (tp) {
65771
66130
  var unmeasurable = false;
65772
66131
  var unreliable = false;
65773
66132
  var oldHandler = outofbandVarianceMarkerHandler;
@@ -65799,7 +66158,7 @@ var ts;
65799
66158
  };
65800
66159
  for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
65801
66160
  var tp = typeParameters_1[_i];
65802
- _loop_21(tp);
66161
+ _loop_22(tp);
65803
66162
  }
65804
66163
  cache.variances = variances;
65805
66164
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -68170,7 +68529,7 @@ var ts;
68170
68529
  function mapTypesByKeyProperty(types, name) {
68171
68530
  var map = new ts.Map();
68172
68531
  var count = 0;
68173
- var _loop_22 = function (type) {
68532
+ var _loop_23 = function (type) {
68174
68533
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
68175
68534
  var discriminant = getTypeOfPropertyOfType(type, name);
68176
68535
  if (discriminant) {
@@ -68196,9 +68555,9 @@ var ts;
68196
68555
  };
68197
68556
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
68198
68557
  var type = types_16[_i];
68199
- var state_8 = _loop_22(type);
68200
- if (typeof state_8 === "object")
68201
- return state_8.value;
68558
+ var state_9 = _loop_23(type);
68559
+ if (typeof state_9 === "object")
68560
+ return state_9.value;
68202
68561
  }
68203
68562
  return count >= 10 && count * 2 >= types.length ? map : undefined;
68204
68563
  }
@@ -69468,7 +69827,7 @@ var ts;
69468
69827
  return result;
69469
69828
  }
69470
69829
  function getCandidateDiscriminantPropertyAccess(expr) {
69471
- if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
69830
+ if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference) || ts.isObjectLiteralMethod(reference)) {
69472
69831
  // When the reference is a binding pattern or function or arrow expression, we are narrowing a pesudo-reference in
69473
69832
  // getNarrowedTypeOfSymbol. An identifier for a destructuring variable declared in the same binding pattern or
69474
69833
  // parameter declared in the same parameter list is a candidate.
@@ -74529,7 +74888,7 @@ var ts;
74529
74888
  if (spreadIndex >= 0) {
74530
74889
  // Create synthetic arguments from spreads of tuple types.
74531
74890
  var effectiveArgs_1 = args.slice(0, spreadIndex);
74532
- var _loop_23 = function (i) {
74891
+ var _loop_24 = function (i) {
74533
74892
  var arg = args[i];
74534
74893
  // We can call checkExpressionCached because spread expressions never have a contextual type.
74535
74894
  var spreadType = arg.kind === 224 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -74546,7 +74905,7 @@ var ts;
74546
74905
  }
74547
74906
  };
74548
74907
  for (var i = spreadIndex; i < args.length; i++) {
74549
- _loop_23(i);
74908
+ _loop_24(i);
74550
74909
  }
74551
74910
  return effectiveArgs_1;
74552
74911
  }
@@ -74859,7 +75218,7 @@ var ts;
74859
75218
  var min_3 = Number.MAX_VALUE;
74860
75219
  var minIndex = 0;
74861
75220
  var i_1 = 0;
74862
- var _loop_24 = function (c) {
75221
+ var _loop_25 = function (c) {
74863
75222
  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)); };
74864
75223
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
74865
75224
  if (diags_2) {
@@ -74877,7 +75236,7 @@ var ts;
74877
75236
  };
74878
75237
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
74879
75238
  var c = candidatesForArgumentError_1[_a];
74880
- _loop_24(c);
75239
+ _loop_25(c);
74881
75240
  }
74882
75241
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
74883
75242
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -75035,7 +75394,7 @@ var ts;
75035
75394
  }
75036
75395
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
75037
75396
  var parameters = [];
75038
- var _loop_25 = function (i) {
75397
+ var _loop_26 = function (i) {
75039
75398
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
75040
75399
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
75041
75400
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -75043,7 +75402,7 @@ var ts;
75043
75402
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
75044
75403
  };
75045
75404
  for (var i = 0; i < maxNonRestParam; i++) {
75046
- _loop_25(i);
75405
+ _loop_26(i);
75047
75406
  }
75048
75407
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
75049
75408
  var flags = 0 /* None */;
@@ -76440,6 +76799,9 @@ var ts;
76440
76799
  assignBindingElementTypes(declaration.name, links.type);
76441
76800
  }
76442
76801
  }
76802
+ else if (type) {
76803
+ ts.Debug.assertEqual(links.type, type, "Parameter symbol already has a cached type which differs from newly assigned type");
76804
+ }
76443
76805
  }
76444
76806
  // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
76445
76807
  // the destructured type into the contained binding elements.
@@ -78270,7 +78632,7 @@ var ts;
78270
78632
  }
78271
78633
  function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
78272
78634
  var type = checkExpression(node, checkMode, forceTuple);
78273
- return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
78635
+ return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
78274
78636
  isTypeAssertion(node) ? type :
78275
78637
  getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
78276
78638
  }
@@ -79039,7 +79401,7 @@ var ts;
79039
79401
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
79040
79402
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
79041
79403
  var indexSignatureMap_1 = new ts.Map();
79042
- var _loop_26 = function (declaration) {
79404
+ var _loop_27 = function (declaration) {
79043
79405
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
79044
79406
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
79045
79407
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -79054,7 +79416,7 @@ var ts;
79054
79416
  };
79055
79417
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
79056
79418
  var declaration = _a[_i];
79057
- _loop_26(declaration);
79419
+ _loop_27(declaration);
79058
79420
  }
79059
79421
  indexSignatureMap_1.forEach(function (entry) {
79060
79422
  if (entry.declarations.length > 1) {
@@ -82433,7 +82795,7 @@ var ts;
82433
82795
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
82434
82796
  var localPropDeclaration = declaration && declaration.kind === 220 /* BinaryExpression */ ||
82435
82797
  name && name.kind === 161 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
82436
- var _loop_27 = function (info) {
82798
+ var _loop_28 = function (info) {
82437
82799
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
82438
82800
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
82439
82801
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -82446,7 +82808,7 @@ var ts;
82446
82808
  };
82447
82809
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
82448
82810
  var info = indexInfos_9[_i];
82449
- _loop_27(info);
82811
+ _loop_28(info);
82450
82812
  }
82451
82813
  }
82452
82814
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -82454,7 +82816,7 @@ var ts;
82454
82816
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
82455
82817
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
82456
82818
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
82457
- var _loop_28 = function (info) {
82819
+ var _loop_29 = function (info) {
82458
82820
  if (info === checkInfo)
82459
82821
  return "continue";
82460
82822
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -82469,7 +82831,7 @@ var ts;
82469
82831
  };
82470
82832
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
82471
82833
  var info = indexInfos_10[_i];
82472
- _loop_28(info);
82834
+ _loop_29(info);
82473
82835
  }
82474
82836
  }
82475
82837
  function checkTypeNameIsReserved(name, message) {
@@ -82780,7 +83142,7 @@ var ts;
82780
83142
  var baseTypes = baseTypeNode && getBaseTypes(type);
82781
83143
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
82782
83144
  var baseStaticType = getBaseConstructorTypeOfClass(type);
82783
- var _loop_29 = function (member) {
83145
+ var _loop_30 = function (member) {
82784
83146
  if (ts.hasAmbientModifier(member)) {
82785
83147
  return "continue";
82786
83148
  }
@@ -82797,7 +83159,7 @@ var ts;
82797
83159
  };
82798
83160
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
82799
83161
  var member = _a[_i];
82800
- _loop_29(member);
83162
+ _loop_30(member);
82801
83163
  }
82802
83164
  }
82803
83165
  /**
@@ -82885,7 +83247,7 @@ var ts;
82885
83247
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
82886
83248
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
82887
83249
  var issuedMemberError = false;
82888
- var _loop_30 = function (member) {
83250
+ var _loop_31 = function (member) {
82889
83251
  if (ts.isStatic(member)) {
82890
83252
  return "continue";
82891
83253
  }
@@ -82904,7 +83266,7 @@ var ts;
82904
83266
  };
82905
83267
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
82906
83268
  var member = _a[_i];
82907
- _loop_30(member);
83269
+ _loop_31(member);
82908
83270
  }
82909
83271
  if (!issuedMemberError) {
82910
83272
  // check again with diagnostics to generate a less-specific error
@@ -87332,8 +87694,8 @@ var ts;
87332
87694
  }
87333
87695
  else {
87334
87696
  var elements = name.elements;
87335
- for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
87336
- var element = elements_1[_i];
87697
+ for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
87698
+ var element = elements_2[_i];
87337
87699
  if (!ts.isOmittedExpression(element)) {
87338
87700
  return checkESModuleMarker(element.name);
87339
87701
  }
@@ -87349,8 +87711,8 @@ var ts;
87349
87711
  }
87350
87712
  else {
87351
87713
  var elements = name.elements;
87352
- for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
87353
- var element = elements_2[_i];
87714
+ for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
87715
+ var element = elements_3[_i];
87354
87716
  if (!ts.isOmittedExpression(element)) {
87355
87717
  checkGrammarNameInLetOrConstDeclarations(element.name);
87356
87718
  }
@@ -89604,8 +89966,8 @@ var ts;
89604
89966
  }
89605
89967
  function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
89606
89968
  var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
89607
- for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
89608
- var element = elements_3[_i];
89969
+ for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
89970
+ var element = elements_4[_i];
89609
89971
  if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
89610
89972
  return true;
89611
89973
  }
@@ -95223,8 +95585,8 @@ var ts;
95223
95585
  function chunkObjectLiteralElements(elements) {
95224
95586
  var chunkObject;
95225
95587
  var objects = [];
95226
- for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
95227
- var e = elements_4[_i];
95588
+ for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) {
95589
+ var e = elements_5[_i];
95228
95590
  if (e.kind === 297 /* SpreadAssignment */) {
95229
95591
  if (chunkObject) {
95230
95592
  objects.push(factory.createObjectLiteralExpression(chunkObject));
@@ -109869,7 +110231,7 @@ var ts;
109869
110231
  return emitRestOrJSDocVariadicType(node);
109870
110232
  case 318 /* JSDocNamepathType */:
109871
110233
  return;
109872
- case 319 /* JSDocComment */:
110234
+ case 319 /* JSDoc */:
109873
110235
  return emitJSDoc(node);
109874
110236
  case 321 /* JSDocTypeLiteral */:
109875
110237
  return emitJSDocTypeLiteral(node);
@@ -114245,7 +114607,7 @@ var ts;
114245
114607
  var existingDirectories = new ts.Map();
114246
114608
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
114247
114609
  var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
114248
- function getSourceFile(fileName, languageVersion, onError) {
114610
+ function getSourceFile(fileName, languageVersionOrOptions, onError) {
114249
114611
  var text;
114250
114612
  try {
114251
114613
  ts.performance.mark("beforeIORead");
@@ -114259,7 +114621,7 @@ var ts;
114259
114621
  }
114260
114622
  text = "";
114261
114623
  }
114262
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
114624
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions, setParentNodes) : undefined;
114263
114625
  }
114264
114626
  function directoryExists(directoryPath) {
114265
114627
  if (existingDirectories.has(directoryPath)) {
@@ -115665,8 +116027,8 @@ var ts;
115665
116027
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
115666
116028
  var oldSourceFile = oldSourceFiles_2[_i];
115667
116029
  var newSourceFile = host.getSourceFileByPath
115668
- ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
115669
- : host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
116030
+ ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile)
116031
+ : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
115670
116032
  if (!newSourceFile) {
115671
116033
  return 0 /* Not */;
115672
116034
  }
@@ -115697,7 +116059,6 @@ var ts;
115697
116059
  newSourceFile.originalFileName = oldSourceFile.originalFileName;
115698
116060
  newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
115699
116061
  newSourceFile.fileName = oldSourceFile.fileName;
115700
- newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
115701
116062
  var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
115702
116063
  if (packageName !== undefined) {
115703
116064
  // If there are 2 different source files for the same package name and at least one of them changes,
@@ -116616,6 +116977,17 @@ var ts;
116616
116977
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
116617
116978
  return result;
116618
116979
  }
116980
+ function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
116981
+ // 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
116982
+ // 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
116983
+ // 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.
116984
+ var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
116985
+ return {
116986
+ languageVersion: ts.getEmitScriptTarget(options),
116987
+ impliedNodeFormat: impliedNodeFormat,
116988
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
116989
+ };
116990
+ }
116619
116991
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
116620
116992
  var path = toPath(fileName);
116621
116993
  if (useSourceOfProjectReferenceRedirect) {
@@ -116703,7 +117075,7 @@ var ts;
116703
117075
  }
116704
117076
  }
116705
117077
  // We haven't looked for this file, do so now and cache result
116706
- 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);
117078
+ 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);
116707
117079
  if (packageId) {
116708
117080
  var packageIdKey = ts.packageIdToString(packageId);
116709
117081
  var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
@@ -116731,10 +117103,6 @@ var ts;
116731
117103
  file.path = path;
116732
117104
  file.resolvedPath = toPath(fileName);
116733
117105
  file.originalFileName = originalFileName;
116734
- // 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
116735
- // 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
116736
- // 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.
116737
- file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
116738
117106
  addFileIncludeReason(file, reason);
116739
117107
  if (host.useCaseSensitiveFileNames()) {
116740
117108
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -117236,7 +117604,7 @@ var ts;
117236
117604
  }
117237
117605
  else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
117238
117606
  // We cannot use createDiagnosticFromNode because nodes do not have parents yet
117239
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117607
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117240
117608
  programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
117241
117609
  }
117242
117610
  // Cannot specify module gen that isn't amd or system with --out
@@ -117245,7 +117613,7 @@ var ts;
117245
117613
  createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
117246
117614
  }
117247
117615
  else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
117248
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117616
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117249
117617
  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"));
117250
117618
  }
117251
117619
  }
@@ -120691,7 +121059,7 @@ var ts;
120691
121059
  });
120692
121060
  // Sort by paths closest to importing file Name directory
120693
121061
  var sortedPaths = [];
120694
- var _loop_31 = function (directory) {
121062
+ var _loop_32 = function (directory) {
120695
121063
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
120696
121064
  var pathsInDirectory;
120697
121065
  allFileNames.forEach(function (_a, fileName) {
@@ -120715,9 +121083,9 @@ var ts;
120715
121083
  };
120716
121084
  var out_directory_1;
120717
121085
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
120718
- var state_9 = _loop_31(directory);
121086
+ var state_10 = _loop_32(directory);
120719
121087
  directory = out_directory_1;
120720
- if (state_9 === "break")
121088
+ if (state_10 === "break")
120721
121089
  break;
120722
121090
  }
120723
121091
  if (allFileNames.size) {
@@ -121507,7 +121875,7 @@ var ts;
121507
121875
  var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
121508
121876
  var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
121509
121877
  return {
121510
- getSourceFile: function (fileName, languageVersion, onError) {
121878
+ getSourceFile: function (fileName, languageVersionOrOptions, onError) {
121511
121879
  var text;
121512
121880
  try {
121513
121881
  ts.performance.mark("beforeIORead");
@@ -121521,7 +121889,7 @@ var ts;
121521
121889
  }
121522
121890
  text = "";
121523
121891
  }
121524
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
121892
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions) : undefined;
121525
121893
  },
121526
121894
  getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
121527
121895
  getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
@@ -121989,7 +122357,7 @@ var ts;
121989
122357
  }
121990
122358
  return directoryStructureHost.fileExists(fileName);
121991
122359
  }
121992
- function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
122360
+ function getVersionedSourceFileByPath(fileName, path, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
121993
122361
  var hostSourceFile = sourceFilesCache.get(path);
121994
122362
  // No source file on the host
121995
122363
  if (isFileMissingOnHost(hostSourceFile)) {
@@ -121997,7 +122365,7 @@ var ts;
121997
122365
  }
121998
122366
  // Create new source file if requested or the versions dont match
121999
122367
  if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
122000
- var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
122368
+ var sourceFile = getNewSourceFile(fileName, languageVersionOrOptions, onError);
122001
122369
  if (hostSourceFile) {
122002
122370
  if (sourceFile) {
122003
122371
  // Set the source file and create file watcher now that file was present on the disk
@@ -133685,9 +134053,15 @@ var ts;
133685
134053
  });
133686
134054
  return JSON.stringify(bucketInfoArray, undefined, 2);
133687
134055
  }
134056
+ function getCompilationSettings(settingsOrHost) {
134057
+ if (typeof settingsOrHost.getCompilationSettings === "function") {
134058
+ return settingsOrHost.getCompilationSettings();
134059
+ }
134060
+ return settingsOrHost;
134061
+ }
133688
134062
  function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
133689
134063
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
133690
- var key = getKeyForCompilationSettings(compilationSettings);
134064
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
133691
134065
  return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
133692
134066
  }
133693
134067
  function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
@@ -133695,20 +134069,28 @@ var ts;
133695
134069
  }
133696
134070
  function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
133697
134071
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
133698
- var key = getKeyForCompilationSettings(compilationSettings);
134072
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
133699
134073
  return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
133700
134074
  }
133701
134075
  function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
133702
- return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
134076
+ return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
133703
134077
  }
133704
134078
  function getDocumentRegistryEntry(bucketEntry, scriptKind) {
133705
134079
  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"));
133706
134080
  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);
133707
134081
  return entry;
133708
134082
  }
133709
- function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
134083
+ function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
134084
+ var _a, _b, _c, _d;
133710
134085
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
134086
+ var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
134087
+ var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
133711
134088
  var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
134089
+ var sourceFileOptions = {
134090
+ languageVersion: scriptTarget,
134091
+ 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),
134092
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
134093
+ };
133712
134094
  var oldBucketCount = buckets.size;
133713
134095
  var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
133714
134096
  if (ts.tracing) {
@@ -133742,7 +134124,7 @@ var ts;
133742
134124
  }
133743
134125
  if (!entry) {
133744
134126
  // Have never seen this file with these settings. Create a new source file for it.
133745
- var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind);
134127
+ var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
133746
134128
  if (externalCache) {
133747
134129
  externalCache.setDocument(key, path, sourceFile);
133748
134130
  }
@@ -142186,7 +142568,7 @@ var ts;
142186
142568
  continue;
142187
142569
  var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, moduleSpecifier));
142188
142570
  var resolvedFile = module_1 && program.getSourceFile(module_1.resolvedFileName);
142189
- if (resolvedFile && resolvedFile.externalModuleIndicator && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
142571
+ if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
142190
142572
  diags.push(ts.createDiagnosticForNode(name, ts.Diagnostics.Import_may_be_converted_to_a_default_import));
142191
142573
  }
142192
142574
  }
@@ -143102,19 +143484,7 @@ var ts;
143102
143484
  options.suppressOutputPathCheck = true;
143103
143485
  // Filename can be non-ts file.
143104
143486
  options.allowNonTsExtensions = true;
143105
- // if jsx is specified then treat file as .tsx
143106
- var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
143107
- var sourceFile = ts.createSourceFile(inputFileName, input, ts.getEmitScriptTarget(options));
143108
- if (transpileOptions.moduleName) {
143109
- sourceFile.moduleName = transpileOptions.moduleName;
143110
- }
143111
- if (transpileOptions.renamedDependencies) {
143112
- sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
143113
- }
143114
143487
  var newLine = ts.getNewLineCharacter(options);
143115
- // Output
143116
- var outputText;
143117
- var sourceMapText;
143118
143488
  // Create a compilerHost object to allow the compiler to read and write files
143119
143489
  var compilerHost = {
143120
143490
  getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; },
@@ -143138,6 +143508,22 @@ var ts;
143138
143508
  directoryExists: function () { return true; },
143139
143509
  getDirectories: function () { return []; }
143140
143510
  };
143511
+ // if jsx is specified then treat file as .tsx
143512
+ var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
143513
+ var sourceFile = ts.createSourceFile(inputFileName, input, {
143514
+ languageVersion: ts.getEmitScriptTarget(options),
143515
+ impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(inputFileName, "", compilerHost.getCanonicalFileName), /*cache*/ undefined, compilerHost, options),
143516
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
143517
+ });
143518
+ if (transpileOptions.moduleName) {
143519
+ sourceFile.moduleName = transpileOptions.moduleName;
143520
+ }
143521
+ if (transpileOptions.renamedDependencies) {
143522
+ sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
143523
+ }
143524
+ // Output
143525
+ var outputText;
143526
+ var sourceMapText;
143141
143527
  var program = ts.createProgram([inputFileName], options, compilerHost);
143142
143528
  if (transpileOptions.reportDiagnostics) {
143143
143529
  ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
@@ -159650,7 +160036,7 @@ var ts;
159650
160036
  for (var i = 1;; i++) {
159651
160037
  var name = ts.combinePaths(inDirectory, newModuleName + extension);
159652
160038
  if (!host.fileExists(name))
159653
- return newModuleName; // TODO: GH#18217
160039
+ return newModuleName;
159654
160040
  newModuleName = moduleName + "." + i;
159655
160041
  }
159656
160042
  }
@@ -162010,6 +162396,7 @@ var ts;
162010
162396
  this.host = host;
162011
162397
  }
162012
162398
  SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) {
162399
+ var _a, _b, _c, _d, _e, _f, _g, _h;
162013
162400
  var scriptSnapshot = this.host.getScriptSnapshot(fileName);
162014
162401
  if (!scriptSnapshot) {
162015
162402
  // The host does not know about this file.
@@ -162020,7 +162407,12 @@ var ts;
162020
162407
  var sourceFile;
162021
162408
  if (this.currentFileName !== fileName) {
162022
162409
  // This is a new file, just parse it
162023
- sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 99 /* Latest */, version, /*setNodeParents*/ true, scriptKind);
162410
+ var options = {
162411
+ languageVersion: 99 /* Latest */,
162412
+ 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()),
162413
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings())
162414
+ };
162415
+ sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, scriptKind);
162024
162416
  }
162025
162417
  else if (this.currentFileVersion !== version) {
162026
162418
  // This is the same file, just a newer version. Incrementally parse the file.
@@ -162042,8 +162434,8 @@ var ts;
162042
162434
  sourceFile.version = version;
162043
162435
  sourceFile.scriptSnapshot = scriptSnapshot;
162044
162436
  }
162045
- function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) {
162046
- var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTarget, setNodeParents, scriptKind);
162437
+ function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTargetOrOptions, version, setNodeParents, scriptKind) {
162438
+ var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTargetOrOptions, setNodeParents, scriptKind);
162047
162439
  setSourceFileFields(sourceFile, scriptSnapshot, version);
162048
162440
  return sourceFile;
162049
162441
  }
@@ -162091,8 +162483,13 @@ var ts;
162091
162483
  return newSourceFile;
162092
162484
  }
162093
162485
  }
162486
+ var options = {
162487
+ languageVersion: sourceFile.languageVersion,
162488
+ impliedNodeFormat: sourceFile.impliedNodeFormat,
162489
+ setExternalModuleIndicator: sourceFile.setExternalModuleIndicator,
162490
+ };
162094
162491
  // Otherwise, just create a new source file.
162095
- return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind);
162492
+ return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, sourceFile.scriptKind);
162096
162493
  }
162097
162494
  ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile;
162098
162495
  var NoopCancellationToken = {
@@ -162436,7 +162833,7 @@ var ts;
162436
162833
  // file's script kind, i.e. in one project some file is treated as ".ts"
162437
162834
  // and in another as ".js"
162438
162835
  if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
162439
- return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
162836
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
162440
162837
  }
162441
162838
  else {
162442
162839
  // Release old source file and fall through to aquire new file with new script kind
@@ -162446,7 +162843,7 @@ var ts;
162446
162843
  // We didn't already have the file. Fall through and acquire it from the registry.
162447
162844
  }
162448
162845
  // Could not find this file in the old program, create a new SourceFile for it.
162449
- return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
162846
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
162450
162847
  }
162451
162848
  }
162452
162849
  // TODO: GH#18217 frequently asserted as defined
@@ -167993,6 +168390,10 @@ var ts;
167993
168390
  this.packageJsonsForAutoImport = new ts.Set(packageJsons.map(function (p) { return p.fileName; }));
167994
168391
  return packageJsons;
167995
168392
  };
168393
+ /* @internal */
168394
+ Project.prototype.getPackageJsonCache = function () {
168395
+ return this.projectService.packageJsonCache;
168396
+ };
167996
168397
  /*@internal*/
167997
168398
  Project.prototype.getCachedExportInfoMap = function () {
167998
168399
  return this.exportMapCache || (this.exportMapCache = ts.createCacheableExportInfoMap(this));
@@ -172431,15 +172832,23 @@ var ts;
172431
172832
  return ts.deduplicate(outputs, ts.equateValues);
172432
172833
  }
172433
172834
  ;
172835
+ function createDocumentSpanSet() {
172836
+ return ts.createSet(function (_a) {
172837
+ var textSpan = _a.textSpan;
172838
+ return textSpan.start + 100003 * textSpan.length;
172839
+ }, ts.documentSpansEqual);
172840
+ }
172434
172841
  function combineProjectOutputForRenameLocations(projects, defaultProject, initialLocation, findInStrings, findInComments, _a) {
172435
172842
  var providePrefixAndSuffixTextForRename = _a.providePrefixAndSuffixTextForRename;
172436
172843
  var outputs = [];
172844
+ var seen = createDocumentSpanSet();
172437
172845
  combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, tryAddToTodo) {
172438
172846
  var projectOutputs = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename);
172439
172847
  if (projectOutputs) {
172440
172848
  for (var _i = 0, projectOutputs_1 = projectOutputs; _i < projectOutputs_1.length; _i++) {
172441
172849
  var output = projectOutputs_1[_i];
172442
- if (!ts.contains(outputs, output, ts.documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(output))) {
172850
+ if (!seen.has(output) && !tryAddToTodo(project, documentSpanLocation(output))) {
172851
+ seen.add(output);
172443
172852
  outputs.push(output);
172444
172853
  }
172445
172854
  }
@@ -173823,6 +174232,7 @@ var ts;
173823
174232
  var projects = this.getProjects(args);
173824
174233
  var fileName = args.file;
173825
174234
  var references = [];
174235
+ var seen = createDocumentSpanSet();
173826
174236
  forEachProjectInProjects(projects, /*path*/ undefined, function (project) {
173827
174237
  if (project.getCancellationToken().isCancellationRequested())
173828
174238
  return;
@@ -173830,8 +174240,9 @@ var ts;
173830
174240
  if (projectOutputs) {
173831
174241
  for (var _i = 0, projectOutputs_3 = projectOutputs; _i < projectOutputs_3.length; _i++) {
173832
174242
  var referenceEntry = projectOutputs_3[_i];
173833
- if (!ts.contains(references, referenceEntry, ts.documentSpansEqual)) {
174243
+ if (!seen.has(referenceEntry)) {
173834
174244
  references.push(referenceEntry);
174245
+ seen.add(referenceEntry);
173835
174246
  }
173836
174247
  }
173837
174248
  }