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/typescript.js
CHANGED
|
@@ -290,11 +290,11 @@ var ts;
|
|
|
290
290
|
(function (ts) {
|
|
291
291
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
292
292
|
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
|
293
|
-
ts.versionMajorMinor = "4.
|
|
293
|
+
ts.versionMajorMinor = "4.8";
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220508";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8603,6 +8603,8 @@ var ts;
|
|
|
8603
8603
|
Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8604
8604
|
The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
|
|
8605
8605
|
The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
|
|
8606
|
+
The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8607
|
+
The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8606
8608
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8607
8609
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
8608
8610
|
Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -9192,6 +9194,7 @@ var ts;
|
|
|
9192
9194
|
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}'."),
|
|
9193
9195
|
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}'?"),
|
|
9194
9196
|
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'."),
|
|
9197
|
+
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'."),
|
|
9195
9198
|
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."),
|
|
9196
9199
|
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."),
|
|
9197
9200
|
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}'."),
|
|
@@ -18198,6 +18201,10 @@ var ts;
|
|
|
18198
18201
|
return indentStrings[1].length;
|
|
18199
18202
|
}
|
|
18200
18203
|
ts.getIndentSize = getIndentSize;
|
|
18204
|
+
function isNightly() {
|
|
18205
|
+
return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
|
|
18206
|
+
}
|
|
18207
|
+
ts.isNightly = isNightly;
|
|
18201
18208
|
function createTextWriter(newLine) {
|
|
18202
18209
|
var output;
|
|
18203
18210
|
var indent;
|
|
@@ -18428,6 +18435,16 @@ var ts;
|
|
|
18428
18435
|
".d.ts" /* Dts */;
|
|
18429
18436
|
}
|
|
18430
18437
|
ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
|
|
18438
|
+
/**
|
|
18439
|
+
* This function is an inverse of `getDeclarationEmitExtensionForPath`.
|
|
18440
|
+
*/
|
|
18441
|
+
function getPossibleOriginalInputExtensionForExtension(path) {
|
|
18442
|
+
return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] :
|
|
18443
|
+
ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] :
|
|
18444
|
+
ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] :
|
|
18445
|
+
[".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
|
|
18446
|
+
}
|
|
18447
|
+
ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension;
|
|
18431
18448
|
function outFile(options) {
|
|
18432
18449
|
return options.outFile || options.out;
|
|
18433
18450
|
}
|
|
@@ -33035,6 +33052,7 @@ var ts;
|
|
|
33035
33052
|
var startPos = scanner.getStartPos();
|
|
33036
33053
|
var result = parseListElement(kind, parseElement);
|
|
33037
33054
|
if (!result) {
|
|
33055
|
+
parsingContext = saveParsingContext;
|
|
33038
33056
|
return undefined;
|
|
33039
33057
|
}
|
|
33040
33058
|
list.push(result);
|
|
@@ -39149,6 +39167,7 @@ var ts;
|
|
|
39149
39167
|
["es2021.intl", "lib.es2021.intl.d.ts"],
|
|
39150
39168
|
["es2022.array", "lib.es2022.array.d.ts"],
|
|
39151
39169
|
["es2022.error", "lib.es2022.error.d.ts"],
|
|
39170
|
+
["es2022.intl", "lib.es2022.intl.d.ts"],
|
|
39152
39171
|
["es2022.object", "lib.es2022.object.d.ts"],
|
|
39153
39172
|
["es2022.string", "lib.es2022.string.d.ts"],
|
|
39154
39173
|
["esnext.array", "lib.es2022.array.d.ts"],
|
|
@@ -42347,7 +42366,7 @@ var ts;
|
|
|
42347
42366
|
ts.Debug.assert(ts.extensionIsTS(resolved.extension));
|
|
42348
42367
|
return { fileName: resolved.path, packageId: resolved.packageId };
|
|
42349
42368
|
}
|
|
42350
|
-
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
|
|
42369
|
+
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
|
|
42351
42370
|
var _a;
|
|
42352
42371
|
if (resultFromCache) {
|
|
42353
42372
|
(_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
|
|
@@ -42355,7 +42374,8 @@ var ts;
|
|
|
42355
42374
|
}
|
|
42356
42375
|
return {
|
|
42357
42376
|
resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
|
|
42358
|
-
failedLookupLocations: failedLookupLocations
|
|
42377
|
+
failedLookupLocations: failedLookupLocations,
|
|
42378
|
+
resolutionDiagnostics: diagnostics
|
|
42359
42379
|
};
|
|
42360
42380
|
}
|
|
42361
42381
|
function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
|
|
@@ -42556,7 +42576,18 @@ var ts;
|
|
|
42556
42576
|
features |= NodeResolutionFeatures.EsmMode;
|
|
42557
42577
|
}
|
|
42558
42578
|
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
42559
|
-
var
|
|
42579
|
+
var diagnostics = [];
|
|
42580
|
+
var moduleResolutionState = {
|
|
42581
|
+
compilerOptions: options,
|
|
42582
|
+
host: host,
|
|
42583
|
+
traceEnabled: traceEnabled,
|
|
42584
|
+
failedLookupLocations: failedLookupLocations,
|
|
42585
|
+
packageJsonInfoCache: cache,
|
|
42586
|
+
features: features,
|
|
42587
|
+
conditions: conditions,
|
|
42588
|
+
requestContainingDirectory: containingDirectory,
|
|
42589
|
+
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
42590
|
+
};
|
|
42560
42591
|
var resolved = primaryLookup();
|
|
42561
42592
|
var primary = true;
|
|
42562
42593
|
if (!resolved) {
|
|
@@ -42575,7 +42606,7 @@ var ts;
|
|
|
42575
42606
|
isExternalLibraryImport: pathContainsNodeModules(fileName),
|
|
42576
42607
|
};
|
|
42577
42608
|
}
|
|
42578
|
-
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
42609
|
+
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
|
|
42579
42610
|
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
42580
42611
|
if (traceEnabled)
|
|
42581
42612
|
traceResult(result);
|
|
@@ -42658,6 +42689,8 @@ var ts;
|
|
|
42658
42689
|
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
42659
42690
|
conditions: ts.emptyArray,
|
|
42660
42691
|
features: NodeResolutionFeatures.None,
|
|
42692
|
+
requestContainingDirectory: containingDirectory,
|
|
42693
|
+
reportDiagnostic: ts.noop
|
|
42661
42694
|
};
|
|
42662
42695
|
return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
|
|
42663
42696
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
@@ -43309,6 +43342,7 @@ var ts;
|
|
|
43309
43342
|
if (compilerOptions.noDtsResolution) {
|
|
43310
43343
|
conditions.pop();
|
|
43311
43344
|
}
|
|
43345
|
+
var diagnostics = [];
|
|
43312
43346
|
var state = {
|
|
43313
43347
|
compilerOptions: compilerOptions,
|
|
43314
43348
|
host: host,
|
|
@@ -43317,9 +43351,11 @@ var ts;
|
|
|
43317
43351
|
packageJsonInfoCache: cache,
|
|
43318
43352
|
features: features,
|
|
43319
43353
|
conditions: conditions,
|
|
43354
|
+
requestContainingDirectory: containingDirectory,
|
|
43355
|
+
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
43320
43356
|
};
|
|
43321
43357
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
43322
|
-
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
|
|
43358
|
+
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
43323
43359
|
function tryResolve(extensions) {
|
|
43324
43360
|
var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
|
|
43325
43361
|
var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
|
|
@@ -43492,9 +43528,9 @@ var ts;
|
|
|
43492
43528
|
}
|
|
43493
43529
|
}
|
|
43494
43530
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
43495
|
-
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.
|
|
43531
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) {
|
|
43496
43532
|
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
43497
|
-
return result !== undefined ? { path: candidate, ext: ts.
|
|
43533
|
+
return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined;
|
|
43498
43534
|
}
|
|
43499
43535
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
43500
43536
|
}
|
|
@@ -43617,6 +43653,8 @@ var ts;
|
|
|
43617
43653
|
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
43618
43654
|
conditions: ["node", "require", "types"],
|
|
43619
43655
|
features: features,
|
|
43656
|
+
requestContainingDirectory: packageJsonInfo.packageDirectory,
|
|
43657
|
+
reportDiagnostic: ts.noop
|
|
43620
43658
|
};
|
|
43621
43659
|
var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
|
|
43622
43660
|
/*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
|
|
@@ -43703,6 +43741,8 @@ var ts;
|
|
|
43703
43741
|
packageJsonInfoCache: packageJsonInfoCache,
|
|
43704
43742
|
features: 0,
|
|
43705
43743
|
conditions: [],
|
|
43744
|
+
requestContainingDirectory: undefined,
|
|
43745
|
+
reportDiagnostic: ts.noop
|
|
43706
43746
|
};
|
|
43707
43747
|
var parts = ts.getPathComponents(fileName);
|
|
43708
43748
|
parts.pop();
|
|
@@ -43994,7 +44034,6 @@ var ts;
|
|
|
43994
44034
|
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
43995
44035
|
return loadModuleFromTargetImportOrExport;
|
|
43996
44036
|
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
43997
|
-
var _a, _b;
|
|
43998
44037
|
if (typeof target === "string") {
|
|
43999
44038
|
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
44000
44039
|
if (state.traceEnabled) {
|
|
@@ -44031,13 +44070,16 @@ var ts;
|
|
|
44031
44070
|
}
|
|
44032
44071
|
return toSearchResult(/*value*/ undefined);
|
|
44033
44072
|
}
|
|
44034
|
-
var finalPath =
|
|
44073
|
+
var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
|
|
44074
|
+
var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
|
|
44075
|
+
if (inputLink)
|
|
44076
|
+
return inputLink;
|
|
44035
44077
|
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
|
|
44036
44078
|
}
|
|
44037
44079
|
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
44038
44080
|
if (!Array.isArray(target)) {
|
|
44039
|
-
for (var _i = 0,
|
|
44040
|
-
var key =
|
|
44081
|
+
for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
|
|
44082
|
+
var key = _a[_i];
|
|
44041
44083
|
if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
|
|
44042
44084
|
var subTarget = target[key];
|
|
44043
44085
|
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
|
|
@@ -44055,8 +44097,8 @@ var ts;
|
|
|
44055
44097
|
}
|
|
44056
44098
|
return toSearchResult(/*value*/ undefined);
|
|
44057
44099
|
}
|
|
44058
|
-
for (var
|
|
44059
|
-
var elem = target_2[
|
|
44100
|
+
for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
|
|
44101
|
+
var elem = target_2[_b];
|
|
44060
44102
|
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
44061
44103
|
if (result) {
|
|
44062
44104
|
return result;
|
|
@@ -44074,6 +44116,128 @@ var ts;
|
|
|
44074
44116
|
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
44075
44117
|
}
|
|
44076
44118
|
return toSearchResult(/*value*/ undefined);
|
|
44119
|
+
function toAbsolutePath(path) {
|
|
44120
|
+
var _a, _b;
|
|
44121
|
+
if (path === undefined)
|
|
44122
|
+
return path;
|
|
44123
|
+
return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)));
|
|
44124
|
+
}
|
|
44125
|
+
function combineDirectoryPath(root, dir) {
|
|
44126
|
+
return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir));
|
|
44127
|
+
}
|
|
44128
|
+
function useCaseSensitiveFileNames() {
|
|
44129
|
+
return !state.host.useCaseSensitiveFileNames ? true :
|
|
44130
|
+
typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
|
|
44131
|
+
state.host.useCaseSensitiveFileNames();
|
|
44132
|
+
}
|
|
44133
|
+
function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) {
|
|
44134
|
+
var _a, _b, _c, _d;
|
|
44135
|
+
// Replace any references to outputs for files in the program with the input files to support package self-names used with outDir
|
|
44136
|
+
// 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
|
|
44137
|
+
// 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!
|
|
44138
|
+
// _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!).
|
|
44139
|
+
// 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.
|
|
44140
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
|
|
44141
|
+
&& (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
|
|
44142
|
+
&& finalPath.indexOf("/node_modules/") === -1
|
|
44143
|
+
&& (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) {
|
|
44144
|
+
// 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.
|
|
44145
|
+
// Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
|
|
44146
|
+
// `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.)
|
|
44147
|
+
var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames });
|
|
44148
|
+
var commonSourceDirGuesses = [];
|
|
44149
|
+
// A `rootDir` compiler option strongly indicates the root location
|
|
44150
|
+
// 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
|
|
44151
|
+
if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) {
|
|
44152
|
+
var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName));
|
|
44153
|
+
commonSourceDirGuesses.push(commonDir);
|
|
44154
|
+
}
|
|
44155
|
+
else if (state.requestContainingDirectory) {
|
|
44156
|
+
// However without either of those set we're in the dark. Let's say you have
|
|
44157
|
+
//
|
|
44158
|
+
// ./tools/index.ts
|
|
44159
|
+
// ./src/index.ts
|
|
44160
|
+
// ./dist/index.js
|
|
44161
|
+
// ./package.json <-- references ./dist/index.js
|
|
44162
|
+
// ./tsconfig.json <-- loads ./src/index.ts
|
|
44163
|
+
//
|
|
44164
|
+
// How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename?
|
|
44165
|
+
// 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
|
|
44166
|
+
// without more context.
|
|
44167
|
+
// 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
|
|
44168
|
+
// must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory
|
|
44169
|
+
var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts"));
|
|
44170
|
+
// And we can try every folder above the common folder for the request folder and the config/package base directory
|
|
44171
|
+
// This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't
|
|
44172
|
+
// know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything
|
|
44173
|
+
// else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then
|
|
44174
|
+
// be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup
|
|
44175
|
+
// logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all
|
|
44176
|
+
// internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first.
|
|
44177
|
+
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));
|
|
44178
|
+
commonSourceDirGuesses.push(commonDir);
|
|
44179
|
+
var fragment = ts.ensureTrailingDirectorySeparator(commonDir);
|
|
44180
|
+
while (fragment && fragment.length > 1) {
|
|
44181
|
+
var parts = ts.getPathComponents(fragment);
|
|
44182
|
+
parts.pop(); // remove a directory
|
|
44183
|
+
var commonDir_1 = ts.getPathFromPathComponents(parts);
|
|
44184
|
+
commonSourceDirGuesses.unshift(commonDir_1);
|
|
44185
|
+
fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
|
|
44186
|
+
}
|
|
44187
|
+
}
|
|
44188
|
+
if (commonSourceDirGuesses.length > 1) {
|
|
44189
|
+
state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
|
|
44190
|
+
? 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
|
|
44191
|
+
: 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
|
|
44192
|
+
packagePath));
|
|
44193
|
+
}
|
|
44194
|
+
for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
|
|
44195
|
+
var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
|
|
44196
|
+
var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
|
|
44197
|
+
for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) {
|
|
44198
|
+
var candidateDir = candidateDirectories_1[_e];
|
|
44199
|
+
if (ts.startsWith(finalPath, candidateDir)) {
|
|
44200
|
+
// 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
|
|
44201
|
+
var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
|
|
44202
|
+
var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment);
|
|
44203
|
+
var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */];
|
|
44204
|
+
for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) {
|
|
44205
|
+
var ext = jsAndDtsExtensions_1[_f];
|
|
44206
|
+
if (ts.fileExtensionIs(possibleInputBase, ext)) {
|
|
44207
|
+
var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase);
|
|
44208
|
+
for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) {
|
|
44209
|
+
var possibleExt = inputExts_1[_g];
|
|
44210
|
+
var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
|
|
44211
|
+
if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) ||
|
|
44212
|
+
(extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) {
|
|
44213
|
+
continue;
|
|
44214
|
+
}
|
|
44215
|
+
if (state.host.fileExists(possibleInputWithInputExtension)) {
|
|
44216
|
+
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state)));
|
|
44217
|
+
}
|
|
44218
|
+
}
|
|
44219
|
+
}
|
|
44220
|
+
}
|
|
44221
|
+
}
|
|
44222
|
+
}
|
|
44223
|
+
}
|
|
44224
|
+
}
|
|
44225
|
+
return undefined;
|
|
44226
|
+
function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) {
|
|
44227
|
+
var _a, _b;
|
|
44228
|
+
// Config file ouput paths are processed to be relative to the host's current directory, while
|
|
44229
|
+
// otherwise the paths are resolved relative to the common source dir the compiler puts together
|
|
44230
|
+
var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess;
|
|
44231
|
+
var candidateDirectories = [];
|
|
44232
|
+
if (state.compilerOptions.declarationDir) {
|
|
44233
|
+
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
|
|
44234
|
+
}
|
|
44235
|
+
if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) {
|
|
44236
|
+
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir)));
|
|
44237
|
+
}
|
|
44238
|
+
return candidateDirectories;
|
|
44239
|
+
}
|
|
44240
|
+
}
|
|
44077
44241
|
}
|
|
44078
44242
|
}
|
|
44079
44243
|
/* @internal */
|
|
@@ -44264,11 +44428,12 @@ var ts;
|
|
|
44264
44428
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
44265
44429
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
44266
44430
|
var failedLookupLocations = [];
|
|
44267
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
44268
44431
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
44432
|
+
var diagnostics = [];
|
|
44433
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
|
|
44269
44434
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
44270
44435
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
44271
|
-
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache);
|
|
44436
|
+
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
44272
44437
|
function tryResolve(extensions) {
|
|
44273
44438
|
var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
|
|
44274
44439
|
if (resolvedUsingSettings) {
|
|
@@ -44311,9 +44476,10 @@ var ts;
|
|
|
44311
44476
|
trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
|
|
44312
44477
|
}
|
|
44313
44478
|
var failedLookupLocations = [];
|
|
44314
|
-
var
|
|
44479
|
+
var diagnostics = [];
|
|
44480
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
|
|
44315
44481
|
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
44316
|
-
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
|
|
44482
|
+
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
44317
44483
|
}
|
|
44318
44484
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
44319
44485
|
/**
|
|
@@ -58177,7 +58343,8 @@ var ts;
|
|
|
58177
58343
|
if (symbol === globalThisSymbol) {
|
|
58178
58344
|
var varsOnly_1 = new ts.Map();
|
|
58179
58345
|
members.forEach(function (p) {
|
|
58180
|
-
|
|
58346
|
+
var _a;
|
|
58347
|
+
if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) {
|
|
58181
58348
|
varsOnly_1.set(p.escapedName, p);
|
|
58182
58349
|
}
|
|
58183
58350
|
});
|
|
@@ -85028,6 +85195,9 @@ var ts;
|
|
|
85028
85195
|
var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
85029
85196
|
var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
|
|
85030
85197
|
if (validForTypeAssertions && override) {
|
|
85198
|
+
if (!ts.isNightly()) {
|
|
85199
|
+
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);
|
|
85200
|
+
}
|
|
85031
85201
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
85032
85202
|
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
85033
85203
|
}
|
|
@@ -86368,7 +86538,7 @@ var ts;
|
|
|
86368
86538
|
if (ts.isDeclaration(node)) {
|
|
86369
86539
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
86370
86540
|
var symbol = getSymbolOfNode(node);
|
|
86371
|
-
return getTypeOfSymbol(symbol);
|
|
86541
|
+
return symbol ? getTypeOfSymbol(symbol) : errorType;
|
|
86372
86542
|
}
|
|
86373
86543
|
if (isDeclarationNameOrImportPropertyName(node)) {
|
|
86374
86544
|
var symbol = getSymbolAtLocation(node);
|
|
@@ -108426,34 +108596,44 @@ var ts;
|
|
|
108426
108596
|
if (!decl.importClause) {
|
|
108427
108597
|
// import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc)
|
|
108428
108598
|
return factory.updateImportDeclaration(decl,
|
|
108429
|
-
/*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108599
|
+
/*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108430
108600
|
}
|
|
108431
108601
|
// The `importClause` visibility corresponds to the default's visibility.
|
|
108432
108602
|
var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
|
|
108433
108603
|
if (!decl.importClause.namedBindings) {
|
|
108434
108604
|
// No named bindings (either namespace or list), meaning the import is just default or should be elided
|
|
108435
108605
|
return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding,
|
|
108436
|
-
/*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108606
|
+
/*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108437
108607
|
}
|
|
108438
108608
|
if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) {
|
|
108439
108609
|
// Namespace import (optionally with visible default)
|
|
108440
108610
|
var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined;
|
|
108441
|
-
return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108611
|
+
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;
|
|
108442
108612
|
}
|
|
108443
108613
|
// Named imports (optionally with visible default)
|
|
108444
108614
|
var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
|
|
108445
108615
|
if ((bindingList && bindingList.length) || visibleDefaultBinding) {
|
|
108446
108616
|
return factory.updateImportDeclaration(decl,
|
|
108447
|
-
/*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),
|
|
108617
|
+
/*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));
|
|
108448
108618
|
}
|
|
108449
108619
|
// Augmentation of export depends on import
|
|
108450
108620
|
if (resolver.isImportRequiredByAugmentation(decl)) {
|
|
108451
108621
|
return factory.updateImportDeclaration(decl,
|
|
108452
108622
|
/*decorators*/ undefined, decl.modifiers,
|
|
108453
|
-
/*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108623
|
+
/*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108454
108624
|
}
|
|
108455
108625
|
// Nothing visible
|
|
108456
108626
|
}
|
|
108627
|
+
function getResolutionModeOverrideForClauseInNightly(assertClause) {
|
|
108628
|
+
var mode = ts.getResolutionModeOverrideForClause(assertClause);
|
|
108629
|
+
if (mode !== undefined) {
|
|
108630
|
+
if (!ts.isNightly()) {
|
|
108631
|
+
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));
|
|
108632
|
+
}
|
|
108633
|
+
return assertClause;
|
|
108634
|
+
}
|
|
108635
|
+
return undefined;
|
|
108636
|
+
}
|
|
108457
108637
|
function transformAndReplaceLatePaintedStatements(statements) {
|
|
108458
108638
|
// This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during
|
|
108459
108639
|
// error handling which must now be included in the output and themselves checked for errors.
|
|
@@ -116282,7 +116462,6 @@ var ts;
|
|
|
116282
116462
|
ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code,
|
|
116283
116463
|
ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code,
|
|
116284
116464
|
ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code,
|
|
116285
|
-
ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code,
|
|
116286
116465
|
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
|
|
116287
116466
|
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
|
116288
116467
|
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
|
@@ -116669,6 +116848,40 @@ var ts;
|
|
|
116669
116848
|
ts.performance.measure("Program", "beforeProgram", "afterProgram");
|
|
116670
116849
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116671
116850
|
return program;
|
|
116851
|
+
function addResolutionDiagnostics(list) {
|
|
116852
|
+
if (!list)
|
|
116853
|
+
return;
|
|
116854
|
+
for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
|
|
116855
|
+
var elem = list_3[_i];
|
|
116856
|
+
programDiagnostics.add(elem);
|
|
116857
|
+
}
|
|
116858
|
+
}
|
|
116859
|
+
function pullDiagnosticsFromCache(names, containingFile) {
|
|
116860
|
+
var _a;
|
|
116861
|
+
if (!moduleResolutionCache)
|
|
116862
|
+
return;
|
|
116863
|
+
var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
|
|
116864
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
116865
|
+
var containingDir = ts.getDirectoryPath(containingFileName);
|
|
116866
|
+
var redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
116867
|
+
var i = 0;
|
|
116868
|
+
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
116869
|
+
var n = names_4[_i];
|
|
116870
|
+
// 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
|
|
116871
|
+
var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
|
|
116872
|
+
var name = typeof n === "string" ? n : n.fileName;
|
|
116873
|
+
i++;
|
|
116874
|
+
// only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
|
|
116875
|
+
// (Since diagnostics are only issued via import or export map lookup)
|
|
116876
|
+
// This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
|
|
116877
|
+
// When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
|
|
116878
|
+
// APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
|
|
116879
|
+
if (ts.isExternalModuleNameRelative(name))
|
|
116880
|
+
continue;
|
|
116881
|
+
var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
|
|
116882
|
+
addResolutionDiagnostics(diags);
|
|
116883
|
+
}
|
|
116884
|
+
}
|
|
116672
116885
|
function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
|
|
116673
116886
|
if (!moduleNames.length)
|
|
116674
116887
|
return ts.emptyArray;
|
|
@@ -116680,6 +116893,7 @@ var ts;
|
|
|
116680
116893
|
ts.performance.mark("afterResolveModule");
|
|
116681
116894
|
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
116682
116895
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116896
|
+
pullDiagnosticsFromCache(moduleNames, containingFile);
|
|
116683
116897
|
return result;
|
|
116684
116898
|
}
|
|
116685
116899
|
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
|
|
@@ -121116,8 +121330,8 @@ var ts;
|
|
|
121116
121330
|
!!redirectedReference;
|
|
121117
121331
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
121118
121332
|
var i = 0;
|
|
121119
|
-
for (var _i = 0,
|
|
121120
|
-
var entry =
|
|
121333
|
+
for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
|
|
121334
|
+
var entry = names_5[_i];
|
|
121121
121335
|
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
121122
121336
|
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
121123
121337
|
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
@@ -121727,14 +121941,14 @@ var ts;
|
|
|
121727
121941
|
if (options === void 0) { options = {}; }
|
|
121728
121942
|
var info = getInfo(importingSourceFile.path, host);
|
|
121729
121943
|
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
|
|
121730
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121944
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121731
121945
|
}
|
|
121732
121946
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
121733
121947
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
|
|
121734
121948
|
if (options === void 0) { options = {}; }
|
|
121735
121949
|
var info = getInfo(importingSourceFileName, host);
|
|
121736
121950
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
121737
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121951
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121738
121952
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
121739
121953
|
}
|
|
121740
121954
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
@@ -121810,7 +122024,7 @@ var ts;
|
|
|
121810
122024
|
var relativeSpecifiers;
|
|
121811
122025
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
121812
122026
|
var modulePath = modulePaths_1[_i];
|
|
121813
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
122027
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
121814
122028
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
121815
122029
|
if (specifier && modulePath.isRedirect) {
|
|
121816
122030
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -122203,7 +122417,7 @@ var ts;
|
|
|
122203
122417
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
122204
122418
|
: ts.removeFileExtension(relativePath);
|
|
122205
122419
|
}
|
|
122206
|
-
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
|
|
122420
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
122207
122421
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
122208
122422
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
122209
122423
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -122217,8 +122431,9 @@ var ts;
|
|
|
122217
122431
|
var moduleSpecifier = path;
|
|
122218
122432
|
var isPackageRootPath = false;
|
|
122219
122433
|
if (!packageNameOnly) {
|
|
122434
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
122220
122435
|
var packageRootIndex = parts.packageRootIndex;
|
|
122221
|
-
var
|
|
122436
|
+
var moduleFileName = void 0;
|
|
122222
122437
|
while (true) {
|
|
122223
122438
|
// If the module could be imported by a directory name, use that directory's name
|
|
122224
122439
|
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
@@ -122235,12 +122450,12 @@ var ts;
|
|
|
122235
122450
|
isPackageRootPath = true;
|
|
122236
122451
|
break;
|
|
122237
122452
|
}
|
|
122238
|
-
if (!
|
|
122239
|
-
|
|
122453
|
+
if (!moduleFileName)
|
|
122454
|
+
moduleFileName = moduleFileToTry;
|
|
122240
122455
|
// try with next level of directory
|
|
122241
122456
|
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
|
|
122242
122457
|
if (packageRootIndex === -1) {
|
|
122243
|
-
moduleSpecifier =
|
|
122458
|
+
moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
|
|
122244
122459
|
break;
|
|
122245
122460
|
}
|
|
122246
122461
|
}
|
|
@@ -122298,7 +122513,7 @@ var ts;
|
|
|
122298
122513
|
}
|
|
122299
122514
|
}
|
|
122300
122515
|
// If the file is the main module, it can be imported by the package name
|
|
122301
|
-
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
|
122516
|
+
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
122302
122517
|
if (ts.isString(mainFileRelative)) {
|
|
122303
122518
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
122304
122519
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
@@ -122306,17 +122521,14 @@ var ts;
|
|
|
122306
122521
|
}
|
|
122307
122522
|
}
|
|
122308
122523
|
}
|
|
122309
|
-
|
|
122310
|
-
|
|
122311
|
-
|
|
122312
|
-
|
|
122313
|
-
|
|
122314
|
-
|
|
122315
|
-
// IFF there is not _also_ a file by the same name
|
|
122316
|
-
if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
|
|
122317
|
-
return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
|
|
122524
|
+
else {
|
|
122525
|
+
// No package.json exists; an index.js will still resolve as the package name
|
|
122526
|
+
var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
|
|
122527
|
+
if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
|
|
122528
|
+
return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
|
|
122529
|
+
}
|
|
122318
122530
|
}
|
|
122319
|
-
return
|
|
122531
|
+
return { moduleFileToTry: moduleFileToTry };
|
|
122320
122532
|
}
|
|
122321
122533
|
}
|
|
122322
122534
|
function tryGetAnyFileFromPath(host, path) {
|
|
@@ -122338,7 +122550,7 @@ var ts;
|
|
|
122338
122550
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
122339
122551
|
});
|
|
122340
122552
|
}
|
|
122341
|
-
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
122553
|
+
function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
122342
122554
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122343
122555
|
return fileName;
|
|
122344
122556
|
var noExtension = ts.removeFileExtension(fileName);
|
|
@@ -122346,7 +122558,13 @@ var ts;
|
|
|
122346
122558
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122347
122559
|
switch (ending) {
|
|
122348
122560
|
case 0 /* Minimal */:
|
|
122349
|
-
|
|
122561
|
+
var withoutIndex = ts.removeSuffix(noExtension, "/index");
|
|
122562
|
+
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
122563
|
+
// Can't remove index if there's a file by the same name as the directory.
|
|
122564
|
+
// Probably more callers should pass `host` so we can determine this?
|
|
122565
|
+
return noExtension;
|
|
122566
|
+
}
|
|
122567
|
+
return withoutIndex;
|
|
122350
122568
|
case 1 /* Index */:
|
|
122351
122569
|
return noExtension;
|
|
122352
122570
|
case 2 /* JsExtension */:
|
|
@@ -129569,23 +129787,30 @@ var ts;
|
|
|
129569
129787
|
(_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
|
|
129570
129788
|
var compilerOptions = program.getCompilerOptions();
|
|
129571
129789
|
var moduleCount = 0;
|
|
129572
|
-
|
|
129573
|
-
|
|
129574
|
-
|
|
129575
|
-
|
|
129576
|
-
|
|
129577
|
-
|
|
129578
|
-
|
|
129579
|
-
|
|
129580
|
-
|
|
129581
|
-
|
|
129582
|
-
|
|
129583
|
-
checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
|
|
129584
|
-
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
|
|
129585
|
-
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
|
|
129790
|
+
try {
|
|
129791
|
+
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
129792
|
+
if (++moduleCount % 100 === 0)
|
|
129793
|
+
cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
|
|
129794
|
+
var seenExports = new ts.Map();
|
|
129795
|
+
var checker = program.getTypeChecker();
|
|
129796
|
+
var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
129797
|
+
// Note: I think we shouldn't actually see resolved module symbols here, but weird merges
|
|
129798
|
+
// can cause it to happen: see 'completionsImport_mergedReExport.ts'
|
|
129799
|
+
if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
|
|
129800
|
+
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
|
|
129586
129801
|
}
|
|
129802
|
+
checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
|
|
129803
|
+
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
|
|
129804
|
+
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
|
|
129805
|
+
}
|
|
129806
|
+
});
|
|
129587
129807
|
});
|
|
129588
|
-
}
|
|
129808
|
+
}
|
|
129809
|
+
catch (err) {
|
|
129810
|
+
// Ensure cache is reset if operation is cancelled
|
|
129811
|
+
cache.clear();
|
|
129812
|
+
throw err;
|
|
129813
|
+
}
|
|
129589
129814
|
(_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms");
|
|
129590
129815
|
return cache;
|
|
129591
129816
|
}
|