@typescript-deploys/pr-build 4.6.0-pr-47590-5 → 4.7.0-pr-47904-2

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
@@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
68
68
  };
69
69
  var ts;
70
70
  (function (ts) {
71
- ts.versionMajorMinor = "4.6";
72
- ts.version = ts.versionMajorMinor + ".0-insiders.20220211";
71
+ ts.versionMajorMinor = "4.7";
72
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220215";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -3306,7 +3306,8 @@ var ts;
3306
3306
  { name: "types", optional: true, captureSpan: true },
3307
3307
  { name: "lib", optional: true, captureSpan: true },
3308
3308
  { name: "path", optional: true, captureSpan: true },
3309
- { name: "no-default-lib", optional: true }
3309
+ { name: "no-default-lib", optional: true },
3310
+ { name: "resolution-mode", optional: true }
3310
3311
  ],
3311
3312
  kind: 1
3312
3313
  },
@@ -4885,18 +4886,6 @@ var ts;
4885
4886
  return getCanonicalFileName(nonCanonicalizedPath);
4886
4887
  }
4887
4888
  ts.toPath = toPath;
4888
- function normalizePathAndParts(path) {
4889
- path = normalizeSlashes(path);
4890
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
4891
- if (parts.length) {
4892
- var joinedParts = root + parts.join(ts.directorySeparator);
4893
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
4894
- }
4895
- else {
4896
- return { path: root, parts: parts };
4897
- }
4898
- }
4899
- ts.normalizePathAndParts = normalizePathAndParts;
4900
4889
  function removeTrailingDirectorySeparator(path) {
4901
4890
  if (hasTrailingDirectorySeparator(path)) {
4902
4891
  return path.substr(0, path.length - 1);
@@ -5295,6 +5284,8 @@ var ts;
5295
5284
  Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
5296
5285
  An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
5297
5286
  Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
5287
+ Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
5288
+ Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
5298
5289
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
5299
5290
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
5300
5291
  Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
@@ -5428,6 +5419,8 @@ var ts;
5428
5419
  Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
5429
5420
  Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
5430
5421
  Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
5422
+ Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."),
5423
+ resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
5431
5424
  The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
5432
5425
  Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
5433
5426
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
@@ -8747,8 +8740,6 @@ var ts;
8747
8740
  case 39:
8748
8741
  tokenValue = scanString(true);
8749
8742
  return token = 10;
8750
- case 96:
8751
- return token = scanTemplateAndSetTokenValue(false);
8752
8743
  default:
8753
8744
  return scan();
8754
8745
  }
@@ -10398,10 +10389,6 @@ var ts;
10398
10389
  || kind === 287;
10399
10390
  }
10400
10391
  ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
10401
- function isStringLiteralOrTemplateExpressionOrJsxExpression(node) {
10402
- return node.kind === 222 || isStringLiteralOrJsxExpression(node);
10403
- }
10404
- ts.isStringLiteralOrTemplateExpressionOrJsxExpression = isStringLiteralOrTemplateExpressionOrJsxExpression;
10405
10392
  function isJsxOpeningLikeElement(node) {
10406
10393
  var kind = node.kind;
10407
10394
  return kind === 279
@@ -10714,7 +10701,10 @@ var ts;
10714
10701
  ts.Debug.assert(names.length === newResolutions.length);
10715
10702
  for (var i = 0; i < names.length; i++) {
10716
10703
  var newResolution = newResolutions[i];
10717
- var oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i));
10704
+ var entry = names[i];
10705
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
10706
+ var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
10707
+ var oldResolution = oldResolutions && oldResolutions.get(name, mode);
10718
10708
  var changed = oldResolution
10719
10709
  ? !newResolution || !comparer(oldResolution, newResolution)
10720
10710
  : newResolution;
@@ -21485,7 +21475,13 @@ var ts;
21485
21475
  referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
21486
21476
  break;
21487
21477
  case "type":
21488
- typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
21478
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
21479
+ break;
21480
+ case "type-import":
21481
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
21482
+ break;
21483
+ case "type-require":
21484
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
21489
21485
  break;
21490
21486
  case "lib":
21491
21487
  libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
@@ -21543,6 +21539,8 @@ var ts;
21543
21539
  case "no-default-lib":
21544
21540
  case "reference":
21545
21541
  case "type":
21542
+ case "type-import":
21543
+ case "type-require":
21546
21544
  case "lib":
21547
21545
  syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
21548
21546
  break;
@@ -27636,26 +27634,15 @@ var ts;
27636
27634
  }
27637
27635
  return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos);
27638
27636
  }
27639
- function parseJsxAttributeValue() {
27640
- if (token() !== 63) {
27641
- return undefined;
27642
- }
27643
- var jsxAttributeValueToken = scanJsxAttributeValue();
27644
- if (jsxAttributeValueToken === 10 || jsxAttributeValueToken === 14) {
27645
- return parseLiteralNode();
27646
- }
27647
- if (jsxAttributeValueToken === 15) {
27648
- return parseTemplateExpression(false);
27649
- }
27650
- return parseJsxExpression(true);
27651
- }
27652
27637
  function parseJsxAttribute() {
27653
27638
  if (token() === 18) {
27654
27639
  return parseJsxSpreadAttribute();
27655
27640
  }
27656
27641
  scanJsxIdentifier();
27657
27642
  var pos = getNodePos();
27658
- return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos);
27643
+ return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 ? undefined :
27644
+ scanJsxAttributeValue() === 10 ? parseLiteralNode() :
27645
+ parseJsxExpression(true)), pos);
27659
27646
  }
27660
27647
  function parseJsxSpreadAttribute() {
27661
27648
  var pos = getNodePos();
@@ -28230,11 +28217,12 @@ var ts;
28230
28217
  }
28231
28218
  function parseCaseClause() {
28232
28219
  var pos = getNodePos();
28220
+ var hasJSDoc = hasPrecedingJSDocComment();
28233
28221
  parseExpected(82);
28234
28222
  var expression = allowInAnd(parseExpression);
28235
28223
  parseExpected(58);
28236
28224
  var statements = parseList(3, parseStatement);
28237
- return finishNode(factory.createCaseClause(expression, statements), pos);
28225
+ return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
28238
28226
  }
28239
28227
  function parseDefaultClause() {
28240
28228
  var pos = getNodePos();
@@ -30654,6 +30642,19 @@ var ts;
30654
30642
  return ts.fileExtensionIsOneOf(fileName, [".d.ts", ".d.mts", ".d.cts"]);
30655
30643
  }
30656
30644
  ts.isDeclarationFileName = isDeclarationFileName;
30645
+ function parseResolutionMode(mode, pos, end, reportDiagnostic) {
30646
+ if (!mode) {
30647
+ return undefined;
30648
+ }
30649
+ if (mode === "import") {
30650
+ return ts.ModuleKind.ESNext;
30651
+ }
30652
+ if (mode === "require") {
30653
+ return ts.ModuleKind.CommonJS;
30654
+ }
30655
+ reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
30656
+ return undefined;
30657
+ }
30657
30658
  function processCommentPragmas(context, sourceText) {
30658
30659
  var pragmas = [];
30659
30660
  for (var _i = 0, _a = ts.getLeadingCommentRanges(sourceText, 0) || ts.emptyArray; _i < _a.length; _i++) {
@@ -30692,12 +30693,13 @@ var ts;
30692
30693
  var typeReferenceDirectives_1 = context.typeReferenceDirectives;
30693
30694
  var libReferenceDirectives_1 = context.libReferenceDirectives;
30694
30695
  ts.forEach(ts.toArray(entryOrList), function (arg) {
30695
- var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
30696
+ var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
30696
30697
  if (arg.arguments["no-default-lib"]) {
30697
30698
  context.hasNoDefaultLib = true;
30698
30699
  }
30699
30700
  else if (types) {
30700
- typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
30701
+ var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
30702
+ typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
30701
30703
  }
30702
30704
  else if (lib) {
30703
30705
  libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
@@ -33940,14 +33942,14 @@ var ts;
33940
33942
  var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames;
33941
33943
  return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0;
33942
33944
  }
33943
- function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
33945
+ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
33944
33946
  var traceEnabled = isTraceEnabled(options, host);
33945
33947
  if (redirectedReference) {
33946
33948
  options = redirectedReference.commandLine.options;
33947
33949
  }
33948
33950
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
33949
33951
  var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
33950
- var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, undefined);
33952
+ var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, resolutionMode);
33951
33953
  if (result) {
33952
33954
  if (traceEnabled) {
33953
33955
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -33982,7 +33984,11 @@ var ts;
33982
33984
  }
33983
33985
  var failedLookupLocations = [];
33984
33986
  var features = getDefaultNodeResolutionFeatures(options);
33985
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
33987
+ if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
33988
+ features |= NodeResolutionFeatures.EsmMode;
33989
+ }
33990
+ var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
33991
+ var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
33986
33992
  var resolved = primaryLookup();
33987
33993
  var primary = true;
33988
33994
  if (!resolved) {
@@ -34002,7 +34008,7 @@ var ts;
34002
34008
  };
34003
34009
  }
34004
34010
  result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
34005
- perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, undefined, result);
34011
+ perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
34006
34012
  if (traceEnabled)
