typescript 4.7.0-dev.20220311 → 4.7.0-dev.20220314

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220311";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220314";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -1270,6 +1270,149 @@ var ts;
1270
1270
  return createMultiMap();
1271
1271
  }
1272
1272
  ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap;
1273
+ function createSet(getHashCode, equals) {
1274
+ var multiMap = new ts.Map();
1275
+ var size = 0;
1276
+ function getElementIterator() {
1277
+ var valueIt = multiMap.values();
1278
+ var arrayIt;
1279
+ return {
1280
+ next: function () {
1281
+ while (true) {
1282
+ if (arrayIt) {
1283
+ var n = arrayIt.next();
1284
+ if (!n.done) {
1285
+ return { value: n.value };
1286
+ }
1287
+ arrayIt = undefined;
1288
+ }
1289
+ else {
1290
+ var n = valueIt.next();
1291
+ if (n.done) {
1292
+ return { value: undefined, done: true };
1293
+ }
1294
+ if (!isArray(n.value)) {
1295
+ return { value: n.value };
1296
+ }
1297
+ arrayIt = arrayIterator(n.value);
1298
+ }
1299
+ }
1300
+ }
1301
+ };
1302
+ }
1303
+ var set = {
1304
+ has: function (element) {
1305
+ var hash = getHashCode(element);
1306
+ if (!multiMap.has(hash))
1307
+ return false;
1308
+ var candidates = multiMap.get(hash);
1309
+ if (!isArray(candidates))
1310
+ return equals(candidates, element);
1311
+ for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
1312
+ var candidate = candidates_1[_i];
1313
+ if (equals(candidate, element)) {
1314
+ return true;
1315
+ }
1316
+ }
1317
+ return false;
1318
+ },
1319
+ add: function (element) {
1320
+ var hash = getHashCode(element);
1321
+ if (multiMap.has(hash)) {
1322
+ var values = multiMap.get(hash);
1323
+ if (isArray(values)) {
1324
+ if (!contains(values, element, equals)) {
1325
+ values.push(element);
1326
+ size++;
1327
+ }
1328
+ }
1329
+ else {
1330
+ var value = values;
1331
+ if (!equals(value, element)) {
1332
+ multiMap.set(hash, [value, element]);
1333
+ size++;
1334
+ }
1335
+ }
1336
+ }
1337
+ else {
1338
+ multiMap.set(hash, element);
1339
+ size++;
1340
+ }
1341
+ return this;
1342
+ },
1343
+ delete: function (element) {
1344
+ var hash = getHashCode(element);
1345
+ if (!multiMap.has(hash))
1346
+ return false;
1347
+ var candidates = multiMap.get(hash);
1348
+ if (isArray(candidates)) {
1349
+ for (var i = 0; i < candidates.length; i++) {
1350
+ if (equals(candidates[i], element)) {
1351
+ if (candidates.length === 1) {
1352
+ multiMap.delete(hash);
1353
+ }
1354
+ else if (candidates.length === 2) {
1355
+ multiMap.set(hash, candidates[1 - i]);
1356
+ }
1357
+ else {
1358
+ unorderedRemoveItemAt(candidates, i);
1359
+ }
1360
+ size--;
1361
+ return true;
1362
+ }
1363
+ }
1364
+ }
1365
+ else {
1366
+ var candidate = candidates;
1367
+ if (equals(candidate, element)) {
1368
+ multiMap.delete(hash);
1369
+ size--;
1370
+ return true;
1371
+ }
1372
+ }
1373
+ return false;
1374
+ },
1375
+ clear: function () {
1376
+ multiMap.clear();
1377
+ size = 0;
1378
+ },
1379
+ get size() {
1380
+ return size;
1381
+ },
1382
+ forEach: function (action) {
1383
+ for (var _i = 0, _a = arrayFrom(multiMap.values()); _i < _a.length; _i++) {
1384
+ var elements = _a[_i];
1385
+ if (isArray(elements)) {
1386
+ for (var _b = 0, elements_1 = elements; _b < elements_1.length; _b++) {
1387
+ var element = elements_1[_b];
1388
+ action(element, element);
1389
+ }
1390
+ }
1391
+ else {
1392
+ var element = elements;
1393
+ action(element, element);
1394
+ }
1395
+ }
1396
+ },
1397
+ keys: function () {
1398
+ return getElementIterator();
1399
+ },
1400
+ values: function () {
1401
+ return getElementIterator();
1402
+ },
1403
+ entries: function () {
1404
+ var it = getElementIterator();
1405
+ return {
1406
+ next: function () {
1407
+ var n = it.next();
1408
+ return n.done ? n : { value: [n.value, n.value] };
1409
+ }
1410
+ };
1411
+ },
1412
+ };
1413
+ return set;
1414
+ }
1415
+ ts.createSet = createSet;
1273
1416
  function isArray(value) {
1274
1417
  return Array.isArray ? Array.isArray(value) : value instanceof Array;
1275
1418
  }
