typescript 4.7.0-dev.20220505 → 4.8.0-dev.20220508
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/cs/diagnosticMessages.generated.json +12 -11
- package/lib/de/diagnosticMessages.generated.json +12 -11
- package/lib/es/diagnosticMessages.generated.json +12 -11
- package/lib/fr/diagnosticMessages.generated.json +12 -11
- package/lib/ja/diagnosticMessages.generated.json +12 -11
- package/lib/ko/diagnosticMessages.generated.json +12 -11
- package/lib/lib.es2022.d.ts +1 -0
- package/lib/lib.es2022.intl.d.ts +111 -0
- package/lib/pl/diagnosticMessages.generated.json +12 -11
- package/lib/pt-br/diagnosticMessages.generated.json +12 -11
- package/lib/ru/diagnosticMessages.generated.json +12 -11
- package/lib/tsc.js +222 -47
- package/lib/tsserver.js +294 -68
- package/lib/tsserverlibrary.d.ts +1 -1
- package/lib/tsserverlibrary.js +294 -68
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +290 -65
- package/lib/typescriptServices.d.ts +1 -1
- package/lib/typescriptServices.js +290 -65
- package/lib/typingsInstaller.js +268 -50
- package/lib/zh-cn/diagnosticMessages.generated.json +12 -11
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -96,11 +96,11 @@ var ts;
|
|
|
96
96
|
(function (ts) {
|
|
97
97
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
98
98
|
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
|
99
|
-
ts.versionMajorMinor = "4.
|
|
99
|
+
ts.versionMajorMinor = "4.8";
|
|
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.20220508";
|
|
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."),
|
|
@@ -8998,6 +9000,7 @@ var ts;
|
|
|
8998
9000
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
|
|
8999
9001
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
|
|
9000
9002
|
Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
9003
|
+
Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
9001
9004
|
The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
|
|
9002
9005
|
Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
|
|
9003
9006
|
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
|
|
@@ -18004,6 +18007,10 @@ var ts;
|
|
|
18004
18007
|
return indentStrings[1].length;
|
|
18005
18008
|
}
|
|
18006
18009
|
ts.getIndentSize = getIndentSize;
|
|
18010
|
+
function isNightly() {
|
|
18011
|
+
return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
|
|
18012
|
+
}
|
|
18013
|
+
ts.isNightly = isNightly;
|
|
18007
18014
|
function createTextWriter(newLine) {
|
|
18008
18015
|
var output;
|
|
18009
18016
|
var indent;
|
|
@@ -18234,6 +18241,16 @@ var ts;
|
|
|
18234
18241
|
".d.ts" /* Dts */;
|
|
18235
18242
|
}
|
|
18236
18243
|
ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
|
|
18244
|
+
/**
|
|
18245
|
+
* This function is an inverse of `getDeclarationEmitExtensionForPath`.
|
|
18246
|
+
*/
|
|
18247
|
+
function getPossibleOriginalInputExtensionForExtension(path) {
|
|
18248
|
+
return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] :
|
|
18249
|
+
ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] :
|
|
18250
|
+
ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] :
|
|
18251
|
+
[".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
|
|
18252
|
+
}
|
|
18253
|
+
ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension;
|
|
18237
18254
|
function outFile(options) {
|
|
18238
18255
|
return options.outFile || options.out;
|
|
18239
18256
|
}
|
|
@@ -32841,6 +32858,7 @@ var ts;
|
|
|
32841
32858
|
var startPos = scanner.getStartPos();
|
|
32842
32859
|
var result = parseListElement(kind, parseElement);
|
|
32843
32860
|
if (!result) {
|
|
32861
|
+
parsingContext = saveParsingContext;
|
|
32844
32862
|
return undefined;
|
|
32845
32863
|
}
|
|
32846
32864
|
list.push(result);
|
|
@@ -38955,6 +38973,7 @@ var ts;
|
|
|
38955
38973
|
["es2021.intl", "lib.es2021.intl.d.ts"],
|
|
38956
38974
|
["es2022.array", "lib.es2022.array.d.ts"],
|
|
38957
38975
|
["es2022.error", "lib.es2022.error.d.ts"],
|
|
38976
|
+
["es2022.intl", "lib.es2022.intl.d.ts"],
|
|
38958
38977
|
["es2022.object", "lib.es2022.object.d.ts"],
|
|
38959
38978
|
["es2022.string", "lib.es2022.string.d.ts"],
|
|
38960
38979
|
["esnext.array", "lib.es2022.array.d.ts"],
|
|
@@ -42153,7 +42172,7 @@ var ts;
|
|
|
42153
42172
|
ts.Debug.assert(ts.extensionIsTS(resolved.extension));
|
|
42154
42173
|
return { fileName: resolved.path, packageId: resolved.packageId };
|
|
42155
42174
|
}
|
|
42156
|
-
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
|
|
42175
|
+
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
|
|
42157
42176
|
var _a;
|
|
42158
42177
|
if (resultFromCache) {
|
|
42159
42178
|
(_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
|
|
@@ -42161,7 +42180,8 @@ var ts;
|
|
|
42161
42180
|
}
|
|
42162
42181
|
return {
|
|
42163
42182
|
resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
|
|
42164
|
-
failedLookupLocations: failedLookupLocations
|
|
42183
|
+
failedLookupLocations: failedLookupLocations,
|
|
42184
|
+
resolutionDiagnostics: diagnostics
|
|
42165
42185
|
};
|
|
42166
42186
|
}
|
|
42167
42187
|
function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
|
|
@@ -42362,7 +42382,18 @@ var ts;
|
|
|
42362
42382
|
features |= NodeResolutionFeatures.EsmMode;
|
|
42363
42383
|
}
|
|
42364
42384
|
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
42365
|
-
var
|
|
42385
|
+
var diagnostics = [];
|
|
42386
|
+
var moduleResolutionState = {
|
|
42387
|
+
compilerOptions: options,
|
|
42388
|
+
host: host,
|
|
42389
|
+
traceEnabled: traceEnabled,
|
|
42390
|
+
failedLookupLocations: failedLookupLocations,
|
|
42391
|
+
packageJsonInfoCache: cache,
|
|
42392
|
+
features: features,
|
|
42393
|
+
conditions: conditions,
|
|
42394
|
+
requestContainingDirectory: containingDirectory,
|
|
42395
|
+
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
42396
|
+
};
|
|
42366
42397
|
var resolved = primaryLookup();
|
|
42367
42398
|
var primary = true;
|
|
42368
42399
|
if (!resolved) {
|
|
@@ -42381,7 +42412,7 @@ var ts;
|
|
|
42381
42412
|
isExternalLibraryImport: pathContainsNodeModules(fileName),
|
|
42382
42413
|
};
|
|
42383
42414
|
}
|
|
42384
|
-
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
42415
|
+
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
|
|
42385
42416
|
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
42386
42417
|
if (traceEnabled)
|
|
42387
42418
|
traceResult(result);
|
|
@@ -42464,6 +42495,8 @@ var ts;
|
|
|
42464
42495
|
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
42465
42496
|
conditions: ts.emptyArray,
|
|
42466
42497
|
features: NodeResolutionFeatures.None,
|
|
42498
|
+
requestContainingDirectory: containingDirectory,
|
|
42499
|
+
reportDiagnostic: ts.noop
|
|
42467
42500
|
};
|
|
42468
42501
|
return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
|
|
42469
42502
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
@@ -43115,6 +43148,7 @@ var ts;
|
|
|
43115
43148
|
if (compilerOptions.noDtsResolution) {
|
|
43116
43149
|
conditions.pop();
|
|
43117
43150
|
}
|
|
43151
|
+
var diagnostics = [];
|
|
43118
43152
|
var state = {
|
|
43119
43153
|
compilerOptions: compilerOptions,
|
|
43120
43154
|
host: host,
|
|
@@ -43123,9 +43157,11 @@ var ts;
|
|
|
43123
43157
|
packageJsonInfoCache: cache,
|
|
43124
43158
|
features: features,
|
|
43125
43159
|
conditions: conditions,
|
|
43160
|
+
requestContainingDirectory: containingDirectory,
|
|
43161
|
+
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
43126
43162
|
};
|
|
43127
43163
|
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);
|
|
43164
|
+
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
43165
|
function tryResolve(extensions) {
|
|
43130
43166
|
var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
|
|
43131
43167
|
var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
|
|
@@ -43298,9 +43334,9 @@ var ts;
|
|
|
43298
43334
|
}
|
|
43299
43335
|
}
|
|
43300
43336
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
43301
|
-
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.
|
|
43337
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) {
|
|
43302
43338
|
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
43303
|
-
return result !== undefined ? { path: candidate, ext: ts.
|
|
43339
|
+
return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined;
|
|
43304
43340
|
}
|
|
43305
43341
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
43306
43342
|
}
|
|
@@ -43423,6 +43459,8 @@ var ts;
|
|
|
43423
43459
|
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
43424
43460
|
conditions: ["node", "require", "types"],
|
|
43425
43461
|
features: features,
|
|
43462
|
+
requestContainingDirectory: packageJsonInfo.packageDirectory,
|
|
43463
|
+
reportDiagnostic: ts.noop
|
|
43426
43464
|
};
|
|
43427
43465
|
var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
|
|
43428
43466
|
/*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
|
|
@@ -43509,6 +43547,8 @@ var ts;
|
|
|
43509
43547
|
packageJsonInfoCache: packageJsonInfoCache,
|
|
43510
43548
|
features: 0,
|
|
43511
43549
|
conditions: [],
|
|
43550
|
+
requestContainingDirectory: undefined,
|
|
43551
|
+
reportDiagnostic: ts.noop
|
|
43512
43552
|
};
|
|
43513
43553
|
var parts = ts.getPathComponents(fileName);
|
|
43514
43554
|
parts.pop();
|
|
@@ -43800,7 +43840,6 @@ var ts;
|
|
|
43800
43840
|
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
43801
43841
|
return loadModuleFromTargetImportOrExport;
|
|
43802
43842
|
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
43803
|
-
var _a, _b;
|
|
43804
43843
|
if (typeof target === "string") {
|
|
43805
43844
|
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
43806
43845
|
if (state.traceEnabled) {
|
|
@@ -43837,13 +43876,16 @@ var ts;
|
|
|
43837
43876
|
}
|
|
43838
43877
|
return toSearchResult(/*value*/ undefined);
|
|
43839
43878
|
}
|
|
43840
|
-
var finalPath =
|
|
43879
|
+
var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
|
|
43880
|
+
var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
|
|
43881
|
+
if (inputLink)
|
|
43882
|
+
return inputLink;
|
|
43841
43883
|
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
|
|
43842
43884
|
}
|
|
43843
43885
|
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
43844
43886
|
if (!Array.isArray(target)) {
|
|
43845
|
-
for (var _i = 0,
|
|
43846
|
-
var key =
|
|
43887
|
+
for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
|
|
43888
|
+
var key = _a[_i];
|
|
43847
43889
|
if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
|
|
43848
43890
|
var subTarget = target[key];
|
|
43849
43891
|
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
|
|
@@ -43861,8 +43903,8 @@ var ts;
|
|
|
43861
43903
|
}
|
|
43862
43904
|
return toSearchResult(/*value*/ undefined);
|
|
43863
43905
|
}
|
|
43864
|
-
for (var
|
|
43865
|
-
var elem = target_2[
|
|
43906
|
+
for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
|
|
43907
|
+
var elem = target_2[_b];
|
|
43866
43908
|
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
43867
43909
|
if (result) {
|
|
43868
43910
|
return result;
|
|
@@ -43880,6 +43922,128 @@ var ts;
|
|
|
43880
43922
|
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
43881
43923
|
}
|
|
43882
43924
|
return toSearchResult(/*value*/ undefined);
|
|
43925
|
+
function toAbsolutePath(path) {
|
|
43926
|
+
var _a, _b;
|
|
43927
|
+
if (path === undefined)
|
|
43928
|
+
return path;
|
|
43929
|
+
return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)));
|
|
43930
|
+
}
|
|
43931
|
+
function combineDirectoryPath(root, dir) {
|
|
43932
|
+
return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir));
|
|
43933
|
+
}
|
|
43934
|
+
function useCaseSensitiveFileNames() {
|
|
43935
|
+
return !state.host.useCaseSensitiveFileNames ? true :
|
|
43936
|
+
typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
|
|
43937
|
+
state.host.useCaseSensitiveFileNames();
|
|
43938
|
+
}
|
|
43939
|
+
function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) {
|
|
43940
|
+
var _a, _b, _c, _d;
|
|
43941
|
+
// Replace any references to outputs for files in the program with the input files to support package self-names used with outDir
|
|
43942
|
+
// 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
|
|
43943
|
+
// 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!
|
|
43944
|
+
// _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!).
|
|
43945
|
+
// 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.
|
|
43946
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
|
|
43947
|
+
&& (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
|
|
43948
|
+
&& finalPath.indexOf("/node_modules/") === -1
|
|
43949
|
+
&& (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) {
|
|
43950
|
+
// 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.
|
|
43951
|
+
// Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
|
|
43952
|
+
// `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.)
|
|
43953
|
+
var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames });
|
|
43954
|
+
var commonSourceDirGuesses = [];
|
|
43955
|
+
// A `rootDir` compiler option strongly indicates the root location
|
|
43956
|
+
// 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
|
|
43957
|
+
if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) {
|
|
43958
|
+
var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName));
|
|
43959
|
+
commonSourceDirGuesses.push(commonDir);
|
|
43960
|
+
}
|
|
43961
|
+
else if (state.requestContainingDirectory) {
|
|
43962
|
+
// However without either of those set we're in the dark. Let's say you have
|
|
43963
|
+
//
|
|
43964
|
+
// ./tools/index.ts
|
|
43965
|
+
// ./src/index.ts
|
|
43966
|
+
// ./dist/index.js
|
|
43967
|
+
// ./package.json <-- references ./dist/index.js
|
|
43968
|
+
// ./tsconfig.json <-- loads ./src/index.ts
|
|
43969
|
+
//
|
|
43970
|
+
// How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename?
|
|
43971
|
+
// 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
|
|
43972
|
+
// without more context.
|
|
43973
|
+
// 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
|
|
43974
|
+
// must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory
|
|
43975
|
+
var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts"));
|
|
43976
|
+
// And we can try every folder above the common folder for the request folder and the config/package base directory
|
|
43977
|
+
// This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't
|
|
43978
|
+
// know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything
|
|
43979
|
+
// else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then
|
|
43980
|
+
// be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup
|
|
43981
|
+
// logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all
|
|
43982
|
+
// internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first.
|
|
43983
|
+
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));
|
|
43984
|
+
commonSourceDirGuesses.push(commonDir);
|
|
43985
|
+
var fragment = ts.ensureTrailingDirectorySeparator(commonDir);
|
|
43986
|
+
while (fragment && fragment.length > 1) {
|
|
43987
|
+
var parts = ts.getPathComponents(fragment);
|
|
43988
|
+
parts.pop(); // remove a directory
|
|
43989
|
+
var commonDir_1 = ts.getPathFromPathComponents(parts);
|
|
43990
|
+
commonSourceDirGuesses.unshift(commonDir_1);
|
|
43991
|
+
fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
|
|
43992
|
+
}
|
|
43993
|
+
}
|
|
43994
|
+
if (commonSourceDirGuesses.length > 1) {
|
|
43995
|
+
state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
|
|
43996
|
+
? 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
|
|
43997
|
+
: 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
|
|
43998
|
+
packagePath));
|
|
43999
|
+
}
|
|
44000
|
+
for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
|
|
44001
|
+
var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
|
|
44002
|
+
var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
|
|
44003
|
+
for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) {
|
|
44004
|
+
var candidateDir = candidateDirectories_1[_e];
|
|
44005
|
+
if (ts.startsWith(finalPath, candidateDir)) {
|
|
44006
|
+
// 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
|
|
44007
|
+
var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
|
|
44008
|
+
var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment);
|
|
44009
|
+
var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */];
|
|
44010
|
+
for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) {
|
|
44011
|
+
var ext = jsAndDtsExtensions_1[_f];
|
|
44012
|
+
if (ts.fileExtensionIs(possibleInputBase, ext)) {
|
|
44013
|
+
var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase);
|
|
44014
|
+
for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) {
|
|
44015
|
+
var possibleExt = inputExts_1[_g];
|
|
44016
|
+
var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
|
|
44017
|
+
if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) ||
|
|
44018
|
+
(extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) {
|
|
44019
|
+
continue;
|
|
44020
|
+
}
|
|
44021
|
+
if (state.host.fileExists(possibleInputWithInputExtension)) {
|
|
44022
|
+
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state)));
|
|
44023
|
+
}
|
|
44024
|
+
}
|
|
44025
|
+
}
|
|
44026
|
+
}
|
|
44027
|
+
}
|
|
44028
|
+
}
|
|
44029
|
+
}
|
|
44030
|
+
}
|
|
44031
|
+
return undefined;
|
|
44032
|
+
function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) {
|
|
44033
|
+
var _a, _b;
|
|
44034
|
+
// Config file ouput paths are processed to be relative to the host's current directory, while
|
|
44035
|
+
// otherwise the paths are resolved relative to the common source dir the compiler puts together
|
|
44036
|
+
var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess;
|
|
44037
|
+
var candidateDirectories = [];
|
|
44038
|
+
if (state.compilerOptions.declarationDir) {
|
|
44039
|
+
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
|
|
44040
|
+
}
|
|
44041
|
+
if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) {
|
|
44042
|
+
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir)));
|
|
44043
|
+
}
|
|
44044
|
+
return candidateDirectories;
|
|
44045
|
+
}
|
|
44046
|
+
}
|
|
43883
44047
|
}
|
|
43884
44048
|
}
|
|
43885
44049
|
/* @internal */
|
|
@@ -44070,11 +44234,12 @@ var ts;
|
|
|
44070
44234
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
44071
44235
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
44072
44236
|
var failedLookupLocations = [];
|
|
44073
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
44074
44237
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
44238
|
+
var diagnostics = [];
|
|
44239
|
+
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
44240
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
44076
44241
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
44077
|
-
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache);
|
|
44242
|
+
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
44078
44243
|
function tryResolve(extensions) {
|
|
44079
44244
|
var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
|
|
44080
44245
|
if (resolvedUsingSettings) {
|
|
@@ -44117,9 +44282,10 @@ var ts;
|
|
|
44117
44282
|
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
44283
|
}
|
|
44119
44284
|
var failedLookupLocations = [];
|
|
44120
|
-
var
|
|
44285
|
+
var diagnostics = [];
|
|
44286
|
+
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
44287
|
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
44122
|
-
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
|
|
44288
|
+
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
44123
44289
|
}
|
|
44124
44290
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
44125
44291
|
/**
|
|
@@ -57983,7 +58149,8 @@ var ts;
|
|
|
57983
58149
|
if (symbol === globalThisSymbol) {
|
|
57984
58150
|
var varsOnly_1 = new ts.Map();
|
|
57985
58151
|
members.forEach(function (p) {
|
|
57986
|
-
|
|
58152
|
+
var _a;
|
|
58153
|
+
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
58154
|
varsOnly_1.set(p.escapedName, p);
|
|
57988
58155
|
}
|
|
57989
58156
|
});
|
|
@@ -84834,6 +85001,9 @@ var ts;
|
|
|
84834
85001
|
var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
84835
85002
|
var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
|
|
84836
85003
|
if (validForTypeAssertions && override) {
|
|
85004
|
+
if (!ts.isNightly()) {
|
|
85005
|
+
grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
|
|
85006
|
+
}
|
|
84837
85007
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
84838
85008
|
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
84839
85009
|
}
|
|
@@ -86174,7 +86344,7 @@ var ts;
|
|
|
86174
86344
|
if (ts.isDeclaration(node)) {
|
|
86175
86345
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
86176
86346
|
var symbol = getSymbolOfNode(node);
|
|
86177
|
-
return getTypeOfSymbol(symbol);
|
|
86347
|
+
return symbol ? getTypeOfSymbol(symbol) : errorType;
|
|
86178
86348
|
}
|
|
86179
86349
|
if (isDeclarationNameOrImportPropertyName(node)) {
|
|
86180
86350
|
var symbol = getSymbolAtLocation(node);
|
|
@@ -108232,34 +108402,44 @@ var ts;
|
|
|
108232
108402
|
if (!decl.importClause) {
|
|
108233
108403
|
// import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc)
|
|
108234
108404
|
return factory.updateImportDeclaration(decl,
|
|
108235
|
-
/*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108405
|
+
/*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108236
108406
|
}
|
|
108237
108407
|
// The `importClause` visibility corresponds to the default's visibility.
|
|
108238
108408
|
var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
|
|
108239
108409
|
if (!decl.importClause.namedBindings) {
|
|
108240
108410
|
// No named bindings (either namespace or list), meaning the import is just default or should be elided
|
|
108241
108411
|
return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding,
|
|
108242
|
-
/*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108412
|
+
/*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108243
108413
|
}
|
|
108244
108414
|
if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) {
|
|
108245
108415
|
// Namespace import (optionally with visible default)
|
|
108246
108416
|
var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined;
|
|
108247
|
-
return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108417
|
+
return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined;
|
|
108248
108418
|
}
|
|
108249
108419
|
// Named imports (optionally with visible default)
|
|
108250
108420
|
var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
|
|
108251
108421
|
if ((bindingList && bindingList.length) || visibleDefaultBinding) {
|
|
108252
108422
|
return factory.updateImportDeclaration(decl,
|
|
108253
|
-
/*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108423
|
+
/*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108254
108424
|
}
|
|
108255
108425
|
// Augmentation of export depends on import
|
|
108256
108426
|
if (resolver.isImportRequiredByAugmentation(decl)) {
|
|
108257
108427
|
return factory.updateImportDeclaration(decl,
|
|
108258
108428
|
/*decorators*/ undefined, decl.modifiers,
|
|
108259
|
-
/*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108429
|
+
/*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108260
108430
|
}
|
|
108261
108431
|
// Nothing visible
|
|
108262
108432
|
}
|
|
108433
|
+
function getResolutionModeOverrideForClauseInNightly(assertClause) {
|
|
108434
|
+
var mode = ts.getResolutionModeOverrideForClause(assertClause);
|
|
108435
|
+
if (mode !== undefined) {
|
|
108436
|
+
if (!ts.isNightly()) {
|
|
108437
|
+
context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
|
|
108438
|
+
}
|
|
108439
|
+
return assertClause;
|
|
108440
|
+
}
|
|
108441
|
+
return undefined;
|
|
108442
|
+
}
|
|
108263
108443
|
function transformAndReplaceLatePaintedStatements(statements) {
|
|
108264
108444
|
// This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during
|
|
108265
108445
|
// error handling which must now be included in the output and themselves checked for errors.
|
|
@@ -116088,7 +116268,6 @@ var ts;
|
|
|
116088
116268
|
ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code,
|
|
116089
116269
|
ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code,
|
|
116090
116270
|
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
116271
|
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
|
|
116093
116272
|
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
|
116094
116273
|
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
|
@@ -116475,6 +116654,40 @@ var ts;
|
|
|
116475
116654
|
ts.performance.measure("Program", "beforeProgram", "afterProgram");
|
|
116476
116655
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116477
116656
|
return program;
|
|
116657
|
+
function addResolutionDiagnostics(list) {
|
|
116658
|
+
if (!list)
|
|
116659
|
+
return;
|
|
116660
|
+
for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
|
|
116661
|
+
var elem = list_3[_i];
|
|
116662
|
+
programDiagnostics.add(elem);
|
|
116663
|
+
}
|
|
116664
|
+
}
|
|
116665
|
+
function pullDiagnosticsFromCache(names, containingFile) {
|
|
116666
|
+
var _a;
|
|
116667
|
+
if (!moduleResolutionCache)
|
|
116668
|
+
return;
|
|
116669
|
+
var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
|
|
116670
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
116671
|
+
var containingDir = ts.getDirectoryPath(containingFileName);
|
|
116672
|
+
var redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
116673
|
+
var i = 0;
|
|
116674
|
+
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
116675
|
+
var n = names_4[_i];
|
|
116676
|
+
// 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
|
|
116677
|
+
var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
|
|
116678
|
+
var name = typeof n === "string" ? n : n.fileName;
|
|
116679
|
+
i++;
|
|
116680
|
+
// only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
|
|
116681
|
+
// (Since diagnostics are only issued via import or export map lookup)
|
|
116682
|
+
// This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
|
|
116683
|
+
// When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
|
|
116684
|
+
// APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
|
|
116685
|
+
if (ts.isExternalModuleNameRelative(name))
|
|
116686
|
+
continue;
|
|
116687
|
+
var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
|
|
116688
|
+
addResolutionDiagnostics(diags);
|
|
116689
|
+
}
|
|
116690
|
+
}
|
|
116478
116691
|
function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
|
|
116479
116692
|
if (!moduleNames.length)
|
|
116480
116693
|
return ts.emptyArray;
|
|
@@ -116486,6 +116699,7 @@ var ts;
|
|
|
116486
116699
|
ts.performance.mark("afterResolveModule");
|
|
116487
116700
|
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
116488
116701
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116702
|
+
pullDiagnosticsFromCache(moduleNames, containingFile);
|
|
116489
116703
|
return result;
|
|
116490
116704
|
}
|
|
116491
116705
|
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
|
|
@@ -120922,8 +121136,8 @@ var ts;
|
|
|
120922
121136
|
!!redirectedReference;
|
|
120923
121137
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
120924
121138
|
var i = 0;
|
|
120925
|
-
for (var _i = 0,
|
|
120926
|
-
var entry =
|
|
121139
|
+
for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
|
|
121140
|
+
var entry = names_5[_i];
|
|
120927
121141
|
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
120928
121142
|
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
120929
121143
|
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
@@ -121533,14 +121747,14 @@ var ts;
|
|
|
121533
121747
|
if (options === void 0) { options = {}; }
|
|
121534
121748
|
var info = getInfo(importingSourceFile.path, host);
|
|
121535
121749
|
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
|
|
121536
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121750
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121537
121751
|
}
|
|
121538
121752
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
121539
121753
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
|
|
121540
121754
|
if (options === void 0) { options = {}; }
|
|
121541
121755
|
var info = getInfo(importingSourceFileName, host);
|
|
121542
121756
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
121543
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121757
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121544
121758
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
121545
121759
|
}
|
|
121546
121760
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
@@ -121616,7 +121830,7 @@ var ts;
|
|
|
121616
121830
|
var relativeSpecifiers;
|
|
121617
121831
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
121618
121832
|
var modulePath = modulePaths_1[_i];
|
|
121619
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
121833
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
121620
121834
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
121621
121835
|
if (specifier && modulePath.isRedirect) {
|
|
121622
121836
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -122009,7 +122223,7 @@ var ts;
|
|
|
122009
122223
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
122010
122224
|
: ts.removeFileExtension(relativePath);
|
|
122011
122225
|
}
|
|
122012
|
-
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
|
|
122226
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
122013
122227
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
122014
122228
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
122015
122229
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -122023,8 +122237,9 @@ var ts;
|
|
|
122023
122237
|
var moduleSpecifier = path;
|
|
122024
122238
|
var isPackageRootPath = false;
|
|
122025
122239
|
if (!packageNameOnly) {
|
|
122240
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
122026
122241
|
var packageRootIndex = parts.packageRootIndex;
|
|
122027
|
-
var
|
|
122242
|
+
var moduleFileName = void 0;
|
|
122028
122243
|
while (true) {
|
|
122029
122244
|
// If the module could be imported by a directory name, use that directory's name
|
|
122030
122245
|
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
@@ -122041,12 +122256,12 @@ var ts;
|
|
|
122041
122256
|
isPackageRootPath = true;
|
|
122042
122257
|
break;
|
|
122043
122258
|
}
|
|
122044
|
-
if (!
|
|
122045
|
-
|
|
122259
|
+
if (!moduleFileName)
|
|
122260
|
+
moduleFileName = moduleFileToTry;
|
|
122046
122261
|
// try with next level of directory
|
|
122047
122262
|
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
|
|
122048
122263
|
if (packageRootIndex === -1) {
|
|
122049
|
-
moduleSpecifier =
|
|
122264
|
+
moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
|
|
122050
122265
|
break;
|
|
122051
122266
|
}
|
|
122052
122267
|
}
|
|
@@ -122104,7 +122319,7 @@ var ts;
|
|
|
122104
122319
|
}
|
|
122105
122320
|
}
|
|
122106
122321
|
// If the file is the main module, it can be imported by the package name
|
|
122107
|
-
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
|
122322
|
+
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
122108
122323
|
if (ts.isString(mainFileRelative)) {
|
|
122109
122324
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
122110
122325
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
@@ -122112,17 +122327,14 @@ var ts;
|
|
|
122112
122327
|
}
|
|
122113
122328
|
}
|
|
122114
122329
|
}
|
|
122115
|
-
|
|
122116
|
-
|
|
122117
|
-
|
|
122118
|
-
|
|
122119
|
-
|
|
122120
|
-
|
|
122121
|
-
// IFF there is not _also_ a file by the same name
|
|
122122
|
-
if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
|
|
122123
|
-
return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
|
|
122330
|
+
else {
|
|
122331
|
+
// No package.json exists; an index.js will still resolve as the package name
|
|
122332
|
+
var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
|
|
122333
|
+
if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
|
|
122334
|
+
return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
|
|
122335
|
+
}
|
|
122124
122336
|
}
|
|
122125
|
-
return
|
|
122337
|
+
return { moduleFileToTry: moduleFileToTry };
|
|
122126
122338
|
}
|
|
122127
122339
|
}
|
|
122128
122340
|
function tryGetAnyFileFromPath(host, path) {
|
|
@@ -122144,7 +122356,7 @@ var ts;
|
|
|
122144
122356
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
122145
122357
|
});
|
|
122146
122358
|
}
|
|
122147
|
-
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
122359
|
+
function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
122148
122360
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122149
122361
|
return fileName;
|
|
122150
122362
|
var noExtension = ts.removeFileExtension(fileName);
|
|
@@ -122152,7 +122364,13 @@ var ts;
|
|
|
122152
122364
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122153
122365
|
switch (ending) {
|
|
122154
122366
|
case 0 /* Minimal */:
|
|
122155
|
-
|
|
122367
|
+
var withoutIndex = ts.removeSuffix(noExtension, "/index");
|
|
122368
|
+
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
122369
|
+
// Can't remove index if there's a file by the same name as the directory.
|
|
122370
|
+
// Probably more callers should pass `host` so we can determine this?
|
|
122371
|
+
return noExtension;
|
|
122372
|
+
}
|
|
122373
|
+
return withoutIndex;
|
|
122156
122374
|
case 1 /* Index */:
|
|
122157
122375
|
return noExtension;
|
|
122158
122376
|
case 2 /* JsExtension */:
|
|
@@ -128958,23 +129176,30 @@ var ts;
|
|
|
128958
129176
|
(_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
|
|
128959
129177
|
var compilerOptions = program.getCompilerOptions();
|
|
128960
129178
|
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);
|
|
129179
|
+
try {
|
|
129180
|
+
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
129181
|
+
if (++moduleCount % 100 === 0)
|
|
129182
|
+
cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
|
|
129183
|
+
var seenExports = new ts.Map();
|
|
129184
|
+
var checker = program.getTypeChecker();
|
|
129185
|
+
var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
129186
|
+
// Note: I think we shouldn't actually see resolved module symbols here, but weird merges
|
|
129187
|
+
// can cause it to happen: see 'completionsImport_mergedReExport.ts'
|
|
129188
|
+
if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
|
|
129189
|
+
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
|
|
128975
129190
|
}
|
|
129191
|
+
checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
|
|
129192
|
+
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
|
|
129193
|
+
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
|
|
129194
|
+
}
|
|
129195
|
+
});
|
|
128976
129196
|
});
|
|
128977
|
-
}
|
|
129197
|
+
}
|
|
129198
|
+
catch (err) {
|
|
129199
|
+
// Ensure cache is reset if operation is cancelled
|
|
129200
|
+
cache.clear();
|
|
129201
|
+
throw err;
|
|
129202
|
+
}
|
|
128978
129203
|
(_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms");
|
|
128979
129204
|
return cache;
|
|
128980
129205
|
}
|
|
@@ -174398,10 +174623,11 @@ var ts;
|
|
|
174398
174623
|
var outputs = [];
|
|
174399
174624
|
combineProjectOutputWorker(projects, defaultProject, initialLocation,
|
|
174400
174625
|
/*isForRename*/ false, function (project, location, getMappedLocation) {
|
|
174626
|
+
var _a, _b;
|
|
174401
174627
|
logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
|
|
174402
174628
|
var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
|
|
174403
174629
|
if (projectOutputs) {
|
|
174404
|
-
var clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined;
|
|
174630
|
+
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
174631
|
var _loop_9 = function (referencedSymbol) {
|
|
174406
174632
|
var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
|
|
174407
174633
|
var definition = mappedDefinitionFile === undefined ?
|
|
@@ -174411,8 +174637,8 @@ var ts;
|
|
|
174411
174637
|
symbolToAddTo = { definition: definition, references: [] };
|
|
174412
174638
|
outputs.push(symbolToAddTo);
|
|
174413
174639
|
}
|
|
174414
|
-
for (var
|
|
174415
|
-
var ref =
|
|
174640
|
+
for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
|
|
174641
|
+
var ref = _d[_c];
|
|
174416
174642
|
// If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
|
|
174417
174643
|
if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) {
|
|
174418
174644
|
if (clearIsDefinition) {
|