34007
34013
  traceResult(result);
34008
34014
  return result;
@@ -34051,7 +34057,7 @@ var ts;
34051
34057
  result_4 = searchResult && searchResult.value;
34052
34058
  }
34053
34059
  else {
34054
- var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
34060
+ var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
34055
34061
  result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true);
34056
34062
  }
34057
34063
  return resolvedTypeScriptOnly(result_4);
@@ -34261,7 +34267,10 @@ var ts;
34261
34267
  ts.Debug.assert(keys.length === values.length);
34262
34268
  var map = createModeAwareCache();
34263
34269
  for (var i = 0; i < keys.length; ++i) {
34264
- map.set(keys[i], ts.getModeForResolutionAtIndex(file, i), values[i]);
34270
+ var entry = keys[i];
34271
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
34272
+ var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
34273
+ map.set(name, mode, values[i]);
34265
34274
  }
34266
34275
  return map;
34267
34276
  }
@@ -34627,12 +34636,19 @@ var ts;
34627
34636
  return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
34628
34637
  }
34629
34638
  else {
34630
- var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
34639
+ var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
34631
34640
  var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, false, state, true);
34632
34641
  return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
34633
34642
  }
34634
34643
  }
34635
34644
  }
34645
+ function normalizePathForCJSResolution(containingDirectory, moduleName) {
34646
+ var combined = ts.combinePaths(containingDirectory, moduleName);
34647
+ var parts = ts.getPathComponents(combined);
34648
+ var lastPart = ts.lastOrUndefined(parts);
34649
+ var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
34650
+ return { path: path, parts: parts };
34651
+ }
34636
34652
  function realPath(path, host, traceEnabled) {
34637
34653
  if (!host.realpath) {
34638
34654
  return path;
@@ -34674,7 +34690,10 @@ var ts;
34674
34690
  onlyRecordFailures = true;
34675
34691
  }
34676
34692
  }
34677
- return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
34693
+ if (!(state.features & NodeResolutionFeatures.EsmMode)) {
34694
+ return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
34695
+ }
34696
+ return undefined;
34678
34697
  }
34679
34698
  ts.nodeModulesPathPart = "/node_modules/";
34680
34699
  function pathContainsNodeModules(path) {
@@ -35002,7 +35021,13 @@ var ts;
35002
35021
  }
35003
35022
  }
35004
35023
  var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
35005
- return nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
35024
+ var features = state.features;
35025
+ if ((jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.type) !== "module") {
35026
+ state.features &= ~NodeResolutionFeatures.EsmMode;
35027
+ }
35028
+ var result = nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
35029
+ state.features = features;
35030
+ return result;
35006
35031
  };
35007
35032
  var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
35008
35033
  var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
@@ -35331,6 +35356,12 @@ var ts;
35331
35356
  }
35332
35357
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
35333
35358
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
35359
+ if (!pathAndExtension && packageInfo
35360
+ && packageInfo.packageJsonContent.exports === undefined
35361
+ && packageInfo.packageJsonContent.main === undefined
35362
+ && state.features & NodeResolutionFeatures.EsmMode) {
35363
+ pathAndExtension = loadModuleFromFile(extensions, ts.combinePaths(candidate, "index.js"), onlyRecordFailures, state);
35364
+ }
35334
35365
  return withPackageId(packageInfo, pathAndExtension);
35335
35366
  };
35336
35367
  if (rest !== "") {
@@ -37698,12 +37729,14 @@ var ts;
37698
37729
  }
37699
37730
  }
