typescript 4.6.0-dev.20220207 → 4.6.0-dev.20220211
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 +1 -2
- package/lib/de/diagnosticMessages.generated.json +1 -2
- package/lib/es/diagnosticMessages.generated.json +1 -2
- package/lib/fr/diagnosticMessages.generated.json +1 -2
- package/lib/it/diagnosticMessages.generated.json +1 -2
- package/lib/ja/diagnosticMessages.generated.json +1 -2
- package/lib/ko/diagnosticMessages.generated.json +1 -2
- package/lib/pl/diagnosticMessages.generated.json +1 -2
- package/lib/pt-br/diagnosticMessages.generated.json +1 -2
- package/lib/ru/diagnosticMessages.generated.json +1 -2
- package/lib/tr/diagnosticMessages.generated.json +1 -2
- package/lib/tsc.js +188 -94
- package/lib/tsserver.js +378 -141
- package/lib/tsserverlibrary.js +378 -141
- package/lib/typescript.js +375 -139
- package/lib/typescriptServices.js +375 -139
- package/lib/typingsInstaller.js +204 -99
- package/lib/zh-cn/diagnosticMessages.generated.json +1 -2
- package/lib/zh-tw/diagnosticMessages.generated.json +1 -2
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220211";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8239,10 +8239,10 @@ var ts;
|
|
|
8239
8239
|
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."),
|
|
8240
8240
|
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."),
|
|
8241
8241
|
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."),
|
|
8242
|
-
|
|
8243
|
-
|
|
8242
|
+
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."),
|
|
8243
|
+
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."),
|
|
8244
8244
|
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."),
|
|
8245
|
-
|
|
8245
|
+
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."),
|
|
8246
8246
|
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'."),
|
|
8247
8247
|
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'."),
|
|
8248
8248
|
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."),
|
|
@@ -8274,6 +8274,7 @@ var ts;
|
|
|
8274
8274
|
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."),
|
|
8275
8275
|
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."),
|
|
8276
8276
|
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."),
|
|
8277
|
+
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."),
|
|
8277
8278
|
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."),
|
|
8278
8279
|
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."),
|
|
8279
8280
|
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."),
|
|
@@ -8410,6 +8411,8 @@ var ts;
|
|
|
8410
8411
|
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."),
|
|
8411
8412
|
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."),
|
|
8412
8413
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8414
|
+
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."),
|
|
8415
|
+
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."),
|
|
8413
8416
|
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."),
|
|
8414
8417
|
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."),
|
|
8415
8418
|
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),
|
|
@@ -9830,6 +9833,9 @@ var ts;
|
|
|
9830
9833
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9831
9834
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9832
9835
|
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9836
|
+
Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
|
|
9837
|
+
Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
|
|
9838
|
+
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}'"),
|
|
9833
9839
|
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."),
|
|
9834
9840
|
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'."),
|
|
9835
9841
|
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?"),
|
|
@@ -14091,6 +14097,10 @@ var ts;
|
|
|
14091
14097
|
return undefined;
|
|
14092
14098
|
}
|
|
14093
14099
|
ts.getDeclarationOfKind = getDeclarationOfKind;
|
|
14100
|
+
function getDeclarationsOfKind(symbol, kind) {
|
|
14101
|
+
return ts.filter(symbol.declarations || ts.emptyArray, function (d) { return d.kind === kind; });
|
|
14102
|
+
}
|
|
14103
|
+
ts.getDeclarationsOfKind = getDeclarationsOfKind;
|
|
14094
14104
|
function createSymbolTable(symbols) {
|
|
14095
14105
|
var result = new ts.Map();
|
|
14096
14106
|
if (symbols) {
|
|
@@ -14326,6 +14336,10 @@ var ts;
|
|
|
14326
14336
|
return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
|
|
14327
14337
|
}
|
|
14328
14338
|
ts.getSourceFileOfModule = getSourceFileOfModule;
|
|
14339
|
+
function isPlainJsFile(file, checkJs) {
|
|
14340
|
+
return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined;
|
|
14341
|
+
}
|
|
14342
|
+
ts.isPlainJsFile = isPlainJsFile;
|
|
14329
14343
|
function isStatementWithLocals(node) {
|
|
14330
14344
|
switch (node.kind) {
|
|
14331
14345
|
case 234 /* Block */:
|
|
@@ -47103,6 +47117,9 @@ var ts;
|
|
|
47103
47117
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47104
47118
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47105
47119
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47120
|
+
CheckMode[CheckMode["RestBindingElement"] = 32] = "RestBindingElement";
|
|
47121
|
+
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
47122
|
+
// we need to preserve generic types instead of substituting them for constraints
|
|
47106
47123
|
})(CheckMode || (CheckMode = {}));
|
|
47107
47124
|
var SignatureCheckMode;
|
|
47108
47125
|
(function (SignatureCheckMode) {
|
|
@@ -48155,13 +48172,13 @@ var ts;
|
|
|
48155
48172
|
else { // error
|
|
48156
48173
|
var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
|
|
48157
48174
|
var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
|
|
48158
|
-
var message = isEitherEnum
|
|
48159
|
-
? ts.Diagnostics.
|
|
48160
|
-
: isEitherBlockScoped_1
|
|
48161
|
-
? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
48175
|
+
var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
|
|
48176
|
+
: isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
48162
48177
|
: ts.Diagnostics.Duplicate_identifier_0;
|
|
48163
48178
|
var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
|
|
48164
48179
|
var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
|
|
48180
|
+
var isSourcePlainJs = ts.isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
|
|
48181
|
+
var isTargetPlainJs = ts.isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
|
|
48165
48182
|
var symbolName_1 = symbolToString(source);
|
|
48166
48183
|
// Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch
|
|
48167
48184
|
if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
|
|
@@ -48173,12 +48190,16 @@ var ts;
|
|
|
48173
48190
|
var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
|
|
48174
48191
|
return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
|
|
48175
48192
|
});
|
|
48176
|
-
|
|
48177
|
-
|
|
48193
|
+
if (!isSourcePlainJs)
|
|
48194
|
+
addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
|
|
48195
|
+
if (!isTargetPlainJs)
|
|
48196
|
+
addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
|
|
48178
48197
|
}
|
|
48179
48198
|
else {
|
|
48180
|
-
|
|
48181
|
-
|
|
48199
|
+
if (!isSourcePlainJs)
|
|
48200
|
+
addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
|
|
48201
|
+
if (!isTargetPlainJs)
|
|
48202
|
+
addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
|
|
48182
48203
|
}
|
|
48183
48204
|
}
|
|
48184
48205
|
return target;
|
|
@@ -48635,6 +48656,8 @@ var ts;
|
|
|
48635
48656
|
// type parameters are visible in parameter list, return type and type parameter list
|
|
48636
48657
|
? lastLocation === location.type ||
|
|
48637
48658
|
lastLocation.kind === 163 /* Parameter */ ||
|
|
48659
|
+
lastLocation.kind === 338 /* JSDocParameterTag */ ||
|
|
48660
|
+
lastLocation.kind === 339 /* JSDocReturnTag */ ||
|
|
48638
48661
|
lastLocation.kind === 162 /* TypeParameter */
|
|
48639
48662
|
// local types not visible outside the function body
|
|
48640
48663
|
: false;
|
|
@@ -48894,9 +48917,9 @@ var ts;
|
|
|
48894
48917
|
lastSelfReferenceLocation = location;
|
|
48895
48918
|
}
|
|
48896
48919
|
lastLocation = location;
|
|
48897
|
-
location = ts.isJSDocTemplateTag(location) ?
|
|
48898
|
-
ts.
|
|
48899
|
-
|
|
48920
|
+
location = ts.isJSDocTemplateTag(location) ? ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
|
|
48921
|
+
ts.isJSDocParameterTag(location) || ts.isJSDocReturnTag(location) ? ts.getHostSignatureFromJSDoc(location) || location.parent :
|
|
48922
|
+
location.parent;
|
|
48900
48923
|
}
|
|
48901
48924
|
// We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
|
|
48902
48925
|
// If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself.
|
|
@@ -50030,16 +50053,20 @@ var ts;
|
|
|
50030
50053
|
return;
|
|
50031
50054
|
}
|
|
50032
50055
|
var host = ts.getJSDocHost(node);
|
|
50033
|
-
if (host &&
|
|
50034
|
-
|
|
50035
|
-
ts.isBinaryExpression(host.expression) &&
|
|
50036
|
-
ts.getAssignmentDeclarationKind(host.expression) === 3 /* PrototypeProperty */) {
|
|
50037
|
-
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
50056
|
+
if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
|
|
50057
|
+
// /** @param {K} p */ X.prototype.m = function () { } <-- look for K on X's declaration
|
|
50038
50058
|
var symbol = getSymbolOfNode(host.expression.left);
|
|
50039
50059
|
if (symbol) {
|
|
50040
50060
|
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
50041
50061
|
}
|
|
50042
50062
|
}
|
|
50063
|
+
if (host && ts.isFunctionExpression(host) && ts.isPrototypePropertyAssignment(host.parent) && ts.isExpressionStatement(host.parent.parent)) {
|
|
50064
|
+
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
50065
|
+
var symbol = getSymbolOfNode(host.parent.left);
|
|
50066
|
+
if (symbol) {
|
|
50067
|
+
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
50068
|
+
}
|
|
50069
|
+
}
|
|
50043
50070
|
if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
|
|
50044
50071
|
ts.isBinaryExpression(host.parent.parent) &&
|
|
50045
50072
|
ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) {
|
|
@@ -54526,9 +54553,12 @@ var ts;
|
|
|
54526
54553
|
}
|
|
54527
54554
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
54528
54555
|
// assigned by contextual typing.
|
|
54529
|
-
function getTypeForBindingElementParent(node) {
|
|
54556
|
+
function getTypeForBindingElementParent(node, checkMode) {
|
|
54557
|
+
if (checkMode !== 0 /* Normal */) {
|
|
54558
|
+
return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54559
|
+
}
|
|
54530
54560
|
var symbol = getSymbolOfNode(node);
|
|
54531
|
-
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
|
|
54561
|
+
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54532
54562
|
}
|
|
54533
54563
|
function getRestType(source, properties, symbol) {
|
|
54534
54564
|
source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
@@ -54646,7 +54676,8 @@ var ts;
|
|
|
54646
54676
|
}
|
|
54647
54677
|
/** Return the inferred type for a binding element */
|
|
54648
54678
|
function getTypeForBindingElement(declaration) {
|
|
54649
|
-
var
|
|
54679
|
+
var checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
54680
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
54650
54681
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
54651
54682
|
}
|
|
54652
54683
|
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
@@ -54718,9 +54749,9 @@ var ts;
|
|
|
54718
54749
|
if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
|
|
54719
54750
|
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
|
54720
54751
|
// undefined from the final type.
|
|
54721
|
-
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54752
|
+
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54722
54753
|
}
|
|
54723
|
-
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
|
|
54754
|
+
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
54724
54755
|
}
|
|
54725
54756
|
function getTypeForDeclarationFromJSDocComment(declaration) {
|
|
54726
54757
|
var jsdocType = ts.getJSDocType(declaration);
|
|
@@ -54743,11 +54774,11 @@ var ts;
|
|
|
54743
54774
|
return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
|
|
54744
54775
|
}
|
|
54745
54776
|
// Return the inferred type for a variable, parameter, or property declaration
|
|
54746
|
-
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
|
54777
|
+
function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
|
|
54747
54778
|
// A variable declared in a for..in statement is of type string, or of type keyof T when the
|
|
54748
54779
|
// right hand expression is of a type parameter type.
|
|
54749
54780
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
|
|
54750
|
-
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
|
|
54781
|
+
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode)));
|
|
54751
54782
|
return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
|
|
54752
54783
|
}
|
|
54753
54784
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
|
|
@@ -54802,12 +54833,9 @@ var ts;
|
|
|
54802
54833
|
}
|
|
54803
54834
|
}
|
|
54804
54835
|
if (ts.isInJSFile(declaration)) {
|
|
54805
|
-
var
|
|
54806
|
-
if (
|
|
54807
|
-
|
|
54808
|
-
var pos = func.parameters.indexOf(declaration);
|
|
54809
|
-
return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
54810
|
-
}
|
|
54836
|
+
var type_1 = getParameterTypeOfTypeTag(func, declaration);
|
|
54837
|
+
if (type_1)
|
|
54838
|
+
return type_1;
|
|
54811
54839
|
}
|
|
54812
54840
|
// Use contextual parameter type if one is available
|
|
54813
54841
|
var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
|
|
@@ -54824,7 +54852,7 @@ var ts;
|
|
|
54824
54852
|
return containerObjectType;
|
|
54825
54853
|
}
|
|
54826
54854
|
}
|
|
54827
|
-
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
|
|
54855
|
+
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
|
|
54828
54856
|
return addOptionality(type, isProperty, isOptional);
|
|
54829
54857
|
}
|
|
54830
54858
|
if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
|
|
@@ -55196,7 +55224,7 @@ var ts;
|
|
|
55196
55224
|
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
|
|
55197
55225
|
// pattern.
|
|
55198
55226
|
var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
|
|
55199
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
|
|
55227
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
55200
55228
|
}
|
|
55201
55229
|
if (ts.isBindingPattern(element.name)) {
|
|
55202
55230
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
|
|
@@ -55285,7 +55313,7 @@ var ts;
|
|
|
55285
55313
|
// binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
|
|
55286
55314
|
// tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
|
|
55287
55315
|
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
|
55288
|
-
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
|
|
55316
|
+
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors);
|
|
55289
55317
|
}
|
|
55290
55318
|
function isGlobalSymbolConstructor(node) {
|
|
55291
55319
|
var symbol = getSymbolOfNode(node);
|
|
@@ -55374,9 +55402,9 @@ var ts;
|
|
|
55374
55402
|
if (typeNode === undefined) {
|
|
55375
55403
|
return useUnknownInCatchVariables ? unknownType : anyType;
|
|
55376
55404
|
}
|
|
55377
|
-
var
|
|
55405
|
+
var type_2 = getTypeOfNode(typeNode);
|
|
55378
55406
|
// an errorType will make `checkTryStatement` issue an error
|
|
55379
|
-
return isTypeAny(
|
|
55407
|
+
return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
|
|
55380
55408
|
}
|
|
55381
55409
|
// Handle export default expressions
|
|
55382
55410
|
if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
|
|
@@ -55514,10 +55542,12 @@ var ts;
|
|
|
55514
55542
|
if (writing === void 0) { writing = false; }
|
|
55515
55543
|
var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
|
|
55516
55544
|
var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */);
|
|
55517
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
55518
55545
|
// For write operations, prioritize type annotations on the setter
|
|
55519
|
-
if (writing
|
|
55520
|
-
|
|
55546
|
+
if (writing) {
|
|
55547
|
+
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
55548
|
+
if (setterType_1) {
|
|
55549
|
+
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
55550
|
+
}
|
|
55521
55551
|
}
|
|
55522
55552
|
// Else defer to the getter type
|
|
55523
55553
|
if (getter && ts.isInJSFile(getter)) {
|
|
@@ -55532,6 +55562,7 @@ var ts;
|
|
|
55532
55562
|
return instantiateTypeIfNeeded(getterType, symbol);
|
|
55533
55563
|
}
|
|
55534
55564
|
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
55565
|
+
var setterType = getAnnotatedAccessorType(setter);
|
|
55535
55566
|
if (setterType) {
|
|
55536
55567
|
return setterType;
|
|
55537
55568
|
}
|
|
@@ -55602,11 +55633,11 @@ var ts;
|
|
|
55602
55633
|
return errorType;
|
|
55603
55634
|
}
|
|
55604
55635
|
var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
|
|
55605
|
-
var
|
|
55636
|
+
var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
|
55606
55637
|
if (!popTypeResolution()) {
|
|
55607
55638
|
return reportCircularityError(symbol);
|
|
55608
55639
|
}
|
|
55609
|
-
return
|
|
55640
|
+
return type_3;
|
|
55610
55641
|
}
|
|
55611
55642
|
}
|
|
55612
55643
|
var type = createObjectType(16 /* Anonymous */, symbol);
|
|
@@ -55680,6 +55711,39 @@ var ts;
|
|
|
55680
55711
|
}
|
|
55681
55712
|
return links.type;
|
|
55682
55713
|
}
|
|
55714
|
+
function getWriteTypeOfSymbolWithDeferredType(symbol) {
|
|
55715
|
+
var links = getSymbolLinks(symbol);
|
|
55716
|
+
if (!links.writeType && links.deferralWriteConstituents) {
|
|
55717
|
+
ts.Debug.assertIsDefined(links.deferralParent);
|
|
55718
|
+
ts.Debug.assertIsDefined(links.deferralConstituents);
|
|
55719
|
+
links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
|
|
55720
|
+
}
|
|
55721
|
+
return links.writeType;
|
|
55722
|
+
}
|
|
55723
|
+
/**
|
|
55724
|
+
* Distinct write types come only from set accessors, but union and intersection
|
|
55725
|
+
* properties deriving from set accessors will either pre-compute or defer the
|
|
55726
|
+
* union or intersection of the writeTypes of their constituents. To account for
|
|
55727
|
+
* this, we will assume that any deferred type or transient symbol may have a
|
|
55728
|
+
* `writeType` (or a deferred write type ready to be computed) that should be
|
|
55729
|
+
* used before looking for set accessor declarations.
|
|
55730
|
+
*/
|
|
55731
|
+
function getWriteTypeOfSymbol(symbol) {
|
|
55732
|
+
var checkFlags = ts.getCheckFlags(symbol);
|
|
55733
|
+
if (checkFlags & 65536 /* DeferredType */) {
|
|
55734
|
+
var writeType = getWriteTypeOfSymbolWithDeferredType(symbol);
|
|
55735
|
+
if (writeType) {
|
|
55736
|
+
return writeType;
|
|
55737
|
+
}
|
|
55738
|
+
}
|
|
55739
|
+
if (symbol.flags & 33554432 /* Transient */) {
|
|
55740
|
+
var writeType = symbol.writeType;
|
|
55741
|
+
if (writeType) {
|
|
55742
|
+
return writeType;
|
|
55743
|
+
}
|
|
55744
|
+
}
|
|
55745
|
+
return getSetAccessorTypeOfSymbol(symbol);
|
|
55746
|
+
}
|
|
55683
55747
|
function getSetAccessorTypeOfSymbol(symbol) {
|
|
55684
55748
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
55685
55749
|
var type = getTypeOfSetAccessor(symbol);
|
|
@@ -57805,10 +57869,10 @@ var ts;
|
|
|
57805
57869
|
var baseTypes = [];
|
|
57806
57870
|
var different = false;
|
|
57807
57871
|
for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
|
|
57808
|
-
var
|
|
57809
|
-
var baseType = getBaseConstraint(
|
|
57872
|
+
var type_4 = types_7[_i];
|
|
57873
|
+
var baseType = getBaseConstraint(type_4);
|
|
57810
57874
|
if (baseType) {
|
|
57811
|
-
if (baseType !==
|
|
57875
|
+
if (baseType !== type_4) {
|
|
57812
57876
|
different = true;
|
|
57813
57877
|
}
|
|
57814
57878
|
baseTypes.push(baseType);
|
|
@@ -58050,6 +58114,7 @@ var ts;
|
|
|
58050
58114
|
var firstType;
|
|
58051
58115
|
var nameType;
|
|
58052
58116
|
var propTypes = [];
|
|
58117
|
+
var writeTypes;
|
|
58053
58118
|
var firstValueDeclaration;
|
|
58054
58119
|
var hasNonUniformValueDeclaration = false;
|
|
58055
58120
|
for (var _d = 0, props_1 = props; _d < props_1.length; _d++) {
|
|
@@ -58066,6 +58131,10 @@ var ts;
|
|
|
58066
58131
|
firstType = type;
|
|
58067
58132
|
nameType = getSymbolLinks(prop).nameType;
|
|
58068
58133
|
}
|
|
58134
|
+
var writeType = getWriteTypeOfSymbol(prop);
|
|
58135
|
+
if (writeTypes || writeType !== type) {
|
|
58136
|
+
writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType);
|
|
58137
|
+
}
|
|
58069
58138
|
else if (type !== firstType) {
|
|
58070
58139
|
checkFlags |= 64 /* HasNonUniformType */;
|
|
58071
58140
|
}
|
|
@@ -58094,9 +58163,13 @@ var ts;
|
|
|
58094
58163
|
result.checkFlags |= 65536 /* DeferredType */;
|
|
58095
58164
|
result.deferralParent = containingType;
|
|
58096
58165
|
result.deferralConstituents = propTypes;
|
|
58166
|
+
result.deferralWriteConstituents = writeTypes;
|
|
58097
58167
|
}
|
|
58098
58168
|
else {
|
|
58099
58169
|
result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
|
|
58170
|
+
if (writeTypes) {
|
|
58171
|
+
result.writeType = isUnion ? getUnionType(writeTypes) : getIntersectionType(writeTypes);
|
|
58172
|
+
}
|
|
58100
58173
|
}
|
|
58101
58174
|
return result;
|
|
58102
58175
|
}
|
|
@@ -58512,6 +58585,13 @@ var ts;
|
|
|
58512
58585
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
58513
58586
|
return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
58514
58587
|
}
|
|
58588
|
+
function getParameterTypeOfTypeTag(func, parameter) {
|
|
58589
|
+
var signature = getSignatureOfTypeTag(func);
|
|
58590
|
+
if (!signature)
|
|
58591
|
+
return undefined;
|
|
58592
|
+
var pos = func.parameters.indexOf(parameter);
|
|
58593
|
+
return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
58594
|
+
}
|
|
58515
58595
|
function getReturnTypeOfTypeTag(node) {
|
|
58516
58596
|
var signature = getSignatureOfTypeTag(node);
|
|
58517
58597
|
return signature && getReturnTypeOfSignature(signature);
|
|
@@ -59238,7 +59318,7 @@ var ts;
|
|
|
59238
59318
|
}
|
|
59239
59319
|
function getImpliedConstraint(type, checkNode, extendsNode) {
|
|
59240
59320
|
return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
|
|
59241
|
-
getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
|
|
59321
|
+
getActualTypeVariable(getTypeFromTypeNode(checkNode)) === getActualTypeVariable(type) ? getTypeFromTypeNode(extendsNode) :
|
|
59242
59322
|
undefined;
|
|
59243
59323
|
}
|
|
59244
59324
|
function getConditionalFlowTypeOfType(type, node) {
|
|
@@ -70047,12 +70127,16 @@ var ts;
|
|
|
70047
70127
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
70048
70128
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
70049
70129
|
}
|
|
70050
|
-
function
|
|
70130
|
+
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
70051
70131
|
// Computing the contextual type for a child of a JSX element involves resolving the type of the
|
|
70052
70132
|
// element's tag name, so we exclude that here to avoid circularities.
|
|
70133
|
+
// If check mode has `CheckMode.RestBindingElement`, we skip binding pattern contextual types,
|
|
70134
|
+
// as we want the type of a rest element to be generic when possible.
|
|
70053
70135
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
70054
70136
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
70055
|
-
|
|
70137
|
+
(checkMode && checkMode & 32 /* RestBindingElement */ ?
|
|
70138
|
+
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
70139
|
+
: getContextualType(node));
|
|
70056
70140
|
return contextualType && !isGenericType(contextualType);
|
|
70057
70141
|
}
|
|
70058
70142
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -70065,7 +70149,7 @@ var ts;
|
|
|
70065
70149
|
// 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
|
|
70066
70150
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
70067
70151
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
70068
|
-
(isConstraintPosition(type, reference) ||
|
|
70152
|
+
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
70069
70153
|
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
|
|
70070
70154
|
}
|
|
70071
70155
|
function isExportOrExportExpression(location) {
|
|
@@ -70133,7 +70217,7 @@ var ts;
|
|
|
70133
70217
|
var links = getNodeLinks(location);
|
|
70134
70218
|
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
70135
70219
|
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
70136
|
-
var parentType = getTypeForBindingElementParent(parent);
|
|
70220
|
+
var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
|
|
70137
70221
|
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
70138
70222
|
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
70139
70223
|
var pattern = declaration.parent;
|
|
@@ -70986,7 +71070,7 @@ var ts;
|
|
|
70986
71070
|
var parent = declaration.parent.parent;
|
|
70987
71071
|
var name = declaration.propertyName || declaration.name;
|
|
70988
71072
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
70989
|
-
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
|
|
71073
|
+
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
|
|
70990
71074
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
70991
71075
|
return undefined;
|
|
70992
71076
|
if (parent.name.kind === 201 /* ArrayBindingPattern */) {
|
|
@@ -73227,7 +73311,7 @@ var ts;
|
|
|
73227
73311
|
error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
|
|
73228
73312
|
return errorType;
|
|
73229
73313
|
}
|
|
73230
|
-
propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ?
|
|
73314
|
+
propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getWriteTypeOfSymbol(prop) : getTypeOfSymbol(prop);
|
|
73231
73315
|
}
|
|
73232
73316
|
return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode);
|
|
73233
73317
|
}
|
|
@@ -75697,8 +75781,8 @@ var ts;
|
|
|
75697
75781
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75698
75782
|
var synthType = type;
|
|
75699
75783
|
if (!synthType.defaultOnlyType) {
|
|
75700
|
-
var
|
|
75701
|
-
synthType.defaultOnlyType =
|
|
75784
|
+
var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75785
|
+
synthType.defaultOnlyType = type_5;
|
|
75702
75786
|
}
|
|
75703
75787
|
return synthType.defaultOnlyType;
|
|
75704
75788
|
}
|
|
@@ -76152,7 +76236,7 @@ var ts;
|
|
|
76152
76236
|
var links = getSymbolLinks(parameter);
|
|
76153
76237
|
if (!links.type) {
|
|
76154
76238
|
var declaration = parameter.valueDeclaration;
|
|
76155
|
-
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*
|
|
76239
|
+
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
|
|
76156
76240
|
if (declaration.name.kind !== 79 /* Identifier */) {
|
|
76157
76241
|
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
|
|
76158
76242
|
if (links.type === unknownType) {
|
|
@@ -76425,12 +76509,12 @@ var ts;
|
|
|
76425
76509
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
76426
76510
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
76427
76511
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
76428
|
-
var
|
|
76512
|
+
var type_6 = getBaseConstraintOfType(operandType) || operandType;
|
|
76429
76513
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
76430
|
-
if (
|
|
76514
|
+
if (type_6.flags & 3 /* AnyOrUnknown */) {
|
|
76431
76515
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
76432
76516
|
}
|
|
76433
|
-
return !!(filterType(
|
|
76517
|
+
return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
76434
76518
|
}
|
|
76435
76519
|
var type = getTypeOfExpression(node.expression);
|
|
76436
76520
|
if (!isLiteralType(type)) {
|
|
@@ -77883,11 +77967,11 @@ var ts;
|
|
|
77883
77967
|
}
|
|
77884
77968
|
}
|
|
77885
77969
|
function checkExpressionCached(node, checkMode) {
|
|
77970
|
+
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77971
|
+
return checkExpression(node, checkMode);
|
|
77972
|
+
}
|
|
77886
77973
|
var links = getNodeLinks(node);
|
|
77887
77974
|
if (!links.resolvedType) {
|
|
77888
|
-
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77889
|
-
return checkExpression(node, checkMode);
|
|
77890
|
-
}
|
|
77891
77975
|
// When computing a type that we're going to cache, we need to ignore any ongoing control flow
|
|
77892
77976
|
// analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
|
|
77893
77977
|
// to the top of the stack ensures all transient types are computed from a known point.
|
|
@@ -77907,10 +77991,12 @@ var ts;
|
|
|
77907
77991
|
node.kind === 228 /* AsExpression */ ||
|
|
77908
77992
|
ts.isJSDocTypeAssertion(node);
|
|
77909
77993
|
}
|
|
77910
|
-
function checkDeclarationInitializer(declaration, contextualType) {
|
|
77994
|
+
function checkDeclarationInitializer(declaration, checkMode, contextualType) {
|
|
77911
77995
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
77912
77996
|
var type = getQuickTypeOfExpression(initializer) ||
|
|
77913
|
-
(contextualType ?
|
|
77997
|
+
(contextualType ?
|
|
77998
|
+
checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
|
|
77999
|
+
: checkExpressionCached(initializer, checkMode));
|
|
77914
78000
|
return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
|
|
77915
78001
|
isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
|
|
77916
78002
|
padTupleType(type, declaration.name) : type;
|
|
@@ -78550,6 +78636,7 @@ var ts;
|
|
|
78550
78636
|
}
|
|
78551
78637
|
}
|
|
78552
78638
|
checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
|
|
78639
|
+
checkUnmatchedJSDocParameters(node);
|
|
78553
78640
|
ts.forEach(node.parameters, checkParameter);
|
|
78554
78641
|
// TODO(rbuckton): Should we start checking JSDoc types?
|
|
78555
78642
|
if (node.type) {
|
|
@@ -80121,31 +80208,6 @@ var ts;
|
|
|
80121
80208
|
}
|
|
80122
80209
|
function checkJSDocParameterTag(node) {
|
|
80123
80210
|
checkSourceElement(node.typeExpression);
|
|
80124
|
-
if (!ts.getParameterSymbolFromJSDoc(node)) {
|
|
80125
|
-
var decl = ts.getHostSignatureFromJSDoc(node);
|
|
80126
|
-
// don't issue an error for invalid hosts -- just functions --
|
|
80127
|
-
// and give a better error message when the host function mentions `arguments`
|
|
80128
|
-
// but the tag doesn't have an array type
|
|
80129
|
-
if (decl) {
|
|
80130
|
-
var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
|
|
80131
|
-
if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
|
|
80132
|
-
return;
|
|
80133
|
-
}
|
|
80134
|
-
if (!containsArgumentsReference(decl)) {
|
|
80135
|
-
if (ts.isQualifiedName(node.name)) {
|
|
80136
|
-
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));
|
|
80137
|
-
}
|
|
80138
|
-
else {
|
|
80139
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
|
|
80140
|
-
}
|
|
80141
|
-
}
|
|
80142
|
-
else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
|
|
80143
|
-
node.typeExpression && node.typeExpression.type &&
|
|
80144
|
-
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
|
|
80145
|
-
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));
|
|
80146
|
-
}
|
|
80147
|
-
}
|
|
80148
|
-
}
|
|
80149
80211
|
}
|
|
80150
80212
|
function checkJSDocPropertyTag(node) {
|
|
80151
80213
|
checkSourceElement(node.typeExpression);
|
|
@@ -80847,7 +80909,8 @@ var ts;
|
|
|
80847
80909
|
}
|
|
80848
80910
|
// check private/protected variable access
|
|
80849
80911
|
var parent = node.parent.parent;
|
|
80850
|
-
var
|
|
80912
|
+
var parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
80913
|
+
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
80851
80914
|
var name = node.propertyName || node.name;
|
|
80852
80915
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
80853
80916
|
var exprType = getLiteralTypeFromPropertyName(name);
|
|
@@ -82086,7 +82149,7 @@ var ts;
|
|
|
82086
82149
|
var declaration = catchClause.variableDeclaration;
|
|
82087
82150
|
var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
|
|
82088
82151
|
if (typeNode) {
|
|
82089
|
-
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
|
|
82152
|
+
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */);
|
|
82090
82153
|
if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
|
|
82091
82154
|
grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
|
|
82092
82155
|
}
|
|
@@ -82217,6 +82280,45 @@ var ts;
|
|
|
82217
82280
|
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
|
|
82218
82281
|
}
|
|
82219
82282
|
}
|
|
82283
|
+
function checkUnmatchedJSDocParameters(node) {
|
|
82284
|
+
var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
|
|
82285
|
+
if (!ts.length(jsdocParameters))
|
|
82286
|
+
return;
|
|
82287
|
+
var isJs = ts.isInJSFile(node);
|
|
82288
|
+
var parameters = new ts.Set();
|
|
82289
|
+
var excludedParameters = new ts.Set();
|
|
82290
|
+
ts.forEach(node.parameters, function (_a, index) {
|
|
82291
|
+
var name = _a.name;
|
|
82292
|
+
if (ts.isIdentifier(name)) {
|
|
82293
|
+
parameters.add(name.escapedText);
|
|
82294
|
+
}
|
|
82295
|
+
if (ts.isBindingPattern(name)) {
|
|
82296
|
+
excludedParameters.add(index);
|
|
82297
|
+
}
|
|
82298
|
+
});
|
|
82299
|
+
var containsArguments = containsArgumentsReference(node);
|
|
82300
|
+
if (containsArguments) {
|
|
82301
|
+
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82302
|
+
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82303
|
+
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82304
|
+
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));
|
|
82305
|
+
}
|
|
82306
|
+
}
|
|
82307
|
+
else {
|
|
82308
|
+
ts.forEach(jsdocParameters, function (_a, index) {
|
|
82309
|
+
var name = _a.name;
|
|
82310
|
+
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
82311
|
+
return;
|
|
82312
|
+
}
|
|
82313
|
+
if (ts.isQualifiedName(name)) {
|
|
82314
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82315
|
+
}
|
|
82316
|
+
else {
|
|
82317
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
82318
|
+
}
|
|
82319
|
+
});
|
|
82320
|
+
}
|
|
82321
|
+
}
|
|
82220
82322
|
/**
|
|
82221
82323
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
82222
82324
|
*/
|
|
@@ -83192,7 +83294,7 @@ var ts;
|
|
|
83192
83294
|
var isAmbientExternalModule = ts.isAmbientModule(node);
|
|
83193
83295
|
var contextErrorMessage = isAmbientExternalModule
|
|
83194
83296
|
? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
|
|
83195
|
-
: ts.Diagnostics.
|
|
83297
|
+
: ts.Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
|
|
83196
83298
|
if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
|
|
83197
83299
|
// If we hit a module declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83198
83300
|
return;
|
|
@@ -83425,6 +83527,9 @@ var ts;
|
|
|
83425
83527
|
var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
|
|
83426
83528
|
addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
|
|
83427
83529
|
}
|
|
83530
|
+
if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
|
|
83531
|
+
error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
|
|
83532
|
+
}
|
|
83428
83533
|
break;
|
|
83429
83534
|
}
|
|
83430
83535
|
case 274 /* ExportSpecifier */: {
|
|
@@ -83508,7 +83613,7 @@ var ts;
|
|
|
83508
83613
|
}
|
|
83509
83614
|
}
|
|
83510
83615
|
function checkImportDeclaration(node) {
|
|
83511
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83616
|
+
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)) {
|
|
83512
83617
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83513
83618
|
return;
|
|
83514
83619
|
}
|
|
@@ -83541,7 +83646,7 @@ var ts;
|
|
|
83541
83646
|
checkAssertClause(node);
|
|
83542
83647
|
}
|
|
83543
83648
|
function checkImportEqualsDeclaration(node) {
|
|
83544
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83649
|
+
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)) {
|
|
83545
83650
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83546
83651
|
return;
|
|
83547
83652
|
}
|
|
@@ -83578,7 +83683,7 @@ var ts;
|
|
|
83578
83683
|
}
|
|
83579
83684
|
}
|
|
83580
83685
|
function checkExportDeclaration(node) {
|
|
83581
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83686
|
+
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)) {
|
|
83582
83687
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
83583
83688
|
return;
|
|
83584
83689
|
}
|
|
@@ -84812,7 +84917,7 @@ var ts;
|
|
|
84812
84917
|
return errorType;
|
|
84813
84918
|
}
|
|
84814
84919
|
if (ts.isBindingPattern(node)) {
|
|
84815
|
-
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
|
|
84920
|
+
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType;
|
|
84816
84921
|
}
|
|
84817
84922
|
if (isInRightSideOfImportOrExportAssignment(node)) {
|
|
84818
84923
|
var symbol = getSymbolAtLocation(node);
|
|
@@ -114559,9 +114664,9 @@ var ts;
|
|
|
114559
114664
|
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
|
|
114560
114665
|
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
|
114561
114666
|
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
|
114562
|
-
ts.Diagnostics.
|
|
114667
|
+
ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114563
114668
|
ts.Diagnostics.An_export_declaration_cannot_have_modifiers.code,
|
|
114564
|
-
ts.Diagnostics.
|
|
114669
|
+
ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114565
114670
|
ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
|
|
114566
114671
|
ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
|
|
114567
114672
|
ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
|
|
@@ -115629,7 +115734,7 @@ var ts;
|
|
|
115629
115734
|
ts.Debug.assert(!!sourceFile.bindDiagnostics);
|
|
115630
115735
|
var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
|
|
115631
115736
|
var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
|
|
115632
|
-
var isPlainJs =
|
|
115737
|
+
var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
|
|
115633
115738
|
var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
|
|
115634
115739
|
// By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
|
|
115635
115740
|
// - plain JS: .js files with no // ts-check and checkJs: undefined
|
|
@@ -130939,7 +131044,8 @@ var ts;
|
|
|
130939
131044
|
case 103 /* NewKeyword */:
|
|
130940
131045
|
return checker.getContextualType(parent);
|
|
130941
131046
|
case 82 /* CaseKeyword */:
|
|
130942
|
-
|
|
131047
|
+
var caseClause = ts.tryCast(parent, ts.isCaseClause);
|
|
131048
|
+
return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined;
|
|
130943
131049
|
case 18 /* OpenBraceToken */:
|
|
130944
131050
|
return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined;
|
|
130945
131051
|
default:
|
|
@@ -133584,7 +133690,24 @@ var ts;
|
|
|
133584
133690
|
function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
|
|
133585
133691
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
|
|
133586
133692
|
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
|
|
133693
|
+
var oldBucketCount = buckets.size;
|
|
133587
133694
|
var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
|
|
133695
|
+
if (ts.tracing) {
|
|
133696
|
+
if (buckets.size > oldBucketCount) {
|
|
133697
|
+
// It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
|
|
133698
|
+
// perhaps they are for two projects that don't have any overlap.
|
|
133699
|
+
// Bonus: these events can help us interpret the more interesting event below.
|
|
133700
|
+
ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
|
|
133701
|
+
}
|
|
133702
|
+
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
133703
|
+
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
133704
|
+
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
133705
|
+
var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
|
|
133706
|
+
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
|
|
133707
|
+
if (otherBucketKey) {
|
|
133708
|
+
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
|
|
133709
|
+
}
|
|
133710
|
+
}
|
|
133588
133711
|
var bucketEntry = bucket.get(path);
|
|
133589
133712
|
var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
133590
133713
|
if (!entry && externalCache) {
|
|
@@ -145720,6 +145843,8 @@ var ts;
|
|
|
145720
145843
|
case 179 /* ConstructorType */:
|
|
145721
145844
|
case 174 /* ConstructSignature */:
|
|
145722
145845
|
return getList(node.typeParameters) || getList(node.parameters);
|
|
145846
|
+
case 171 /* GetAccessor */:
|
|
145847
|
+
return getList(node.parameters);
|
|
145723
145848
|
case 256 /* ClassDeclaration */:
|
|
145724
145849
|
case 225 /* ClassExpression */:
|
|
145725
145850
|
case 257 /* InterfaceDeclaration */:
|
|
@@ -146340,8 +146465,18 @@ var ts;
|
|
|
146340
146465
|
var indent = sourceFile.text.slice(startPosition, fnStart);
|
|
146341
146466
|
this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
|
|
146342
146467
|
};
|
|
146468
|
+
ChangeTracker.prototype.createJSDocText = function (sourceFile, node) {
|
|
146469
|
+
var comments = ts.flatMap(node.jsDoc, function (jsDoc) {
|
|
146470
|
+
return ts.isString(jsDoc.comment) ? ts.factory.createJSDocText(jsDoc.comment) : jsDoc.comment;
|
|
146471
|
+
});
|
|
146472
|
+
var jsDoc = ts.singleOrUndefined(node.jsDoc);
|
|
146473
|
+
return jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && ts.length(comments) === 0 ? undefined :
|
|
146474
|
+
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
146475
|
+
};
|
|
146476
|
+
ChangeTracker.prototype.replaceJSDocComment = function (sourceFile, node, tags) {
|
|
146477
|
+
this.insertJsdocCommentBefore(sourceFile, updateJSDocHost(node), ts.factory.createJSDocComment(this.createJSDocText(sourceFile, node), ts.factory.createNodeArray(tags)));
|
|
146478
|
+
};
|
|
146343
146479
|
ChangeTracker.prototype.addJSDocTags = function (sourceFile, parent, newTags) {
|
|
146344
|
-
var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
|
|
146345
146480
|
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
146346
146481
|
var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags.some(function (tag, i) {
|
|
146347
146482
|
var merged = tryMergeJsdocTags(tag, newTag);
|
|
@@ -146349,20 +146484,10 @@ var ts;
|
|
|
146349
146484
|
oldTags[i] = merged;
|
|
146350
146485
|
return !!merged;
|
|
146351
146486
|
}); });
|
|
146352
|
-
|
|
146353
|
-
var jsDoc = ts.singleOrUndefined(parent.jsDoc);
|
|
146354
|
-
var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
|
|
146355
|
-
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
146356
|
-
var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
|
|
146357
|
-
var host = updateJSDocHost(parent);
|
|
146358
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
146487
|
+
this.replaceJSDocComment(sourceFile, parent, __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true));
|
|
146359
146488
|
};
|
|
146360
146489
|
ChangeTracker.prototype.filterJSDocTags = function (sourceFile, parent, predicate) {
|
|
146361
|
-
|
|
146362
|
-
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
146363
|
-
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)));
|
|
146364
|
-
var host = updateJSDocHost(parent);
|
|
146365
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
146490
|
+
this.replaceJSDocComment(sourceFile, parent, ts.filter(ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }), predicate));
|
|
146366
146491
|
};
|
|
146367
146492
|
ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) {
|
|
146368
146493
|
this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text });
|
|
@@ -150157,9 +150282,9 @@ var ts;
|
|
|
150157
150282
|
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
|
|
150158
150283
|
var checker = program.getTypeChecker();
|
|
150159
150284
|
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
|
|
150160
|
-
var
|
|
150285
|
+
var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
|
|
150161
150286
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150162
|
-
var fix = getImportFixForSymbol(sourceFile,
|
|
150287
|
+
var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
150163
150288
|
if (fix) {
|
|
150164
150289
|
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
150165
150290
|
}
|
|
@@ -150348,7 +150473,7 @@ var ts;
|
|
|
150348
150473
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
150349
150474
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
150350
150475
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
150351
|
-
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
|
|
150476
|
+
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
|
|
150352
150477
|
}
|
|
150353
150478
|
function codeFixActionToCodeAction(_a) {
|
|
150354
150479
|
var description = _a.description, changes = _a.changes, commands = _a.commands;
|
|
@@ -150408,7 +150533,7 @@ var ts;
|
|
|
150408
150533
|
/*position*/ undefined,
|
|
150409
150534
|
/*isValidTypeOnlyUseSite*/ false,
|
|
150410
150535
|
/*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
150411
|
-
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
|
|
150536
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
|
150412
150537
|
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
150413
150538
|
}
|
|
150414
150539
|
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
@@ -150578,7 +150703,7 @@ var ts;
|
|
|
150578
150703
|
// 5. Literally nothing to go on
|
|
150579
150704
|
return true;
|
|
150580
150705
|
}
|
|
150581
|
-
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire,
|
|
150706
|
+
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
|
|
150582
150707
|
var isJs = ts.isSourceFileJS(sourceFile);
|
|
150583
150708
|
var compilerOptions = program.getCompilerOptions();
|
|
150584
150709
|
var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
|
|
@@ -150587,7 +150712,7 @@ var ts;
|
|
|
150587
150712
|
? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
|
|
150588
150713
|
: function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
|
|
150589
150714
|
var computedWithoutCacheCount = 0;
|
|
150590
|
-
var fixes = ts.flatMap(
|
|
150715
|
+
var fixes = ts.flatMap(exportInfo, function (exportInfo, i) {
|
|
150591
150716
|
var checker = getChecker(exportInfo.isFromPackageJson);
|
|
150592
150717
|
var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
|
|
150593
150718
|
var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
|
|
@@ -150596,7 +150721,7 @@ var ts;
|
|
|
150596
150721
|
return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
|
|
150597
150722
|
// `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
|
|
150598
150723
|
return !importedSymbolHasValueMeaning && isJs && position !== undefined
|
|
150599
|
-
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo }
|
|
150724
|
+
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
|
|
150600
150725
|
: {
|
|
150601
150726
|
kind: 3 /* AddNew */,
|
|
150602
150727
|
moduleSpecifier: moduleSpecifier,
|
|
@@ -150604,6 +150729,7 @@ var ts;
|
|
|
150604
150729
|
useRequire: useRequire,
|
|
150605
150730
|
addAsTypeOnly: addAsTypeOnly,
|
|
150606
150731
|
exportInfo: exportInfo,
|
|
150732
|
+
isReExport: i > 0,
|
|
150607
150733
|
};
|
|
150608
150734
|
});
|
|
150609
150735
|
});
|
|
@@ -150641,12 +150767,13 @@ var ts;
|
|
|
150641
150767
|
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
150642
150768
|
}
|
|
150643
150769
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
150644
|
-
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
150770
|
+
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
|
|
150645
150771
|
}
|
|
150646
|
-
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150647
|
-
|
|
150772
|
+
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150773
|
+
var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
|
|
150774
|
+
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
|
|
150648
150775
|
}
|
|
150649
|
-
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150776
|
+
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150650
150777
|
if (!ts.some(fixes))
|
|
150651
150778
|
return;
|
|
150652
150779
|
// These will always be placed first if available, and are better than other kinds
|
|
@@ -150655,22 +150782,37 @@ var ts;
|
|
|
150655
150782
|
}
|
|
150656
150783
|
return fixes.reduce(function (best, fix) {
|
|
150657
150784
|
// Takes true branch of conditional if `fix` is better than `best`
|
|
150658
|
-
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
150785
|
+
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best;
|
|
150659
150786
|
});
|
|
150660
150787
|
}
|
|
150661
150788
|
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
150662
|
-
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
|
|
150789
|
+
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) {
|
|
150663
150790
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
150664
150791
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
150665
150792
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
150666
|
-
|| ts.compareBooleans(
|
|
150793
|
+
|| ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath))
|
|
150667
150794
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
150668
150795
|
}
|
|
150669
150796
|
return 0 /* EqualTo */;
|
|
150670
150797
|
}
|
|
150671
|
-
|
|
150672
|
-
|
|
150673
|
-
|
|
150798
|
+
// This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export.
|
|
150799
|
+
// E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`.
|
|
150800
|
+
// This can produce false positives or negatives if re-exports cross into sibling directories
|
|
150801
|
+
// (e.g. `export * from "../whatever"`) or are not named "index" (we don't even try to consider
|
|
150802
|
+
// this if we're in a resolution mode where you can't drop trailing "/index" from paths).
|
|
150803
|
+
function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath) {
|
|
150804
|
+
var _a;
|
|
150805
|
+
if (fix.isReExport &&
|
|
150806
|
+
((_a = fix.exportInfo) === null || _a === void 0 ? void 0 : _a.moduleFileName) &&
|
|
150807
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
|
|
150808
|
+
isIndexFileName(fix.exportInfo.moduleFileName)) {
|
|
150809
|
+
var reExportDir = toPath(ts.getDirectoryPath(fix.exportInfo.moduleFileName));
|
|
150810
|
+
return ts.startsWith((importingFile.path), reExportDir);
|
|
150811
|
+
}
|
|
150812
|
+
return false;
|
|
150813
|
+
}
|
|
150814
|
+
function isIndexFileName(fileName) {
|
|
150815
|
+
return ts.getBaseFileName(fileName, [".js", ".jsx", ".d.ts", ".ts", ".tsx"], /*ignoreCase*/ true) === "index";
|
|
150674
150816
|
}
|
|
150675
150817
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
150676
150818
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
@@ -150688,9 +150830,9 @@ var ts;
|
|
|
150688
150830
|
return undefined;
|
|
150689
150831
|
var symbol = checker.getAliasedSymbol(umdSymbol);
|
|
150690
150832
|
var symbolName = umdSymbol.name;
|
|
150691
|
-
var
|
|
150833
|
+
var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
150692
150834
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150693
|
-
var fixes = getImportFixes(
|
|
150835
|
+
var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
150694
150836
|
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
150695
150837
|
}
|
|
150696
150838
|
function getUmdSymbol(token, checker) {
|
|
@@ -150757,8 +150899,8 @@ var ts;
|
|
|
150757
150899
|
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
|
|
150758
150900
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
|
|
150759
150901
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150760
|
-
var
|
|
150761
|
-
var fixes = ts.arrayFrom(ts.flatMapIterator(
|
|
150902
|
+
var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150903
|
+
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
|
|
150762
150904
|
var _ = _a[0], exportInfos = _a[1];
|
|
150763
150905
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
150764
150906
|
}));
|
|
@@ -152859,6 +153001,95 @@ var ts;
|
|
|
152859
153001
|
})(ts || (ts = {}));
|
|
152860
153002
|
/* @internal */
|
|
152861
153003
|
var ts;
|
|
153004
|
+
(function (ts) {
|
|
153005
|
+
var codefix;
|
|
153006
|
+
(function (codefix) {
|
|
153007
|
+
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
153008
|
+
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
153009
|
+
var errorCodes = [
|
|
153010
|
+
ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code,
|
|
153011
|
+
];
|
|
153012
|
+
codefix.registerCodeFix({
|
|
153013
|
+
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
153014
|
+
errorCodes: errorCodes,
|
|
153015
|
+
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
153016
|
+
var sourceFile = context.sourceFile, span = context.span;
|
|
153017
|
+
var actions = [];
|
|
153018
|
+
var info = getInfo(sourceFile, span.start);
|
|
153019
|
+
if (info) {
|
|
153020
|
+
ts.append(actions, getDeleteAction(context, info));
|
|
153021
|
+
ts.append(actions, getRenameAction(context, info));
|
|
153022
|
+
return actions;
|
|
153023
|
+
}
|
|
153024
|
+
return undefined;
|
|
153025
|
+
},
|
|
153026
|
+
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
153027
|
+
var tagsToSignature = new ts.Map();
|
|
153028
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
153029
|
+
codefix.eachDiagnostic(context, errorCodes, function (_a) {
|
|
153030
|
+
var file = _a.file, start = _a.start;
|
|
153031
|
+
var info = getInfo(file, start);
|
|
153032
|
+
if (info) {
|
|
153033
|
+
tagsToSignature.set(info.signature, ts.append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
153034
|
+
}
|
|
153035
|
+
});
|
|
153036
|
+
tagsToSignature.forEach(function (tags, signature) {
|
|
153037
|
+
if (context.fixId === deleteUnmatchedParameter) {
|
|
153038
|
+
var tagsSet_1 = new ts.Set(tags);
|
|
153039
|
+
changes.filterJSDocTags(signature.getSourceFile(), signature, function (t) { return !tagsSet_1.has(t); });
|
|
153040
|
+
}
|
|
153041
|
+
});
|
|
153042
|
+
}));
|
|
153043
|
+
}
|
|
153044
|
+
});
|
|
153045
|
+
function getDeleteAction(context, _a) {
|
|
153046
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
153047
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
153048
|
+
return changeTracker.filterJSDocTags(context.sourceFile, signature, function (t) { return t !== jsDocParameterTag; });
|
|
153049
|
+
});
|
|
153050
|
+
return codefix.createCodeFixAction(deleteUnmatchedParameter, changes, [ts.Diagnostics.Delete_unused_param_tag_0, name.getText(context.sourceFile)], deleteUnmatchedParameter, ts.Diagnostics.Delete_all_unused_param_tags);
|
|
153051
|
+
}
|
|
153052
|
+
function getRenameAction(context, _a) {
|
|
153053
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
153054
|
+
if (!ts.length(signature.parameters))
|
|
153055
|
+
return undefined;
|
|
153056
|
+
var sourceFile = context.sourceFile;
|
|
153057
|
+
var tags = ts.getJSDocTags(signature);
|
|
153058
|
+
var names = new ts.Set();
|
|
153059
|
+
for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
|
|
153060
|
+
var tag = tags_2[_i];
|
|
153061
|
+
if (ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name)) {
|
|
153062
|
+
names.add(tag.name.escapedText);
|
|
153063
|
+
}
|
|
153064
|
+
}
|
|
153065
|
+
// @todo - match to all available names instead to the first parameter name
|
|
153066
|
+
// @see /codeFixRenameUnmatchedParameter3.ts
|
|
153067
|
+
var parameterName = ts.firstDefined(signature.parameters, function (p) {
|
|
153068
|
+
return ts.isIdentifier(p.name) && !names.has(p.name.escapedText) ? p.name.getText(sourceFile) : undefined;
|
|
153069
|
+
});
|
|
153070
|
+
if (parameterName === undefined)
|
|
153071
|
+
return undefined;
|
|
153072
|
+
var newJSDocParameterTag = ts.factory.updateJSDocParameterTag(jsDocParameterTag, jsDocParameterTag.tagName, ts.factory.createIdentifier(parameterName), jsDocParameterTag.isBracketed, jsDocParameterTag.typeExpression, jsDocParameterTag.isNameFirst, jsDocParameterTag.comment);
|
|
153073
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
153074
|
+
return changeTracker.replaceJSDocComment(sourceFile, signature, ts.map(tags, function (t) { return t === jsDocParameterTag ? newJSDocParameterTag : t; }));
|
|
153075
|
+
});
|
|
153076
|
+
return codefix.createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [ts.Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
|
|
153077
|
+
}
|
|
153078
|
+
function getInfo(sourceFile, pos) {
|
|
153079
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
153080
|
+
if (token.parent && ts.isJSDocParameterTag(token.parent) && ts.isIdentifier(token.parent.name)) {
|
|
153081
|
+
var jsDocParameterTag = token.parent;
|
|
153082
|
+
var signature = ts.getHostSignatureFromJSDoc(jsDocParameterTag);
|
|
153083
|
+
if (signature) {
|
|
153084
|
+
return { signature: signature, name: token.parent.name, jsDocParameterTag: jsDocParameterTag };
|
|
153085
|
+
}
|
|
153086
|
+
}
|
|
153087
|
+
return undefined;
|
|
153088
|
+
}
|
|
153089
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
153090
|
+
})(ts || (ts = {}));
|
|
153091
|
+
/* @internal */
|
|
153092
|
+
var ts;
|
|
152862
153093
|
(function (ts) {
|
|
152863
153094
|
var codefix;
|
|
152864
153095
|
(function (codefix) {
|
|
@@ -153156,6 +153387,9 @@ var ts;
|
|
|
153156
153387
|
case 172 /* SetAccessor */:
|
|
153157
153388
|
// Setter must have a parameter
|
|
153158
153389
|
return false;
|
|
153390
|
+
case 171 /* GetAccessor */:
|
|
153391
|
+
// Getter cannot have parameters
|
|
153392
|
+
return true;
|
|
153159
153393
|
default:
|
|
153160
153394
|
return ts.Debug.failBadSyntaxKind(parent);
|
|
153161
153395
|
}
|
|
@@ -155766,10 +156000,12 @@ var ts;
|
|
|
155766
156000
|
});
|
|
155767
156001
|
function getInfo(sourceFile, pos) {
|
|
155768
156002
|
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
155769
|
-
var indexSignature = ts.
|
|
155770
|
-
if (
|
|
156003
|
+
var indexSignature = ts.tryCast(token.parent.parent, ts.isIndexSignatureDeclaration);
|
|
156004
|
+
if (!indexSignature)
|
|
156005
|
+
return undefined;
|
|
156006
|
+
var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.tryCast(indexSignature.parent.parent, ts.isTypeAliasDeclaration);
|
|
156007
|
+
if (!container)
|
|
155771
156008
|
return undefined;
|
|
155772
|
-
var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.cast(indexSignature.parent.parent, ts.isTypeAliasDeclaration);
|
|
155773
156009
|
return { indexSignature: indexSignature, container: container };
|
|
155774
156010
|
}
|
|
155775
156011
|
function createTypeAliasFromInterface(declaration, type) {
|
|
@@ -157360,8 +157596,8 @@ var ts;
|
|
|
157360
157596
|
// but a super *method call* simply implies a 'this' reference
|
|
157361
157597
|
if (node.parent.kind === 207 /* CallExpression */) {
|
|
157362
157598
|
// Super constructor call
|
|
157363
|
-
var containingClass_1 = ts.getContainingClass(node);
|
|
157364
|
-
if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
|
|
157599
|
+
var containingClass_1 = ts.getContainingClass(node);
|
|
157600
|
+
if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
|
|
157365
157601
|
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper));
|
|
157366
157602
|
return true;
|
|
157367
157603
|
}
|
|
@@ -171763,9 +171999,10 @@ var ts;
|
|
|
171763
171999
|
var info = infos && ts.firstOrUndefined(infos);
|
|
171764
172000
|
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
|
171765
172001
|
}
|
|
171766
|
-
function combineProjectOutputForReferences(projects, defaultProject, initialLocation) {
|
|
172002
|
+
function combineProjectOutputForReferences(projects, defaultProject, initialLocation, logger) {
|
|
171767
172003
|
var outputs = [];
|
|
171768
172004
|
combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, getMappedLocation) {
|
|
172005
|
+
logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
|
|
171769
172006
|
var _loop_8 = function (outputReferencedSymbol) {
|
|
171770
172007
|
var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition));
|
|
171771
172008
|
var definition = mappedDefinitionFile === undefined ?
|
|
@@ -173123,7 +173360,7 @@ var ts;
|
|
|
173123
173360
|
var file = server.toNormalizedPath(args.file);
|
|
173124
173361
|
var projects = this.getProjects(args);
|
|
173125
173362
|
var position = this.getPositionInFile(args, file);
|
|
173126
|
-
var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position });
|
|
173363
|
+
var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
|
|
173127
173364
|
if (!simplifiedResult)
|
|
173128
173365
|
return references;
|
|
173129
173366
|
var defaultProject = this.getDefaultProject(args);
|