@@ -1524,8 +1667,8 @@ var ts;
1524
1667
  var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
1525
1668
  var bestDistance = Math.floor(name.length * 0.4) + 1;
1526
1669
  var bestCandidate;
1527
- for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
1528
- var candidate = candidates_1[_i];
1670
+ for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
1671
+ var candidate = candidates_2[_i];
1529
1672
  var candidateName = getName(candidate);
1530
1673
  if (candidateName !== undefined && Math.abs(candidateName.length - name.length) <= maximumLengthDifference) {
1531
1674
  if (candidateName === name) {
@@ -1733,13 +1876,15 @@ var ts;
1733
1876
  for (var _i = 0; _i < arguments.length; _i++) {
1734
1877
  args[_i] = arguments[_i];
1735
1878
  }
1879
+ var lastResult;
1736
1880
  for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
1737
1881
  var f = fs_1[_a];
1738
- if (f.apply(void 0, args)) {
1739
- return true;
1882
+ lastResult = f.apply(void 0, args);
1883
+ if (lastResult) {
1884
+ return lastResult;
1740
1885
  }
1741
1886
  }
1742
- return false;
1887
+ return lastResult;
1743
1888
  };
1744
1889
  }
1745
1890
  ts.or = or;
@@ -3263,6 +3408,12 @@ var ts;
3263
3408
  ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12";
3264
3409
  ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext";
3265
3410
  })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
3411
+ var ModuleDetectionKind;
3412
+ (function (ModuleDetectionKind) {
3413
+ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy";
3414
+ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto";
3415
+ ModuleDetectionKind[ModuleDetectionKind["Force"] = 3] = "Force";
3416
+ })(ModuleDetectionKind = ts.ModuleDetectionKind || (ts.ModuleDetectionKind = {}));
3266
3417
  var WatchFileKind;
3267
3418
  (function (WatchFileKind) {
3268
3419
  WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
@@ -5428,6 +5579,8 @@ var ts;
5428
5579
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
5429
5580
  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."),
5430
5581
  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."),
5582
+ 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."),
5583
+ 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."),
5431
5584
  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."),
5432
5585
  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."),
5433
5586
  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.", undefined, true),
@@ -15604,6 +15757,42 @@ var ts;
15604
15757
  return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 || scriptKind === 6 ? 1 : 0;
15605
15758
  }
15606
15759
  ts.getLanguageVariant = getLanguageVariant;
15760
+ function walkTreeForJSXTags(node) {
15761
+ if (!(node.transformFlags & 2))
15762
+ return undefined;
15763
+ return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags);
15764
+ }
15765
+ function isFileModuleFromUsingJSXTag(file) {
15766
+ return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined;
15767
+ }
15768
+ function isFileForcedToBeModuleByFormat(file) {
15769
+ return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
15770
+ }
15771
+ function getSetExternalModuleIndicator(options) {
15772
+ switch (getEmitModuleDetectionKind(options)) {
15773
+ case ts.ModuleDetectionKind.Force:
15774
+ return function (file) {
15775
+ file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
15776
+ };
15777
+ case ts.ModuleDetectionKind.Legacy:
15778
+ return function (file) {
15779
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file);
15780
+ };
15781
+ case ts.ModuleDetectionKind.Auto:
15782
+ var checks = [ts.isFileProbablyExternalModule];
15783
+ if (options.jsx === 4 || options.jsx === 5) {
15784
+ checks.push(isFileModuleFromUsingJSXTag);
15785
+ }
15786
+ var moduleKind = getEmitModuleKind(options);
15787
+ if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
15788
+ checks.push(isFileForcedToBeModuleByFormat);
15789
+ }
15790
+ var combined_1 = ts.or.apply(void 0, checks);
15791
+ var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
15792
+ return callback;
15793
+ }
15794
+ }
15795
+ ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator;
15607
15796
  function getEmitScriptTarget(compilerOptions) {
15608
15797
  return compilerOptions.target ||
15609
15798
  (compilerOptions.module === ts.ModuleKind.Node12 && 7) ||
@@ -15638,6 +15827,10 @@ var ts;
15638
15827
  return moduleResolution;
15639
15828
  }