37700
37731
  function setCommonJsModuleIndicator(node) {
37701
- if (file.externalModuleIndicator) {
37732
+ if (file.externalModuleIndicator && file.commonJsModuleIndicator) {
37702
37733
  return false;
37703
37734
  }
37704
- if (!file.commonJsModuleIndicator) {
37735
+ if (file.commonJsModuleIndicator === undefined) {
37705
37736
  file.commonJsModuleIndicator = node;
37706
- bindSourceFileAsExternalModule();
37737
+ if (file.externalModuleIndicator === undefined) {
37738
+ bindSourceFileAsExternalModule();
37739
+ }
37707
37740
  }
37708
37741
  return true;
37709
37742
  }
@@ -41438,8 +41471,13 @@ var ts;
41438
41471
  return res;
41439
41472
  }
41440
41473
  var candidates = ts.mapDefined(symbol.declarations, function (d) {
41441
- if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
41442
- return getSymbolOfNode(d.parent);
41474
+ if (!ts.isAmbientModule(d) && d.parent) {
41475
+ if (hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
41476
+ return getSymbolOfNode(d.parent);
41477
+ }
41478
+ if (ts.isModuleBlock(d.parent) && d.parent.parent && resolveExternalModuleSymbol(getSymbolOfNode(d.parent.parent)) === symbol) {
41479
+ return getSymbolOfNode(d.parent.parent);
41480
+ }
41443
41481
  }
41444
41482
  if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
41445
41483
  if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
@@ -48593,9 +48631,10 @@ var ts;
48593
48631
  return signature;
48594
48632
  }
48595
48633
  function getOrCreateTypeFromSignature(signature) {
48634
+ var _a;
48596
48635
  if (!signature.isolatedSignatureType) {
48597
- var kind = signature.declaration ? signature.declaration.kind : 0;
48598
- var isConstructor = kind === 170 || kind === 174 || kind === 179;
48636
+ var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
48637
+ var isConstructor = kind === undefined || kind === 170 || kind === 174 || kind === 179;
48599
48638
  var type = createObjectType(16);
48600
48639
  type.members = emptySymbols;
48601
48640
  type.properties = ts.emptyArray;
@@ -52609,9 +52648,9 @@ var ts;
52609
52648
  isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
52610
52649
  return true;
52611
52650
  }
52612
- if (s & 32768 && (!strictNullChecks || t & (32768 | 16384)))
52651
+ if (s & 32768 && (!strictNullChecks && !(t & 3145728) || t & (32768 | 16384)))
52613
52652
  return true;
52614
- if (s & 65536 && (!strictNullChecks || t & 65536))
52653
+ if (s & 65536 && (!strictNullChecks && !(t & 3145728) || t & 65536))
52615
52654
  return true;
52616
52655
  if (s & 524288 && t & 67108864)
52617
52656
  return true;
@@ -52686,11 +52725,11 @@ var ts;
52686
52725
  var overflow = false;
52687
52726
  var overrideNextErrorInfo = 0;
52688
52727
  var lastSkippedInfo;
52689
- var incompatibleStack = [];
52728
+ var incompatibleStack;
52690
52729
  var inPropertyCheck = false;
52691
52730
  ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
52692
52731
  var result = isRelatedTo(source, target, 3, !!errorNode, headMessage);
52693
- if (incompatibleStack.length) {
52732
+ if (incompatibleStack) {
52694
52733
  reportIncompatibleStack();
52695
52734
  }
52696
52735
  if (overflow) {
@@ -52745,19 +52784,19 @@ var ts;
52745
52784
  return {
52746
52785
  errorInfo: errorInfo,
52747
52786
  lastSkippedInfo: lastSkippedInfo,
52748
- incompatibleStack: incompatibleStack.slice(),
52787
+ incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
52749
52788
  overrideNextErrorInfo: overrideNextErrorInfo,
52750
- relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
52789
+ relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
52751
52790
  };
52752
52791
  }
52753
52792
  function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
52754
52793
  overrideNextErrorInfo++;
52755
52794
  lastSkippedInfo = undefined;
52756
- incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
52795
+ (incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
52757
52796
  }
52758
52797
  function reportIncompatibleStack() {
52759
- var stack = incompatibleStack;
52760
- incompatibleStack = [];
52798
+ var stack = incompatibleStack || [];
52799
+ incompatibleStack = undefined;
52761
52800
  var info = lastSkippedInfo;
52762
52801
  lastSkippedInfo = undefined;
52763
52802
  if (stack.length === 1) {
@@ -52851,7 +52890,7 @@ var ts;
52851
52890
  }
52852
52891
  function reportError(message, arg0, arg1, arg2, arg3) {
52853
52892
  ts.Debug.assert(!!errorNode);
52854
- if (incompatibleStack.length)
52893
+ if (incompatibleStack)
52855
52894
  reportIncompatibleStack();
52856
52895
  if (message.elidedInCompatabilityPyramid)
52857
52896
  return;
@@ -52867,7 +52906,7 @@ var ts;
52867
52906
  }
52868
52907
  }
52869
52908
  function reportRelationError(message, source, target) {
52870
- if (incompatibleStack.length)
52909
+ if (incompatibleStack)
52871
52910
  reportIncompatibleStack();
52872
52911
  var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
52873
52912
  var generalizedSource = source;
@@ -52958,7 +52997,9 @@ var ts;
52958
52997
  if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
52959
52998
  return -1;
52960
52999
  }
52961
- reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 2048));
53000
+ if (reportErrors) {
53001
+ reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
53002
+ }
52962
53003
  return 0;
52963
53004
  }
52964
53005
  var source = getNormalizedType(originalSource, false);
@@ -52966,127 +53007,121 @@ var ts;
52966
53007
  if (source === target)
52967
53008
  return -1;
52968
53009
  if (relation === identityRelation) {
52969
- return isIdenticalTo(source, target, recursionFlags);
53010
+ if (source.flags !== target.flags)
53011
+ return 0;
53012
+ if (source.flags & 67358815)
53013
+ return -1;
53014
+ traceUnionsOrIntersectionsTooLarge(source, target);
53015
+ return recursiveTypeRelatedTo(source, target, false, 0, recursionFlags);
52970
53016
  }
52971
53017
  if (source.flags & 262144 && getConstraintOfType(source) === target) {
52972
53018
  return -1;
52973
53019
  }
52974
- if (target.flags & 1048576 && source.flags & 524288 &&
52975
- target.types.length <= 3 && maybeTypeOfKind(target, 98304)) {
52976
- var nullStrippedTarget = extractTypesOfKind(target, ~98304);
52977
- if (!(nullStrippedTarget.flags & (1048576 | 131072))) {
52978
- target = getNormalizedType(nullStrippedTarget, true);
53020
+ if (source.flags & 470302716 && target.flags & 1048576) {
53021
+ var types = target.types;
53022
+ var candidate = types.length === 2 && types[0].flags & 98304 ? types[1] :
53023
+ types.length === 3 && types[0].flags & 98304 && types[1].flags & 98304 ? types[2] :
53024
+ undefined;
53025
+ if (candidate && !(candidate.flags & 98304)) {
53026
+ target = getNormalizedType(candidate, true);
53027
+ if (source === target)
53028
+ return -1;
52979
53029
  }
52980
- if (source === nullStrippedTarget)
52981
- return -1;
52982
53030
  }
52983
53031
  if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) ||
52984
53032
  isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
52985
53033
  return -1;
52986
- var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048);
52987
- var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384);
52988
- if (isPerformingExcessPropertyChecks) {
52989
- if (hasExcessProperties(source, target, reportErrors)) {
53034
+ if (source.flags & 469499904 || target.flags & 469499904) {
53035
+ var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384);
53036
+ if (isPerformingExcessPropertyChecks) {
53037
+ if (hasExcessProperties(source, target, reportErrors)) {
53038
+ if (reportErrors) {
53039
+ reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
53040
+ }
53041
+ return 0;
53042
+ }
53043
+ }
53044
+ var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
53045
+ source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
53046
+ target.flags & (524288 | 2097152) && isWeakType(target) &&
53047
+ (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
53048
+ var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048);
53049
+ if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
52990
53050
  if (reportErrors) {
52991
- reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
53051
+ var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
53052
+ var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
53053
+ var calls = getSignaturesOfType(source, 0);
53054
+ var constructs = getSignaturesOfType(source, 1);
53055
+ if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1, false) ||
53056
+ constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1, false)) {
53057
+ reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
53058
+ }
53059
+ else {
53060
+ reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
53061
+ }
52992
53062
  }
52993
53063
  return 0;
52994
53064
  }
52995
- }
52996
- var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
52997
- source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
52998
- target.flags & (524288 | 2097152) && isWeakType(target) &&
52999
- (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
53000
- if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
53001
- if (reportErrors) {
53002
- var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
53003
- var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
53004
- var calls = getSignaturesOfType(source, 0);
53005
- var constructs = getSignaturesOfType(source, 1);
53006
- if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1, false) ||
53007
- constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1, false)) {
53008
- reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
53009
- }
53010
- else {
53011
- reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
53012
- }
53065
+ traceUnionsOrIntersectionsTooLarge(source, target);
53066
+ var skipCaching = source.flags & 1048576 && source.types.length < 4 && !(target.flags & 1048576) ||
53067
+ target.flags & 1048576 && target.types.length < 4 && !(source.flags & 469499904);
53068
+ var result_7 = skipCaching ?
53069
+ unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
53070
+ recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
53071
+ if (result_7 && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
53072
+ isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288); }))) {
53073
+ inPropertyCheck = true;
53074
+ result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4, recursionFlags);
53075
+ inPropertyCheck = false;
53013
53076
  }
53014
- return 0;
53015
- }
53016
- traceUnionsOrIntersectionsTooLarge(source, target);
53017
- var result = 0;
53018
- var saveErrorInfo = captureErrorCalculationState();
53019
- if ((source.flags & 1048576 || target.flags & 1048576) && getConstituentCount(source) * getConstituentCount(target) < 4) {
53020
- result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8);
53021
- }
53022
- else if (source.flags & 3145728 || target.flags & 3145728) {
53023
- result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8, recursionFlags);
53024
- }
53025
- if (!result && !(source.flags & 1048576) && (source.flags & (469499904) || target.flags & 469499904)) {
53026
- if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
53027
- resetErrorInfo(saveErrorInfo);
53077
+ if (result_7) {
53078
+ return result_7;
53028
53079
  }
53029
53080
  }
