typescript 5.1.0-dev.20230301 → 5.1.0-dev.20230303
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/tsc.js +135 -102
- package/lib/tsserver.js +878 -641
- package/lib/tsserverlibrary.d.ts +2 -37
- package/lib/tsserverlibrary.js +937 -691
- package/lib/typescript.d.ts +0 -3
- package/lib/typescript.js +815 -581
- package/lib/typingsInstaller.js +52 -49
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -23,7 +23,7 @@ var __export = (target, all) => {
|
|
|
23
23
|
|
|
24
24
|
// src/compiler/corePublic.ts
|
|
25
25
|
var versionMajorMinor = "5.1";
|
|
26
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
26
|
+
var version = `${versionMajorMinor}.0-dev.20230303`;
|
|
27
27
|
|
|
28
28
|
// src/compiler/core.ts
|
|
29
29
|
var emptyArray = [];
|
|
@@ -899,10 +899,6 @@ function cast(value, test) {
|
|
|
899
899
|
}
|
|
900
900
|
function noop(_) {
|
|
901
901
|
}
|
|
902
|
-
var noopPush = {
|
|
903
|
-
push: noop,
|
|
904
|
-
length: 0
|
|
905
|
-
};
|
|
906
902
|
function returnFalse() {
|
|
907
903
|
return false;
|
|
908
904
|
}
|
|
@@ -2628,41 +2624,8 @@ function tryGetWebPerformanceHooks() {
|
|
|
2628
2624
|
function tryGetNodePerformanceHooks() {
|
|
2629
2625
|
if (isNodeLikeSystem()) {
|
|
2630
2626
|
try {
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
if (hasRequiredAPI(nodePerformance, PerformanceObserver2)) {
|
|
2634
|
-
performance2 = nodePerformance;
|
|
2635
|
-
const version2 = new Version(process.versions.node);
|
|
2636
|
-
const range = new VersionRange("<12.16.3 || 13 <13.13");
|
|
2637
|
-
if (range.test(version2)) {
|
|
2638
|
-
performance2 = {
|
|
2639
|
-
get timeOrigin() {
|
|
2640
|
-
return nodePerformance.timeOrigin;
|
|
2641
|
-
},
|
|
2642
|
-
now() {
|
|
2643
|
-
return nodePerformance.now();
|
|
2644
|
-
},
|
|
2645
|
-
mark(name) {
|
|
2646
|
-
return nodePerformance.mark(name);
|
|
2647
|
-
},
|
|
2648
|
-
measure(name, start = "nodeStart", end) {
|
|
2649
|
-
if (end === void 0) {
|
|
2650
|
-
end = "__performance.measure-fix__";
|
|
2651
|
-
nodePerformance.mark(end);
|
|
2652
|
-
}
|
|
2653
|
-
nodePerformance.measure(name, start, end);
|
|
2654
|
-
if (end === "__performance.measure-fix__") {
|
|
2655
|
-
nodePerformance.clearMarks("__performance.measure-fix__");
|
|
2656
|
-
}
|
|
2657
|
-
},
|
|
2658
|
-
clearMarks(name) {
|
|
2659
|
-
return nodePerformance.clearMarks(name);
|
|
2660
|
-
},
|
|
2661
|
-
clearMeasures(name) {
|
|
2662
|
-
return nodePerformance.clearMeasures(name);
|
|
2663
|
-
}
|
|
2664
|
-
};
|
|
2665
|
-
}
|
|
2627
|
+
const { performance: performance2, PerformanceObserver: PerformanceObserver2 } = require("perf_hooks");
|
|
2628
|
+
if (hasRequiredAPI(performance2, PerformanceObserver2)) {
|
|
2666
2629
|
return {
|
|
2667
2630
|
// By default, only write native events when generating a cpu profile or using the v8 profiler.
|
|
2668
2631
|
shouldWriteNativeEvents: false,
|
|
@@ -7172,6 +7135,7 @@ var Diagnostics = {
|
|
|
7172
7135
|
File_name_0_has_a_1_extension_looking_up_2_instead: diag(6262, 3 /* Message */, "File_name_0_has_a_1_extension_looking_up_2_instead_6262", "File name '{0}' has a '{1}' extension - looking up '{2}' instead."),
|
|
7173
7136
|
Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set: diag(6263, 1 /* Error */, "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263", "Module '{0}' was resolved to '{1}', but '--allowArbitraryExtensions' is not set."),
|
|
7174
7137
|
Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present: diag(6264, 3 /* Message */, "Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present_6264", "Enable importing files with any extension, provided a declaration file is present."),
|
|
7138
|
+
Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder: diag(6265, 3 /* Message */, "Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_no_6265", "Resolving type reference directive for program that specifies custom typeRoots, skipping lookup in 'node_modules' folder."),
|
|
7175
7139
|
Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, 3 /* Message */, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
|
|
7176
7140
|
Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, 3 /* Message */, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
|
|
7177
7141
|
Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, 3 /* Message */, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
|
|
@@ -7567,6 +7531,8 @@ var Diagnostics = {
|
|
|
7567
7531
|
This_may_be_converted_to_an_async_function: diag(80006, 2 /* Suggestion */, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."),
|
|
7568
7532
|
await_has_no_effect_on_the_type_of_this_expression: diag(80007, 2 /* Suggestion */, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."),
|
|
7569
7533
|
Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, 2 /* Suggestion */, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."),
|
|
7534
|
+
JSDoc_typedef_may_be_converted_to_TypeScript_type: diag(80009, 2 /* Suggestion */, "JSDoc_typedef_may_be_converted_to_TypeScript_type_80009", "JSDoc typedef may be converted to TypeScript type."),
|
|
7535
|
+
JSDoc_typedefs_may_be_converted_to_TypeScript_types: diag(80010, 2 /* Suggestion */, "JSDoc_typedefs_may_be_converted_to_TypeScript_types_80010", "JSDoc typedefs may be converted to TypeScript types."),
|
|
7570
7536
|
Add_missing_super_call: diag(90001, 3 /* Message */, "Add_missing_super_call_90001", "Add missing 'super()' call"),
|
|
7571
7537
|
Make_super_call_the_first_statement_in_the_constructor: diag(90002, 3 /* Message */, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"),
|
|
7572
7538
|
Change_extends_to_implements: diag(90003, 3 /* Message */, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
|
|
@@ -7781,6 +7747,8 @@ var Diagnostics = {
|
|
|
7781
7747
|
Rename_param_tag_name_0_to_1: diag(95173, 3 /* Message */, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
|
|
7782
7748
|
Use_0: diag(95174, 3 /* Message */, "Use_0_95174", "Use `{0}`."),
|
|
7783
7749
|
Use_Number_isNaN_in_all_conditions: diag(95175, 3 /* Message */, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
|
|
7750
|
+
Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
|
|
7751
|
+
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
|
|
7784
7752
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
7785
7753
|
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
7786
7754
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -36539,20 +36507,14 @@ function getEffectiveTypeRoots(options, host) {
|
|
|
36539
36507
|
currentDirectory = host.getCurrentDirectory();
|
|
36540
36508
|
}
|
|
36541
36509
|
if (currentDirectory !== void 0) {
|
|
36542
|
-
return getDefaultTypeRoots(currentDirectory
|
|
36510
|
+
return getDefaultTypeRoots(currentDirectory);
|
|
36543
36511
|
}
|
|
36544
36512
|
}
|
|
36545
|
-
function getDefaultTypeRoots(currentDirectory
|
|
36546
|
-
if (!host.directoryExists) {
|
|
36547
|
-
return [combinePaths(currentDirectory, nodeModulesAtTypes)];
|
|
36548
|
-
}
|
|
36513
|
+
function getDefaultTypeRoots(currentDirectory) {
|
|
36549
36514
|
let typeRoots;
|
|
36550
36515
|
forEachAncestorDirectory(normalizePath(currentDirectory), (directory) => {
|
|
36551
36516
|
const atTypes = combinePaths(directory, nodeModulesAtTypes);
|
|
36552
|
-
|
|
36553
|
-
(typeRoots || (typeRoots = [])).push(atTypes);
|
|
36554
|
-
}
|
|
36555
|
-
return void 0;
|
|
36517
|
+
(typeRoots != null ? typeRoots : typeRoots = []).push(atTypes);
|
|
36556
36518
|
});
|
|
36557
36519
|
return typeRoots;
|
|
36558
36520
|
}
|
|
@@ -36689,10 +36651,22 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
36689
36651
|
}
|
|
36690
36652
|
return firstDefined(typeRoots, (typeRoot) => {
|
|
36691
36653
|
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
|
|
36692
|
-
const
|
|
36693
|
-
const directoryExists = directoryProbablyExists(candidateDirectory, host);
|
|
36654
|
+
const directoryExists = directoryProbablyExists(typeRoot, host);
|
|
36694
36655
|
if (!directoryExists && traceEnabled) {
|
|
36695
|
-
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it,
|
|
36656
|
+
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
36657
|
+
}
|
|
36658
|
+
if (options.typeRoots) {
|
|
36659
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, moduleResolutionState);
|
|
36660
|
+
if (resolvedFromFile) {
|
|
36661
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
36662
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
36663
|
+
packageDirectory,
|
|
36664
|
+
/*onlyRecordFailures*/
|
|
36665
|
+
false,
|
|
36666
|
+
moduleResolutionState
|
|
36667
|
+
) : void 0;
|
|
36668
|
+
return resolvedTypeScriptOnly(withPackageId(packageInfo, resolvedFromFile));
|
|
36669
|
+
}
|
|
36696
36670
|
}
|
|
36697
36671
|
return resolvedTypeScriptOnly(
|
|
36698
36672
|
loadNodeModuleFromDirectory(
|
|
@@ -36712,33 +36686,37 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
36712
36686
|
function secondaryLookup() {
|
|
36713
36687
|
const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile);
|
|
36714
36688
|
if (initialLocationForSecondaryLookup !== void 0) {
|
|
36715
|
-
if (traceEnabled) {
|
|
36716
|
-
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
36717
|
-
}
|
|
36718
36689
|
let result2;
|
|
36719
|
-
if (!
|
|
36720
|
-
|
|
36721
|
-
|
|
36722
|
-
|
|
36723
|
-
|
|
36724
|
-
|
|
36725
|
-
|
|
36726
|
-
|
|
36727
|
-
|
|
36728
|
-
|
|
36729
|
-
|
|
36730
|
-
|
|
36731
|
-
|
|
36732
|
-
|
|
36733
|
-
|
|
36734
|
-
|
|
36735
|
-
|
|
36736
|
-
|
|
36737
|
-
|
|
36738
|
-
|
|
36739
|
-
|
|
36740
|
-
|
|
36741
|
-
|
|
36690
|
+
if (!options.typeRoots || !endsWith(containingFile, inferredTypesContainingFile)) {
|
|
36691
|
+
if (traceEnabled) {
|
|
36692
|
+
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
36693
|
+
}
|
|
36694
|
+
if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
|
|
36695
|
+
const searchResult = loadModuleFromNearestNodeModulesDirectory(
|
|
36696
|
+
4 /* Declaration */,
|
|
36697
|
+
typeReferenceDirectiveName,
|
|
36698
|
+
initialLocationForSecondaryLookup,
|
|
36699
|
+
moduleResolutionState,
|
|
36700
|
+
/*cache*/
|
|
36701
|
+
void 0,
|
|
36702
|
+
/*redirectedReference*/
|
|
36703
|
+
void 0
|
|
36704
|
+
);
|
|
36705
|
+
result2 = searchResult && searchResult.value;
|
|
36706
|
+
} else {
|
|
36707
|
+
const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
|
|
36708
|
+
result2 = nodeLoadModuleByRelativeName(
|
|
36709
|
+
4 /* Declaration */,
|
|
36710
|
+
candidate,
|
|
36711
|
+
/*onlyRecordFailures*/
|
|
36712
|
+
false,
|
|
36713
|
+
moduleResolutionState,
|
|
36714
|
+
/*considerPackageJson*/
|
|
36715
|
+
true
|
|
36716
|
+
);
|
|
36717
|
+
}
|
|
36718
|
+
} else if (traceEnabled) {
|
|
36719
|
+
trace(host, Diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder);
|
|
36742
36720
|
}
|
|
36743
36721
|
return resolvedTypeScriptOnly(result2);
|
|
36744
36722
|
} else {
|
|
@@ -37532,6 +37510,9 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
37532
37510
|
}
|
|
37533
37511
|
resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
37534
37512
|
}
|
|
37513
|
+
if (extensions2 & 4 /* Declaration */) {
|
|
37514
|
+
resolved2 != null ? resolved2 : resolved2 = resolveFromTypeRoot(moduleName, state2);
|
|
37515
|
+
}
|
|
37535
37516
|
return resolved2 && { value: resolved2.value && { resolved: resolved2.value, isExternalLibraryImport: true } };
|
|
37536
37517
|
} else {
|
|
37537
37518
|
const { path: candidate, parts } = normalizePathForCJSResolution(containingDirectory, moduleName);
|
|
@@ -37712,6 +37693,7 @@ function tryFile(fileName, onlyRecordFailures, state) {
|
|
|
37712
37693
|
return forEach(state.compilerOptions.moduleSuffixes, (suffix) => tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state));
|
|
37713
37694
|
}
|
|
37714
37695
|
function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
37696
|
+
var _a2;
|
|
37715
37697
|
if (!onlyRecordFailures) {
|
|
37716
37698
|
if (state.host.fileExists(fileName)) {
|
|
37717
37699
|
if (state.traceEnabled) {
|
|
@@ -37724,7 +37706,7 @@ function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
|
37724
37706
|
}
|
|
37725
37707
|
}
|
|
37726
37708
|
}
|
|
37727
|
-
state.failedLookupLocations.push(fileName);
|
|
37709
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(fileName);
|
|
37728
37710
|
return void 0;
|
|
37729
37711
|
}
|
|
37730
37712
|
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson = true) {
|
|
@@ -37738,8 +37720,8 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
|
|
|
37738
37720
|
host,
|
|
37739
37721
|
compilerOptions: options,
|
|
37740
37722
|
traceEnabled: isTraceEnabled(options, host),
|
|
37741
|
-
failedLookupLocations:
|
|
37742
|
-
affectingLocations:
|
|
37723
|
+
failedLookupLocations: void 0,
|
|
37724
|
+
affectingLocations: void 0,
|
|
37743
37725
|
packageJsonInfoCache,
|
|
37744
37726
|
features: 0 /* None */,
|
|
37745
37727
|
conditions: emptyArray,
|
|
@@ -37773,24 +37755,24 @@ function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) {
|
|
|
37773
37755
|
return packageJsonInfo.contents.versionPaths || void 0;
|
|
37774
37756
|
}
|
|
37775
37757
|
function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
37776
|
-
var _a2, _b, _c;
|
|
37758
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
37777
37759
|
const { host, traceEnabled } = state;
|
|
37778
37760
|
const packageJsonPath = combinePaths(packageDirectory, "package.json");
|
|
37779
37761
|
if (onlyRecordFailures) {
|
|
37780
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
37762
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(packageJsonPath);
|
|
37781
37763
|
return void 0;
|
|
37782
37764
|
}
|
|
37783
|
-
const existing = (
|
|
37765
|
+
const existing = (_b = state.packageJsonInfoCache) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
37784
37766
|
if (existing !== void 0) {
|
|
37785
37767
|
if (typeof existing !== "boolean") {
|
|
37786
37768
|
if (traceEnabled)
|
|
37787
37769
|
trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
|
|
37788
|
-
state.affectingLocations.push(packageJsonPath);
|
|
37770
|
+
(_c = state.affectingLocations) == null ? void 0 : _c.push(packageJsonPath);
|
|
37789
37771
|
return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents };
|
|
37790
37772
|
} else {
|
|
37791
37773
|
if (existing && traceEnabled)
|
|
37792
37774
|
trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath);
|
|
37793
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
37775
|
+
(_d = state.failedLookupLocations) == null ? void 0 : _d.push(packageJsonPath);
|
|
37794
37776
|
return void 0;
|
|
37795
37777
|
}
|
|
37796
37778
|
}
|
|
@@ -37801,15 +37783,15 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
|
37801
37783
|
trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
|
|
37802
37784
|
}
|
|
37803
37785
|
const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } };
|
|
37804
|
-
(
|
|
37805
|
-
state.affectingLocations.push(packageJsonPath);
|
|
37786
|
+
(_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result);
|
|
37787
|
+
(_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath);
|
|
37806
37788
|
return result;
|
|
37807
37789
|
} else {
|
|
37808
37790
|
if (directoryExists && traceEnabled) {
|
|
37809
37791
|
trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
|
|
37810
37792
|
}
|
|
37811
|
-
(
|
|
37812
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
37793
|
+
(_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists);
|
|
37794
|
+
(_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath);
|
|
37813
37795
|
}
|
|
37814
37796
|
}
|
|
37815
37797
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
|
|
@@ -38630,11 +38612,13 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
|
|
|
38630
38612
|
state
|
|
38631
38613
|
));
|
|
38632
38614
|
});
|
|
38633
|
-
if (resolved2)
|
|
38615
|
+
if (resolved2)
|
|
38634
38616
|
return resolved2;
|
|
38635
|
-
}
|
|
38636
38617
|
if (extensions & (1 /* TypeScript */ | 4 /* Declaration */)) {
|
|
38637
|
-
|
|
38618
|
+
let resolved3 = loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
|
|
38619
|
+
if (extensions & 4 /* Declaration */)
|
|
38620
|
+
resolved3 != null ? resolved3 : resolved3 = resolveFromTypeRoot(moduleName, state);
|
|
38621
|
+
return resolved3;
|
|
38638
38622
|
}
|
|
38639
38623
|
} else {
|
|
38640
38624
|
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
|
@@ -38648,6 +38632,31 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
|
|
|
38648
38632
|
}
|
|
38649
38633
|
}
|
|
38650
38634
|
}
|
|
38635
|
+
function resolveFromTypeRoot(moduleName, state) {
|
|
38636
|
+
if (!state.compilerOptions.typeRoots)
|
|
38637
|
+
return;
|
|
38638
|
+
for (const typeRoot of state.compilerOptions.typeRoots) {
|
|
38639
|
+
const candidate = combinePaths(typeRoot, moduleName);
|
|
38640
|
+
const directoryExists = directoryProbablyExists(typeRoot, state.host);
|
|
38641
|
+
if (!directoryExists && state.traceEnabled) {
|
|
38642
|
+
trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
38643
|
+
}
|
|
38644
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, state);
|
|
38645
|
+
if (resolvedFromFile) {
|
|
38646
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
38647
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
38648
|
+
packageDirectory,
|
|
38649
|
+
/*onlyRecordFailures*/
|
|
38650
|
+
false,
|
|
38651
|
+
state
|
|
38652
|
+
) : void 0;
|
|
38653
|
+
return toSearchResult(withPackageId(packageInfo, resolvedFromFile));
|
|
38654
|
+
}
|
|
38655
|
+
const resolved = loadNodeModuleFromDirectory(4 /* Declaration */, candidate, !directoryExists, state);
|
|
38656
|
+
if (resolved)
|
|
38657
|
+
return toSearchResult(resolved);
|
|
38658
|
+
}
|
|
38659
|
+
}
|
|
38651
38660
|
function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
|
|
38652
38661
|
return !!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName);
|
|
38653
38662
|
}
|
|
@@ -51592,7 +51601,11 @@ function createTypeChecker(host) {
|
|
|
51592
51601
|
const baseTypeVariable = getBaseTypeVariableOfClass(symbol);
|
|
51593
51602
|
return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
|
|
51594
51603
|
} else {
|
|
51595
|
-
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
51604
|
+
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
51605
|
+
type,
|
|
51606
|
+
/*isProperty*/
|
|
51607
|
+
true
|
|
51608
|
+
) : type;
|
|
51596
51609
|
}
|
|
51597
51610
|
}
|
|
51598
51611
|
function getTypeOfEnumMember(symbol) {
|
|
@@ -60293,6 +60306,7 @@ function createTypeChecker(host) {
|
|
|
60293
60306
|
} else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
60294
60307
|
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
60295
60308
|
if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
|
|
60309
|
+
instantiateType(source2.objectType, reportUnreliableMapper);
|
|
60296
60310
|
result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
|
|
60297
60311
|
}
|
|
60298
60312
|
if (result2) {
|
|
@@ -63438,7 +63452,7 @@ function createTypeChecker(host) {
|
|
|
63438
63452
|
);
|
|
63439
63453
|
}
|
|
63440
63454
|
function isInAmbientOrTypeNode(node) {
|
|
63441
|
-
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeLiteralNode(n)));
|
|
63455
|
+
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeAliasDeclaration(n) || isTypeLiteralNode(n)));
|
|
63442
63456
|
}
|
|
63443
63457
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
63444
63458
|
switch (node.kind) {
|
|
@@ -66586,6 +66600,16 @@ function createTypeChecker(host) {
|
|
|
66586
66600
|
const symbol = getSymbolOfDeclaration(element);
|
|
66587
66601
|
return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
|
|
66588
66602
|
}
|
|
66603
|
+
if (hasDynamicName(element)) {
|
|
66604
|
+
const name = getNameOfDeclaration(element);
|
|
66605
|
+
if (name && isComputedPropertyName(name)) {
|
|
66606
|
+
const exprType = checkExpression(name.expression);
|
|
66607
|
+
const propType = isTypeUsableAsPropertyName(exprType) && getTypeOfPropertyOfContextualType(type, getPropertyNameFromType(exprType));
|
|
66608
|
+
if (propType) {
|
|
66609
|
+
return propType;
|
|
66610
|
+
}
|
|
66611
|
+
}
|
|
66612
|
+
}
|
|
66589
66613
|
if (element.name) {
|
|
66590
66614
|
const nameType = getLiteralTypeFromPropertyName(element.name);
|
|
66591
66615
|
return mapType(
|
|
@@ -69193,16 +69217,20 @@ function createTypeChecker(host) {
|
|
|
69193
69217
|
) : createTupleType([type], [8 /* Variadic */]);
|
|
69194
69218
|
}
|
|
69195
69219
|
function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) {
|
|
69220
|
+
const inConstContext = isConstTypeVariable(restType);
|
|
69196
69221
|
if (index >= argCount - 1) {
|
|
69197
69222
|
const arg = args[argCount - 1];
|
|
69198
69223
|
if (isSpreadArgument(arg)) {
|
|
69199
|
-
|
|
69224
|
+
const spreadType = arg.kind === 234 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode);
|
|
69225
|
+
if (isArrayLikeType(spreadType)) {
|
|
69226
|
+
return getMutableArrayOrTupleType(spreadType);
|
|
69227
|
+
}
|
|
69228
|
+
return createArrayType(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 227 /* SpreadElement */ ? arg.expression : arg), inConstContext);
|
|
69200
69229
|
}
|
|
69201
69230
|
}
|
|
69202
69231
|
const types = [];
|
|
69203
69232
|
const flags = [];
|
|
69204
69233
|
const names = [];
|
|
69205
|
-
const inConstContext = isConstTypeVariable(restType);
|
|
69206
69234
|
for (let i = index; i < argCount; i++) {
|
|
69207
69235
|
const arg = args[i];
|
|
69208
69236
|
if (isSpreadArgument(arg)) {
|
|
@@ -71359,7 +71387,7 @@ function createTypeChecker(host) {
|
|
|
71359
71387
|
}
|
|
71360
71388
|
function getNonArrayRestType(signature) {
|
|
71361
71389
|
const restType = getEffectiveRestType(signature);
|
|
71362
|
-
return restType && !isArrayType(restType) && !isTypeAny(restType)
|
|
71390
|
+
return restType && !isArrayType(restType) && !isTypeAny(restType) ? restType : void 0;
|
|
71363
71391
|
}
|
|
71364
71392
|
function getTypeOfFirstParameterOfSignature(signature) {
|
|
71365
71393
|
return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
|
|
@@ -76173,6 +76201,9 @@ function createTypeChecker(host) {
|
|
|
76173
76201
|
return;
|
|
76174
76202
|
}
|
|
76175
76203
|
if (isBindingPattern(node.name)) {
|
|
76204
|
+
if (isInAmbientOrTypeNode(node)) {
|
|
76205
|
+
return;
|
|
76206
|
+
}
|
|
76176
76207
|
const needCheckInitializer = hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 246 /* ForInStatement */;
|
|
76177
76208
|
const needCheckWidenedType = !some(node.name.elements, not(isOmittedExpression));
|
|
76178
76209
|
if (needCheckInitializer || needCheckWidenedType) {
|
|
@@ -118524,7 +118555,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118524
118555
|
return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
|
|
118525
118556
|
}
|
|
118526
118557
|
function createTypeRootsWatch(typeRootPath, typeRoot) {
|
|
118527
|
-
return resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
118558
|
+
return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
118528
118559
|
const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
|
|
118529
118560
|
if (cachedDirectoryStructureHost) {
|
|
118530
118561
|
cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
|
|
@@ -118535,7 +118566,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118535
118566
|
if (dirPath) {
|
|
118536
118567
|
scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
|
|
118537
118568
|
}
|
|
118538
|
-
}, 1 /* Recursive */);
|
|
118569
|
+
}, 1 /* Recursive */) : noopFileWatcher;
|
|
118539
118570
|
}
|
|
118540
118571
|
function updateTypeRootsWatch() {
|
|
118541
118572
|
const options = resolutionHost.getCompilationSettings();
|
|
@@ -118543,7 +118574,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118543
118574
|
closeTypeRootsWatch();
|
|
118544
118575
|
return;
|
|
118545
118576
|
}
|
|
118546
|
-
const typeRoots = getEffectiveTypeRoots(options, {
|
|
118577
|
+
const typeRoots = getEffectiveTypeRoots(options, { getCurrentDirectory });
|
|
118547
118578
|
if (typeRoots) {
|
|
118548
118579
|
mutateMap(
|
|
118549
118580
|
typeRootsWatches,
|
|
@@ -118557,7 +118588,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118557
118588
|
closeTypeRootsWatch();
|
|
118558
118589
|
}
|
|
118559
118590
|
}
|
|
118560
|
-
function
|
|
118591
|
+
function canWatchTypeRootPath(nodeTypesDirectory) {
|
|
118592
|
+
if (resolutionHost.getCompilationSettings().typeRoots)
|
|
118593
|
+
return true;
|
|
118561
118594
|
const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
|
|
118562
118595
|
const dirPath = resolutionHost.toPath(dir);
|
|
118563
118596
|
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|