15640
15829
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
15830
+ function getEmitModuleDetectionKind(options) {
15831
+ return options.moduleDetection || ts.ModuleDetectionKind.Auto;
15832
+ }
15833
+ ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
15641
15834
  function hasJsonModuleEmitEnabled(options) {
15642
15835
  switch (getEmitModuleKind(options)) {
15643
15836
  case ts.ModuleKind.CommonJS:
@@ -24073,6 +24266,32 @@ var ts;
24073
24266
  text.charCodeAt(start + 3) !== 47;
24074
24267
  }
24075
24268
  ts.isJSDocLikeText = isJSDocLikeText;
24269
+ function isFileProbablyExternalModule(sourceFile) {
24270
+ return ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
24271
+ getImportMetaIfNecessary(sourceFile);
24272
+ }
24273
+ ts.isFileProbablyExternalModule = isFileProbablyExternalModule;
24274
+ function isAnExternalModuleIndicatorNode(node) {
24275
+ return hasModifierOfKind(node, 93)
24276
+ || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
24277
+ || ts.isImportDeclaration(node)
24278
+ || ts.isExportAssignment(node)
24279
+ || ts.isExportDeclaration(node) ? node : undefined;
24280
+ }
24281
+ function getImportMetaIfNecessary(sourceFile) {
24282
+ return sourceFile.flags & 2097152 ?
24283
+ walkTreeForImportMeta(sourceFile) :
24284
+ undefined;
24285
+ }
24286
+ function walkTreeForImportMeta(node) {
24287
+ return isImportMeta(node) ? node : forEachChild(node, walkTreeForImportMeta);
24288
+ }
24289
+ function hasModifierOfKind(node, kind) {
24290
+ return ts.some(node.modifiers, function (m) { return m.kind === kind; });
24291
+ }
24292
+ function isImportMeta(node) {
24293
+ return ts.isMetaProperty(node) && node.keywordToken === 100 && node.name.escapedText === "meta";
24294
+ }
24076
24295
  function forEachChild(node, cbNode, cbNodes) {
24077
24296
  if (!node || node.kind <= 159) {
24078
24297
  return;
@@ -24626,17 +24845,25 @@ var ts;
24626
24845
  children.unshift(n);
24627
24846
  }
24628
24847
  }
24629
- function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
24848
+ function setExternalModuleIndicator(sourceFile) {
24849
+ sourceFile.externalModuleIndicator = isFileProbablyExternalModule(sourceFile);
24850
+ }
24851
+ function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) {
24630
24852
  if (setParentNodes === void 0) { setParentNodes = false; }
24631
24853
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse", "createSourceFile", { path: fileName }, true);
24632
24854
  ts.performance.mark("beforeParse");
24633
24855
  var result;
24634
24856
  ts.perfLogger.logStartParseSourceFile(fileName);
24857
+ var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat;
24635
24858
  if (languageVersion === 100) {
24636
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6);
24859
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6, ts.noop);
24637
24860
  }
