typescript 4.6.0-dev.20220209 → 4.7.0-dev.20220215
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 +9 -3
- package/lib/de/diagnosticMessages.generated.json +9 -3
- package/lib/es/diagnosticMessages.generated.json +9 -3
- package/lib/fr/diagnosticMessages.generated.json +9 -3
- package/lib/it/diagnosticMessages.generated.json +9 -3
- package/lib/ja/diagnosticMessages.generated.json +9 -3
- package/lib/ko/diagnosticMessages.generated.json +9 -3
- package/lib/pl/diagnosticMessages.generated.json +9 -3
- package/lib/pt-br/diagnosticMessages.generated.json +9 -3
- package/lib/ru/diagnosticMessages.generated.json +9 -3
- package/lib/tr/diagnosticMessages.generated.json +9 -3
- package/lib/tsc.js +191 -113
- package/lib/tsserver.js +439 -161
- package/lib/tsserverlibrary.d.ts +1 -1
- package/lib/tsserverlibrary.js +439 -161
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +439 -161
- package/lib/typescriptServices.d.ts +1 -1
- package/lib/typescriptServices.js +439 -161
- package/lib/typingsInstaller.js +223 -118
- package/lib/zh-cn/diagnosticMessages.generated.json +9 -3
- package/lib/zh-tw/diagnosticMessages.generated.json +9 -3
- 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.7";
|
|
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.20220215";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -7636,18 +7636,6 @@ var ts;
|
|
|
7636
7636
|
return getCanonicalFileName(nonCanonicalizedPath);
|
|
7637
7637
|
}
|
|
7638
7638
|
ts.toPath = toPath;
|
|
7639
|
-
function normalizePathAndParts(path) {
|
|
7640
|
-
path = normalizeSlashes(path);
|
|
7641
|
-
var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
|
|
7642
|
-
if (parts.length) {
|
|
7643
|
-
var joinedParts = root + parts.join(ts.directorySeparator);
|
|
7644
|
-
return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
|
|
7645
|
-
}
|
|
7646
|
-
else {
|
|
7647
|
-
return { path: root, parts: parts };
|
|
7648
|
-
}
|
|
7649
|
-
}
|
|
7650
|
-
ts.normalizePathAndParts = normalizePathAndParts;
|
|
7651
7639
|
function removeTrailingDirectorySeparator(path) {
|
|
7652
7640
|
if (hasTrailingDirectorySeparator(path)) {
|
|
7653
7641
|
return path.substr(0, path.length - 1);
|
|
@@ -8045,10 +8033,10 @@ var ts;
|
|
|
8045
8033
|
A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."),
|
|
8046
8034
|
A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."),
|
|
8047
8035
|
An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."),
|
|
8048
|
-
|
|
8049
|
-
|
|
8036
|
+
An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1232", "An import declaration can only be used at the top level of a namespace or module."),
|
|
8037
|
+
An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1233", "An export declaration can only be used at the top level of a namespace or module."),
|
|
8050
8038
|
An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."),
|
|
8051
|
-
|
|
8039
|
+
A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module_1235", "A namespace declaration is only allowed at the top level of a namespace or module."),
|
|
8052
8040
|
The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."),
|
|
8053
8041
|
The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."),
|
|
8054
8042
|
Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."),
|
|
@@ -8080,6 +8068,7 @@ var ts;
|
|
|
8080
8068
|
An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."),
|
|
8081
8069
|
Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
|
|
8082
8070
|
An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
|
|
8071
|
+
Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
|
|
8083
8072
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
8084
8073
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
8085
8074
|
Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
|
|
@@ -8216,6 +8205,8 @@ var ts;
|
|
|
8216
8205
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8217
8206
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8218
8207
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8208
|
+
An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."),
|
|
8209
|
+
An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."),
|
|
8219
8210
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
8220
8211
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
8221
8212
|
Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
@@ -9636,6 +9627,9 @@ var ts;
|
|
|
9636
9627
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9637
9628
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9638
9629
|
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9630
|
+
Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
|
|
9631
|
+
Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
|
|
9632
|
+
Rename_param_tag_name_0_to_1: diag(95173, ts.DiagnosticCategory.Message, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
|
|
9639
9633
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.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."),
|
|
9640
9634
|
Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
9641
9635
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.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?"),
|
|
@@ -14136,6 +14130,10 @@ var ts;
|
|
|
14136
14130
|
return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
|
|
14137
14131
|
}
|
|
14138
14132
|
ts.getSourceFileOfModule = getSourceFileOfModule;
|
|
14133
|
+
function isPlainJsFile(file, checkJs) {
|
|
14134
|
+
return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined;
|
|
14135
|
+
}
|
|
14136
|
+
ts.isPlainJsFile = isPlainJsFile;
|
|
14139
14137
|
function isStatementWithLocals(node) {
|
|
14140
14138
|
switch (node.kind) {
|
|
14141
14139
|
case 234 /* Block */:
|
|
@@ -41711,7 +41709,7 @@ var ts;
|
|
|
41711
41709
|
result_4 = searchResult && searchResult.value;
|
|
41712
41710
|
}
|
|
41713
41711
|
else {
|
|
41714
|
-
var candidate =
|
|
41712
|
+
var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
|
|
41715
41713
|
result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
|
|
41716
41714
|
}
|
|
41717
41715
|
return resolvedTypeScriptOnly(result_4);
|
|
@@ -42414,13 +42412,25 @@ var ts;
|
|
|
42414
42412
|
return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
|
|
42415
42413
|
}
|
|
42416
42414
|
else {
|
|
42417
|
-
var _a =
|
|
42415
|
+
var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
|
|
42418
42416
|
var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
|
|
42419
42417
|
// Treat explicit "node_modules" import as an external library import.
|
|
42420
42418
|
return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
|
|
42421
42419
|
}
|
|
42422
42420
|
}
|
|
42423
42421
|
}
|
|
42422
|
+
// If you import from "." inside a containing directory "/foo", the result of `normalizePath`
|
|
42423
|
+
// would be "/foo", but this loses the information that `foo` is a directory and we intended
|
|
42424
|
+
// to look inside of it. The Node CommonJS resolution algorithm doesn't call this out
|
|
42425
|
+
// (https://nodejs.org/api/modules.html#all-together), but it seems that module paths ending
|
|
42426
|
+
// in `.` are actually normalized to `./` before proceeding with the resolution algorithm.
|
|
42427
|
+
function normalizePathForCJSResolution(containingDirectory, moduleName) {
|
|
42428
|
+
var combined = ts.combinePaths(containingDirectory, moduleName);
|
|
42429
|
+
var parts = ts.getPathComponents(combined);
|
|
42430
|
+
var lastPart = ts.lastOrUndefined(parts);
|
|
42431
|
+
var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
|
|
42432
|
+
return { path: path, parts: parts };
|
|
42433
|
+
}
|
|
42424
42434
|
function realPath(path, host, traceEnabled) {
|
|
42425
42435
|
if (!host.realpath) {
|
|
42426
42436
|
return path;
|
|
@@ -42462,7 +42472,13 @@ var ts;
|
|
|
42462
42472
|
onlyRecordFailures = true;
|
|
42463
42473
|
}
|
|
42464
42474
|
}
|
|
42465
|
-
|
|
42475
|
+
// esm mode relative imports shouldn't do any directory lookups (either inside `package.json`
|
|
42476
|
+
// files or implicit `index.js`es). This is a notable depature from cjs norms, where `./foo/pkg`
|
|
42477
|
+
// could have been redirected by `./foo/pkg/package.json` to an arbitrary location!
|
|
42478
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42479
|
+
return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
|
|
42480
|
+
}
|
|
42481
|
+
return undefined;
|
|
42466
42482
|
}
|
|
42467
42483
|
/*@internal*/
|
|
42468
42484
|
ts.nodeModulesPathPart = "/node_modules/";
|
|
@@ -42829,7 +42845,16 @@ var ts;
|
|
|
42829
42845
|
// Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types"
|
|
42830
42846
|
var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
|
|
42831
42847
|
// Don't do package.json lookup recursively, because Node.js' package lookup doesn't.
|
|
42832
|
-
|
|
42848
|
+
// Disable `EsmMode` for the resolution of the package path for cjs-mode packages (so the `main` field can omit extensions)
|
|
42849
|
+
// (technically it only emits a deprecation warning in esm packages right now, but that's probably
|
|
42850
|
+
// enough to mean we don't need to support it)
|
|
42851
|
+
var features = state.features;
|
|
42852
|
+
if ((jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.type) !== "module") {
|
|
42853
|
+
state.features &= ~NodeResolutionFeatures.EsmMode;
|
|
42854
|
+
}
|
|
42855
|
+
var result = nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ false);
|
|
42856
|
+
state.features = features;
|
|
42857
|
+
return result;
|
|
42833
42858
|
};
|
|
42834
42859
|
var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
|
|
42835
42860
|
var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
|
|
@@ -43174,6 +43199,14 @@ var ts;
|
|
|
43174
43199
|
}
|
|
43175
43200
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
43176
43201
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
43202
|
+
if (!pathAndExtension && packageInfo
|
|
43203
|
+
&& packageInfo.packageJsonContent.exports === undefined
|
|
43204
|
+
&& packageInfo.packageJsonContent.main === undefined
|
|
43205
|
+
&& state.features & NodeResolutionFeatures.EsmMode) {
|
|
43206
|
+
// EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
|
|
43207
|
+
// a default `index.js` entrypoint if no `main` or `exports` are present
|
|
43208
|
+
pathAndExtension = loadModuleFromFile(extensions, ts.combinePaths(candidate, "index.js"), onlyRecordFailures, state);
|
|
43209
|
+
}
|
|
43177
43210
|
return withPackageId(packageInfo, pathAndExtension);
|
|
43178
43211
|
};
|
|
43179
43212
|
if (rest !== "") { // If "rest" is empty, we just did this search above.
|
|
@@ -46913,6 +46946,9 @@ var ts;
|
|
|
46913
46946
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
46914
46947
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
46915
46948
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
46949
|
+
CheckMode[CheckMode["RestBindingElement"] = 32] = "RestBindingElement";
|
|
46950
|
+
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
46951
|
+
// we need to preserve generic types instead of substituting them for constraints
|
|
46916
46952
|
})(CheckMode || (CheckMode = {}));
|
|
46917
46953
|
var SignatureCheckMode;
|
|
46918
46954
|
(function (SignatureCheckMode) {
|
|
@@ -47965,13 +48001,13 @@ var ts;
|
|
|
47965
48001
|
else { // error
|
|
47966
48002
|
var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
|
|
47967
48003
|
var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
|
|
47968
|
-
var message = isEitherEnum
|
|
47969
|
-
? ts.Diagnostics.
|
|
47970
|
-
: isEitherBlockScoped_1
|
|
47971
|
-
? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
48004
|
+
var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
|
|
48005
|
+
: isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
47972
48006
|
: ts.Diagnostics.Duplicate_identifier_0;
|
|
47973
48007
|
var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
|
|
47974
48008
|
var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
|
|
48009
|
+
var isSourcePlainJs = ts.isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
|
|
48010
|
+
var isTargetPlainJs = ts.isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
|
|
47975
48011
|
var symbolName_1 = symbolToString(source);
|
|
47976
48012
|
// Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch
|
|
47977
48013
|
if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
|
|
@@ -47983,12 +48019,16 @@ var ts;
|
|
|
47983
48019
|
var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
|
|
47984
48020
|
return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
|
|
47985
48021
|
});
|
|
47986
|
-
|
|
47987
|
-
|
|
48022
|
+
if (!isSourcePlainJs)
|
|
48023
|
+
addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
|
|
48024
|
+
if (!isTargetPlainJs)
|
|
48025
|
+
addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
|
|
47988
48026
|
}
|
|
47989
48027
|
else {
|
|
47990
|
-
|
|
47991
|
-
|
|
48028
|
+
if (!isSourcePlainJs)
|
|
48029
|
+
addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
|
|
48030
|
+
if (!isTargetPlainJs)
|
|
48031
|
+
addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
|
|
47992
48032
|
}
|
|
47993
48033
|
}
|
|
47994
48034
|
return target;
|
|
@@ -48445,6 +48485,8 @@ var ts;
|
|
|
48445
48485
|
// type parameters are visible in parameter list, return type and type parameter list
|
|
48446
48486
|
? lastLocation === location.type ||
|
|
48447
48487
|
lastLocation.kind === 163 /* Parameter */ ||
|
|
48488
|
+
lastLocation.kind === 338 /* JSDocParameterTag */ ||
|
|
48489
|
+
lastLocation.kind === 339 /* JSDocReturnTag */ ||
|
|
48448
48490
|
lastLocation.kind === 162 /* TypeParameter */
|
|
48449
48491
|
// local types not visible outside the function body
|
|
48450
48492
|
: false;
|
|
@@ -48704,9 +48746,9 @@ var ts;
|
|
|
48704
48746
|
lastSelfReferenceLocation = location;
|
|
48705
48747
|
}
|
|
48706
48748
|
lastLocation = location;
|
|
48707
|
-
location = ts.isJSDocTemplateTag(location) ?
|
|
48708
|
-
ts.
|
|
48709
|
-
|
|
48749
|
+
location = ts.isJSDocTemplateTag(location) ? ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
|
|
48750
|
+
ts.isJSDocParameterTag(location) || ts.isJSDocReturnTag(location) ? ts.getHostSignatureFromJSDoc(location) || location.parent :
|
|
48751
|
+
location.parent;
|
|
48710
48752
|
}
|
|
48711
48753
|
// We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
|
|
48712
48754
|
// If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself.
|
|
@@ -49840,16 +49882,20 @@ var ts;
|
|
|
49840
49882
|
return;
|
|
49841
49883
|
}
|
|
49842
49884
|
var host = ts.getJSDocHost(node);
|
|
49843
|
-
if (host &&
|
|
49844
|
-
|
|
49845
|
-
ts.isBinaryExpression(host.expression) &&
|
|
49846
|
-
ts.getAssignmentDeclarationKind(host.expression) === 3 /* PrototypeProperty */) {
|
|
49847
|
-
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
49885
|
+
if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
|
|
49886
|
+
// /** @param {K} p */ X.prototype.m = function () { } <-- look for K on X's declaration
|
|
49848
49887
|
var symbol = getSymbolOfNode(host.expression.left);
|
|
49849
49888
|
if (symbol) {
|
|
49850
49889
|
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
49851
49890
|
}
|
|
49852
49891
|
}
|
|
49892
|
+
if (host && ts.isFunctionExpression(host) && ts.isPrototypePropertyAssignment(host.parent) && ts.isExpressionStatement(host.parent.parent)) {
|
|
49893
|
+
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
49894
|
+
var symbol = getSymbolOfNode(host.parent.left);
|
|
49895
|
+
if (symbol) {
|
|
49896
|
+
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
49897
|
+
}
|
|
49898
|
+
}
|
|
49853
49899
|
if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
|
|
49854
49900
|
ts.isBinaryExpression(host.parent.parent) &&
|
|
49855
49901
|
ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) {
|
|
@@ -50378,8 +50424,15 @@ var ts;
|
|
|
50378
50424
|
return res;
|
|
50379
50425
|
}
|
|
50380
50426
|
var candidates = ts.mapDefined(symbol.declarations, function (d) {
|
|
50381
|
-
if (!ts.isAmbientModule(d) && d.parent
|
|
50382
|
-
|
|
50427
|
+
if (!ts.isAmbientModule(d) && d.parent) {
|
|
50428
|
+
// direct children of a module
|
|
50429
|
+
if (hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
|
|
50430
|
+
return getSymbolOfNode(d.parent);
|
|
50431
|
+
}
|
|
50432
|
+
// export ='d member of an ambient module
|
|
50433
|
+
if (ts.isModuleBlock(d.parent) && d.parent.parent && resolveExternalModuleSymbol(getSymbolOfNode(d.parent.parent)) === symbol) {
|
|
50434
|
+
return getSymbolOfNode(d.parent.parent);
|
|
50435
|
+
}
|
|
50383
50436
|
}
|
|
50384
50437
|
if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
|
|
50385
50438
|
if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
|
|
@@ -54336,9 +54389,12 @@ var ts;
|
|
|
54336
54389
|
}
|
|
54337
54390
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
54338
54391
|
// assigned by contextual typing.
|
|
54339
|
-
function getTypeForBindingElementParent(node) {
|
|
54392
|
+
function getTypeForBindingElementParent(node, checkMode) {
|
|
54393
|
+
if (checkMode !== 0 /* Normal */) {
|
|
54394
|
+
return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54395
|
+
}
|
|
54340
54396
|
var symbol = getSymbolOfNode(node);
|
|
54341
|
-
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
|
|
54397
|
+
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54342
54398
|
}
|
|
54343
54399
|
function getRestType(source, properties, symbol) {
|
|
54344
54400
|
source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
@@ -54456,7 +54512,8 @@ var ts;
|
|
|
54456
54512
|
}
|
|
54457
54513
|
/** Return the inferred type for a binding element */
|
|
54458
54514
|
function getTypeForBindingElement(declaration) {
|
|
54459
|
-
var
|
|
54515
|
+
var checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
54516
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
54460
54517
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
54461
54518
|
}
|
|
54462
54519
|
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
@@ -54528,9 +54585,9 @@ var ts;
|
|
|
54528
54585
|
if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
|
|
54529
54586
|
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
|
54530
54587
|
// undefined from the final type.
|
|
54531
|
-
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54588
|
+
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54532
54589
|
}
|
|
54533
|
-
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
|
|
54590
|
+
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
54534
54591
|
}
|
|
54535
54592
|
function getTypeForDeclarationFromJSDocComment(declaration) {
|
|
54536
54593
|
var jsdocType = ts.getJSDocType(declaration);
|
|
@@ -54553,11 +54610,11 @@ var ts;
|
|
|
54553
54610
|
return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
|
|
54554
54611
|
}
|
|
54555
54612
|
// Return the inferred type for a variable, parameter, or property declaration
|
|
54556
|
-
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
|
54613
|
+
function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
|
|
54557
54614
|
// A variable declared in a for..in statement is of type string, or of type keyof T when the
|
|
54558
54615
|
// right hand expression is of a type parameter type.
|
|
54559
54616
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
|
|
54560
|
-
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
|
|
54617
|
+
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode)));
|
|
54561
54618
|
return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
|
|
54562
54619
|
}
|
|
54563
54620
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
|
|
@@ -54612,12 +54669,9 @@ var ts;
|
|
|
54612
54669
|
}
|
|
54613
54670
|
}
|
|
54614
54671
|
if (ts.isInJSFile(declaration)) {
|
|
54615
|
-
var
|
|
54616
|
-
if (
|
|
54617
|
-
|
|
54618
|
-
var pos = func.parameters.indexOf(declaration);
|
|
54619
|
-
return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
54620
|
-
}
|
|
54672
|
+
var type_1 = getParameterTypeOfTypeTag(func, declaration);
|
|
54673
|
+
if (type_1)
|
|
54674
|
+
return type_1;
|
|
54621
54675
|
}
|
|
54622
54676
|
// Use contextual parameter type if one is available
|
|
54623
54677
|
var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
|
|
@@ -54634,7 +54688,7 @@ var ts;
|
|
|
54634
54688
|
return containerObjectType;
|
|
54635
54689
|
}
|
|
54636
54690
|
}
|
|
54637
|
-
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
|
|
54691
|
+
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
|
|
54638
54692
|
return addOptionality(type, isProperty, isOptional);
|
|
54639
54693
|
}
|
|
54640
54694
|
if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
|
|
@@ -55006,7 +55060,7 @@ var ts;
|
|
|
55006
55060
|
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
|
|
55007
55061
|
// pattern.
|
|
55008
55062
|
var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
|
|
55009
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
|
|
55063
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
55010
55064
|
}
|
|
55011
55065
|
if (ts.isBindingPattern(element.name)) {
|
|
55012
55066
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
|
|
@@ -55095,7 +55149,7 @@ var ts;
|
|
|
55095
55149
|
// binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
|
|
55096
55150
|
// tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
|
|
55097
55151
|
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
|
55098
|
-
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
|
|
55152
|
+
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors);
|
|
55099
55153
|
}
|
|
55100
55154
|
function isGlobalSymbolConstructor(node) {
|
|
55101
55155
|
var symbol = getSymbolOfNode(node);
|
|
@@ -55184,9 +55238,9 @@ var ts;
|
|
|
55184
55238
|
if (typeNode === undefined) {
|
|
55185
55239
|
return useUnknownInCatchVariables ? unknownType : anyType;
|
|
55186
55240
|
}
|
|
55187
|
-
var
|
|
55241
|
+
var type_2 = getTypeOfNode(typeNode);
|
|
55188
55242
|
// an errorType will make `checkTryStatement` issue an error
|
|
55189
|
-
return isTypeAny(
|
|
55243
|
+
return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
|
|
55190
55244
|
}
|
|
55191
55245
|
// Handle export default expressions
|
|
55192
55246
|
if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
|
|
@@ -55324,10 +55378,12 @@ var ts;
|
|
|
55324
55378
|
if (writing === void 0) { writing = false; }
|
|
55325
55379
|
var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
|
|
55326
55380
|
var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */);
|
|
55327
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
55328
55381
|
// For write operations, prioritize type annotations on the setter
|
|
55329
|
-
if (writing
|
|
55330
|
-
|
|
55382
|
+
if (writing) {
|
|
55383
|
+
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
55384
|
+
if (setterType_1) {
|
|
55385
|
+
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
55386
|
+
}
|
|
55331
55387
|
}
|
|
55332
55388
|
// Else defer to the getter type
|
|
55333
55389
|
if (getter && ts.isInJSFile(getter)) {
|
|
@@ -55342,6 +55398,7 @@ var ts;
|
|
|
55342
55398
|
return instantiateTypeIfNeeded(getterType, symbol);
|
|
55343
55399
|
}
|
|
55344
55400
|
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
55401
|
+
var setterType = getAnnotatedAccessorType(setter);
|
|
55345
55402
|
if (setterType) {
|
|
55346
55403
|
return setterType;
|
|
55347
55404
|
}
|
|
@@ -55412,11 +55469,11 @@ var ts;
|
|
|
55412
55469
|
return errorType;
|
|
55413
55470
|
}
|
|
55414
55471
|
var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
|
|
55415
|
-
var
|
|
55472
|
+
var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
|
55416
55473
|
if (!popTypeResolution()) {
|
|
55417
55474
|
return reportCircularityError(symbol);
|
|
55418
55475
|
}
|
|
55419
|
-
return
|
|
55476
|
+
return type_3;
|
|
55420
55477
|
}
|
|
55421
55478
|
}
|
|
55422
55479
|
var type = createObjectType(16 /* Anonymous */, symbol);
|
|
@@ -57648,10 +57705,10 @@ var ts;
|
|
|
57648
57705
|
var baseTypes = [];
|
|
57649
57706
|
var different = false;
|
|
57650
57707
|
for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
|
|
57651
|
-
var
|
|
57652
|
-
var baseType = getBaseConstraint(
|
|
57708
|
+
var type_4 = types_7[_i];
|
|
57709
|
+
var baseType = getBaseConstraint(type_4);
|
|
57653
57710
|
if (baseType) {
|
|
57654
|
-
if (baseType !==
|
|
57711
|
+
if (baseType !== type_4) {
|
|
57655
57712
|
different = true;
|
|
57656
57713
|
}
|
|
57657
57714
|
baseTypes.push(baseType);
|
|
@@ -58364,6 +58421,13 @@ var ts;
|
|
|
58364
58421
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
58365
58422
|
return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
58366
58423
|
}
|
|
58424
|
+
function getParameterTypeOfTypeTag(func, parameter) {
|
|
58425
|
+
var signature = getSignatureOfTypeTag(func);
|
|
58426
|
+
if (!signature)
|
|
58427
|
+
return undefined;
|
|
58428
|
+
var pos = func.parameters.indexOf(parameter);
|
|
58429
|
+
return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
58430
|
+
}
|
|
58367
58431
|
function getReturnTypeOfTypeTag(node) {
|
|
58368
58432
|
var signature = getSignatureOfTypeTag(node);
|
|
58369
58433
|
return signature && getReturnTypeOfSignature(signature);
|
|
@@ -63103,9 +63167,11 @@ var ts;
|
|
|
63103
63167
|
isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
|
|
63104
63168
|
return true;
|
|
63105
63169
|
}
|
|
63106
|
-
|
|
63170
|
+
// In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`.
|
|
63171
|
+
// Since unions and intersections may reduce to `never`, we exclude them here.
|
|
63172
|
+
if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */)))
|
|
63107
63173
|
return true;
|
|
63108
|
-
if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */))
|
|
63174
|
+
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
63109
63175
|
return true;
|
|
63110
63176
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
|
|
63111
63177
|
return true;
|
|
@@ -64561,6 +64627,11 @@ var ts;
|
|
|
64561
64627
|
}
|
|
64562
64628
|
if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target &&
|
|
64563
64629
|
!isTupleType(source) && !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) {
|
|
64630
|
+
// When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType,
|
|
64631
|
+
// and an empty array literal wouldn't be assignable to a `never[]` without this check.
|
|
64632
|
+
if (isEmptyArrayLiteralType(source)) {
|
|
64633
|
+
return -1 /* True */;
|
|
64634
|
+
}
|
|
64564
64635
|
// We have type references to the same generic type, and the type references are not marker
|
|
64565
64636
|
// type references (which are intended by be compared structurally). Obtain the variance
|
|
64566
64637
|
// information for the type parameters and relate the type arguments accordingly.
|
|
@@ -64867,6 +64938,15 @@ var ts;
|
|
|
64867
64938
|
}
|
|
64868
64939
|
return 0 /* False */;
|
|
64869
64940
|
}
|
|
64941
|
+
// Ensure {readonly a: whatever} is not a subtype of {a: whatever},
|
|
64942
|
+
// while {a: whatever} is a subtype of {readonly a: whatever}.
|
|
64943
|
+
// This ensures the subtype relationship is ordered, and preventing declaration order
|
|
64944
|
+
// from deciding which type "wins" in union subtype reduction.
|
|
64945
|
+
// They're still assignable to one another, since `readonly` doesn't affect assignability.
|
|
64946
|
+
if ((relation === subtypeRelation || relation === strictSubtypeRelation) &&
|
|
64947
|
+
!!(sourcePropFlags & 64 /* Readonly */) && !(targetPropFlags & 64 /* Readonly */)) {
|
|
64948
|
+
return 0 /* False */;
|
|
64949
|
+
}
|
|
64870
64950
|
// If the target comes from a partial union prop, allow `undefined` in the target type
|
|
64871
64951
|
var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
|
|
64872
64952
|
if (!related) {
|
|
@@ -69899,12 +69979,16 @@ var ts;
|
|
|
69899
69979
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
69900
69980
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
69901
69981
|
}
|
|
69902
|
-
function
|
|
69982
|
+
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
69903
69983
|
// Computing the contextual type for a child of a JSX element involves resolving the type of the
|
|
69904
69984
|
// element's tag name, so we exclude that here to avoid circularities.
|
|
69985
|
+
// If check mode has `CheckMode.RestBindingElement`, we skip binding pattern contextual types,
|
|
69986
|
+
// as we want the type of a rest element to be generic when possible.
|
|
69905
69987
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
69906
69988
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
69907
|
-
|
|
69989
|
+
(checkMode && checkMode & 32 /* RestBindingElement */ ?
|
|
69990
|
+
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
69991
|
+
: getContextualType(node));
|
|
69908
69992
|
return contextualType && !isGenericType(contextualType);
|
|
69909
69993
|
}
|
|
69910
69994
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -69917,7 +70001,7 @@ var ts;
|
|
|
69917
70001
|
// 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
|
|
69918
70002
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
69919
70003
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
69920
|
-
(isConstraintPosition(type, reference) ||
|
|
70004
|
+
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
69921
70005
|
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
|
|
69922
70006
|
}
|
|
69923
70007
|
function isExportOrExportExpression(location) {
|
|
@@ -69985,7 +70069,7 @@ var ts;
|
|
|
69985
70069
|
var links = getNodeLinks(location);
|
|
69986
70070
|
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
69987
70071
|
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
69988
|
-
var parentType = getTypeForBindingElementParent(parent);
|
|
70072
|
+
var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
|
|
69989
70073
|
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
69990
70074
|
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
69991
70075
|
var pattern = declaration.parent;
|
|
@@ -70838,7 +70922,7 @@ var ts;
|
|
|
70838
70922
|
var parent = declaration.parent.parent;
|
|
70839
70923
|
var name = declaration.propertyName || declaration.name;
|
|
70840
70924
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
70841
|
-
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
|
|
70925
|
+
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
|
|
70842
70926
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
70843
70927
|
return undefined;
|
|
70844
70928
|
if (parent.name.kind === 201 /* ArrayBindingPattern */) {
|
|
@@ -75549,8 +75633,8 @@ var ts;
|
|
|
75549
75633
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75550
75634
|
var synthType = type;
|
|
75551
75635
|
if (!synthType.defaultOnlyType) {
|
|
75552
|
-
var
|
|
75553
|
-
synthType.defaultOnlyType =
|
|
75636
|
+
var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75637
|
+
synthType.defaultOnlyType = type_5;
|
|
75554
75638
|
}
|
|
75555
75639
|
return synthType.defaultOnlyType;
|
|
75556
75640
|
}
|
|
@@ -76004,7 +76088,7 @@ var ts;
|
|
|
76004
76088
|
var links = getSymbolLinks(parameter);
|
|
76005
76089
|
if (!links.type) {
|
|
76006
76090
|
var declaration = parameter.valueDeclaration;
|
|
76007
|
-
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*
|
|
76091
|
+
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
|
|
76008
76092
|
if (declaration.name.kind !== 79 /* Identifier */) {
|
|
76009
76093
|
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
|
|
76010
76094
|
if (links.type === unknownType) {
|
|
@@ -76277,12 +76361,12 @@ var ts;
|
|
|
76277
76361
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
76278
76362
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
76279
76363
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
76280
|
-
var
|
|
76364
|
+
var type_6 = getBaseConstraintOfType(operandType) || operandType;
|
|
76281
76365
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
76282
|
-
if (
|
|
76366
|
+
if (type_6.flags & 3 /* AnyOrUnknown */) {
|
|
76283
76367
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
76284
76368
|
}
|
|
76285
|
-
return !!(filterType(
|
|
76369
|
+
return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
76286
76370
|
}
|
|
76287
76371
|
var type = getTypeOfExpression(node.expression);
|
|
76288
76372
|
if (!isLiteralType(type)) {
|
|
@@ -77735,11 +77819,11 @@ var ts;
|
|
|
77735
77819
|
}
|
|
77736
77820
|
}
|
|
77737
77821
|
function checkExpressionCached(node, checkMode) {
|
|
77822
|
+
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77823
|
+
return checkExpression(node, checkMode);
|
|
77824
|
+
}
|
|
77738
77825
|
var links = getNodeLinks(node);
|
|
77739
77826
|
if (!links.resolvedType) {
|
|
77740
|
-
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77741
|
-
return checkExpression(node, checkMode);
|
|
77742
|
-
}
|
|
77743
77827
|
// When computing a type that we're going to cache, we need to ignore any ongoing control flow
|
|
77744
77828
|
// analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
|
|
77745
77829
|
// to the top of the stack ensures all transient types are computed from a known point.
|
|
@@ -77759,10 +77843,12 @@ var ts;
|
|
|
77759
77843
|
node.kind === 228 /* AsExpression */ ||
|
|
77760
77844
|
ts.isJSDocTypeAssertion(node);
|
|
77761
77845
|
}
|
|
77762
|
-
function checkDeclarationInitializer(declaration, contextualType) {
|
|
77846
|
+
function checkDeclarationInitializer(declaration, checkMode, contextualType) {
|
|
77763
77847
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
77764
77848
|
var type = getQuickTypeOfExpression(initializer) ||
|
|
77765
|
-
(contextualType ?
|
|
77849
|
+
(contextualType ?
|
|
77850
|
+
checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
|
|
77851
|
+
: checkExpressionCached(initializer, checkMode));
|
|
77766
77852
|
return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
|
|
77767
77853
|
isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
|
|
77768
77854
|
padTupleType(type, declaration.name) : type;
|
|
@@ -78402,6 +78488,7 @@ var ts;
|
|
|
78402
78488
|
}
|
|
78403
78489
|
}
|
|
78404
78490
|
checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
|
|
78491
|
+
checkUnmatchedJSDocParameters(node);
|
|
78405
78492
|
ts.forEach(node.parameters, checkParameter);
|
|
78406
78493
|
// TODO(rbuckton): Should we start checking JSDoc types?
|
|
78407
78494
|
if (node.type) {
|
|
@@ -79973,31 +80060,6 @@ var ts;
|
|
|
79973
80060
|
}
|
|
79974
80061
|
function checkJSDocParameterTag(node) {
|
|
79975
80062
|
checkSourceElement(node.typeExpression);
|
|
79976
|
-
if (!ts.getParameterSymbolFromJSDoc(node)) {
|
|
79977
|
-
var decl = ts.getHostSignatureFromJSDoc(node);
|
|
79978
|
-
// don't issue an error for invalid hosts -- just functions --
|
|
79979
|
-
// and give a better error message when the host function mentions `arguments`
|
|
79980
|
-
// but the tag doesn't have an array type
|
|
79981
|
-
if (decl) {
|
|
79982
|
-
var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
|
|
79983
|
-
if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
|
|
79984
|
-
return;
|
|
79985
|
-
}
|
|
79986
|
-
if (!containsArgumentsReference(decl)) {
|
|
79987
|
-
if (ts.isQualifiedName(node.name)) {
|
|
79988
|
-
error(node.name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(node.name), ts.entityNameToString(node.name.left));
|
|
79989
|
-
}
|
|
79990
|
-
else {
|
|
79991
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
|
|
79992
|
-
}
|
|
79993
|
-
}
|
|
79994
|
-
else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
|
|
79995
|
-
node.typeExpression && node.typeExpression.type &&
|
|
79996
|
-
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
|
|
79997
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 160 /* QualifiedName */ ? node.name.right : node.name));
|
|
79998
|
-
}
|
|
79999
|
-
}
|
|
80000
|
-
}
|
|
80001
80063
|
}
|
|
80002
80064
|
function checkJSDocPropertyTag(node) {
|
|
80003
80065
|
checkSourceElement(node.typeExpression);
|
|
@@ -80699,7 +80761,8 @@ var ts;
|
|
|
80699
80761
|
}
|
|
80700
80762
|
// check private/protected variable access
|
|
80701
80763
|
var parent = node.parent.parent;
|
|
80702
|
-
var
|
|
80764
|
+
var parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
80765
|
+
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
80703
80766
|
var name = node.propertyName || node.name;
|
|
80704
80767
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
80705
80768
|
var exprType = getLiteralTypeFromPropertyName(name);
|
|
@@ -81938,7 +82001,7 @@ var ts;
|
|
|
81938
82001
|
var declaration = catchClause.variableDeclaration;
|
|
81939
82002
|
var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
|
|
81940
82003
|
if (typeNode) {
|
|
81941
|
-
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
|
|
82004
|
+
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */);
|
|
81942
82005
|
if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
|
|
81943
82006
|
grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
|
|
81944
82007
|
}
|
|
@@ -82069,6 +82132,45 @@ var ts;
|
|
|
82069
82132
|
error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
|
|
82070
82133
|
}
|
|
82071
82134
|
}
|
|
82135
|
+
function checkUnmatchedJSDocParameters(node) {
|
|
82136
|
+
var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
|
|
82137
|
+
if (!ts.length(jsdocParameters))
|
|
82138
|
+
return;
|
|
82139
|
+
var isJs = ts.isInJSFile(node);
|
|
82140
|
+
var parameters = new ts.Set();
|
|
82141
|
+
var excludedParameters = new ts.Set();
|
|
82142
|
+
ts.forEach(node.parameters, function (_a, index) {
|
|
82143
|
+
var name = _a.name;
|
|
82144
|
+
if (ts.isIdentifier(name)) {
|
|
82145
|
+
parameters.add(name.escapedText);
|
|
82146
|
+
}
|
|
82147
|
+
if (ts.isBindingPattern(name)) {
|
|
82148
|
+
excludedParameters.add(index);
|
|
82149
|
+
}
|
|
82150
|
+
});
|
|
82151
|
+
var containsArguments = containsArgumentsReference(node);
|
|
82152
|
+
if (containsArguments) {
|
|
82153
|
+
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82154
|
+
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82155
|
+
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82156
|
+
errorOrSuggestion(isJs, lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
|
|
82157
|
+
}
|
|
82158
|
+
}
|
|
82159
|
+
else {
|
|
82160
|
+
ts.forEach(jsdocParameters, function (_a, index) {
|
|
82161
|
+
var name = _a.name;
|
|
82162
|
+
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
82163
|
+
return;
|
|
82164
|
+
}
|
|
82165
|
+
if (ts.isQualifiedName(name)) {
|
|
82166
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82167
|
+
}
|
|
82168
|
+
else {
|
|
82169
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
82170
|
+
}
|
|
82171
|
+
});
|
|
82172
|
+
}
|
|
82173
|
+
}
|
|
82072
82174
|
/**
|
|
82073
82175
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
82074
82176
|
*/
|
|
@@ -83044,7 +83146,7 @@ var ts;
|
|
|
83044
83146
|
var isAmbientExternalModule = ts.isAmbientModule(node);
|
|
83045
83147
|
var contextErrorMessage = isAmbientExternalModule
|
|
83046
83148
|
? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
|
|
83047
|
-
: ts.Diagnostics.
|
|
83149
|
+
: ts.Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
|
|
83048
83150
|
if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
|
|
83049
83151
|
// If we hit a module declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83050
83152
|
return;
|
|
@@ -83277,6 +83379,9 @@ var ts;
|
|
|
83277
83379
|
var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
|
|
83278
83380
|
addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
|
|
83279
83381
|
}
|
|
83382
|
+
if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
|
|
83383
|
+
error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
|
|
83384
|
+
}
|
|
83280
83385
|
break;
|
|
83281
83386
|
}
|
|
83282
83387
|
case 274 /* ExportSpecifier */: {
|
|
@@ -83360,7 +83465,7 @@ var ts;
|
|
|
83360
83465
|
}
|
|
83361
83466
|
}
|
|
83362
83467
|
function checkImportDeclaration(node) {
|
|
83363
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83468
|
+
if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
83364
83469
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83365
83470
|
return;
|
|
83366
83471
|
}
|
|
@@ -83393,7 +83498,7 @@ var ts;
|
|
|
83393
83498
|
checkAssertClause(node);
|
|
83394
83499
|
}
|
|
83395
83500
|
function checkImportEqualsDeclaration(node) {
|
|
83396
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83501
|
+
if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
83397
83502
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83398
83503
|
return;
|
|
83399
83504
|
}
|
|
@@ -83430,7 +83535,7 @@ var ts;
|
|
|
83430
83535
|
}
|
|
83431
83536
|
}
|
|
83432
83537
|
function checkExportDeclaration(node) {
|
|
83433
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83538
|
+
if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
83434
83539
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
83435
83540
|
return;
|
|
83436
83541
|
}
|
|
@@ -84664,7 +84769,7 @@ var ts;
|
|
|
84664
84769
|
return errorType;
|
|
84665
84770
|
}
|
|
84666
84771
|
if (ts.isBindingPattern(node)) {
|
|
84667
|
-
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
|
|
84772
|
+
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType;
|
|
84668
84773
|
}
|
|
84669
84774
|
if (isInRightSideOfImportOrExportAssignment(node)) {
|
|
84670
84775
|
var symbol = getSymbolAtLocation(node);
|
|
@@ -114411,9 +114516,9 @@ var ts;
|
|
|
114411
114516
|
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
|
|
114412
114517
|
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
|
114413
114518
|
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
|
114414
|
-
ts.Diagnostics.
|
|
114519
|
+
ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114415
114520
|
ts.Diagnostics.An_export_declaration_cannot_have_modifiers.code,
|
|
114416
|
-
ts.Diagnostics.
|
|
114521
|
+
ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114417
114522
|
ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
|
|
114418
114523
|
ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
|
|
114419
114524
|
ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
|
|
@@ -115481,7 +115586,7 @@ var ts;
|
|
|
115481
115586
|
ts.Debug.assert(!!sourceFile.bindDiagnostics);
|
|
115482
115587
|
var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
|
|
115483
115588
|
var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
|
|
115484
|
-
var isPlainJs =
|
|
115589
|
+
var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
|
|
115485
115590
|
var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
|
|
115486
115591
|
// By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
|
|
115487
115592
|
// - plain JS: .js files with no // ts-check and checkJs: undefined
|
|
@@ -126875,6 +126980,10 @@ var ts;
|
|
|
126875
126980
|
return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
|
|
126876
126981
|
}
|
|
126877
126982
|
ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
|
|
126983
|
+
function jsxModeNeedsExplicitImport(jsx) {
|
|
126984
|
+
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
126985
|
+
}
|
|
126986
|
+
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
126878
126987
|
// #endregion
|
|
126879
126988
|
})(ts || (ts = {}));
|
|
126880
126989
|
/*@internal*/
|
|
@@ -128819,9 +128928,18 @@ var ts;
|
|
|
128819
128928
|
return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
|
|
128820
128929
|
}
|
|
128821
128930
|
}
|
|
128931
|
+
function isEmitResolutionKindUsingNodeModules(compilerOptions) {
|
|
128932
|
+
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ||
|
|
128933
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
|
|
128934
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
|
|
128935
|
+
}
|
|
128936
|
+
function isEmitModuleResolutionRespectingExportMaps(compilerOptions) {
|
|
128937
|
+
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
|
|
128938
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
|
|
128939
|
+
}
|
|
128822
128940
|
function getSupportedExtensionsForModuleResolution(compilerOptions) {
|
|
128823
128941
|
var extensions = ts.getSupportedExtensions(compilerOptions);
|
|
128824
|
-
return
|
|
128942
|
+
return isEmitResolutionKindUsingNodeModules(compilerOptions) ?
|
|
128825
128943
|
ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
|
|
128826
128944
|
extensions;
|
|
128827
128945
|
}
|
|
@@ -128984,7 +129102,7 @@ var ts;
|
|
|
128984
129102
|
result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
128985
129103
|
}
|
|
128986
129104
|
getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
|
|
128987
|
-
if (
|
|
129105
|
+
if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
|
|
128988
129106
|
// If looking for a global package name, don't just include everything in `node_modules` because that includes dependencies' own dependencies.
|
|
128989
129107
|
// (But do if we didn't find anything, e.g. 'package.json' missing.)
|
|
128990
129108
|
var foundGlobal = false;
|
|
@@ -129001,12 +129119,68 @@ var ts;
|
|
|
129001
129119
|
}
|
|
129002
129120
|
}
|
|
129003
129121
|
if (!foundGlobal) {
|
|
129004
|
-
|
|
129122
|
+
var ancestorLookup = function (ancestor) {
|
|
129005
129123
|
var nodeModules = ts.combinePaths(ancestor, "node_modules");
|
|
129006
129124
|
if (ts.tryDirectoryExists(host, nodeModules)) {
|
|
129007
129125
|
getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result);
|
|
129008
129126
|
}
|
|
129009
|
-
}
|
|
129127
|
+
};
|
|
129128
|
+
if (fragmentDirectory && isEmitModuleResolutionRespectingExportMaps(compilerOptions)) {
|
|
129129
|
+
var nodeModulesDirectoryLookup_1 = ancestorLookup;
|
|
129130
|
+
ancestorLookup = function (ancestor) {
|
|
129131
|
+
var components = ts.getPathComponents(fragment);
|
|
129132
|
+
components.shift(); // shift off empty root
|
|
129133
|
+
var packagePath = components.shift();
|
|
129134
|
+
if (!packagePath) {
|
|
129135
|
+
return nodeModulesDirectoryLookup_1(ancestor);
|
|
129136
|
+
}
|
|
129137
|
+
if (ts.startsWith(packagePath, "@")) {
|
|
129138
|
+
var subName = components.shift();
|
|
129139
|
+
if (!subName) {
|
|
129140
|
+
return nodeModulesDirectoryLookup_1(ancestor);
|
|
129141
|
+
}
|
|
129142
|
+
packagePath = ts.combinePaths(packagePath, subName);
|
|
129143
|
+
}
|
|
129144
|
+
var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
|
|
129145
|
+
if (ts.tryFileExists(host, packageFile)) {
|
|
129146
|
+
var packageJson = ts.readJson(packageFile, host);
|
|
129147
|
+
var exports = packageJson.exports;
|
|
129148
|
+
if (exports) {
|
|
129149
|
+
if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
|
|
129150
|
+
return; // null exports or entrypoint only, no sub-modules available
|
|
129151
|
+
}
|
|
129152
|
+
var keys = ts.getOwnKeys(exports);
|
|
129153
|
+
var fragmentSubpath_1 = components.join("/");
|
|
129154
|
+
var processedKeys = ts.mapDefined(keys, function (k) {
|
|
129155
|
+
if (k === ".")
|
|
129156
|
+
return undefined;
|
|
129157
|
+
if (!ts.startsWith(k, "./"))
|
|
129158
|
+
return undefined;
|
|
129159
|
+
var subpath = k.substring(2);
|
|
129160
|
+
if (!ts.startsWith(subpath, fragmentSubpath_1))
|
|
129161
|
+
return undefined;
|
|
129162
|
+
// subpath is a valid export (barring conditions, which we don't currently check here)
|
|
129163
|
+
if (!ts.stringContains(subpath, "*")) {
|
|
129164
|
+
return subpath;
|
|
129165
|
+
}
|
|
129166
|
+
// pattern export - only return everything up to the `*`, so the user can autocomplete, then
|
|
129167
|
+
// keep filling in the pattern (we could speculatively return a list of options by hitting disk,
|
|
129168
|
+
// but conditions will make that somewhat awkward, as each condition may have a different set of possible
|
|
129169
|
+
// options for the `*`.
|
|
129170
|
+
return subpath.slice(0, subpath.indexOf("*"));
|
|
129171
|
+
});
|
|
129172
|
+
ts.forEach(processedKeys, function (k) {
|
|
129173
|
+
if (k) {
|
|
129174
|
+
result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
129175
|
+
}
|
|
129176
|
+
});
|
|
129177
|
+
return;
|
|
129178
|
+
}
|
|
129179
|
+
}
|
|
129180
|
+
return nodeModulesDirectoryLookup_1(ancestor);
|
|
129181
|
+
};
|
|
129182
|
+
}
|
|
129183
|
+
ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
|
|
129010
129184
|
}
|
|
129011
129185
|
}
|
|
129012
129186
|
return result;
|
|
@@ -138499,6 +138673,7 @@ var ts;
|
|
|
138499
138673
|
return oldImports;
|
|
138500
138674
|
}
|
|
138501
138675
|
var typeChecker = program.getTypeChecker();
|
|
138676
|
+
var compilerOptions = program.getCompilerOptions();
|
|
138502
138677
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
138503
138678
|
var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile);
|
|
138504
138679
|
var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */);
|
|
@@ -138555,7 +138730,7 @@ var ts;
|
|
|
138555
138730
|
return usedImports;
|
|
138556
138731
|
function isDeclarationUsed(identifier) {
|
|
138557
138732
|
// The JSX factory symbol is always used if JSX elements are present - even if they are not allowed.
|
|
138558
|
-
return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) ||
|
|
138733
|
+
return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx) ||
|
|
138559
138734
|
ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile);
|
|
138560
138735
|
}
|
|
138561
138736
|
}
|
|
@@ -145795,8 +145970,18 @@ var ts;
|
|
|
145795
145970
|
var indent = sourceFile.text.slice(startPosition, fnStart);
|
|
145796
145971
|
this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
|
|
145797
145972
|
};
|
|
145973
|
+
ChangeTracker.prototype.createJSDocText = function (sourceFile, node) {
|
|
145974
|
+
var comments = ts.flatMap(node.jsDoc, function (jsDoc) {
|
|
145975
|
+
return ts.isString(jsDoc.comment) ? ts.factory.createJSDocText(jsDoc.comment) : jsDoc.comment;
|
|
145976
|
+
});
|
|
145977
|
+
var jsDoc = ts.singleOrUndefined(node.jsDoc);
|
|
145978
|
+
return jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && ts.length(comments) === 0 ? undefined :
|
|
145979
|
+
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
145980
|
+
};
|
|
145981
|
+
ChangeTracker.prototype.replaceJSDocComment = function (sourceFile, node, tags) {
|
|
145982
|
+
this.insertJsdocCommentBefore(sourceFile, updateJSDocHost(node), ts.factory.createJSDocComment(this.createJSDocText(sourceFile, node), ts.factory.createNodeArray(tags)));
|
|
145983
|
+
};
|
|
145798
145984
|
ChangeTracker.prototype.addJSDocTags = function (sourceFile, parent, newTags) {
|
|
145799
|
-
var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
|
|
145800
145985
|
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
145801
145986
|
var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags.some(function (tag, i) {
|
|
145802
145987
|
var merged = tryMergeJsdocTags(tag, newTag);
|
|
@@ -145804,20 +145989,10 @@ var ts;
|
|
|
145804
145989
|
oldTags[i] = merged;
|
|
145805
145990
|
return !!merged;
|
|
145806
145991
|
}); });
|
|
145807
|
-
|
|
145808
|
-
var jsDoc = ts.singleOrUndefined(parent.jsDoc);
|
|
145809
|
-
var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
|
|
145810
|
-
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
145811
|
-
var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
|
|
145812
|
-
var host = updateJSDocHost(parent);
|
|
145813
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
145992
|
+
this.replaceJSDocComment(sourceFile, parent, __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true));
|
|
145814
145993
|
};
|
|
145815
145994
|
ChangeTracker.prototype.filterJSDocTags = function (sourceFile, parent, predicate) {
|
|
145816
|
-
|
|
145817
|
-
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
145818
|
-
var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray([], (ts.filter(oldTags, predicate) || ts.emptyArray), true)));
|
|
145819
|
-
var host = updateJSDocHost(parent);
|
|
145820
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
145995
|
+
this.replaceJSDocComment(sourceFile, parent, ts.filter(ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }), predicate));
|
|
145821
145996
|
};
|
|
145822
145997
|
ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) {
|
|
145823
145998
|
this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text });
|
|
@@ -149612,9 +149787,9 @@ var ts;
|
|
|
149612
149787
|
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
|
|
149613
149788
|
var checker = program.getTypeChecker();
|
|
149614
149789
|
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
|
|
149615
|
-
var
|
|
149790
|
+
var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
|
|
149616
149791
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149617
|
-
var fix = getImportFixForSymbol(sourceFile,
|
|
149792
|
+
var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
149618
149793
|
if (fix) {
|
|
149619
149794
|
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
149620
149795
|
}
|
|
@@ -149803,7 +149978,7 @@ var ts;
|
|
|
149803
149978
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
149804
149979
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
149805
149980
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
149806
|
-
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
|
|
149981
|
+
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
|
|
149807
149982
|
}
|
|
149808
149983
|
function codeFixActionToCodeAction(_a) {
|
|
149809
149984
|
var description = _a.description, changes = _a.changes, commands = _a.commands;
|
|
@@ -149863,7 +150038,7 @@ var ts;
|
|
|
149863
150038
|
/*position*/ undefined,
|
|
149864
150039
|
/*isValidTypeOnlyUseSite*/ false,
|
|
149865
150040
|
/*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
149866
|
-
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
|
|
150041
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
|
149867
150042
|
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
149868
150043
|
}
|
|
149869
150044
|
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
@@ -150033,7 +150208,7 @@ var ts;
|
|
|
150033
150208
|
// 5. Literally nothing to go on
|
|
150034
150209
|
return true;
|
|
150035
150210
|
}
|
|
150036
|
-
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire,
|
|
150211
|
+
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
|
|
150037
150212
|
var isJs = ts.isSourceFileJS(sourceFile);
|
|
150038
150213
|
var compilerOptions = program.getCompilerOptions();
|
|
150039
150214
|
var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
|
|
@@ -150042,7 +150217,7 @@ var ts;
|
|
|
150042
150217
|
? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
|
|
150043
150218
|
: function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
|
|
150044
150219
|
var computedWithoutCacheCount = 0;
|
|
150045
|
-
var fixes = ts.flatMap(
|
|
150220
|
+
var fixes = ts.flatMap(exportInfo, function (exportInfo, i) {
|
|
150046
150221
|
var checker = getChecker(exportInfo.isFromPackageJson);
|
|
150047
150222
|
var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
|
|
150048
150223
|
var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
|
|
@@ -150051,7 +150226,7 @@ var ts;
|
|
|
150051
150226
|
return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
|
|
150052
150227
|
// `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
|
|
150053
150228
|
return !importedSymbolHasValueMeaning && isJs && position !== undefined
|
|
150054
|
-
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo }
|
|
150229
|
+
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
|
|
150055
150230
|
: {
|
|
150056
150231
|
kind: 3 /* AddNew */,
|
|
150057
150232
|
moduleSpecifier: moduleSpecifier,
|
|
@@ -150059,6 +150234,7 @@ var ts;
|
|
|
150059
150234
|
useRequire: useRequire,
|
|
150060
150235
|
addAsTypeOnly: addAsTypeOnly,
|
|
150061
150236
|
exportInfo: exportInfo,
|
|
150237
|
+
isReExport: i > 0,
|
|
150062
150238
|
};
|
|
150063
150239
|
});
|
|
150064
150240
|
});
|
|
@@ -150096,12 +150272,13 @@ var ts;
|
|
|
150096
150272
|
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
150097
150273
|
}
|
|
150098
150274
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
150099
|
-
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
150275
|
+
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
|
|
150100
150276
|
}
|
|
150101
|
-
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150102
|
-
|
|
150277
|
+
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150278
|
+
var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
|
|
150279
|
+
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
|
|
150103
150280
|
}
|
|
150104
|
-
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150281
|
+
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150105
150282
|
if (!ts.some(fixes))
|
|
150106
150283
|
return;
|
|
150107
150284
|
// These will always be placed first if available, and are better than other kinds
|
|
@@ -150110,22 +150287,37 @@ var ts;
|
|
|
150110
150287
|
}
|
|
150111
150288
|
return fixes.reduce(function (best, fix) {
|
|
150112
150289
|
// Takes true branch of conditional if `fix` is better than `best`
|
|
150113
|
-
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
150290
|
+
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best;
|
|
150114
150291
|
});
|
|
150115
150292
|
}
|
|
150116
150293
|
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
150117
|
-
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
|
|
150294
|
+
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) {
|
|
150118
150295
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
150119
150296
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
150120
150297
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
150121
|
-
|| ts.compareBooleans(
|
|
150298
|
+
|| ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath))
|
|
150122
150299
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
150123
150300
|
}
|
|
150124
150301
|
return 0 /* EqualTo */;
|
|
150125
150302
|
}
|
|
150126
|
-
|
|
150127
|
-
|
|
150128
|
-
|
|
150303
|
+
// This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export.
|
|
150304
|
+
// E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`.
|
|
150305
|
+
// This can produce false positives or negatives if re-exports cross into sibling directories
|
|
150306
|
+
// (e.g. `export * from "../whatever"`) or are not named "index" (we don't even try to consider
|
|
150307
|
+
// this if we're in a resolution mode where you can't drop trailing "/index" from paths).
|
|
150308
|
+
function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath) {
|
|
150309
|
+
var _a;
|
|
150310
|
+
if (fix.isReExport &&
|
|
150311
|
+
((_a = fix.exportInfo) === null || _a === void 0 ? void 0 : _a.moduleFileName) &&
|
|
150312
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
|
|
150313
|
+
isIndexFileName(fix.exportInfo.moduleFileName)) {
|
|
150314
|
+
var reExportDir = toPath(ts.getDirectoryPath(fix.exportInfo.moduleFileName));
|
|
150315
|
+
return ts.startsWith((importingFile.path), reExportDir);
|
|
150316
|
+
}
|
|
150317
|
+
return false;
|
|
150318
|
+
}
|
|
150319
|
+
function isIndexFileName(fileName) {
|
|
150320
|
+
return ts.getBaseFileName(fileName, [".js", ".jsx", ".d.ts", ".ts", ".tsx"], /*ignoreCase*/ true) === "index";
|
|
150129
150321
|
}
|
|
150130
150322
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
150131
150323
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
@@ -150143,9 +150335,9 @@ var ts;
|
|
|
150143
150335
|
return undefined;
|
|
150144
150336
|
var symbol = checker.getAliasedSymbol(umdSymbol);
|
|
150145
150337
|
var symbolName = umdSymbol.name;
|
|
150146
|
-
var
|
|
150338
|
+
var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
150147
150339
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150148
|
-
var fixes = getImportFixes(
|
|
150340
|
+
var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
150149
150341
|
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
150150
150342
|
}
|
|
150151
150343
|
function getUmdSymbol(token, checker) {
|
|
@@ -150212,8 +150404,8 @@ var ts;
|
|
|
150212
150404
|
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
|
|
150213
150405
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
|
|
150214
150406
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150215
|
-
var
|
|
150216
|
-
var fixes = ts.arrayFrom(ts.flatMapIterator(
|
|
150407
|
+
var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150408
|
+
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
|
|
150217
150409
|
var _ = _a[0], exportInfos = _a[1];
|
|
150218
150410
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
150219
150411
|
}));
|
|
@@ -150229,12 +150421,9 @@ var ts;
|
|
|
150229
150421
|
return undefined;
|
|
150230
150422
|
return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
|
|
150231
150423
|
}
|
|
150232
|
-
function jsxModeNeedsExplicitImport(jsx) {
|
|
150233
|
-
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
150234
|
-
}
|
|
150235
150424
|
function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
|
|
150236
150425
|
var parent = symbolToken.parent;
|
|
150237
|
-
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
150426
|
+
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
150238
150427
|
var jsxNamespace = checker.getJsxNamespace(sourceFile);
|
|
150239
150428
|
if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
|
|
150240
150429
|
return jsxNamespace;
|
|
@@ -152314,6 +152503,95 @@ var ts;
|
|
|
152314
152503
|
})(ts || (ts = {}));
|
|
152315
152504
|
/* @internal */
|
|
152316
152505
|
var ts;
|
|
152506
|
+
(function (ts) {
|
|
152507
|
+
var codefix;
|
|
152508
|
+
(function (codefix) {
|
|
152509
|
+
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
152510
|
+
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
152511
|
+
var errorCodes = [
|
|
152512
|
+
ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code,
|
|
152513
|
+
];
|
|
152514
|
+
codefix.registerCodeFix({
|
|
152515
|
+
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
152516
|
+
errorCodes: errorCodes,
|
|
152517
|
+
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
152518
|
+
var sourceFile = context.sourceFile, span = context.span;
|
|
152519
|
+
var actions = [];
|
|
152520
|
+
var info = getInfo(sourceFile, span.start);
|
|
152521
|
+
if (info) {
|
|
152522
|
+
ts.append(actions, getDeleteAction(context, info));
|
|
152523
|
+
ts.append(actions, getRenameAction(context, info));
|
|
152524
|
+
return actions;
|
|
152525
|
+
}
|
|
152526
|
+
return undefined;
|
|
152527
|
+
},
|
|
152528
|
+
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
152529
|
+
var tagsToSignature = new ts.Map();
|
|
152530
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
152531
|
+
codefix.eachDiagnostic(context, errorCodes, function (_a) {
|
|
152532
|
+
var file = _a.file, start = _a.start;
|
|
152533
|
+
var info = getInfo(file, start);
|
|
152534
|
+
if (info) {
|
|
152535
|
+
tagsToSignature.set(info.signature, ts.append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
152536
|
+
}
|
|
152537
|
+
});
|
|
152538
|
+
tagsToSignature.forEach(function (tags, signature) {
|
|
152539
|
+
if (context.fixId === deleteUnmatchedParameter) {
|
|
152540
|
+
var tagsSet_1 = new ts.Set(tags);
|
|
152541
|
+
changes.filterJSDocTags(signature.getSourceFile(), signature, function (t) { return !tagsSet_1.has(t); });
|
|
152542
|
+
}
|
|
152543
|
+
});
|
|
152544
|
+
}));
|
|
152545
|
+
}
|
|
152546
|
+
});
|
|
152547
|
+
function getDeleteAction(context, _a) {
|
|
152548
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
152549
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
152550
|
+
return changeTracker.filterJSDocTags(context.sourceFile, signature, function (t) { return t !== jsDocParameterTag; });
|
|
152551
|
+
});
|
|
152552
|
+
return codefix.createCodeFixAction(deleteUnmatchedParameter, changes, [ts.Diagnostics.Delete_unused_param_tag_0, name.getText(context.sourceFile)], deleteUnmatchedParameter, ts.Diagnostics.Delete_all_unused_param_tags);
|
|
152553
|
+
}
|
|
152554
|
+
function getRenameAction(context, _a) {
|
|
152555
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
152556
|
+
if (!ts.length(signature.parameters))
|
|
152557
|
+
return undefined;
|
|
152558
|
+
var sourceFile = context.sourceFile;
|
|
152559
|
+
var tags = ts.getJSDocTags(signature);
|
|
152560
|
+
var names = new ts.Set();
|
|
152561
|
+
for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
|
|
152562
|
+
var tag = tags_2[_i];
|
|
152563
|
+
if (ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name)) {
|
|
152564
|
+
names.add(tag.name.escapedText);
|
|
152565
|
+
}
|
|
152566
|
+
}
|
|
152567
|
+
// @todo - match to all available names instead to the first parameter name
|
|
152568
|
+
// @see /codeFixRenameUnmatchedParameter3.ts
|
|
152569
|
+
var parameterName = ts.firstDefined(signature.parameters, function (p) {
|
|
152570
|
+
return ts.isIdentifier(p.name) && !names.has(p.name.escapedText) ? p.name.getText(sourceFile) : undefined;
|
|
152571
|
+
});
|
|
152572
|
+
if (parameterName === undefined)
|
|
152573
|
+
return undefined;
|
|
152574
|
+
var newJSDocParameterTag = ts.factory.updateJSDocParameterTag(jsDocParameterTag, jsDocParameterTag.tagName, ts.factory.createIdentifier(parameterName), jsDocParameterTag.isBracketed, jsDocParameterTag.typeExpression, jsDocParameterTag.isNameFirst, jsDocParameterTag.comment);
|
|
152575
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
152576
|
+
return changeTracker.replaceJSDocComment(sourceFile, signature, ts.map(tags, function (t) { return t === jsDocParameterTag ? newJSDocParameterTag : t; }));
|
|
152577
|
+
});
|
|
152578
|
+
return codefix.createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [ts.Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
|
|
152579
|
+
}
|
|
152580
|
+
function getInfo(sourceFile, pos) {
|
|
152581
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
152582
|
+
if (token.parent && ts.isJSDocParameterTag(token.parent) && ts.isIdentifier(token.parent.name)) {
|
|
152583
|
+
var jsDocParameterTag = token.parent;
|
|
152584
|
+
var signature = ts.getHostSignatureFromJSDoc(jsDocParameterTag);
|
|
152585
|
+
if (signature) {
|
|
152586
|
+
return { signature: signature, name: token.parent.name, jsDocParameterTag: jsDocParameterTag };
|
|
152587
|
+
}
|
|
152588
|
+
}
|
|
152589
|
+
return undefined;
|
|
152590
|
+
}
|
|
152591
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
152592
|
+
})(ts || (ts = {}));
|
|
152593
|
+
/* @internal */
|
|
152594
|
+
var ts;
|
|
152317
152595
|
(function (ts) {
|
|
152318
152596
|
var codefix;
|
|
152319
152597
|
(function (codefix) {
|