typescript 4.7.0-dev.20220505 → 4.7.0-dev.20220506

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220505";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220506";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -8603,6 +8603,8 @@ var ts;
8603
8603
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8604
8604
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8605
8605
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8606
+ The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8607
+ The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8606
8608
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
8607
8609
  Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
8608
8610
  Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
@@ -18428,6 +18430,16 @@ var ts;
18428
18430
  ".d.ts" /* Dts */;
18429
18431
  }
18430
18432
  ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
18433
+ /**
18434
+ * This function is an inverse of `getDeclarationEmitExtensionForPath`.
18435
+ */
18436
+ function getPossibleOriginalInputExtensionForExtension(path) {
18437
+ return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] :
18438
+ ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] :
18439
+ ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] :
18440
+ [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
18441
+ }
18442
+ ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension;
18431
18443
  function outFile(options) {
18432
18444
  return options.outFile || options.out;
18433
18445
  }
@@ -39149,6 +39161,7 @@ var ts;
39149
39161
  ["es2021.intl", "lib.es2021.intl.d.ts"],
39150
39162
  ["es2022.array", "lib.es2022.array.d.ts"],
39151
39163
  ["es2022.error", "lib.es2022.error.d.ts"],
39164
+ ["es2022.intl", "lib.es2022.intl.d.ts"],
39152
39165
  ["es2022.object", "lib.es2022.object.d.ts"],
39153
39166
  ["es2022.string", "lib.es2022.string.d.ts"],
39154
39167
  ["esnext.array", "lib.es2022.array.d.ts"],
@@ -42347,7 +42360,7 @@ var ts;
42347
42360
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
42348
42361
  return { fileName: resolved.path, packageId: resolved.packageId };
42349
42362
  }
42350
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
42363
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
42351
42364
  var _a;
42352
42365
  if (resultFromCache) {
42353
42366
  (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
@@ -42355,7 +42368,8 @@ var ts;
42355
42368
  }
42356
42369
  return {
42357
42370
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
42358
- failedLookupLocations: failedLookupLocations
42371
+ failedLookupLocations: failedLookupLocations,
42372
+ resolutionDiagnostics: diagnostics
42359
42373
  };
42360
42374
  }
42361
42375
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -42556,7 +42570,18 @@ var ts;
42556
42570
  features |= NodeResolutionFeatures.EsmMode;
42557
42571
  }
42558
42572
  var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
42559
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
42573
+ var diagnostics = [];
42574
+ var moduleResolutionState = {
42575
+ compilerOptions: options,
42576
+ host: host,
42577
+ traceEnabled: traceEnabled,
42578
+ failedLookupLocations: failedLookupLocations,
42579
+ packageJsonInfoCache: cache,
42580
+ features: features,
42581
+ conditions: conditions,
42582
+ requestContainingDirectory: containingDirectory,
42583
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
42584
+ };
42560
42585
  var resolved = primaryLookup();
42561
42586
  var primary = true;
42562
42587
  if (!resolved) {
@@ -42575,7 +42600,7 @@ var ts;
42575
42600
  isExternalLibraryImport: pathContainsNodeModules(fileName),
42576
42601
  };
42577
42602
  }
42578
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
42603
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
42579
42604
  perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
42580
42605
  if (traceEnabled)
42581
42606
  traceResult(result);
@@ -42658,6 +42683,8 @@ var ts;
42658
42683
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42659
42684
  conditions: ts.emptyArray,
42660
42685
  features: NodeResolutionFeatures.None,
42686
+ requestContainingDirectory: containingDirectory,
42687
+ reportDiagnostic: ts.noop
42661
42688
  };
42662
42689
  return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
42663
42690
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
@@ -43309,6 +43336,7 @@ var ts;
43309
43336
  if (compilerOptions.noDtsResolution) {
43310
43337
  conditions.pop();
43311
43338
  }
43339
+ var diagnostics = [];
43312
43340
  var state = {
43313
43341
  compilerOptions: compilerOptions,
43314
43342
  host: host,
@@ -43317,9 +43345,11 @@ var ts;
43317
43345
  packageJsonInfoCache: cache,
43318
43346
  features: features,
43319
43347
  conditions: conditions,
43348
+ requestContainingDirectory: containingDirectory,
43349
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43320
43350
  };