24638
24861
  else {
24639
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind);
24862
+ var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) {
24863
+ file.impliedNodeFormat = format;
24864
+ return (overrideSetExternalModuleIndicator || setExternalModuleIndicator)(file);
24865
+ };
24866
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind, setIndicator);
24640
24867
  }
24641
24868
  ts.perfLogger.logStopParseSourceFile();
24642
24869
  ts.performance.mark("afterParse");
@@ -24716,7 +24943,7 @@ var ts;
24716
24943
  var contextFlags;
24717
24944
  var topLevel = true;
24718
24945
  var parseErrorBeforeNextFinishedNode = false;
24719
- function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
24946
+ function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind, setExternalModuleIndicatorOverride) {
24720
24947
  var _a;
24721
24948
  if (setParentNodes === void 0) { setParentNodes = false; }
24722
24949
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
@@ -24732,7 +24959,7 @@ var ts;
24732
24959
  return result_3;
24733
24960
  }
24734
24961
  initializeState(fileName, sourceText, languageVersion, syntaxCursor, scriptKind);
24735
- var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind);
24962
+ var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicatorOverride || setExternalModuleIndicator);
24736
24963
  clearState();
24737
24964
  return result;
24738
24965
  }
@@ -24808,7 +25035,7 @@ var ts;
24808
25035
  statements = createNodeArray([statement], pos);
24809
25036
  endOfFileToken = parseExpectedToken(1, ts.Diagnostics.Unexpected_token);
24810
25037
  }
24811
- var sourceFile = createSourceFile(fileName, 2, 6, false, statements, endOfFileToken, sourceFlags);
25038
+ var sourceFile = createSourceFile(fileName, 2, 6, false, statements, endOfFileToken, sourceFlags, ts.noop);
24812
25039
  if (setParentNodes) {
24813
25040
  fixupParentReferences(sourceFile);
24814
25041
  }
@@ -24879,7 +25106,7 @@ var ts;
24879
25106
  notParenthesizedArrow = undefined;
24880
25107
  topLevel = true;
24881
25108
  }
24882
- function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
25109
+ function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
24883
25110
  var isDeclarationFile = isDeclarationFileName(fileName);
24884
25111
  if (isDeclarationFile) {
24885
25112
  contextFlags |= 8388608;
@@ -24889,7 +25116,7 @@ var ts;
24889
25116
  var statements = parseList(0, parseStatement);
24890
25117
  ts.Debug.assert(token() === 1);
24891
25118
  var endOfFileToken = addJSDocComment(parseTokenNode());
24892
- var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags);
25119
+ var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
24893
25120
  processCommentPragmas(sourceFile, sourceText);
24894
25121
  processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
24895
25122
  sourceFile.commentDirectives = scanner.getCommentDirectives();
@@ -25013,22 +25240,27 @@ var ts;
25013
25240
  ts.setParentRecursive(rootNode, true);
25014
25241
  }
25015
25242
  Parser.fixupParentReferences = fixupParentReferences;
25016
- function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags) {
25243
+ function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags, setExternalModuleIndicator) {
25017
25244
  var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
25018
25245
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
25019
- setExternalModuleIndicator(sourceFile);
25246
+ setFields(sourceFile);
25020
25247
  if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216) {
25021
25248
  sourceFile = reparseTopLevelAwait(sourceFile);
25249
+ setFields(sourceFile);
25022
25250
  }
25023
- sourceFile.text = sourceText;
25024
- sourceFile.bindDiagnostics = [];
25025
- sourceFile.bindSuggestionDiagnostics = undefined;
25026
- sourceFile.languageVersion = languageVersion;
25027
- sourceFile.fileName = fileName;
25028
- sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
25029
- sourceFile.isDeclarationFile = isDeclarationFile;
25030
- sourceFile.scriptKind = scriptKind;
25031
25251
  return sourceFile;
