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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220505";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220506";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -8398,6 +8398,8 @@ var ts;
8398
8398
  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),
8399
8399
  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."),
8400
8400
  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."),
8401
+ 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."),
8402
+ 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."),
8401
8403
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
8402
8404
  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."),
8403
8405
  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."),
@@ -18223,6 +18225,16 @@ var ts;
18223
18225
  ".d.ts" /* Dts */;
18224
18226
  }
18225
18227
  ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
18228
+ /**
18229
+ * This function is an inverse of `getDeclarationEmitExtensionForPath`.
18230
+ */
18231
+ function getPossibleOriginalInputExtensionForExtension(path) {
18232
+ return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] :
18233
+ ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] :
18234
+ ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] :
18235
+ [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
18236
+ }
18237
+ ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension;
18226
18238
  function outFile(options) {
18227
18239
  return options.outFile || options.out;
18228
18240
  }
@@ -38944,6 +38956,7 @@ var ts;
38944
38956
  ["es2021.intl", "lib.es2021.intl.d.ts"],
38945
38957
  ["es2022.array", "lib.es2022.array.d.ts"],
38946
38958
  ["es2022.error", "lib.es2022.error.d.ts"],
38959
+ ["es2022.intl", "lib.es2022.intl.d.ts"],
38947
38960
  ["es2022.object", "lib.es2022.object.d.ts"],
38948
38961
  ["es2022.string", "lib.es2022.string.d.ts"],
38949
38962
  ["esnext.array", "lib.es2022.array.d.ts"],
@@ -42142,7 +42155,7 @@ var ts;
42142
42155
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
42143
42156
  return { fileName: resolved.path, packageId: resolved.packageId };
42144
42157
  }
42145
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
42158
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
42146
42159
  var _a;
42147
42160
  if (resultFromCache) {
42148
42161
  (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
@@ -42150,7 +42163,8 @@ var ts;
42150
42163
  }
42151
42164
  return {
42152
42165
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
42153
- failedLookupLocations: failedLookupLocations
42166
+ failedLookupLocations: failedLookupLocations,
42167
+ resolutionDiagnostics: diagnostics
42154
42168
  };
42155
42169
  }
42156
42170
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -42351,7 +42365,18 @@ var ts;
42351
42365
  features |= NodeResolutionFeatures.EsmMode;
42352
42366
  }
42353
42367
  var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
42354
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
42368
+ var diagnostics = [];
42369
+ var moduleResolutionState = {
42370
+ compilerOptions: options,
42371
+ host: host,
42372
+ traceEnabled: traceEnabled,
42373
+ failedLookupLocations: failedLookupLocations,
42374
+ packageJsonInfoCache: cache,
42375
+ features: features,
42376
+ conditions: conditions,
42377
+ requestContainingDirectory: containingDirectory,
42378
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
42379
+ };
42355
42380
  var resolved = primaryLookup();
42356
42381
  var primary = true;
42357
42382
  if (!resolved) {
@@ -42370,7 +42395,7 @@ var ts;
42370
42395
  isExternalLibraryImport: pathContainsNodeModules(fileName),
42371
42396
  };
42372
42397
  }
42373
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
42398
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
42374
42399
  perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
42375
42400
  if (traceEnabled)
42376
42401
  traceResult(result);
@@ -42453,6 +42478,8 @@ var ts;
42453
42478
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42454
42479
  conditions: ts.emptyArray,
42455
42480
  features: NodeResolutionFeatures.None,
42481
+ requestContainingDirectory: containingDirectory,
42482
+ reportDiagnostic: ts.noop
42456
42483
  };
42457
42484
  return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
42458
42485
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
@@ -43104,6 +43131,7 @@ var ts;
43104
43131
  if (compilerOptions.noDtsResolution) {
43105
43132
  conditions.pop();
43106
43133
  }