43321
43351
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43322
- return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
43352
+ return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache);
43323
43353
  function tryResolve(extensions) {
43324
43354
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
43325
43355
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -43492,9 +43522,9 @@ var ts;
43492
43522
  }
43493
43523
  }
43494
43524
  function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
43495
- if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
43525
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) {
43496
43526
  var result = tryFile(candidate, onlyRecordFailures, state);
43497
- return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43527
+ return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined;
43498
43528
  }
43499
43529
  return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
43500
43530
  }
@@ -43617,6 +43647,8 @@ var ts;
43617
43647
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43618
43648
  conditions: ["node", "require", "types"],
43619
43649
  features: features,
43650
+ requestContainingDirectory: packageJsonInfo.packageDirectory,
43651
+ reportDiagnostic: ts.noop
43620
43652
  };
43621
43653
  var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
43622
43654
  /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
@@ -43703,6 +43735,8 @@ var ts;
43703
43735
  packageJsonInfoCache: packageJsonInfoCache,
43704
43736
  features: 0,
43705
43737
  conditions: [],
43738
+ requestContainingDirectory: undefined,
43739
+ reportDiagnostic: ts.noop
43706
43740
  };
43707
43741
  var parts = ts.getPathComponents(fileName);
43708
43742
  parts.pop();
@@ -43994,7 +44028,6 @@ var ts;
43994
44028
  function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
43995
44029
  return loadModuleFromTargetImportOrExport;
43996
44030
  function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
43997
- var _a, _b;
43998
44031
  if (typeof target === "string") {
43999
44032
  if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
44000
44033
  if (state.traceEnabled) {
@@ -44031,13 +44064,16 @@ var ts;
44031
44064
  }
44032
44065
  return toSearchResult(/*value*/ undefined);
44033
44066
  }
44034
- var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
44067
+ var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
44068
+ var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
44069
+ if (inputLink)
44070
+ return inputLink;
44035
44071
  return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
44036
44072
  }
44037
44073
  else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
44038
44074
  if (!Array.isArray(target)) {
44039
- for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) {
44040
- var key = _c[_i];
44075
+ for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
44076
+ var key = _a[_i];
44041
44077
  if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
44042
44078
  var subTarget = target[key];
44043
44079
  var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
@@ -44055,8 +44091,8 @@ var ts;
44055
44091
  }
44056
44092
  return toSearchResult(/*value*/ undefined);
44057
44093
  }
44058
- for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
44059
- var elem = target_2[_d];
44094
+ for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
44095
+ var elem = target_2[_b];
44060
44096
  var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
44061
44097
  if (result) {
44062
44098
  return result;
@@ -44074,6 +44110,128 @@ var ts;
44074
44110
  trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
44075
44111
  }
44076
44112
  return toSearchResult(/*value*/ undefined);