25252
+ function setFields(sourceFile) {
25253
+ sourceFile.text = sourceText;
25254
+ sourceFile.bindDiagnostics = [];
25255
+ sourceFile.bindSuggestionDiagnostics = undefined;
25256
+ sourceFile.languageVersion = languageVersion;
25257
+ sourceFile.fileName = fileName;
25258
+ sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
25259
+ sourceFile.isDeclarationFile = isDeclarationFile;
25260
+ sourceFile.scriptKind = scriptKind;
25261
+ setExternalModuleIndicator(sourceFile);
25262
+ sourceFile.setExternalModuleIndicator = setExternalModuleIndicator;
25263
+ }
25032
25264
  }
25033
25265
  function setContextFlag(val, flag) {
25034
25266
  if (val) {
@@ -29473,32 +29705,6 @@ var ts;
29473
29705
  var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
29474
29706
  return withJSDoc(finishNode(node, pos), hasJSDoc);
29475
29707
  }
29476
- function setExternalModuleIndicator(sourceFile) {
29477
- sourceFile.externalModuleIndicator =
29478
- ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
29479
- getImportMetaIfNecessary(sourceFile);
29480
- }
29481
- function isAnExternalModuleIndicatorNode(node) {
29482
- return hasModifierOfKind(node, 93)
29483
- || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
29484
- || ts.isImportDeclaration(node)
29485
- || ts.isExportAssignment(node)
29486
- || ts.isExportDeclaration(node) ? node : undefined;
29487
- }
29488
- function getImportMetaIfNecessary(sourceFile) {
29489
- return sourceFile.flags & 2097152 ?
29490
- walkTreeForExternalModuleIndicators(sourceFile) :
29491
- undefined;
29492
- }
29493
- function walkTreeForExternalModuleIndicators(node) {
29494
- return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
29495
- }
29496
- function hasModifierOfKind(node, kind) {
29497
- return ts.some(node.modifiers, function (m) { return m.kind === kind; });
29498
- }
29499
- function isImportMeta(node) {
29500
- return ts.isMetaProperty(node) && node.keywordToken === 100 && node.name.escapedText === "meta";
29501
- }
29502
29708
  var JSDocParser;
29503
29709
  (function (JSDocParser) {
29504
29710
  function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -29506,7 +29712,7 @@ var ts;
29506
29712
  scanner.setText(content, start, length);
29507
29713
  currentToken = scanner.scan();
29508
29714
  var jsDocTypeExpression = parseJSDocTypeExpression();
29509
- var sourceFile = createSourceFile("file.js", 99, 1, false, [], factory.createToken(1), 0);
29715
+ var sourceFile = createSourceFile("file.js", 99, 1, false, [], factory.createToken(1), 0, ts.noop);
29510
29716
  var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
29511
29717
  if (jsDocDiagnostics) {
29512
29718
  sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
@@ -30402,7 +30608,7 @@ var ts;
30402
30608
  return sourceFile;
30403
30609
  }
30404
30610
  if (sourceFile.statements.length === 0) {
30405
- return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind);
30611
+ return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
30406
30612
  }
30407
30613
  var incrementalSourceFile = sourceFile;
30408
30614
  ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed);
@@ -30417,7 +30623,7 @@ var ts;
30417
30623
  ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)));
30418
30624
  var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
30419
30625
  updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks);
30420
- var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind);
30626
+ var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
30421
30627
  result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
30422
30628
  result.impliedNodeFormat = sourceFile.impliedNodeFormat;
30423
30629
  return result;
@@ -32129,6 +32335,18 @@ var ts;
32129
32335
  description: ts.Diagnostics.Specify_a_list_of_language_service_plugins_to_include,
32130
32336
  category: ts.Diagnostics.Editor_Support,
32131
32337
  },
32338
+ {
32339
+ name: "moduleDetection",
32340
+ type: new ts.Map(ts.getEntries({
32341
+ auto: ts.ModuleDetectionKind.Auto,
32342
+ legacy: ts.ModuleDetectionKind.Legacy,
32343
+ force: ts.ModuleDetectionKind.Force,
32344
+ })),
32345
+ affectsModuleResolution: true,
32346
+ description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files,
32347
+ category: ts.Diagnostics.Language_and_Environment,
32348
+ 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,
32349
+ }
32132
32350
  ];