43134
+ var diagnostics = [];
43107
43135
  var state = {
43108
43136
  compilerOptions: compilerOptions,
43109
43137
  host: host,
@@ -43112,9 +43140,11 @@ var ts;
43112
43140
  packageJsonInfoCache: cache,
43113
43141
  features: features,
43114
43142
  conditions: conditions,
43143
+ requestContainingDirectory: containingDirectory,
43144
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43115
43145
  };
43116
43146
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43117
- 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);
43147
+ 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);
43118
43148
  function tryResolve(extensions) {
43119
43149
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
43120
43150
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -43287,9 +43317,9 @@ var ts;
43287
43317
  }
43288
43318
  }
43289
43319
  function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
43290
- if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
43320
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) {
43291
43321
  var result = tryFile(candidate, onlyRecordFailures, state);
43292
- return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43322
+ return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined;
43293
43323
  }
43294
43324
  return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
43295
43325
  }
@@ -43412,6 +43442,8 @@ var ts;
43412
43442
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43413
43443
  conditions: ["node", "require", "types"],
43414
43444
  features: features,
43445
+ requestContainingDirectory: packageJsonInfo.packageDirectory,
43446
+ reportDiagnostic: ts.noop
43415
43447
  };
43416
43448
  var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
43417
43449
  /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
@@ -43498,6 +43530,8 @@ var ts;
43498
43530
  packageJsonInfoCache: packageJsonInfoCache,
43499
43531
  features: 0,
43500
43532
  conditions: [],
43533
+ requestContainingDirectory: undefined,
43534
+ reportDiagnostic: ts.noop
43501
43535
  };
43502
43536
  var parts = ts.getPathComponents(fileName);
43503
43537
  parts.pop();
@@ -43789,7 +43823,6 @@ var ts;
43789
43823
  function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
43790
43824
  return loadModuleFromTargetImportOrExport;
43791
43825
  function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
43792
- var _a, _b;
43793
43826
  if (typeof target === "string") {
43794
43827
  if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
43795
43828
  if (state.traceEnabled) {
@@ -43826,13 +43859,16 @@ var ts;
43826
43859
  }
43827
43860
  return toSearchResult(/*value*/ undefined);
43828
43861
  }
43829
- 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));
43862
+ var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
43863
+ var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
43864
+ if (inputLink)
43865
+ return inputLink;
43830
43866
  return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
43831
43867
  }
43832
43868
  else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
43833
43869
  if (!Array.isArray(target)) {
43834
- for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) {
43835
- var key = _c[_i];
43870
+ for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
43871
+ var key = _a[_i];
43836
43872
  if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
43837
43873
  var subTarget = target[key];
43838
43874
  var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
@@ -43850,8 +43886,8 @@ var ts;
43850
43886
  }
43851
43887
  return toSearchResult(/*value*/ undefined);
43852
43888
  }
43853
- for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
43854
- var elem = target_2[_d];
43889
+ for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
43890
+ var elem = target_2[_b];
43855
43891
  var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
43856
43892
  if (result) {
43857
43893
  return result;
@@ -43869,6 +43905,128 @@ var ts;
43869
43905
  trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
43870
43906
  }
43871
43907
  return toSearchResult(/*value*/ undefined);