53030
- if (!result && source.flags & (2097152 | 262144)) {
53031
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
53032
- if (constraint && (source.flags & 2097152 || target.flags & 1048576)) {
53033
- if (everyType(constraint, function (c) { return c !== source; })) {
53034
- if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
53035
- resetErrorInfo(saveErrorInfo);
53036
- }
53037
- }
53081
+ if (reportErrors) {
53082
+ reportErrorResults(originalSource, originalTarget, source, target, headMessage);
53083
+ }
53084
+ return 0;
53085
+ }
53086
+ function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
53087
+ var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
53088
+ var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
53089
+ source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
53090
+ target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
53091
+ var maybeSuppress = overrideNextErrorInfo > 0;
53092
+ if (maybeSuppress) {
53093
+ overrideNextErrorInfo--;
53094
+ }
53095
+ if (source.flags & 524288 && target.flags & 524288) {
53096
+ var currentError = errorInfo;
53097
+ tryElaborateArrayLikeErrors(source, target, true);
53098
+ if (errorInfo !== currentError) {
53099
+ maybeSuppress = !!errorInfo;
53100
+ }
53101
+ }
53102
+ if (source.flags & 524288 && target.flags & 131068) {
53103
+ tryElaborateErrorsForPrimitivesAndObjects(source, target);
53104
+ }
53105
+ else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
53106
+ reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
53107
+ }
53108
+ else if (ts.getObjectFlags(source) & 2048 && target.flags & 2097152) {
53109
+ var targetTypes = target.types;
53110
+ var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
53111
+ var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
53112
+ if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
53113
+ (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
53114
+ return;
53038
53115
  }
53039
53116
  }
53040
- if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
53041
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288); }))) {
53042
- inPropertyCheck = true;
53043
- result &= recursiveTypeRelatedTo(source, target, reportErrors, 4, recursionFlags);
53044
- inPropertyCheck = false;
53117
+ else {
53118
+ errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
53045
53119
  }
53046
- reportErrorResults(source, target, result, isComparingJsxAttributes);
53047
- return result;
53048
- function reportErrorResults(source, target, result, isComparingJsxAttributes) {
53049
- if (!result && reportErrors) {
53050
- var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
53051
- var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
53052
- source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
53053
- target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
53054
- var maybeSuppress = overrideNextErrorInfo > 0;
53055
- if (maybeSuppress) {
53056
- overrideNextErrorInfo--;
53057
- }
53058
- if (source.flags & 524288 && target.flags & 524288) {
53059
- var currentError = errorInfo;
53060
- tryElaborateArrayLikeErrors(source, target, reportErrors);
53061
- if (errorInfo !== currentError) {
53062
- maybeSuppress = !!errorInfo;
53063
- }
53064
- }
53065
- if (source.flags & 524288 && target.flags & 131068) {
53066
- tryElaborateErrorsForPrimitivesAndObjects(source, target);
53067
- }
53068
- else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
53069
- reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
53070
- }
53071
- else if (isComparingJsxAttributes && target.flags & 2097152) {
53072
- var targetTypes = target.types;
53073
- var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
53074
- var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
53075
- if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
53076
- (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
53077
- return result;
53078
- }
53079
- }
53080
- else {
53081
- errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
53082
- }
53083
- if (!headMessage && maybeSuppress) {
53084
- lastSkippedInfo = [source, target];
53085
- return result;
53086
- }
53087
- reportRelationError(headMessage, source, target);
53088
- }
53120
+ if (!headMessage && maybeSuppress) {
53121
+ lastSkippedInfo = [source, target];
53122
+ return;
53089
53123
  }
53124
+ reportRelationError(headMessage, source, target);
53090
53125
  }
53091
53126
  function traceUnionsOrIntersectionsTooLarge(source, target) {
53092
53127
  if (!ts.tracing) {
@@ -53112,21 +53147,6 @@ var ts;
53112
53147
  }
53113
53148
  }
53114
53149
  }
53115
- function isIdenticalTo(source, target, recursionFlags) {
53116
- if (source.flags !== target.flags)
53117
- return 0;
53118
- if (source.flags & 67358815)
53119
- return -1;
53120
- traceUnionsOrIntersectionsTooLarge(source, target);
53121
- if (source.flags & 3145728) {
53122
- var result_7 = eachTypeRelatedToSomeType(source, target);
53123
- if (result_7) {
53124
- result_7 &= eachTypeRelatedToSomeType(target, source);
53125
- }
53126
- return result_7;
53127
- }
53128
- return recursiveTypeRelatedTo(source, target, false, 0, recursionFlags);
53129
- }
53130
53150
  function getTypeOfPropertyInTypes(types, name) {
53131
53151
  var appendPropType = function (propTypes, type) {
53132
53152
  var _a;
@@ -53215,6 +53235,29 @@ var ts;
53215
53235
  function shouldCheckAsExcessProperty(prop, container) {
53216
53236
  return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
53217
53237
  }
53238
+ function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
53239
+ if (source.flags & 1048576) {
53240
+ return relation === comparableRelation ?
53241
+ someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState) :
53242
+ eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState);
53243
+ }
53244
+ if (target.flags & 1048576) {
53245
+ return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
53246
+ }
53247
+ if (target.flags & 2097152) {
53248
+ return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
53249
+ }
53250
+ if (relation === comparableRelation && target.flags & 131068) {
53251
+ var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
53252
+ if (constraints !== source.types) {
53253
+ source = getIntersectionType(constraints);
53254
+ if (!(source.flags & 2097152)) {
53255
+ return isRelatedTo(source, target, 1, false);
53256
+ }
53257
+ }
53258
+ }
53259
+ return someTypeRelatedToType(source, target, false, 1);
53260
+ }
53218
53261
  function eachTypeRelatedToSomeType(source, target) {
53219
53262
  var result = -1;
53220
53263
  var sourceTypes = source.types;
@@ -53251,7 +53294,9 @@ var ts;
53251
53294
  }
53252
53295
  if (reportErrors) {
53253
53296
  var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
53254
- isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2, true);
53297
+ if (bestMatchingType) {
53298
+ isRelatedTo(source, bestMatchingType, 2, true);
53299
+ }
53255
53300
  }
53256
53301
  return 0;
53257
53302
  }
@@ -53359,7 +53404,7 @@ var ts;
53359
53404
  if (overflow) {
53360
53405
  return 0;
53361
53406
  }
53362
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 : 0);
53407
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 : 0);
53363
53408
  var id = getRelationKey(source, target, keyIntersectionState, relation, false);
53364
53409
  var entry = relation.get(id);
53365
53410
  if (entry !== undefined) {
@@ -53420,6 +53465,7 @@ var ts;
53420
53465
  return originalHandler(onlyUnreliable);
53421
53466
  };
53422
53467
  }
53468
+ var result;
53423
53469
  if (expandingFlags === 3) {
53424
53470
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "recursiveTypeRelatedTo_DepthLimit", {
53425
53471
  sourceId: source.id,
@@ -53429,8 +53475,13 @@ var ts;
53429
53475
  depth: sourceDepth,
53430
53476
  targetDepth: targetDepth
53431
53477
  });
53478
+ result = 3;
53479
+ }
53480
+ else {
53481
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
53482
+ result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
53483
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
53432
53484
  }
53433
- var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3;
53434
53485
  if (outofbandVarianceMarkerHandler) {
53435
53486
  outofbandVarianceMarkerHandler = originalHandler;
53436
53487
  }
@@ -53458,74 +53509,73 @@ var ts;
53458
53509
  return result;
53459
53510
  }
53460
53511
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
53461
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
53462
- var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
53463
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
53464
- return result;
53465
- }
53466
- function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
53467
53512
  if (intersectionState & 4) {
53468
53513
  return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
53469
53514
  }