32133
32351
  ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild, true), commandOptionsWithoutBuild, true);
32134
32352
  ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; });
@@ -52874,7 +53092,7 @@ var ts;
52874
53092
  return true;
52875
53093
  }
52876
53094
  }
52877
- else {
53095
+ else if (!((source.flags | target.flags) & (3145728 | 8388608 | 16777216 | 33554432))) {
52878
53096
  if (source.flags !== target.flags)
52879
53097
  return false;
52880
53098
  if (source.flags & 67358815)
@@ -58120,7 +58338,7 @@ var ts;
58120
58338
  return result;
58121
58339
  }
58122
58340
  function getCandidateDiscriminantPropertyAccess(expr) {
58123
- if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
58341
+ if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference) || ts.isObjectLiteralMethod(reference)) {
58124
58342
  if (ts.isIdentifier(expr)) {
58125
58343
  var symbol = getResolvedSymbol(expr);
58126
58344
  var declaration = symbol.valueDeclaration;
@@ -64044,6 +64262,9 @@ var ts;
64044
64262
  assignBindingElementTypes(declaration.name, links.type);
64045
64263
  }
64046
64264
  }
64265
+ else if (type) {
64266
+ ts.Debug.assertEqual(links.type, type, "Parameter symbol already has a cached type which differs from newly assigned type");
64267
+ }
64047
64268
  }
64048
64269
  function assignBindingElementTypes(pattern, parentType) {
64049
64270
  for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
@@ -73530,8 +73751,8 @@ var ts;
73530
73751
  }
73531
73752
  else {
73532
73753
  var elements = name.elements;
73533
- for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
73534
- var element = elements_1[_i];
73754
+ for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
73755
+ var element = elements_2[_i];
73535
73756
  if (!ts.isOmittedExpression(element)) {
73536
73757
  return checkESModuleMarker(element.name);
73537
73758
  }
@@ -73547,8 +73768,8 @@ var ts;
73547
73768
  }
73548
73769
  else {
73549
73770
  var elements = name.elements;
73550
- for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
73551
- var element = elements_2[_i];
73771
+ for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
73772
+ var element = elements_3[_i];
73552
73773
  if (!ts.isOmittedExpression(element)) {
73553
73774
  checkGrammarNameInLetOrConstDeclarations(element.name);
73554
73775
  }
@@ -75566,8 +75787,8 @@ var ts;
75566
75787
  }
75567
75788
  function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
75568
75789
  var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
75569
- for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
75570
- var element = elements_3[_i];
75790
+ for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
75791
+ var element = elements_4[_i];
75571
75792
  if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
75572
75793
  return true;
75573
75794
  }
@@ -79608,8 +79829,8 @@ var ts;
79608
79829
  function chunkObjectLiteralElements(elements) {
79609
79830
  var chunkObject;
79610
79831
  var objects = [];
79611
- for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
79612
- var e = elements_4[_i];
79832
+ for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) {
79833
+ var e = elements_5[_i];
79613
79834
  if (e.kind === 297) {
79614
79835
  if (chunkObject) {
79615
79836
  objects.push(factory.createObjectLiteralExpression(chunkObject));
@@ -94284,7 +94505,7 @@ var ts;
94284
94505
  var existingDirectories = new ts.Map();
94285
94506
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
94286
94507
  var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
94287
- function getSourceFile(fileName, languageVersion, onError) {
94508
+ function getSourceFile(fileName, languageVersionOrOptions, onError) {
94288
94509
  var text;
94289
94510
  try {
94290
94511
  ts.performance.mark("beforeIORead");
@@ -94298,7 +94519,7 @@ var ts;
94298
94519
  }
94299
94520
  text = "";
94300
94521
  }
94301
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
94522
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions, setParentNodes) : undefined;
94302
94523
  }
94303
94524
  function directoryExists(directoryPath) {
94304
94525
  if (existingDirectories.has(directoryPath)) {
@@ -95519,8 +95740,8 @@ var ts;
95519
95740
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
95520
95741
  var oldSourceFile = oldSourceFiles_2[_i];
95521
95742
  var newSourceFile = host.getSourceFileByPath
95522
- ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), undefined, shouldCreateNewSourceFile)
95523
- : host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), undefined, shouldCreateNewSourceFile);
95743
+ ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), undefined, shouldCreateNewSourceFile)
95744
+ : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), undefined, shouldCreateNewSourceFile);
95524
95745
  if (!newSourceFile) {
95525
95746
  return 0;
95526
95747
  }