43908
+ function toAbsolutePath(path) {
43909
+ var _a, _b;
43910
+ if (path === undefined)
43911
+ return path;
43912
+ return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)));
43913
+ }
43914
+ function combineDirectoryPath(root, dir) {
43915
+ return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir));
43916
+ }
43917
+ function useCaseSensitiveFileNames() {
43918
+ return !state.host.useCaseSensitiveFileNames ? true :
43919
+ typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
43920
+ state.host.useCaseSensitiveFileNames();
43921
+ }
43922
+ function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) {
43923
+ var _a, _b, _c, _d;
43924
+ // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir
43925
+ // 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
43926
+ // 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!
43927
+ // _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!).
43928
+ // 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.
43929
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
43930
+ && (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
43931
+ && finalPath.indexOf("/node_modules/") === -1
43932
+ && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) {
43933
+ // 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.
43934
+ // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
43935
+ // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.)
43936
+ var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames });
43937
+ var commonSourceDirGuesses = [];
43938
+ // A `rootDir` compiler option strongly indicates the root location
43939
+ // 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
43940
+ if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) {
43941
+ var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName));
43942
+ commonSourceDirGuesses.push(commonDir);
43943
+ }
43944
+ else if (state.requestContainingDirectory) {
43945
+ // However without either of those set we're in the dark. Let's say you have
43946
+ //
43947
+ // ./tools/index.ts
43948
+ // ./src/index.ts
43949
+ // ./dist/index.js
43950
+ // ./package.json <-- references ./dist/index.js
43951
+ // ./tsconfig.json <-- loads ./src/index.ts
43952
+ //
43953
+ // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename?
43954
+ // 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
43955
+ // without more context.
43956
+ // 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
43957
+ // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory
43958
+ var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts"));
43959
+ // And we can try every folder above the common folder for the request folder and the config/package base directory
43960
+ // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't
43961
+ // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything
43962
+ // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then
43963
+ // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup
43964
+ // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all
43965
+ // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first.
43966
+ 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));
43967
+ commonSourceDirGuesses.push(commonDir);
43968
+ var fragment = ts.ensureTrailingDirectorySeparator(commonDir);
43969
+ while (fragment && fragment.length > 1) {
43970
+ var parts = ts.getPathComponents(fragment);
43971
+ parts.pop(); // remove a directory
43972
+ var commonDir_1 = ts.getPathFromPathComponents(parts);
43973
+ commonSourceDirGuesses.unshift(commonDir_1);
43974
+ fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
43975
+ }
43976
+ }
43977
+ if (commonSourceDirGuesses.length > 1) {
43978
+ state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
43979
+ ? 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
43980
+ : 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
43981
+ packagePath));
43982
+ }
43983
+ for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
43984
+ var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
43985
+ var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
43986
+ for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) {
43987
+ var candidateDir = candidateDirectories_1[_e];
43988
+ if (ts.startsWith(finalPath, candidateDir)) {
43989
+ // 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
43990
+ var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
43991
+ var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment);
43992
+ var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */];
43993
+ for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) {
43994
+ var ext = jsAndDtsExtensions_1[_f];
43995
+ if (ts.fileExtensionIs(possibleInputBase, ext)) {
43996
+ var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase);
43997
+ for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) {
43998
+ var possibleExt = inputExts_1[_g];
43999
+ var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
44000
+ if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) ||
44001
+ (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) {
44002
+ continue;
44003
+ }
44004
+ if (state.host.fileExists(possibleInputWithInputExtension)) {
44005
+ return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state)));
44006
+ }
44007
+ }
44008
+ }
44009
+ }
44010
+ }
44011
+ }
44012
+ }
44013
+ }
44014
+ return undefined;
44015
+ function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) {
44016
+ var _a, _b;
44017
+ // Config file ouput paths are processed to be relative to the host's current directory, while
44018
+ // otherwise the paths are resolved relative to the common source dir the compiler puts together
44019
+ var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess;
44020
+ var candidateDirectories = [];
44021
+ if (state.compilerOptions.declarationDir) {
44022
+ candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
44023
+ }
44024
+ if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) {
44025
+ candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir)));
44026
+ }
44027
+ return candidateDirectories;
44028
+ }
44029
+ }
43872
44030
  }
43873
44031
  }
43874
44032
  /* @internal */
@@ -44059,11 +44217,12 @@ var ts;
44059
44217
  function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
44060
44218
  var traceEnabled = isTraceEnabled(compilerOptions, host);
44061
44219
  var failedLookupLocations = [];
44062
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
44063
44220
  var containingDirectory = ts.getDirectoryPath(containingFile);
44221
+ var diagnostics = [];
44222
+ 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); } };
44064
44223
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
44065
44224
  // No originalPath because classic resolution doesn't resolve realPath