44113
+ function toAbsolutePath(path) {
44114
+ var _a, _b;
44115
+ if (path === undefined)
44116
+ return path;
44117
+ return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)));
44118
+ }
44119
+ function combineDirectoryPath(root, dir) {
44120
+ return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir));
44121
+ }
44122
+ function useCaseSensitiveFileNames() {
44123
+ return !state.host.useCaseSensitiveFileNames ? true :
44124
+ typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
44125
+ state.host.useCaseSensitiveFileNames();
44126
+ }
44127
+ function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) {
44128
+ var _a, _b, _c, _d;
44129
+ // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir
44130
+ // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure
44131
+ // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving!
44132
+ // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!).
44133
+ // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups.
44134
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
44135
+ && (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
44136
+ && finalPath.indexOf("/node_modules/") === -1
44137
+ && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) {
44138
+ // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings.
44139
+ // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
44140
+ // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.)
44141
+ var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames });
44142
+ var commonSourceDirGuesses = [];
44143
+ // A `rootDir` compiler option strongly indicates the root location
44144
+ // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations
44145
+ if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) {
44146
+ var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName));
44147
+ commonSourceDirGuesses.push(commonDir);
44148
+ }
44149
+ else if (state.requestContainingDirectory) {
44150
+ // However without either of those set we're in the dark. Let's say you have
44151
+ //
44152
+ // ./tools/index.ts
44153
+ // ./src/index.ts
44154
+ // ./dist/index.js
44155
+ // ./package.json <-- references ./dist/index.js
44156
+ // ./tsconfig.json <-- loads ./src/index.ts
44157
+ //
44158
+ // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename?
44159
+ // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from
44160
+ // without more context.
44161
+ // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too
44162
+ // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory
44163
+ var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts"));
44164
+ // And we can try every folder above the common folder for the request folder and the config/package base directory
44165
+ // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't
44166
+ // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything
44167
+ // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then
44168
+ // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup
44169
+ // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all
44170
+ // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first.
44171
+ var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName));
44172
+ commonSourceDirGuesses.push(commonDir);
44173
+ var fragment = ts.ensureTrailingDirectorySeparator(commonDir);
44174
+ while (fragment && fragment.length > 1) {
44175
+ var parts = ts.getPathComponents(fragment);
44176
+ parts.pop(); // remove a directory
44177
+ var commonDir_1 = ts.getPathFromPathComponents(parts);
44178
+ commonSourceDirGuesses.unshift(commonDir_1);
44179
+ fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
44180
+ }
44181
+ }
44182
+ if (commonSourceDirGuesses.length > 1) {
44183
+ state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
44184
+ ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
44185
+ : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird
44186
+ packagePath));
44187
+ }
44188
+ for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
44189
+ var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
44190
+ var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
44191
+ for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) {
44192
+ var candidateDir = candidateDirectories_1[_e];
44193
+ if (ts.startsWith(finalPath, candidateDir)) {
44194
+ // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension
44195
+ var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
44196
+ var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment);
44197
+ var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */];
44198
+ for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) {
44199
+ var ext = jsAndDtsExtensions_1[_f];
44200
+ if (ts.fileExtensionIs(possibleInputBase, ext)) {
44201
+ var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase);
44202
+ for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) {
44203
+ var possibleExt = inputExts_1[_g];
44204
+ var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
44205
+ if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) ||
44206
+ (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) {
44207
+ continue;
44208
+ }
44209
+ if (state.host.fileExists(possibleInputWithInputExtension)) {
44210
+ return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state)));
44211
+ }
44212
+ }
44213
+ }
44214
+ }
44215
+ }
44216
+ }
44217
+ }
44218
+ }
44219
+ return undefined;
44220
+ function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) {
44221
+ var _a, _b;
44222
+ // Config file ouput paths are processed to be relative to the host's current directory, while
44223
+ // otherwise the paths are resolved relative to the common source dir the compiler puts together
44224
+ var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess;
44225
+ var candidateDirectories = [];
44226
+ if (state.compilerOptions.declarationDir) {
44227
+ candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
44228
+ }
44229
+ if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) {
44230
+ candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir)));
44231
+ }
44232
+ return candidateDirectories;
44233
+ }
44234
+ }
44077
44235
  }
44078
44236
  }
44079
44237
  /* @internal */
@@ -44264,11 +44422,12 @@ var ts;
44264
44422
  function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
44265
44423
  var traceEnabled = isTraceEnabled(compilerOptions, host);
44266
44424
  var failedLookupLocations = [];
44267
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
44268
44425
  var containingDirectory = ts.getDirectoryPath(containingFile);
44426
+ var diagnostics = [];
44427
+ var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
44269
44428
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
44270
44429
  // No originalPath because classic resolution doesn't resolve realPath
44271
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache);
44430
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
44272
44431
  function tryResolve(extensions) {
44273
44432
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
44274
44433
  if (resolvedUsingSettings) {
@@ -44311,9 +44470,10 @@ var ts;
44311
44470
  trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
44312
44471
  }
44313
44472
  var failedLookupLocations = [];
44314
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
44473
+ var diagnostics = [];
44474
+ var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
44315
44475
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
44316
- return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
44476
+ return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
44317
44477
  }
44318
44478
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
44319
44479
  /**
@@ -58177,7 +58337,8 @@ var ts;
58177
58337
  if (symbol === globalThisSymbol) {
58178
58338
  var varsOnly_1 = new ts.Map();
58179
58339
  members.forEach(function (p) {
58180
- if (!(p.flags & 418 /* BlockScoped */)) {
58340
+ var _a;
58341
+ if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) {
58181
58342
  varsOnly_1.set(p.escapedName, p);
58182
58343
  }