@@ -95546,7 +95767,6 @@ var ts;
95546
95767
  newSourceFile.originalFileName = oldSourceFile.originalFileName;
95547
95768
  newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
95548
95769
  newSourceFile.fileName = oldSourceFile.fileName;
95549
- newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
95550
95770
  var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
95551
95771
  if (packageName !== undefined) {
95552
95772
  var prevKind = seenPackageNames.get(packageName);
@@ -96353,6 +96573,14 @@ var ts;
96353
96573
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
96354
96574
  return result;
96355
96575
  }
96576
+ function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
96577
+ var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
96578
+ return {
96579
+ languageVersion: ts.getEmitScriptTarget(options),
96580
+ impliedNodeFormat: impliedNodeFormat,
96581
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
96582
+ };
96583
+ }
96356
96584
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
96357
96585
  var path = toPath(fileName);
96358
96586
  if (useSourceOfProjectReferenceRedirect) {
@@ -96423,7 +96651,7 @@ var ts;
96423
96651
  redirectedPath = toPath(redirect);
96424
96652
  }
96425
96653
  }
96426
- var file = host.getSourceFile(fileName, ts.getEmitScriptTarget(options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
96654
+ var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
96427
96655
  if (packageId) {
96428
96656
  var packageIdKey = ts.packageIdToString(packageId);
96429
96657
  var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
@@ -96448,7 +96676,6 @@ var ts;
96448
96676
  file.path = path;
96449
96677
  file.resolvedPath = toPath(fileName);
96450
96678
  file.originalFileName = originalFileName;
96451
- file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
96452
96679
  addFileIncludeReason(file, reason);
96453
96680
  if (host.useCaseSensitiveFileNames()) {
96454
96681
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -96909,7 +97136,7 @@ var ts;
96909
97136
  }
96910
97137
  }
96911
97138
  else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
96912
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
97139
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
96913
97140
  programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
96914
97141
  }
96915
97142
  if (outputFile && !options.emitDeclarationOnly) {
@@ -96917,7 +97144,7 @@ var ts;
96917
97144
  createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
96918
97145
  }
96919
97146
  else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
96920
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
97147
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
96921
97148
  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"));
96922
97149
  }
96923
97150
  }
@@ -100581,7 +100808,7 @@ var ts;
100581
100808
  var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
100582
100809
  var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
100583
100810
  return {
100584
- getSourceFile: function (fileName, languageVersion, onError) {
100811
+ getSourceFile: function (fileName, languageVersionOrOptions, onError) {
100585
100812
  var text;
100586
100813
  try {
100587
100814
  ts.performance.mark("beforeIORead");
@@ -100595,7 +100822,7 @@ var ts;
100595
100822
  }
100596
100823
  text = "";
100597
100824
  }
100598
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
100825
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions) : undefined;
100599
100826
  },
100600
100827
  getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
100601
100828
  getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
@@ -101026,13 +101253,13 @@ var ts;
101026
101253
  }
101027
101254
  return directoryStructureHost.fileExists(fileName);
101028
101255
  }
101029
- function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
101256
+ function getVersionedSourceFileByPath(fileName, path, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
101030
101257
  var hostSourceFile = sourceFilesCache.get(path);
101031
101258
  if (isFileMissingOnHost(hostSourceFile)) {
101032
101259
  return undefined;
101033
101260
  }
101034
101261
  if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
101035
- var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
101262
+ var sourceFile = getNewSourceFile(fileName, languageVersionOrOptions, onError);
101036
101263
  if (hostSourceFile) {
101037
101264
  if (sourceFile) {
101038
101265
  hostSourceFile.sourceFile = sourceFile;