44066
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache);
44225
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
44067
44226
  function tryResolve(extensions) {
44068
44227
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
44069
44228
  if (resolvedUsingSettings) {
@@ -44106,9 +44265,10 @@ var ts;
44106
44265
  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);
44107
44266
  }
44108
44267
  var failedLookupLocations = [];
44109
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
44268
+ var diagnostics = [];
44269
+ 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); } };
44110
44270
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
44111
- return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
44271
+ return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
44112
44272
  }
44113
44273
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
44114
44274
  /**
@@ -57972,7 +58132,8 @@ var ts;
57972
58132
  if (symbol === globalThisSymbol) {
57973
58133
  var varsOnly_1 = new ts.Map();
57974
58134
  members.forEach(function (p) {
57975
- if (!(p.flags & 418 /* BlockScoped */)) {
58135
+ var _a;
58136
+ 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))) {
57976
58137
  varsOnly_1.set(p.escapedName, p);
57977
58138
  }
57978
58139
  });
@@ -86163,7 +86324,7 @@ var ts;
86163
86324
  if (ts.isDeclaration(node)) {
86164
86325
  // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
86165
86326
  var symbol = getSymbolOfNode(node);
86166
- return getTypeOfSymbol(symbol);
86327
+ return symbol ? getTypeOfSymbol(symbol) : errorType;
86167
86328
  }
86168
86329
  if (isDeclarationNameOrImportPropertyName(node)) {
86169
86330
  var symbol = getSymbolAtLocation(node);
@@ -116077,7 +116238,6 @@ var ts;
116077
116238
  ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code,
116078
116239
  ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code,
116079
116240
  ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code,
116080
- ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code,
116081
116241
  ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
116082
116242
  ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
116083
116243
  ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
@@ -116464,6 +116624,40 @@ var ts;
116464
116624
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
116465
116625
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
116466
116626
  return program;
116627
+ function addResolutionDiagnostics(list) {
116628
+ if (!list)
116629
+ return;
116630
+ for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
116631
+ var elem = list_3[_i];
116632
+ programDiagnostics.add(elem);
116633
+ }
116634
+ }
116635
+ function pullDiagnosticsFromCache(names, containingFile) {
116636
+ var _a;
116637
+ if (!moduleResolutionCache)
116638
+ return;
116639
+ var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
116640
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
116641
+ var containingDir = ts.getDirectoryPath(containingFileName);
116642
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
116643
+ var i = 0;
116644
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
116645
+ var n = names_4[_i];
116646
+ // 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
116647
+ var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
116648
+ var name = typeof n === "string" ? n : n.fileName;
116649
+ i++;
116650
+ // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
116651
+ // (Since diagnostics are only issued via import or export map lookup)
116652
+ // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
116653
+ // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
116654
+ // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
116655
+ if (ts.isExternalModuleNameRelative(name))
116656
+ continue;
116657
+ var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
116658
+ addResolutionDiagnostics(diags);
116659
+ }
116660
+ }
116467
116661
  function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
116468
116662
  if (!moduleNames.length)
116469
116663
  return ts.emptyArray;
@@ -116475,6 +116669,7 @@ var ts;
116475
116669
  ts.performance.mark("afterResolveModule");
116476
116670
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
116477
116671
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
116672
+ pullDiagnosticsFromCache(moduleNames, containingFile);
116478
116673
  return result;
116479
116674
  }
116480
116675
  function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
@@ -120911,8 +121106,8 @@ var ts;
120911
121106
  !!redirectedReference;
120912
121107
  var seenNamesInFile = ts.createModeAwareCache();
120913
121108
  var i = 0;
120914
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
120915
- var entry = names_4[_i];
121109
+ for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
121110
+ var entry = names_5[_i];
120916
121111
  var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
120917
121112
  // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
120918
121113
  // they require calculating the mode for a given import from it's position in the resolution table, since a given
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.7.0-dev.20220505",
5
+ "version": "4.7.0-dev.20220506",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [