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.
- package/lib/lib.es2022.d.ts +1 -0
- package/lib/lib.es2022.intl.d.ts +111 -0
- package/lib/tsc.js +175 -23
- package/lib/tsserver.js +244 -41
- package/lib/tsserverlibrary.js +244 -41
- package/lib/typescript.js +240 -38
- package/lib/typescriptServices.js +240 -38
- package/lib/typingsInstaller.js +218 -23
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220506";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8409,6 +8409,8 @@ var ts;
|
|
|
8409
8409
|
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),
|
|
8410
8410
|
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."),
|
|
8411
8411
|
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."),
|
|
8412
|
+
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."),
|
|
8413
|
+
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."),
|
|
8412
8414
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8413
8415
|
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."),
|
|
8414
8416
|
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."),
|
|
@@ -18234,6 +18236,16 @@ var ts;
|
|
|
18234
18236
|
".d.ts" /* Dts */;
|
|
18235
18237
|
}
|
|
18236
18238
|
ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
|
|
18239
|
+
/**
|
|
18240
|
+
* This function is an inverse of `getDeclarationEmitExtensionForPath`.
|
|
18241
|
+
*/
|
|
18242
|
+
function getPossibleOriginalInputExtensionForExtension(path) {
|
|
18243
|
+
return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] :
|
|
18244
|
+
ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] :
|
|
18245
|
+
ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] :
|
|
18246
|
+
[".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
|
|
18247
|
+
}
|
|
18248
|
+
ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension;
|
|
18237
18249
|
function outFile(options) {
|
|
18238
18250
|
return options.outFile || options.out;
|
|
18239
18251
|
}
|
|
@@ -38955,6 +38967,7 @@ var ts;
|
|
|
38955
38967
|
["es2021.intl", "lib.es2021.intl.d.ts"],
|
|
38956
38968
|
["es2022.array", "lib.es2022.array.d.ts"],
|
|
38957
38969
|
["es2022.error", "lib.es2022.error.d.ts"],
|
|
38970
|
+
["es2022.intl", "lib.es2022.intl.d.ts"],
|
|
38958
38971
|
["es2022.object", "lib.es2022.object.d.ts"],
|
|
38959
38972
|
["es2022.string", "lib.es2022.string.d.ts"],
|
|
38960
38973
|
["esnext.array", "lib.es2022.array.d.ts"],
|
|
@@ -42153,7 +42166,7 @@ var ts;
|
|
|
42153
42166
|
ts.Debug.assert(ts.extensionIsTS(resolved.extension));
|
|
42154
42167
|
return { fileName: resolved.path, packageId: resolved.packageId };
|
|
42155
42168
|
}
|
|
42156
|
-
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
|
|
42169
|
+
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
|
|
42157
42170
|
var _a;
|
|
42158
42171
|
if (resultFromCache) {
|
|
42159
42172
|
(_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
|
|
@@ -42161,7 +42174,8 @@ var ts;
|
|
|
42161
42174
|
}
|
|
42162
42175
|
return {
|
|
42163
42176
|
resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
|
|
42164
|
-
failedLookupLocations: failedLookupLocations
|
|
42177
|
+
failedLookupLocations: failedLookupLocations,
|
|
42178
|
+
resolutionDiagnostics: diagnostics
|
|
42165
42179
|
};
|
|
42166
42180
|
}
|
|
42167
42181
|
function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
|
|
@@ -42362,7 +42376,18 @@ var ts;
|
|
|
42362
42376
|
features |= NodeResolutionFeatures.EsmMode;
|
|
42363
42377
|
}
|
|
42364
42378
|
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
42365
|
-
var
|
|
42379
|
+
var diagnostics = [];
|
|
42380
|
+
var moduleResolutionState = {
|
|
42381
|
+
compilerOptions: options,
|
|
42382
|
+
host: host,
|
|
42383
|
+
traceEnabled: traceEnabled,
|
|
42384
|
+
failedLookupLocations: failedLookupLocations,
|
|
42385
|
+
packageJsonInfoCache: cache,
|
|
42386
|
+
features: features,
|
|
42387
|
+
conditions: conditions,
|
|
42388
|
+
requestContainingDirectory: containingDirectory,
|
|
42389
|
+
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
42390
|
+
};
|
|
42366
42391
|
var resolved = primaryLookup();
|
|
42367
42392
|
var primary = true;
|
|
42368
42393
|
if (!resolved) {
|
|
@@ -42381,7 +42406,7 @@ var ts;
|
|
|
42381
42406
|
isExternalLibraryImport: pathContainsNodeModules(fileName),
|
|
42382
42407
|
};
|
|
42383
42408
|
}
|
|
42384
|
-
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
42409
|
+
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
|
|
42385
42410
|
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
42386
42411
|
if (traceEnabled)
|
|
42387
42412
|
traceResult(result);
|
|
@@ -42464,6 +42489,8 @@ var ts;
|
|
|
42464
42489
|
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
42465
42490
|
conditions: ts.emptyArray,
|
|
42466
42491
|
features: NodeResolutionFeatures.None,
|
|
42492
|
+
requestContainingDirectory: containingDirectory,
|
|
42493
|
+
reportDiagnostic: ts.noop
|
|
42467
42494
|
};
|
|
42468
42495
|
return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
|
|
42469
42496
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
@@ -43115,6 +43142,7 @@ var ts;
|
|
|
43115
43142
|
if (compilerOptions.noDtsResolution) {
|
|
43116
43143
|
conditions.pop();
|
|
43117
43144
|
}
|
|
43145
|
+
var diagnostics = [];
|
|
43118
43146
|
var state = {
|
|
43119
43147
|
compilerOptions: compilerOptions,
|
|
43120
43148
|
host: host,
|
|
@@ -43123,9 +43151,11 @@ var ts;
|
|
|
43123
43151
|
packageJsonInfoCache: cache,
|
|
43124
43152
|
features: features,
|
|
43125
43153
|
conditions: conditions,
|
|
43154
|
+
requestContainingDirectory: containingDirectory,
|
|
43155
|
+
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
43126
43156
|
};
|
|
43127
43157
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
43128
|
-
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);
|
|
43158
|
+
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);
|
|
43129
43159
|
function tryResolve(extensions) {
|
|
43130
43160
|
var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
|
|
43131
43161
|
var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
|
|
@@ -43298,9 +43328,9 @@ var ts;
|
|
|
43298
43328
|
}
|
|
43299
43329
|
}
|
|
43300
43330
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
43301
|
-
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.
|
|
43331
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) {
|
|
43302
43332
|
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
43303
|
-
return result !== undefined ? { path: candidate, ext: ts.
|
|
43333
|
+
return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined;
|
|
43304
43334
|
}
|
|
43305
43335
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
43306
43336
|
}
|
|
@@ -43423,6 +43453,8 @@ var ts;
|
|
|
43423
43453
|
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
43424
43454
|
conditions: ["node", "require", "types"],
|
|
43425
43455
|
features: features,
|
|
43456
|
+
requestContainingDirectory: packageJsonInfo.packageDirectory,
|
|
43457
|
+
reportDiagnostic: ts.noop
|
|
43426
43458
|
};
|
|
43427
43459
|
var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
|
|
43428
43460
|
/*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
|
|
@@ -43509,6 +43541,8 @@ var ts;
|
|
|
43509
43541
|
packageJsonInfoCache: packageJsonInfoCache,
|
|
43510
43542
|
features: 0,
|
|
43511
43543
|
conditions: [],
|
|
43544
|
+
requestContainingDirectory: undefined,
|
|
43545
|
+
reportDiagnostic: ts.noop
|
|
43512
43546
|
};
|
|
43513
43547
|
var parts = ts.getPathComponents(fileName);
|
|
43514
43548
|
parts.pop();
|
|
@@ -43800,7 +43834,6 @@ var ts;
|
|
|
43800
43834
|
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
43801
43835
|
return loadModuleFromTargetImportOrExport;
|
|
43802
43836
|
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
43803
|
-
var _a, _b;
|
|
43804
43837
|
if (typeof target === "string") {
|
|
43805
43838
|
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
43806
43839
|
if (state.traceEnabled) {
|
|
@@ -43837,13 +43870,16 @@ var ts;
|
|
|
43837
43870
|
}
|
|
43838
43871
|
return toSearchResult(/*value*/ undefined);
|
|
43839
43872
|
}
|
|
43840
|
-
var finalPath =
|
|
43873
|
+
var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
|
|
43874
|
+
var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
|
|
43875
|
+
if (inputLink)
|
|
43876
|
+
return inputLink;
|
|
43841
43877
|
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
|
|
43842
43878
|
}
|
|
43843
43879
|
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
43844
43880
|
if (!Array.isArray(target)) {
|
|
43845
|
-
for (var _i = 0,
|
|
43846
|
-
var key =
|
|
43881
|
+
for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
|
|
43882
|
+
var key = _a[_i];
|
|
43847
43883
|
if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
|
|
43848
43884
|
var subTarget = target[key];
|
|
43849
43885
|
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
|
|
@@ -43861,8 +43897,8 @@ var ts;
|
|
|
43861
43897
|
}
|
|
43862
43898
|
return toSearchResult(/*value*/ undefined);
|
|
43863
43899
|
}
|
|
43864
|
-
for (var
|
|
43865
|
-
var elem = target_2[
|
|
43900
|
+
for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
|
|
43901
|
+
var elem = target_2[_b];
|
|
43866
43902
|
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
43867
43903
|
if (result) {
|
|
43868
43904
|
return result;
|
|
@@ -43880,6 +43916,128 @@ var ts;
|
|
|
43880
43916
|
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
43881
43917
|
}
|
|
43882
43918
|
return toSearchResult(/*value*/ undefined);
|
|
43919
|
+
function toAbsolutePath(path) {
|
|
43920
|
+
var _a, _b;
|
|
43921
|
+
if (path === undefined)
|
|
43922
|
+
return path;
|
|
43923
|
+
return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)));
|
|
43924
|
+
}
|
|
43925
|
+
function combineDirectoryPath(root, dir) {
|
|
43926
|
+
return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir));
|
|
43927
|
+
}
|
|
43928
|
+
function useCaseSensitiveFileNames() {
|
|
43929
|
+
return !state.host.useCaseSensitiveFileNames ? true :
|
|
43930
|
+
typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
|
|
43931
|
+
state.host.useCaseSensitiveFileNames();
|
|
43932
|
+
}
|
|
43933
|
+
function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) {
|
|
43934
|
+
var _a, _b, _c, _d;
|
|
43935
|
+
// Replace any references to outputs for files in the program with the input files to support package self-names used with outDir
|
|
43936
|
+
// 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
|
|
43937
|
+
// 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!
|
|
43938
|
+
// _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!).
|
|
43939
|
+
// 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.
|
|
43940
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
|
|
43941
|
+
&& (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
|
|
43942
|
+
&& finalPath.indexOf("/node_modules/") === -1
|
|
43943
|
+
&& (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) {
|
|
43944
|
+
// 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.
|
|
43945
|
+
// Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
|
|
43946
|
+
// `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.)
|
|
43947
|
+
var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames });
|
|
43948
|
+
var commonSourceDirGuesses = [];
|
|
43949
|
+
// A `rootDir` compiler option strongly indicates the root location
|
|
43950
|
+
// 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
|
|
43951
|
+
if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) {
|
|
43952
|
+
var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName));
|
|
43953
|
+
commonSourceDirGuesses.push(commonDir);
|
|
43954
|
+
}
|
|
43955
|
+
else if (state.requestContainingDirectory) {
|
|
43956
|
+
// However without either of those set we're in the dark. Let's say you have
|
|
43957
|
+
//
|
|
43958
|
+
// ./tools/index.ts
|
|
43959
|
+
// ./src/index.ts
|
|
43960
|
+
// ./dist/index.js
|
|
43961
|
+
// ./package.json <-- references ./dist/index.js
|
|
43962
|
+
// ./tsconfig.json <-- loads ./src/index.ts
|
|
43963
|
+
//
|
|
43964
|
+
// How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename?
|
|
43965
|
+
// 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
|
|
43966
|
+
// without more context.
|
|
43967
|
+
// 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
|
|
43968
|
+
// must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory
|
|
43969
|
+
var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts"));
|
|
43970
|
+
// And we can try every folder above the common folder for the request folder and the config/package base directory
|
|
43971
|
+
// This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't
|
|
43972
|
+
// know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything
|
|
43973
|
+
// else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then
|
|
43974
|
+
// be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup
|
|
43975
|
+
// logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all
|
|
43976
|
+
// internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first.
|
|
43977
|
+
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));
|
|
43978
|
+
commonSourceDirGuesses.push(commonDir);
|
|
43979
|
+
var fragment = ts.ensureTrailingDirectorySeparator(commonDir);
|
|
43980
|
+
while (fragment && fragment.length > 1) {
|
|
43981
|
+
var parts = ts.getPathComponents(fragment);
|
|
43982
|
+
parts.pop(); // remove a directory
|
|
43983
|
+
var commonDir_1 = ts.getPathFromPathComponents(parts);
|
|
43984
|
+
commonSourceDirGuesses.unshift(commonDir_1);
|
|
43985
|
+
fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
|
|
43986
|
+
}
|
|
43987
|
+
}
|
|
43988
|
+
if (commonSourceDirGuesses.length > 1) {
|
|
43989
|
+
state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
|
|
43990
|
+
? 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
|
|
43991
|
+
: 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
|
|
43992
|
+
packagePath));
|
|
43993
|
+
}
|
|
43994
|
+
for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
|
|
43995
|
+
var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
|
|
43996
|
+
var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
|
|
43997
|
+
for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) {
|
|
43998
|
+
var candidateDir = candidateDirectories_1[_e];
|
|
43999
|
+
if (ts.startsWith(finalPath, candidateDir)) {
|
|
44000
|
+
// 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
|
|
44001
|
+
var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
|
|
44002
|
+
var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment);
|
|
44003
|
+
var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */];
|
|
44004
|
+
for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) {
|
|
44005
|
+
var ext = jsAndDtsExtensions_1[_f];
|
|
44006
|
+
if (ts.fileExtensionIs(possibleInputBase, ext)) {
|
|
44007
|
+
var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase);
|
|
44008
|
+
for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) {
|
|
44009
|
+
var possibleExt = inputExts_1[_g];
|
|
44010
|
+
var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
|
|
44011
|
+
if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) ||
|
|
44012
|
+
(extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) {
|
|
44013
|
+
continue;
|
|
44014
|
+
}
|
|
44015
|
+
if (state.host.fileExists(possibleInputWithInputExtension)) {
|
|
44016
|
+
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state)));
|
|
44017
|
+
}
|
|
44018
|
+
}
|
|
44019
|
+
}
|
|
44020
|
+
}
|
|
44021
|
+
}
|
|
44022
|
+
}
|
|
44023
|
+
}
|
|
44024
|
+
}
|
|
44025
|
+
return undefined;
|
|
44026
|
+
function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) {
|
|
44027
|
+
var _a, _b;
|
|
44028
|
+
// Config file ouput paths are processed to be relative to the host's current directory, while
|
|
44029
|
+
// otherwise the paths are resolved relative to the common source dir the compiler puts together
|
|
44030
|
+
var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess;
|
|
44031
|
+
var candidateDirectories = [];
|
|
44032
|
+
if (state.compilerOptions.declarationDir) {
|
|
44033
|
+
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
|
|
44034
|
+
}
|
|
44035
|
+
if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) {
|
|
44036
|
+
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir)));
|
|
44037
|
+
}
|
|
44038
|
+
return candidateDirectories;
|
|
44039
|
+
}
|
|
44040
|
+
}
|
|
43883
44041
|
}
|
|
43884
44042
|
}
|
|
43885
44043
|
/* @internal */
|
|
@@ -44070,11 +44228,12 @@ var ts;
|
|
|
44070
44228
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
44071
44229
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
44072
44230
|
var failedLookupLocations = [];
|
|
44073
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
44074
44231
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
44232
|
+
var diagnostics = [];
|
|
44233
|
+
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); } };
|
|
44075
44234
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
44076
44235
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
44077
|
-
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache);
|
|
44236
|
+
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
44078
44237
|
function tryResolve(extensions) {
|
|
44079
44238
|
var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
|
|
44080
44239
|
if (resolvedUsingSettings) {
|
|
@@ -44117,9 +44276,10 @@ var ts;
|
|
|
44117
44276
|
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);
|
|
44118
44277
|
}
|
|
44119
44278
|
var failedLookupLocations = [];
|
|
44120
|
-
var
|
|
44279
|
+
var diagnostics = [];
|
|
44280
|
+
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); } };
|
|
44121
44281
|
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
44122
|
-
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
|
|
44282
|
+
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
44123
44283
|
}
|
|
44124
44284
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
44125
44285
|
/**
|
|
@@ -57983,7 +58143,8 @@ var ts;
|
|
|
57983
58143
|
if (symbol === globalThisSymbol) {
|
|
57984
58144
|
var varsOnly_1 = new ts.Map();
|
|
57985
58145
|
members.forEach(function (p) {
|
|
57986
|
-
|
|
58146
|
+
var _a;
|
|
58147
|
+
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))) {
|
|
57987
58148
|
varsOnly_1.set(p.escapedName, p);
|
|
57988
58149
|
}
|
|
57989
58150
|
});
|
|
@@ -86174,7 +86335,7 @@ var ts;
|
|
|
86174
86335
|
if (ts.isDeclaration(node)) {
|
|
86175
86336
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
86176
86337
|
var symbol = getSymbolOfNode(node);
|
|
86177
|
-
return getTypeOfSymbol(symbol);
|
|
86338
|
+
return symbol ? getTypeOfSymbol(symbol) : errorType;
|
|
86178
86339
|
}
|
|
86179
86340
|
if (isDeclarationNameOrImportPropertyName(node)) {
|
|
86180
86341
|
var symbol = getSymbolAtLocation(node);
|
|
@@ -116088,7 +116249,6 @@ var ts;
|
|
|
116088
116249
|
ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code,
|
|
116089
116250
|
ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code,
|
|
116090
116251
|
ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code,
|
|
116091
|
-
ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code,
|
|
116092
116252
|
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
|
|
116093
116253
|
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
|
116094
116254
|
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
|
@@ -116475,6 +116635,40 @@ var ts;
|
|
|
116475
116635
|
ts.performance.measure("Program", "beforeProgram", "afterProgram");
|
|
116476
116636
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116477
116637
|
return program;
|
|
116638
|
+
function addResolutionDiagnostics(list) {
|
|
116639
|
+
if (!list)
|
|
116640
|
+
return;
|
|
116641
|
+
for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
|
|
116642
|
+
var elem = list_3[_i];
|
|
116643
|
+
programDiagnostics.add(elem);
|
|
116644
|
+
}
|
|
116645
|
+
}
|
|
116646
|
+
function pullDiagnosticsFromCache(names, containingFile) {
|
|
116647
|
+
var _a;
|
|
116648
|
+
if (!moduleResolutionCache)
|
|
116649
|
+
return;
|
|
116650
|
+
var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
|
|
116651
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
116652
|
+
var containingDir = ts.getDirectoryPath(containingFileName);
|
|
116653
|
+
var redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
116654
|
+
var i = 0;
|
|
116655
|
+
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
116656
|
+
var n = names_4[_i];
|
|
116657
|
+
// 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
|
|
116658
|
+
var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
|
|
116659
|
+
var name = typeof n === "string" ? n : n.fileName;
|
|
116660
|
+
i++;
|
|
116661
|
+
// only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
|
|
116662
|
+
// (Since diagnostics are only issued via import or export map lookup)
|
|
116663
|
+
// This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
|
|
116664
|
+
// When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
|
|
116665
|
+
// APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
|
|
116666
|
+
if (ts.isExternalModuleNameRelative(name))
|
|
116667
|
+
continue;
|
|
116668
|
+
var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
|
|
116669
|
+
addResolutionDiagnostics(diags);
|
|
116670
|
+
}
|
|
116671
|
+
}
|
|
116478
116672
|
function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
|
|
116479
116673
|
if (!moduleNames.length)
|
|
116480
116674
|
return ts.emptyArray;
|
|
@@ -116486,6 +116680,7 @@ var ts;
|
|
|
116486
116680
|
ts.performance.mark("afterResolveModule");
|
|
116487
116681
|
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
116488
116682
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116683
|
+
pullDiagnosticsFromCache(moduleNames, containingFile);
|
|
116489
116684
|
return result;
|
|
116490
116685
|
}
|
|
116491
116686
|
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
|
|
@@ -120922,8 +121117,8 @@ var ts;
|
|
|
120922
121117
|
!!redirectedReference;
|
|
120923
121118
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
120924
121119
|
var i = 0;
|
|
120925
|
-
for (var _i = 0,
|
|
120926
|
-
var entry =
|
|
121120
|
+
for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
|
|
121121
|
+
var entry = names_5[_i];
|
|
120927
121122
|
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
120928
121123
|
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
120929
121124
|
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
@@ -128958,23 +129153,30 @@ var ts;
|
|
|
128958
129153
|
(_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
|
|
128959
129154
|
var compilerOptions = program.getCompilerOptions();
|
|
128960
129155
|
var moduleCount = 0;
|
|
128961
|
-
|
|
128962
|
-
|
|
128963
|
-
|
|
128964
|
-
|
|
128965
|
-
|
|
128966
|
-
|
|
128967
|
-
|
|
128968
|
-
|
|
128969
|
-
|
|
128970
|
-
|
|
128971
|
-
|
|
128972
|
-
checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
|
|
128973
|
-
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
|
|
128974
|
-
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
|
|
129156
|
+
try {
|
|
129157
|
+
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
129158
|
+
if (++moduleCount % 100 === 0)
|
|
129159
|
+
cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
|
|
129160
|
+
var seenExports = new ts.Map();
|
|
129161
|
+
var checker = program.getTypeChecker();
|
|
129162
|
+
var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
129163
|
+
// Note: I think we shouldn't actually see resolved module symbols here, but weird merges
|
|
129164
|
+
// can cause it to happen: see 'completionsImport_mergedReExport.ts'
|
|
129165
|
+
if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
|
|
129166
|
+
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
|
|
128975
129167
|
}
|
|
129168
|
+
checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
|
|
129169
|
+
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
|
|
129170
|
+
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
|
|
129171
|
+
}
|
|
129172
|
+
});
|
|
128976
129173
|
});
|
|
128977
|
-
}
|
|
129174
|
+
}
|
|
129175
|
+
catch (err) {
|
|
129176
|
+
// Ensure cache is reset if operation is cancelled
|
|
129177
|
+
cache.clear();
|
|
129178
|
+
throw err;
|
|
129179
|
+
}
|
|
128978
129180
|
(_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms");
|
|
128979
129181
|
return cache;
|
|
128980
129182
|
}
|
|
@@ -174398,10 +174600,11 @@ var ts;
|
|
|
174398
174600
|
var outputs = [];
|
|
174399
174601
|
combineProjectOutputWorker(projects, defaultProject, initialLocation,
|
|
174400
174602
|
/*isForRename*/ false, function (project, location, getMappedLocation) {
|
|
174603
|
+
var _a, _b;
|
|
174401
174604
|
logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
|
|
174402
174605
|
var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
|
|
174403
174606
|
if (projectOutputs) {
|
|
174404
|
-
var clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined;
|
|
174607
|
+
var clearIsDefinition = ((_b = (_a = projectOutputs[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined;
|
|
174405
174608
|
var _loop_9 = function (referencedSymbol) {
|
|
174406
174609
|
var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
|
|
174407
174610
|
var definition = mappedDefinitionFile === undefined ?
|
|
@@ -174411,8 +174614,8 @@ var ts;
|
|
|
174411
174614
|
symbolToAddTo = { definition: definition, references: [] };
|
|
174412
174615
|
outputs.push(symbolToAddTo);
|
|
174413
174616
|
}
|
|
174414
|
-
for (var
|
|
174415
|
-
var ref =
|
|
174617
|
+
for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
|
|
174618
|
+
var ref = _d[_c];
|
|
174416
174619
|
// If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
|
|
174417
174620
|
if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) {
|
|
174418
174621
|
if (clearIsDefinition) {
|