53470
- if (intersectionState & 8) {
53471
- if (source.flags & 1048576) {
53472
- return relation === comparableRelation ?
53473
- someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState & ~8) :
53474
- eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState & ~8);
53475
- }
53476
- if (target.flags & 1048576) {
53477
- return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
53478
- }
53479
- if (target.flags & 2097152) {
53480
- return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
53481
- }
53482
- if (relation === comparableRelation && target.flags & 131068) {
53483
- var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
53484
- if (constraints !== source.types) {
53485
- source = getIntersectionType(constraints);
53486
- if (!(source.flags & 2097152)) {
53487
- return isRelatedTo(source, target, 1, false);
53488
- }
53515
+ var result;
53516
+ var originalErrorInfo;
53517
+ var varianceCheckFailed = false;
53518
+ var saveErrorInfo = captureErrorCalculationState();
53519
+ var sourceFlags = source.flags;
53520
+ var targetFlags = target.flags;
53521
+ if (relation === identityRelation) {
53522
+ if (sourceFlags & 3145728) {
53523
+ var result_8 = eachTypeRelatedToSomeType(source, target);
53524
+ if (result_8) {
53525
+ result_8 &= eachTypeRelatedToSomeType(target, source);
53489
53526
  }
53527
+ return result_8;
53490
53528
  }
53491
- return someTypeRelatedToType(source, target, false, 1);
53492
- }
53493
- var flags = source.flags & target.flags;
53494
- if (relation === identityRelation && !(flags & 524288)) {
53495
- if (flags & 4194304) {
53529
+ if (sourceFlags & 4194304) {
53496
53530
  return isRelatedTo(source.type, target.type, 3, false);
53497
53531
  }
53498
- var result_8 = 0;
53499
- if (flags & 8388608) {
53500
- if (result_8 = isRelatedTo(source.objectType, target.objectType, 3, false)) {
53501
- if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3, false)) {
53502
- return result_8;
53532
+ if (sourceFlags & 8388608) {
53533
+ if (result = isRelatedTo(source.objectType, target.objectType, 3, false)) {
53534
+ if (result &= isRelatedTo(source.indexType, target.indexType, 3, false)) {
53535
+ return result;
53503
53536
  }
53504
53537
  }
53505
53538
  }
53506
- if (flags & 16777216) {
53539
+ if (sourceFlags & 16777216) {
53507
53540
  if (source.root.isDistributive === target.root.isDistributive) {
53508
- if (result_8 = isRelatedTo(source.checkType, target.checkType, 3, false)) {
53509
- if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3, false)) {
53510
- if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3, false)) {
53511
- if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3, false)) {
53512
- return result_8;
53541
+ if (result = isRelatedTo(source.checkType, target.checkType, 3, false)) {
53542
+ if (result &= isRelatedTo(source.extendsType, target.extendsType, 3, false)) {
53543
+ if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3, false)) {
53544
+ if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3, false)) {
53545
+ return result;
53513
53546
  }
53514
53547
  }
53515
53548
  }
53516
53549
  }
53517
53550
  }
53518
53551
  }
53519
- if (flags & 33554432) {
53552
+ if (sourceFlags & 33554432) {
53520
53553
  return isRelatedTo(source.substitute, target.substitute, 3, false);
53521
53554
  }
53522
- return 0;
53555
+ if (!(sourceFlags & 524288)) {
53556
+ return 0;
53557
+ }
53523
53558
  }
53524
- var result;
53525
- var originalErrorInfo;
53526
- var varianceCheckFailed = false;
53527
- var saveErrorInfo = captureErrorCalculationState();
53528
- if (source.flags & (524288 | 16777216) && source.aliasSymbol &&
53559
+ else if (sourceFlags & 3145728 || targetFlags & 3145728) {
53560
+ if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
53561
+ return result;
53562
+ }
53563
+ if (source.flags & 2097152 || source.flags & 262144 && target.flags & 1048576) {
53564
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
53565
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) {
53566
+ if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
53567
+ resetErrorInfo(saveErrorInfo);
53568
+ return result;
53569
+ }
53570
+ }
53571
+ }
53572
+ if (!(sourceFlags & 465829888 ||
53573
+ sourceFlags & 524288 && targetFlags & 1048576 ||
53574
+ sourceFlags & 2097152 && targetFlags & (524288 | 1048576 | 465829888))) {
53575
+ return 0;
53576
+ }
53577
+ }
53578
+ if (sourceFlags & (524288 | 16777216) && source.aliasSymbol &&
53529
53579
  source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
53530
53580
  !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
53531
53581
  var variances = getAliasVariances(source.aliasSymbol);
@@ -53541,7 +53591,7 @@ var ts;
53541
53591
  isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2))) {
53542
53592
  return result;
53543
53593
  }
53544
- if (target.flags & 262144) {
53594
+ if (targetFlags & 262144) {
53545
53595
  if (ts.getObjectFlags(source) & 32 && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3)) {
53546
53596
  if (!(getMappedTypeModifiers(source) & 4)) {
53547
53597
  var templateType = getTemplateTypeFromMappedType(source);
@@ -53552,9 +53602,9 @@ var ts;
53552
53602
  }
53553
53603
  }
53554
53604
  }
53555
- else if (target.flags & 4194304) {
53605
+ else if (targetFlags & 4194304) {
53556
53606
  var targetType_1 = target.type;
53557
- if (source.flags & 4194304) {
53607
+ if (sourceFlags & 4194304) {
53558
53608
  if (result = isRelatedTo(targetType_1, source.type, 3, false)) {
53559
53609
  return result;
53560
53610
  }
@@ -53590,8 +53640,8 @@ var ts;
53590
53640
  }
53591
53641
  }
53592
53642
  }
53593
- else if (target.flags & 8388608) {
53594
- if (source.flags & 8388608) {
53643
+ else if (targetFlags & 8388608) {
53644
+ if (sourceFlags & 8388608) {
53595
53645
  if (result = isRelatedTo(source.objectType, target.objectType, 3, reportErrors)) {
53596
53646
  result &= isRelatedTo(source.indexType, target.indexType, 3, reportErrors);
53597
53647
  }
@@ -53670,7 +53720,7 @@ var ts;
53670
53720
  }
53671
53721
  }
53672
53722
  }
53673
- else if (target.flags & 16777216) {
53723
+ else if (targetFlags & 16777216) {
53674
53724
  if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
53675
53725
  resetErrorInfo(saveErrorInfo);
53676
53726
  return 3;
@@ -53688,8 +53738,8 @@ var ts;
53688
53738
  }
53689
53739
  }
53690
53740
  }
53691
- else if (target.flags & 134217728) {
53692
- if (source.flags & 134217728) {
53741
+ else if (targetFlags & 134217728) {
53742
+ if (sourceFlags & 134217728) {
53693
53743
  if (relation === comparableRelation) {
53694
53744
  return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 : -1;
53695
53745
  }
@@ -53699,10 +53749,10 @@ var ts;
53699
53749
  return -1;
53700
53750
  }
53701
53751
  }
53702
- if (source.flags & 8650752) {
53703
- if (!(source.flags & 8388608 && target.flags & 8388608)) {
53752
+ if (sourceFlags & 8650752) {
53753
+ if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
53704
53754
  var constraint = getConstraintOfType(source);
53705
- if (!constraint || (source.flags & 262144 && constraint.flags & 1)) {
53755
+ if (!constraint || (sourceFlags & 262144 && constraint.flags & 1)) {
53706
53756
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) {
53707
53757
  resetErrorInfo(saveErrorInfo);
53708
53758
  return result;
@@ -53712,7 +53762,7 @@ var ts;
53712
53762
  resetErrorInfo(saveErrorInfo);
53713
53763
  return result;
53714
53764
  }
53715
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(target.flags & source.flags & 262144), undefined, intersectionState)) {
53765
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) {
53716
53766
  resetErrorInfo(saveErrorInfo);
53717
53767
  return result;
53718
53768
  }
@@ -53727,14 +53777,14 @@ var ts;
53727
53777
  }
53728
53778
  }
53729
53779
  }
53730
- else if (source.flags & 4194304) {
53780
+ else if (sourceFlags & 4194304) {
53731
53781
  if (result = isRelatedTo(keyofConstraintType, target, 1, reportErrors)) {
53732
53782
  resetErrorInfo(saveErrorInfo);
53733
53783
  return result;
53734
53784
  }
53735
53785
  }
53736
- else if (source.flags & 134217728 && !(target.flags & 524288)) {
53737
- if (!(target.flags & 134217728)) {
53786
+ else if (sourceFlags & 134217728 && !(targetFlags & 524288)) {
53787
+ if (!(targetFlags & 134217728)) {
53738
53788
  var constraint = getBaseConstraintOfType(source);
53739
53789
  if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1, reportErrors))) {
53740
53790
  resetErrorInfo(saveErrorInfo);
@@ -53742,8 +53792,8 @@ var ts;
53742
53792
  }
53743
53793
  }
53744
53794
  }
53745
- else if (source.flags & 268435456) {
53746
- if (target.flags & 268435456 && source.symbol === target.symbol) {
53795
+ else if (sourceFlags & 268435456) {
53796
+ if (targetFlags & 268435456 && source.symbol === target.symbol) {
53747
53797
  if (result = isRelatedTo(source.type, target.type, 3, reportErrors)) {
53748
53798
  resetErrorInfo(saveErrorInfo);
53749
53799
  return result;
@@ -53757,12 +53807,12 @@ var ts;
53757
53807
  }
53758
53808
  }
53759
53809
  }
53760
- else if (source.flags & 16777216) {
53810
+ else if (sourceFlags & 16777216) {
53761
53811
  if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
53762
53812
  resetErrorInfo(saveErrorInfo);
53763
53813
  return 3;
53764
53814
  }
53765
- if (target.flags & 16777216) {
53815
+ if (targetFlags & 16777216) {
53766
53816
  var sourceParams = source.root.inferTypeParameters;
53767
53817
  var sourceExtends = source.extendsType;
53768
53818
  var mapper = void 0;
@@ -53813,15 +53863,19 @@ var ts;
53813
53863
  }
53814
53864
  return 0;
53815
53865
  }
53816
- var sourceIsPrimitive = !!(source.flags & 131068);
53866
+ var sourceIsPrimitive = !!(sourceFlags & 131068);
53817
53867
  if (relation !== identityRelation) {
53818
53868
  source = getApparentType(source);
53869
+ sourceFlags = source.flags;
53819
53870
  }
53820
53871
  else if (isGenericMappedType(source)) {
53821
53872
  return 0;
53822
53873
  }
53823
53874
  if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target &&
53824
53875
  !isTupleType(source) && !(ts.getObjectFlags(source) & 4096 || ts.getObjectFlags(target) & 4096)) {
53876
+ if (isEmptyArrayLiteralType(source)) {
53877
+ return -1;
53878
+ }
53825
53879
  var variances = getVariances(source.target);
53826
53880
  if (variances === ts.emptyArray) {
53827
53881
  return 1;
@@ -53842,7 +53896,7 @@ var ts;
53842
53896
  else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 && !isEmptyObjectType(source)) {
53843
53897
  return 0;
53844
53898
  }
53845
- if (source.flags & (524288 | 2097152) && target.flags & 524288) {
53899
+ if (sourceFlags & (524288 | 2097152) && targetFlags & 524288) {
53846
53900
  var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
53847
53901
  result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, intersectionState);
53848
53902
  if (result) {
@@ -53861,7 +53915,7 @@ var ts;
53861
53915
  return result;
53862
53916
  }
53863
53917
  }
53864
- if (source.flags & (524288 | 2097152) && target.flags & 1048576) {
53918
+ if (sourceFlags & (524288 | 2097152) && targetFlags & 1048576) {
53865
53919
  var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432);
53866
53920
  if (objectOnlyTarget.flags & 1048576) {
53867
53921
  var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
@@ -54057,6 +54111,10 @@ var ts;
54057
54111
  }
54058
54112
  return 0;
54059
54113
  }
54114
+ if ((relation === subtypeRelation || relation === strictSubtypeRelation) &&
54115
+ !!(sourcePropFlags & 64) && !(targetPropFlags & 64)) {
54116
+ return 0;
54117
+ }
54060
54118
  var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
54061
54119
  if (!related) {
54062
54120
  if (reportErrors) {
@@ -54307,7 +54365,6 @@ var ts;
54307
54365
  }
54308
54366
  }
54309
54367
  var result = -1;
54310
- var saveErrorInfo = captureErrorCalculationState();
54311
54368
  var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
54312
54369
  var sourceObjectFlags = ts.getObjectFlags(source);
54313
54370
  var targetObjectFlags = ts.getObjectFlags(target);
@@ -54339,6 +54396,7 @@ var ts;
54339
54396
  else {
54340
54397
  outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
54341
54398
  var t = targetSignatures_1[_i];
54399
+ var saveErrorInfo = captureErrorCalculationState();
54342
54400
  var shouldElaborateErrors = reportErrors;
54343
54401
  for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
54344
54402
  var s = sourceSignatures_1[_c];
@@ -57127,9 +57185,6 @@ var ts;
57127
57185
  getUnionType(ts.map(type.types, mapper), 1, aliasSymbol, aliasTypeArguments) :
57128
57186
  mapType(type, mapper);
57129
57187
  }
57130
- function getConstituentCount(type) {
57131
- return type.flags & 1048576 ? type.types.length : 1;
57132
- }
57133
57188
  function extractTypesOfKind(type, kind) {
57134
57189
  return filterType(type, function (t) { return (t.flags & kind) !== 0; });
57135
57190
  }
@@ -63638,19 +63693,20 @@ var ts;
63638
63693
  if (links.type === unknownType) {
63639
63694
  links.type = getTypeFromBindingPattern(declaration.name);
63640
63695
  }
63641
- assignBindingElementTypes(declaration.name);
63696
+ assignBindingElementTypes(declaration.name, links.type);
63642
63697
  }
63643
63698
  }
63644
63699
  }
63645
- function assignBindingElementTypes(pattern) {
63700
+ function assignBindingElementTypes(pattern, parentType) {
63646
63701
  for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
63647
63702
  var element = _a[_i];
63648
63703
  if (!ts.isOmittedExpression(element)) {
63704
+ var type = getBindingElementTypeFromParentType(element, parentType);
63649
63705
  if (element.name.kind === 79) {
63650
- getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
63706
+ getSymbolLinks(getSymbolOfNode(element)).type = type;
63651
63707
  }
63652
63708
  else {
63653
- assignBindingElementTypes(element.name);
63709
+ assignBindingElementTypes(element.name, type);
63654
63710
  }
63655
63711
  }
63656
63712
  }
@@ -66845,26 +66901,24 @@ var ts;
66845
66901
  if (returnType.flags & 1) {
66846
66902
  return;
66847
66903
  }
66904
+ var headMessage;
66848
66905
  var expectedReturnType;
66849
- var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
66850
- var errorInfo;
66851
66906
  switch (node.parent.kind) {
66852
66907
  case 256:
66908
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
66853
66909
  var classSymbol = getSymbolOfNode(node.parent);
66854
66910
  var classConstructorType = getTypeOfSymbol(classSymbol);
66855
66911
  expectedReturnType = getUnionType([classConstructorType, voidType]);
66856
66912
  break;
66857
- case 163:
66858
- expectedReturnType = voidType;
66859
- errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
66860
- break;
66861
66913
  case 166:
66914
+ case 163:
66915
+ headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
66862
66916
  expectedReturnType = voidType;
66863
- errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
66864
66917
  break;
66865
66918
  case 168:
66866
66919
  case 171:
66867
66920
  case 172:
66921
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
66868
66922
  var methodType = getTypeOfNode(node.parent);
66869
66923
  var descriptorType = createTypedPropertyDescriptorType(methodType);
66870
66924
  expectedReturnType = getUnionType([descriptorType, voidType]);
@@ -66872,7 +66926,7 @@ var ts;
66872
66926
  default:
66873
66927
  return ts.Debug.fail();
66874
66928
  }
66875
- checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
66929
+ checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
66876
66930
  }
66877
66931
  function markTypeNodeAsReferenced(node) {
66878
66932
  markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
@@ -71657,13 +71711,13 @@ var ts;
71657
71711
  var fileToDirective;
71658
71712
  if (resolvedTypeReferenceDirectives) {
71659
71713
  fileToDirective = new ts.Map();
71660
- resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
71714
+ resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
71661
71715
  if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
71662
71716
  return;
71663
71717
  }
71664
71718
  var file = host.getSourceFile(resolvedDirective.resolvedFileName);
71665
71719
  if (file) {
71666
- addReferencedFilesToTypeDirective(file, key);
71720
+ addReferencedFilesToTypeDirective(file, key, mode);
71667
71721
  }
71668
71722
  });
71669
71723
  }
@@ -71841,16 +71895,16 @@ var ts;
71841
71895
  }
71842
71896
  return false;
71843
71897
  }
71844
- function addReferencedFilesToTypeDirective(file, key) {
71898
+ function addReferencedFilesToTypeDirective(file, key, mode) {
71845
71899
  if (fileToDirective.has(file.path))
71846
71900
  return;
71847
- fileToDirective.set(file.path, key);
71901
+ fileToDirective.set(file.path, [key, mode]);
71848
71902
  for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
71849
- var fileName = _a[_i].fileName;
71903
+ var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
71850
71904
  var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
71851
71905
  var referencedFile = host.getSourceFile(resolvedFile);
71852
71906
  if (referencedFile) {
71853
- addReferencedFilesToTypeDirective(referencedFile, key);
71907
+ addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
71854
71908
  }
71855
71909
  }
71856
71910
  }
@@ -73441,25 +73495,24 @@ var ts;
73441
73495
  }
73442
73496
  function findMostOverlappyType(source, unionTarget) {
73443
73497
  var bestMatch;
73444
- var matchingCount = 0;
73445
- for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
73446
- var target = _a[_i];
73447
- var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
73448
- if (overlap.flags & 4194304) {
73449
- bestMatch = target;
73450
- matchingCount = Infinity;
73451
- }
73452
- else if (overlap.flags & 1048576) {
73453
- var len = ts.length(ts.filter(overlap.types, isUnitType));
73454
- if (len >= matchingCount) {
73455
- bestMatch = target;
73456
- matchingCount = len;
73498
+ if (!(source.flags & (131068 | 406847488))) {
73499
+ var matchingCount = 0;
73500
+ for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
73501
+ var target = _a[_i];
73502
+ if (!(target.flags & (131068 | 406847488))) {
73503
+ var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
73504
+ if (overlap.flags & 4194304) {
73505
+ return target;
73506
+ }
73507
+ else if (isUnitType(overlap) || overlap.flags & 1048576) {
73508
+ var len = overlap.flags & 1048576 ? ts.countWhere(overlap.types, isUnitType) : 1;
73509
+ if (len >= matchingCount) {
73510
+ bestMatch = target;
73511
+ matchingCount = len;
73512
+ }
73513
+ }
73457
73514
  }
73458
73515
  }
73459
- else if (isUnitType(overlap) && 1 >= matchingCount) {
73460
- bestMatch = target;
73461
- matchingCount = 1;
73462
- }
73463
73516
  }
73464
73517
  return bestMatch;
73465
73518
  }
@@ -74091,7 +74144,7 @@ var ts;
74091
74144
  return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment));
74092
74145
  case 284:
74093
74146
  ts.Debug.type(node);
74094
- return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrTemplateExpressionOrJsxExpression));
74147
+ return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
74095
74148
  case 285:
74096
74149
  ts.Debug.type(node);
74097
74150
  return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
@@ -80263,9 +80316,6 @@ var ts;
80263
80316
  var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote);
80264
80317
  return ts.setTextRange(literal, node);
80265
80318
  }
80266
- else if (node.kind === 14 || node.kind === 222) {
80267
- return node;
80268
- }
80269
80319
  else if (node.kind === 287) {
80270
80320
  if (node.expression === undefined) {
80271
80321
  return factory.createTrue();
@@ -80868,8 +80918,6 @@ var ts;
80868
80918
  return visitReturnStatement(node);
80869
80919
  case 216:
80870
80920
  return visitVoidExpression(node);
80871
- case 284:
80872
- return visitJsxAttribute(node);
80873
80921
  default:
80874
80922
  return ts.visitEachChild(node, visitor, context);
80875
80923
  }
@@ -80899,12 +80947,6 @@ var ts;
80899
80947
  }
80900
80948
  return ts.visitEachChild(node, visitor, context);
80901
80949
  }
80902
- function visitJsxAttribute(node) {
80903
- if (node.initializer && ts.isTemplateExpression(node.initializer)) {
80904
- return factory.createJsxAttribute(ts.visitNode(node.name, visitor, ts.isIdentifier), factory.createJsxExpression(undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)));
80905
- }
80906
- return ts.visitEachChild(node, visitor, context);
80907
- }
80908
80950
  function visitCaseBlock(node) {
80909
80951
  var ancestorFacts = enterSubtree(7104, 0);
80910
80952
  var updated = ts.visitEachChild(node, visitor, context);
@@ -87154,7 +87196,7 @@ var ts;
87154
87196
  var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
87155
87197
  hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
87156
87198
  collectReferences(sourceFile, refs);
87157
- recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
87199
+ recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
87158
87200
  collectLibs(sourceFile, libs);
87159
87201
  return sourceFile;
87160
87202
  }
@@ -87208,9 +87250,10 @@ var ts;
87208
87250
  return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
87209
87251
  }
87210
87252
  function getFileReferencesForUsedTypeReferences() {
87211
- return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
87253
+ return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
87212
87254
  }
87213
- function getFileReferenceForTypeName(typeName) {
87255
+ function getFileReferenceForSpecifierModeTuple(_a) {
87256
+ var typeName = _a[0], mode = _a[1];
87214
87257
  if (emittedImports) {
87215
87258
  for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
87216
87259
  var importStatement = emittedImports_1[_i];
@@ -87225,7 +87268,7 @@ var ts;
87225
87268
  }
87226
87269
  }
87227
87270
  }
87228
- return { fileName: typeName, pos: -1, end: -1 };
87271
+ return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
87229
87272
  }
87230
87273
  function mapReferencesIntoArray(references, outputFilePath) {
87231
87274
  return function (file) {
@@ -87242,7 +87285,7 @@ var ts;
87242
87285
  if (declFileName) {
87243
87286
  var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host);
87244
87287
  if (!ts.pathIsRelative(specifier)) {
87245
- recordTypeReferenceDirectivesIfNecessary([specifier]);
87288
+ recordTypeReferenceDirectivesIfNecessary([[specifier, undefined]]);
87246
87289
  return;
87247
87290
  }
87248
87291
  var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
@@ -91877,9 +91920,12 @@ var ts;
91877
91920
  for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
91878
91921
  var directive = types_24[_d];
91879
91922
  var pos = writer.getTextPos();
91880
- writeComment("/// <reference types=\"" + directive.fileName + "\" />");
91923
+ var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
91924
+ ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
91925
+ : "";
91926
+ writeComment("/// <reference types=\"" + directive.fileName + "\" " + resolutionMode + "/>");
91881
91927
  if (bundleFileInfo)
91882
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName });
91928
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" : "type-require", data: directive.fileName });
91883
91929
  writeLine();
91884
91930
  }
91885
91931
  for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
@@ -94185,7 +94231,7 @@ var ts;
94185
94231
  return result;
94186
94232
  }
94187
94233
  ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
94188
- function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
94234
+ function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
94189
94235
  if (names.length === 0) {
94190
94236
  return [];
94191
94237
  }
@@ -94194,18 +94240,25 @@ var ts;
94194
94240
  for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
94195
94241
  var name = names_2[_i];
94196
94242
  var result = void 0;
94197
- if (cache.has(name)) {
94198
- result = cache.get(name);
94243
+ var mode = getModeForFileReference(name, containingFileMode);
94244
+ var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
94245
+ var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
94246
+ if (cache.has(cacheKey)) {
94247
+ result = cache.get(cacheKey);
94199
94248
  }
94200
94249
  else {
94201
- cache.set(name, result = loader(name, containingFile, redirectedReference));
94250
+ cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
94202
94251
  }
94203
94252
  resolutions.push(result);
94204
94253
  }