58183
58344
  });
@@ -86368,7 +86529,7 @@ var ts;
86368
86529
  if (ts.isDeclaration(node)) {
86369
86530
  // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
86370
86531
  var symbol = getSymbolOfNode(node);
86371
- return getTypeOfSymbol(symbol);
86532
+ return symbol ? getTypeOfSymbol(symbol) : errorType;
86372
86533
  }
86373
86534
  if (isDeclarationNameOrImportPropertyName(node)) {
86374
86535
  var symbol = getSymbolAtLocation(node);
@@ -116282,7 +116443,6 @@ var ts;
116282
116443
  ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code,
116283
116444
  ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code,
116284
116445
  ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code,
116285
- ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code,
116286
116446
  ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
116287
116447
  ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
116288
116448
  ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
@@ -116669,6 +116829,40 @@ var ts;
116669
116829
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
116670
116830
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
116671
116831
  return program;
116832
+ function addResolutionDiagnostics(list) {
116833
+ if (!list)
116834
+ return;
116835
+ for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
116836
+ var elem = list_3[_i];
116837
+ programDiagnostics.add(elem);
116838
+ }
116839
+ }
116840
+ function pullDiagnosticsFromCache(names, containingFile) {
116841
+ var _a;
116842
+ if (!moduleResolutionCache)
116843
+ return;
116844
+ var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
116845
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
116846
+ var containingDir = ts.getDirectoryPath(containingFileName);
116847
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
116848
+ var i = 0;
116849
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
116850
+ var n = names_4[_i];
116851
+ // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less
116852
+ var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
116853
+ var name = typeof n === "string" ? n : n.fileName;
116854
+ i++;
116855
+ // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
116856
+ // (Since diagnostics are only issued via import or export map lookup)
116857
+ // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
116858
+ // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
116859
+ // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
116860
+ if (ts.isExternalModuleNameRelative(name))
116861
+ continue;
116862
+ var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
116863
+ addResolutionDiagnostics(diags);
116864
+ }
116865
+ }
116672
116866
  function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
116673
116867
  if (!moduleNames.length)
116674
116868
  return ts.emptyArray;
@@ -116680,6 +116874,7 @@ var ts;
116680
116874
  ts.performance.mark("afterResolveModule");
116681
116875
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
116682
116876
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
116877
+ pullDiagnosticsFromCache(moduleNames, containingFile);
116683
116878
  return result;
116684
116879
  }
116685
116880
  function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
@@ -121116,8 +121311,8 @@ var ts;
121116
121311
  !!redirectedReference;
121117
121312
  var seenNamesInFile = ts.createModeAwareCache();
121118
121313
  var i = 0;
121119
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
121120
- var entry = names_4[_i];
121314
+ for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
121315
+ var entry = names_5[_i];
121121
121316
  var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
121122
121317
  // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
121123
121318
  // they require calculating the mode for a given import from it's position in the resolution table, since a given
@@ -129569,23 +129764,30 @@ var ts;
129569
129764
  (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
129570
129765
  var compilerOptions = program.getCompilerOptions();
129571
129766
  var moduleCount = 0;
129572
- forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
129573
- if (++moduleCount % 100 === 0)
129574
- cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
129575
- var seenExports = new ts.Map();
129576
- var checker = program.getTypeChecker();
129577
- var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
129578
- // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
129579
- // can cause it to happen: see 'completionsImport_mergedReExport.ts'
129580
- if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
129581
- cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
129582
- }
129583
- checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
129584
- if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
129585
- cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
129767
+ try {
129768
+ forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
129769
+ if (++moduleCount % 100 === 0)
129770
+ cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
129771
+ var seenExports = new ts.Map();
129772
+ var checker = program.getTypeChecker();
129773
+ var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
129774
+ // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
129775
+ // can cause it to happen: see 'completionsImport_mergedReExport.ts'
129776
+ if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
129777
+ cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
129586
129778
  }
129779
+ checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
129780
+ if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
129781
+ cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
129782
+ }
129783
+ });
129587
129784
  });
129588
- });
129785
+ }
129786
+ catch (err) {
129787
+ // Ensure cache is reset if operation is cancelled
129788
+ cache.clear();
129789
+ throw err;
129790
+ }
129589
129791
  (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms");
129590
129792
  return cache;
129591
129793
  }