94205
94254
  return resolutions;
94206
94255
  }
94207
- ts.loadWithLocalCache = loadWithLocalCache;
94256
+ ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
94208
94257
  ;
94258
+ function getModeForFileReference(ref, containingFileMode) {
94259
+ return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
94260
+ }
94261
+ ts.getModeForFileReference = getModeForFileReference;
94209
94262
  function getModeForResolutionAtIndex(file, index) {
94210
94263
  if (file.impliedNodeFormat === undefined)
94211
94264
  return undefined;
@@ -94294,7 +94347,7 @@ var ts;
94294
94347
  var _d, _e, _f, _g;
94295
94348
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
94296
94349
  var kind = ref.kind, index = ref.index;
94297
- var pos, end, packageId;
94350
+ var pos, end, packageId, resolutionMode;
94298
94351
  switch (kind) {
94299
94352
  case ts.FileIncludeKind.Import:
94300
94353
  var importLiteral = getModuleNameStringLiteralAt(file, index);
@@ -94308,8 +94361,8 @@ var ts;
94308
94361
  (_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
94309
94362
  break;
94310
94363
  case ts.FileIncludeKind.TypeReferenceDirective:
94311
- (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
94312
- packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
94364
+ (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
94365
+ packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
94313
94366
  break;
94314
94367
  case ts.FileIncludeKind.LibReferenceDirective:
94315
94368
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -94515,7 +94568,7 @@ var ts;
94515
94568
  var fileReasons = ts.createMultiMap();
94516
94569
  var cachedBindAndCheckDiagnosticsForFile = {};
94517
94570
  var cachedDeclarationDiagnosticsForFile = {};
94518
- var resolvedTypeReferenceDirectives = new ts.Map();
94571
+ var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
94519
94572
  var fileProcessingDiagnostics;
94520
94573
  var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
94521
94574
  var currentNodeModulesDepth = 0;
@@ -94556,12 +94609,12 @@ var ts;
94556
94609
  }
94557
94610
  var actualResolveTypeReferenceDirectiveNamesWorker;
94558
94611
  if (host.resolveTypeReferenceDirectives) {
94559
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
94612
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
94560
94613
  }
94561
94614
  else {
94562
94615
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
94563
- var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
94564
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
94616
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; };
94617
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
94565
94618
  }
94566
94619
  var packageIdToSourceFile = new ts.Map();
94567
94620
  var sourceFileToPackageName = new ts.Map();
@@ -94640,7 +94693,7 @@ var ts;
94640
94693
  var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
94641
94694
  var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
94642
94695
  for (var i = 0; i < typeReferences.length; i++) {
94643
- processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
94696
+ processTypeReferenceDirective(typeReferences[i], undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
94644
94697
  }
94645
94698
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
94646
94699
  }
@@ -94788,9 +94841,10 @@ var ts;
94788
94841
  return [];
94789
94842
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
94790
94843
  var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
94844
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
94791
94845
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
94792
94846
  ts.performance.mark("beforeResolveTypeReference");
94793
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
94847
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
94794
94848
  ts.performance.mark("afterResolveTypeReference");
94795
94849
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
94796
94850
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -95092,7 +95146,7 @@ var ts;
95092
95146
  else {
95093
95147
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
95094
95148
  }
95095
- var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
95149
+ var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
95096
95150
  var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
95097
95151
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
95098
95152
  if (typeReferenceResolutionsChanged) {
@@ -96043,7 +96097,7 @@ var ts;
96043
96097
  });
96044
96098
  }
96045
96099
  function processTypeReferenceDirectives(file) {
96046
- var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
96100
+ var typeDirectives = file.typeReferenceDirectives;
96047
96101
  if (!typeDirectives) {
96048
96102
  return;
96049
96103
  }
@@ -96053,16 +96107,20 @@ var ts;
96053
96107
  var resolvedTypeReferenceDirective = resolutions[index];
96054
96108
  var fileName = ts.toFileNameLowerCase(ref.fileName);
96055
96109
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
96056
- processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
96110
+ var mode = ref.resolutionMode || file.impliedNodeFormat;
96111
+ if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
96112
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext));
96113
+ }
96114
+ processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
96057
96115
  }
96058
96116
  }
96059
- function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
96117
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
96060
96118
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
96061
- processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
96119
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
96062
96120
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
96063
96121
  }
96064
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
96065
- var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
96122
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
96123
+ var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
96066
96124
  if (previousResolution && previousResolution.primary) {
96067
96125
  return;
96068
96126
  }
@@ -96095,7 +96153,7 @@ var ts;
96095
96153
  addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
96096
96154
  }
96097
96155
  if (saveResolution) {
96098
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
96156
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
96099
96157
  }
96100
96158
  }
96101
96159
  function pathForLibFile(libFileName) {
@@ -98504,9 +98562,9 @@ var ts;
98504
98562
  });
98505
98563
  hasChangedAutomaticTypeDirectiveNames = false;
98506
98564
  }
98507
- function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
98565
+ function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
98508
98566
  var _a;
98509
- var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
98567
+ var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
98510
98568
  if (!resolutionHost.getGlobalCache) {
98511
98569
  return primaryResult;
98512
98570
  }
@@ -98521,12 +98579,12 @@ var ts;
98521
98579
  }
98522
98580
  return primaryResult;
98523
98581
  }
98524
- function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
98525
- return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
98582
+ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
98583
+ return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
98526
98584
  }
98527
98585
  function resolveNamesWithLocalCache(_a) {
98528
98586
  var _b, _c, _d;
98529
- var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile;
98587
+ var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
98530
98588
  var path = resolutionHost.toPath(containingFile);
98531
98589
  var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
98532
98590
  var dirPath = ts.getDirectoryPath(path);
@@ -98547,8 +98605,10 @@ var ts;
98547
98605
  var seenNamesInFile = ts.createModeAwareCache();
98548
98606
  var i = 0;
98549
98607
  for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
98550
- var name = names_4[_i];
98551
- var mode = containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
98608
+ var entry = names_4[_i];
98609
+ var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
98610
+ var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
98611
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
98552
98612
  i++;
98553
98613
  var resolution = resolutionsInFile.get(name, mode);
98554
98614
  if (!seenNamesInFile.has(name, mode) &&
@@ -98575,7 +98635,7 @@ var ts;
98575
98635
  }
98576
98636
  }
98577
98637
  else {
98578
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
98638
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
98579
98639
  perDirectoryResolution.set(name, mode, resolution);
98580
98640
  if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
98581
98641
  resolutionHost.onDiscoveredSymlink();
@@ -98637,7 +98697,7 @@ var ts;
98637
98697
  return oldResult.resolvedFileName === newResult.resolvedFileName;
98638
98698
  }
98639
98699
  }
98640
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
98700
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
98641
98701
  return resolveNamesWithLocalCache({
98642
98702
  names: typeDirectiveNames,
98643
98703
  containingFile: containingFile,
@@ -98647,6 +98707,7 @@ var ts;
98647
98707
  loader: resolveTypeReferenceDirective,
98648
98708
  getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
98649
98709
  shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
98710
+ containingSourceFileMode: containingFileMode
98650
98711
  });
98651
98712
  }
98652
98713
  function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
@@ -100338,7 +100399,7 @@ var ts;
100338
100399
  }
100339
100400
  return host.resolveTypeReferenceDirectives.apply(host, args);
100340
100401
  }) :
100341
- (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
100402
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
100342
100403
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
100343
100404
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
100344
100405
  synchronizeProgram();
@@ -100992,9 +101053,9 @@ var ts;
100992
101053
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
100993
101054
  }
100994
101055
  if (!compilerHost.resolveTypeReferenceDirectives) {
100995
- var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
100996
- compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
100997
- return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4);
101056
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
101057
+ compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
101058
+ return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
100998
101059
  };
100999
101060
  }
101000
101061
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;