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/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
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.20220211";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8045,10 +8045,10 @@ var ts;
|
|
|
8045
8045
|
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
8046
|
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
8047
|
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
|
-
|
|
8048
|
+
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."),
|
|
8049
|
+
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
8050
|
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
|
-
|
|
8051
|
+
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
8052
|
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
8053
|
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
8054
|
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 +8080,7 @@ var ts;
|
|
|
8080
8080
|
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
8081
|
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
8082
|
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."),
|
|
8083
|
+
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
8084
|
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
8085
|
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
8086
|
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 +8217,8 @@ var ts;
|
|
|
8216
8217
|
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
8218
|
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
8219
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8220
|
+
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."),
|
|
8221
|
+
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
8222
|
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
8223
|
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
8224
|
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 +9639,9 @@ var ts;
|
|
|
9636
9639
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9637
9640
|
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
9641
|
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9642
|
+
Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
|
|
9643
|
+
Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
|
|
9644
|
+
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
9645
|
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
9646
|
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
9647
|
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?"),
|
|
@@ -13897,6 +13903,10 @@ var ts;
|
|
|
13897
13903
|
return undefined;
|
|
13898
13904
|
}
|
|
13899
13905
|
ts.getDeclarationOfKind = getDeclarationOfKind;
|
|
13906
|
+
function getDeclarationsOfKind(symbol, kind) {
|
|
13907
|
+
return ts.filter(symbol.declarations || ts.emptyArray, function (d) { return d.kind === kind; });
|
|
13908
|
+
}
|
|
13909
|
+
ts.getDeclarationsOfKind = getDeclarationsOfKind;
|
|
13900
13910
|
function createSymbolTable(symbols) {
|
|
13901
13911
|
var result = new ts.Map();
|
|
13902
13912
|
if (symbols) {
|
|
@@ -14132,6 +14142,10 @@ var ts;
|
|
|
14132
14142
|
return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
|
|
14133
14143
|
}
|
|
14134
14144
|
ts.getSourceFileOfModule = getSourceFileOfModule;
|
|
14145
|
+
function isPlainJsFile(file, checkJs) {
|
|
14146
|
+
return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined;
|
|
14147
|
+
}
|
|
14148
|
+
ts.isPlainJsFile = isPlainJsFile;
|
|
14135
14149
|
function isStatementWithLocals(node) {
|
|
14136
14150
|
switch (node.kind) {
|
|
14137
14151
|
case 234 /* Block */:
|
|
@@ -46909,6 +46923,9 @@ var ts;
|
|
|
46909
46923
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
46910
46924
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
46911
46925
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
46926
|
+
CheckMode[CheckMode["RestBindingElement"] = 32] = "RestBindingElement";
|
|
46927
|
+
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
46928
|
+
// we need to preserve generic types instead of substituting them for constraints
|
|
46912
46929
|
})(CheckMode || (CheckMode = {}));
|
|
46913
46930
|
var SignatureCheckMode;
|
|
46914
46931
|
(function (SignatureCheckMode) {
|
|
@@ -47961,13 +47978,13 @@ var ts;
|
|
|
47961
47978
|
else { // error
|
|
47962
47979
|
var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
|
|
47963
47980
|
var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
|
|
47964
|
-
var message = isEitherEnum
|
|
47965
|
-
? ts.Diagnostics.
|
|
47966
|
-
: isEitherBlockScoped_1
|
|
47967
|
-
? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
47981
|
+
var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
|
|
47982
|
+
: isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
47968
47983
|
: ts.Diagnostics.Duplicate_identifier_0;
|
|
47969
47984
|
var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
|
|
47970
47985
|
var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
|
|
47986
|
+
var isSourcePlainJs = ts.isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
|
|
47987
|
+
var isTargetPlainJs = ts.isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
|
|
47971
47988
|
var symbolName_1 = symbolToString(source);
|
|
47972
47989
|
// Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch
|
|
47973
47990
|
if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
|
|
@@ -47979,12 +47996,16 @@ var ts;
|
|
|
47979
47996
|
var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
|
|
47980
47997
|
return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
|
|
47981
47998
|
});
|
|
47982
|
-
|
|
47983
|
-
|
|
47999
|
+
if (!isSourcePlainJs)
|
|
48000
|
+
addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
|
|
48001
|
+
if (!isTargetPlainJs)
|
|
48002
|
+
addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
|
|
47984
48003
|
}
|
|
47985
48004
|
else {
|
|
47986
|
-
|
|
47987
|
-
|
|
48005
|
+
if (!isSourcePlainJs)
|
|
48006
|
+
addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
|
|
48007
|
+
if (!isTargetPlainJs)
|
|
48008
|
+
addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
|
|
47988
48009
|
}
|
|
47989
48010
|
}
|
|
47990
48011
|
return target;
|
|
@@ -48441,6 +48462,8 @@ var ts;
|
|
|
48441
48462
|
// type parameters are visible in parameter list, return type and type parameter list
|
|
48442
48463
|
? lastLocation === location.type ||
|
|
48443
48464
|
lastLocation.kind === 163 /* Parameter */ ||
|
|
48465
|
+
lastLocation.kind === 338 /* JSDocParameterTag */ ||
|
|
48466
|
+
lastLocation.kind === 339 /* JSDocReturnTag */ ||
|
|
48444
48467
|
lastLocation.kind === 162 /* TypeParameter */
|
|
48445
48468
|
// local types not visible outside the function body
|
|
48446
48469
|
: false;
|
|
@@ -48700,9 +48723,9 @@ var ts;
|
|
|
48700
48723
|
lastSelfReferenceLocation = location;
|
|
48701
48724
|
}
|
|
48702
48725
|
lastLocation = location;
|
|
48703
|
-
location = ts.isJSDocTemplateTag(location) ?
|
|
48704
|
-
ts.
|
|
48705
|
-
|
|
48726
|
+
location = ts.isJSDocTemplateTag(location) ? ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
|
|
48727
|
+
ts.isJSDocParameterTag(location) || ts.isJSDocReturnTag(location) ? ts.getHostSignatureFromJSDoc(location) || location.parent :
|
|
48728
|
+
location.parent;
|
|
48706
48729
|
}
|
|
48707
48730
|
// We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
|
|
48708
48731
|
// If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself.
|
|
@@ -49836,16 +49859,20 @@ var ts;
|
|
|
49836
49859
|
return;
|
|
49837
49860
|
}
|
|
49838
49861
|
var host = ts.getJSDocHost(node);
|
|
49839
|
-
if (host &&
|
|
49840
|
-
|
|
49841
|
-
ts.isBinaryExpression(host.expression) &&
|
|
49842
|
-
ts.getAssignmentDeclarationKind(host.expression) === 3 /* PrototypeProperty */) {
|
|
49843
|
-
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
49862
|
+
if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
|
|
49863
|
+
// /** @param {K} p */ X.prototype.m = function () { } <-- look for K on X's declaration
|
|
49844
49864
|
var symbol = getSymbolOfNode(host.expression.left);
|
|
49845
49865
|
if (symbol) {
|
|
49846
49866
|
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
49847
49867
|
}
|
|
49848
49868
|
}
|
|
49869
|
+
if (host && ts.isFunctionExpression(host) && ts.isPrototypePropertyAssignment(host.parent) && ts.isExpressionStatement(host.parent.parent)) {
|
|
49870
|
+
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
49871
|
+
var symbol = getSymbolOfNode(host.parent.left);
|
|
49872
|
+
if (symbol) {
|
|
49873
|
+
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
49874
|
+
}
|
|
49875
|
+
}
|
|
49849
49876
|
if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
|
|
49850
49877
|
ts.isBinaryExpression(host.parent.parent) &&
|
|
49851
49878
|
ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) {
|
|
@@ -54332,9 +54359,12 @@ var ts;
|
|
|
54332
54359
|
}
|
|
54333
54360
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
54334
54361
|
// assigned by contextual typing.
|
|
54335
|
-
function getTypeForBindingElementParent(node) {
|
|
54362
|
+
function getTypeForBindingElementParent(node, checkMode) {
|
|
54363
|
+
if (checkMode !== 0 /* Normal */) {
|
|
54364
|
+
return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54365
|
+
}
|
|
54336
54366
|
var symbol = getSymbolOfNode(node);
|
|
54337
|
-
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
|
|
54367
|
+
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54338
54368
|
}
|
|
54339
54369
|
function getRestType(source, properties, symbol) {
|
|
54340
54370
|
source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
@@ -54452,7 +54482,8 @@ var ts;
|
|
|
54452
54482
|
}
|
|
54453
54483
|
/** Return the inferred type for a binding element */
|
|
54454
54484
|
function getTypeForBindingElement(declaration) {
|
|
54455
|
-
var
|
|
54485
|
+
var checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
54486
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
54456
54487
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
54457
54488
|
}
|
|
54458
54489
|
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
@@ -54524,9 +54555,9 @@ var ts;
|
|
|
54524
54555
|
if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
|
|
54525
54556
|
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
|
54526
54557
|
// undefined from the final type.
|
|
54527
|
-
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54558
|
+
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54528
54559
|
}
|
|
54529
|
-
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
|
|
54560
|
+
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
54530
54561
|
}
|
|
54531
54562
|
function getTypeForDeclarationFromJSDocComment(declaration) {
|
|
54532
54563
|
var jsdocType = ts.getJSDocType(declaration);
|
|
@@ -54549,11 +54580,11 @@ var ts;
|
|
|
54549
54580
|
return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
|
|
54550
54581
|
}
|
|
54551
54582
|
// Return the inferred type for a variable, parameter, or property declaration
|
|
54552
|
-
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
|
54583
|
+
function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
|
|
54553
54584
|
// A variable declared in a for..in statement is of type string, or of type keyof T when the
|
|
54554
54585
|
// right hand expression is of a type parameter type.
|
|
54555
54586
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
|
|
54556
|
-
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
|
|
54587
|
+
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode)));
|
|
54557
54588
|
return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
|
|
54558
54589
|
}
|
|
54559
54590
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
|
|
@@ -54608,12 +54639,9 @@ var ts;
|
|
|
54608
54639
|
}
|
|
54609
54640
|
}
|
|
54610
54641
|
if (ts.isInJSFile(declaration)) {
|
|
54611
|
-
var
|
|
54612
|
-
if (
|
|
54613
|
-
|
|
54614
|
-
var pos = func.parameters.indexOf(declaration);
|
|
54615
|
-
return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
54616
|
-
}
|
|
54642
|
+
var type_1 = getParameterTypeOfTypeTag(func, declaration);
|
|
54643
|
+
if (type_1)
|
|
54644
|
+
return type_1;
|
|
54617
54645
|
}
|
|
54618
54646
|
// Use contextual parameter type if one is available
|
|
54619
54647
|
var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
|
|
@@ -54630,7 +54658,7 @@ var ts;
|
|
|
54630
54658
|
return containerObjectType;
|
|
54631
54659
|
}
|
|
54632
54660
|
}
|
|
54633
|
-
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
|
|
54661
|
+
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
|
|
54634
54662
|
return addOptionality(type, isProperty, isOptional);
|
|
54635
54663
|
}
|
|
54636
54664
|
if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
|
|
@@ -55002,7 +55030,7 @@ var ts;
|
|
|
55002
55030
|
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
|
|
55003
55031
|
// pattern.
|
|
55004
55032
|
var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
|
|
55005
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
|
|
55033
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
55006
55034
|
}
|
|
55007
55035
|
if (ts.isBindingPattern(element.name)) {
|
|
55008
55036
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
|
|
@@ -55091,7 +55119,7 @@ var ts;
|
|
|
55091
55119
|
// binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
|
|
55092
55120
|
// tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
|
|
55093
55121
|
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
|
55094
|
-
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
|
|
55122
|
+
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors);
|
|
55095
55123
|
}
|
|
55096
55124
|
function isGlobalSymbolConstructor(node) {
|
|
55097
55125
|
var symbol = getSymbolOfNode(node);
|
|
@@ -55180,9 +55208,9 @@ var ts;
|
|
|
55180
55208
|
if (typeNode === undefined) {
|
|
55181
55209
|
return useUnknownInCatchVariables ? unknownType : anyType;
|
|
55182
55210
|
}
|
|
55183
|
-
var
|
|
55211
|
+
var type_2 = getTypeOfNode(typeNode);
|
|
55184
55212
|
// an errorType will make `checkTryStatement` issue an error
|
|
55185
|
-
return isTypeAny(
|
|
55213
|
+
return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
|
|
55186
55214
|
}
|
|
55187
55215
|
// Handle export default expressions
|
|
55188
55216
|
if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
|
|
@@ -55320,10 +55348,12 @@ var ts;
|
|
|
55320
55348
|
if (writing === void 0) { writing = false; }
|
|
55321
55349
|
var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
|
|
55322
55350
|
var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */);
|
|
55323
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
55324
55351
|
// For write operations, prioritize type annotations on the setter
|
|
55325
|
-
if (writing
|
|
55326
|
-
|
|
55352
|
+
if (writing) {
|
|
55353
|
+
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
55354
|
+
if (setterType_1) {
|
|
55355
|
+
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
55356
|
+
}
|
|
55327
55357
|
}
|
|
55328
55358
|
// Else defer to the getter type
|
|
55329
55359
|
if (getter && ts.isInJSFile(getter)) {
|
|
@@ -55338,6 +55368,7 @@ var ts;
|
|
|
55338
55368
|
return instantiateTypeIfNeeded(getterType, symbol);
|
|
55339
55369
|
}
|
|
55340
55370
|
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
55371
|
+
var setterType = getAnnotatedAccessorType(setter);
|
|
55341
55372
|
if (setterType) {
|
|
55342
55373
|
return setterType;
|
|
55343
55374
|
}
|
|
@@ -55408,11 +55439,11 @@ var ts;
|
|
|
55408
55439
|
return errorType;
|
|
55409
55440
|
}
|
|
55410
55441
|
var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
|
|
55411
|
-
var
|
|
55442
|
+
var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
|
55412
55443
|
if (!popTypeResolution()) {
|
|
55413
55444
|
return reportCircularityError(symbol);
|
|
55414
55445
|
}
|
|
55415
|
-
return
|
|
55446
|
+
return type_3;
|
|
55416
55447
|
}
|
|
55417
55448
|
}
|
|
55418
55449
|
var type = createObjectType(16 /* Anonymous */, symbol);
|
|
@@ -55486,6 +55517,39 @@ var ts;
|
|
|
55486
55517
|
}
|
|
55487
55518
|
return links.type;
|
|
55488
55519
|
}
|
|
55520
|
+
function getWriteTypeOfSymbolWithDeferredType(symbol) {
|
|
55521
|
+
var links = getSymbolLinks(symbol);
|
|
55522
|
+
if (!links.writeType && links.deferralWriteConstituents) {
|
|
55523
|
+
ts.Debug.assertIsDefined(links.deferralParent);
|
|
55524
|
+
ts.Debug.assertIsDefined(links.deferralConstituents);
|
|
55525
|
+
links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
|
|
55526
|
+
}
|
|
55527
|
+
return links.writeType;
|
|
55528
|
+
}
|
|
55529
|
+
/**
|
|
55530
|
+
* Distinct write types come only from set accessors, but union and intersection
|
|
55531
|
+
* properties deriving from set accessors will either pre-compute or defer the
|
|
55532
|
+
* union or intersection of the writeTypes of their constituents. To account for
|
|
55533
|
+
* this, we will assume that any deferred type or transient symbol may have a
|
|
55534
|
+
* `writeType` (or a deferred write type ready to be computed) that should be
|
|
55535
|
+
* used before looking for set accessor declarations.
|
|
55536
|
+
*/
|
|
55537
|
+
function getWriteTypeOfSymbol(symbol) {
|
|
55538
|
+
var checkFlags = ts.getCheckFlags(symbol);
|
|
55539
|
+
if (checkFlags & 65536 /* DeferredType */) {
|
|
55540
|
+
var writeType = getWriteTypeOfSymbolWithDeferredType(symbol);
|
|
55541
|
+
if (writeType) {
|
|
55542
|
+
return writeType;
|
|
55543
|
+
}
|
|
55544
|
+
}
|
|
55545
|
+
if (symbol.flags & 33554432 /* Transient */) {
|
|
55546
|
+
var writeType = symbol.writeType;
|
|
55547
|
+
if (writeType) {
|
|
55548
|
+
return writeType;
|
|
55549
|
+
}
|
|
55550
|
+
}
|
|
55551
|
+
return getSetAccessorTypeOfSymbol(symbol);
|
|
55552
|
+
}
|
|
55489
55553
|
function getSetAccessorTypeOfSymbol(symbol) {
|
|
55490
55554
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
55491
55555
|
var type = getTypeOfSetAccessor(symbol);
|
|
@@ -57611,10 +57675,10 @@ var ts;
|
|
|
57611
57675
|
var baseTypes = [];
|
|
57612
57676
|
var different = false;
|
|
57613
57677
|
for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
|
|
57614
|
-
var
|
|
57615
|
-
var baseType = getBaseConstraint(
|
|
57678
|
+
var type_4 = types_7[_i];
|
|
57679
|
+
var baseType = getBaseConstraint(type_4);
|
|
57616
57680
|
if (baseType) {
|
|
57617
|
-
if (baseType !==
|
|
57681
|
+
if (baseType !== type_4) {
|
|
57618
57682
|
different = true;
|
|
57619
57683
|
}
|
|
57620
57684
|
baseTypes.push(baseType);
|
|
@@ -57856,6 +57920,7 @@ var ts;
|
|
|
57856
57920
|
var firstType;
|
|
57857
57921
|
var nameType;
|
|
57858
57922
|
var propTypes = [];
|
|
57923
|
+
var writeTypes;
|
|
57859
57924
|
var firstValueDeclaration;
|
|
57860
57925
|
var hasNonUniformValueDeclaration = false;
|
|
57861
57926
|
for (var _d = 0, props_1 = props; _d < props_1.length; _d++) {
|
|
@@ -57872,6 +57937,10 @@ var ts;
|
|
|
57872
57937
|
firstType = type;
|
|
57873
57938
|
nameType = getSymbolLinks(prop).nameType;
|
|
57874
57939
|
}
|
|
57940
|
+
var writeType = getWriteTypeOfSymbol(prop);
|
|
57941
|
+
if (writeTypes || writeType !== type) {
|
|
57942
|
+
writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType);
|
|
57943
|
+
}
|
|
57875
57944
|
else if (type !== firstType) {
|
|
57876
57945
|
checkFlags |= 64 /* HasNonUniformType */;
|
|
57877
57946
|
}
|
|
@@ -57900,9 +57969,13 @@ var ts;
|
|
|
57900
57969
|
result.checkFlags |= 65536 /* DeferredType */;
|
|
57901
57970
|
result.deferralParent = containingType;
|
|
57902
57971
|
result.deferralConstituents = propTypes;
|
|
57972
|
+
result.deferralWriteConstituents = writeTypes;
|
|
57903
57973
|
}
|
|
57904
57974
|
else {
|
|
57905
57975
|
result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
|
|
57976
|
+
if (writeTypes) {
|
|
57977
|
+
result.writeType = isUnion ? getUnionType(writeTypes) : getIntersectionType(writeTypes);
|
|
57978
|
+
}
|
|
57906
57979
|
}
|
|
57907
57980
|
return result;
|
|
57908
57981
|
}
|
|
@@ -58318,6 +58391,13 @@ var ts;
|
|
|
58318
58391
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
58319
58392
|
return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
58320
58393
|
}
|
|
58394
|
+
function getParameterTypeOfTypeTag(func, parameter) {
|
|
58395
|
+
var signature = getSignatureOfTypeTag(func);
|
|
58396
|
+
if (!signature)
|
|
58397
|
+
return undefined;
|
|
58398
|
+
var pos = func.parameters.indexOf(parameter);
|
|
58399
|
+
return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
58400
|
+
}
|
|
58321
58401
|
function getReturnTypeOfTypeTag(node) {
|
|
58322
58402
|
var signature = getSignatureOfTypeTag(node);
|
|
58323
58403
|
return signature && getReturnTypeOfSignature(signature);
|
|
@@ -59044,7 +59124,7 @@ var ts;
|
|
|
59044
59124
|
}
|
|
59045
59125
|
function getImpliedConstraint(type, checkNode, extendsNode) {
|
|
59046
59126
|
return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
|
|
59047
|
-
getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
|
|
59127
|
+
getActualTypeVariable(getTypeFromTypeNode(checkNode)) === getActualTypeVariable(type) ? getTypeFromTypeNode(extendsNode) :
|
|
59048
59128
|
undefined;
|
|
59049
59129
|
}
|
|
59050
59130
|
function getConditionalFlowTypeOfType(type, node) {
|
|
@@ -69853,12 +69933,16 @@ var ts;
|
|
|
69853
69933
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
69854
69934
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
69855
69935
|
}
|
|
69856
|
-
function
|
|
69936
|
+
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
69857
69937
|
// Computing the contextual type for a child of a JSX element involves resolving the type of the
|
|
69858
69938
|
// element's tag name, so we exclude that here to avoid circularities.
|
|
69939
|
+
// If check mode has `CheckMode.RestBindingElement`, we skip binding pattern contextual types,
|
|
69940
|
+
// as we want the type of a rest element to be generic when possible.
|
|
69859
69941
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
69860
69942
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
69861
|
-
|
|
69943
|
+
(checkMode && checkMode & 32 /* RestBindingElement */ ?
|
|
69944
|
+
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
69945
|
+
: getContextualType(node));
|
|
69862
69946
|
return contextualType && !isGenericType(contextualType);
|
|
69863
69947
|
}
|
|
69864
69948
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -69871,7 +69955,7 @@ var ts;
|
|
|
69871
69955
|
// 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
|
|
69872
69956
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
69873
69957
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
69874
|
-
(isConstraintPosition(type, reference) ||
|
|
69958
|
+
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
69875
69959
|
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
|
|
69876
69960
|
}
|
|
69877
69961
|
function isExportOrExportExpression(location) {
|
|
@@ -69939,7 +70023,7 @@ var ts;
|
|
|
69939
70023
|
var links = getNodeLinks(location);
|
|
69940
70024
|
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
69941
70025
|
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
69942
|
-
var parentType = getTypeForBindingElementParent(parent);
|
|
70026
|
+
var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
|
|
69943
70027
|
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
69944
70028
|
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
69945
70029
|
var pattern = declaration.parent;
|
|
@@ -70792,7 +70876,7 @@ var ts;
|
|
|
70792
70876
|
var parent = declaration.parent.parent;
|
|
70793
70877
|
var name = declaration.propertyName || declaration.name;
|
|
70794
70878
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
70795
|
-
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
|
|
70879
|
+
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
|
|
70796
70880
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
70797
70881
|
return undefined;
|
|
70798
70882
|
if (parent.name.kind === 201 /* ArrayBindingPattern */) {
|
|
@@ -73033,7 +73117,7 @@ var ts;
|
|
|
73033
73117
|
error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
|
|
73034
73118
|
return errorType;
|
|
73035
73119
|
}
|
|
73036
|
-
propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ?
|
|
73120
|
+
propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getWriteTypeOfSymbol(prop) : getTypeOfSymbol(prop);
|
|
73037
73121
|
}
|
|
73038
73122
|
return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode);
|
|
73039
73123
|
}
|
|
@@ -75503,8 +75587,8 @@ var ts;
|
|
|
75503
75587
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75504
75588
|
var synthType = type;
|
|
75505
75589
|
if (!synthType.defaultOnlyType) {
|
|
75506
|
-
var
|
|
75507
|
-
synthType.defaultOnlyType =
|
|
75590
|
+
var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75591
|
+
synthType.defaultOnlyType = type_5;
|
|
75508
75592
|
}
|
|
75509
75593
|
return synthType.defaultOnlyType;
|
|
75510
75594
|
}
|
|
@@ -75958,7 +76042,7 @@ var ts;
|
|
|
75958
76042
|
var links = getSymbolLinks(parameter);
|
|
75959
76043
|
if (!links.type) {
|
|
75960
76044
|
var declaration = parameter.valueDeclaration;
|
|
75961
|
-
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*
|
|
76045
|
+
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
|
|
75962
76046
|
if (declaration.name.kind !== 79 /* Identifier */) {
|
|
75963
76047
|
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
|
|
75964
76048
|
if (links.type === unknownType) {
|
|
@@ -76231,12 +76315,12 @@ var ts;
|
|
|
76231
76315
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
76232
76316
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
76233
76317
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
76234
|
-
var
|
|
76318
|
+
var type_6 = getBaseConstraintOfType(operandType) || operandType;
|
|
76235
76319
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
76236
|
-
if (
|
|
76320
|
+
if (type_6.flags & 3 /* AnyOrUnknown */) {
|
|
76237
76321
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
76238
76322
|
}
|
|
76239
|
-
return !!(filterType(
|
|
76323
|
+
return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
76240
76324
|
}
|
|
76241
76325
|
var type = getTypeOfExpression(node.expression);
|
|
76242
76326
|
if (!isLiteralType(type)) {
|
|
@@ -77689,11 +77773,11 @@ var ts;
|
|
|
77689
77773
|
}
|
|
77690
77774
|
}
|
|
77691
77775
|
function checkExpressionCached(node, checkMode) {
|
|
77776
|
+
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77777
|
+
return checkExpression(node, checkMode);
|
|
77778
|
+
}
|
|
77692
77779
|
var links = getNodeLinks(node);
|
|
77693
77780
|
if (!links.resolvedType) {
|
|
77694
|
-
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77695
|
-
return checkExpression(node, checkMode);
|
|
77696
|
-
}
|
|
77697
77781
|
// When computing a type that we're going to cache, we need to ignore any ongoing control flow
|
|
77698
77782
|
// analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
|
|
77699
77783
|
// to the top of the stack ensures all transient types are computed from a known point.
|
|
@@ -77713,10 +77797,12 @@ var ts;
|
|
|
77713
77797
|
node.kind === 228 /* AsExpression */ ||
|
|
77714
77798
|
ts.isJSDocTypeAssertion(node);
|
|
77715
77799
|
}
|
|
77716
|
-
function checkDeclarationInitializer(declaration, contextualType) {
|
|
77800
|
+
function checkDeclarationInitializer(declaration, checkMode, contextualType) {
|
|
77717
77801
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
77718
77802
|
var type = getQuickTypeOfExpression(initializer) ||
|
|
77719
|
-
(contextualType ?
|
|
77803
|
+
(contextualType ?
|
|
77804
|
+
checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
|
|
77805
|
+
: checkExpressionCached(initializer, checkMode));
|
|
77720
77806
|
return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
|
|
77721
77807
|
isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
|
|
77722
77808
|
padTupleType(type, declaration.name) : type;
|
|
@@ -78356,6 +78442,7 @@ var ts;
|
|
|
78356
78442
|
}
|
|
78357
78443
|
}
|
|
78358
78444
|
checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
|
|
78445
|
+
checkUnmatchedJSDocParameters(node);
|
|
78359
78446
|
ts.forEach(node.parameters, checkParameter);
|
|
78360
78447
|
// TODO(rbuckton): Should we start checking JSDoc types?
|
|
78361
78448
|
if (node.type) {
|
|
@@ -79927,31 +80014,6 @@ var ts;
|
|
|
79927
80014
|
}
|
|
79928
80015
|
function checkJSDocParameterTag(node) {
|
|
79929
80016
|
checkSourceElement(node.typeExpression);
|
|
79930
|
-
if (!ts.getParameterSymbolFromJSDoc(node)) {
|
|
79931
|
-
var decl = ts.getHostSignatureFromJSDoc(node);
|
|
79932
|
-
// don't issue an error for invalid hosts -- just functions --
|
|
79933
|
-
// and give a better error message when the host function mentions `arguments`
|
|
79934
|
-
// but the tag doesn't have an array type
|
|
79935
|
-
if (decl) {
|
|
79936
|
-
var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
|
|
79937
|
-
if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
|
|
79938
|
-
return;
|
|
79939
|
-
}
|
|
79940
|
-
if (!containsArgumentsReference(decl)) {
|
|
79941
|
-
if (ts.isQualifiedName(node.name)) {
|
|
79942
|
-
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));
|
|
79943
|
-
}
|
|
79944
|
-
else {
|
|
79945
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
|
|
79946
|
-
}
|
|
79947
|
-
}
|
|
79948
|
-
else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
|
|
79949
|
-
node.typeExpression && node.typeExpression.type &&
|
|
79950
|
-
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
|
|
79951
|
-
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));
|
|
79952
|
-
}
|
|
79953
|
-
}
|
|
79954
|
-
}
|
|
79955
80017
|
}
|
|
79956
80018
|
function checkJSDocPropertyTag(node) {
|
|
79957
80019
|
checkSourceElement(node.typeExpression);
|
|
@@ -80653,7 +80715,8 @@ var ts;
|
|
|
80653
80715
|
}
|
|
80654
80716
|
// check private/protected variable access
|
|
80655
80717
|
var parent = node.parent.parent;
|
|
80656
|
-
var
|
|
80718
|
+
var parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
80719
|
+
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
80657
80720
|
var name = node.propertyName || node.name;
|
|
80658
80721
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
80659
80722
|
var exprType = getLiteralTypeFromPropertyName(name);
|
|
@@ -81892,7 +81955,7 @@ var ts;
|
|
|
81892
81955
|
var declaration = catchClause.variableDeclaration;
|
|
81893
81956
|
var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
|
|
81894
81957
|
if (typeNode) {
|
|
81895
|
-
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
|
|
81958
|
+
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */);
|
|
81896
81959
|
if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
|
|
81897
81960
|
grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
|
|
81898
81961
|
}
|
|
@@ -82023,6 +82086,45 @@ var ts;
|
|
|
82023
82086
|
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
|
|
82024
82087
|
}
|
|
82025
82088
|
}
|
|
82089
|
+
function checkUnmatchedJSDocParameters(node) {
|
|
82090
|
+
var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
|
|
82091
|
+
if (!ts.length(jsdocParameters))
|
|
82092
|
+
return;
|
|
82093
|
+
var isJs = ts.isInJSFile(node);
|
|
82094
|
+
var parameters = new ts.Set();
|
|
82095
|
+
var excludedParameters = new ts.Set();
|
|
82096
|
+
ts.forEach(node.parameters, function (_a, index) {
|
|
82097
|
+
var name = _a.name;
|
|
82098
|
+
if (ts.isIdentifier(name)) {
|
|
82099
|
+
parameters.add(name.escapedText);
|
|
82100
|
+
}
|
|
82101
|
+
if (ts.isBindingPattern(name)) {
|
|
82102
|
+
excludedParameters.add(index);
|
|
82103
|
+
}
|
|
82104
|
+
});
|
|
82105
|
+
var containsArguments = containsArgumentsReference(node);
|
|
82106
|
+
if (containsArguments) {
|
|
82107
|
+
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82108
|
+
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82109
|
+
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82110
|
+
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));
|
|
82111
|
+
}
|
|
82112
|
+
}
|
|
82113
|
+
else {
|
|
82114
|
+
ts.forEach(jsdocParameters, function (_a, index) {
|
|
82115
|
+
var name = _a.name;
|
|
82116
|
+
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
82117
|
+
return;
|
|
82118
|
+
}
|
|
82119
|
+
if (ts.isQualifiedName(name)) {
|
|
82120
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82121
|
+
}
|
|
82122
|
+
else {
|
|
82123
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
82124
|
+
}
|
|
82125
|
+
});
|
|
82126
|
+
}
|
|
82127
|
+
}
|
|
82026
82128
|
/**
|
|
82027
82129
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
82028
82130
|
*/
|
|
@@ -82998,7 +83100,7 @@ var ts;
|
|
|
82998
83100
|
var isAmbientExternalModule = ts.isAmbientModule(node);
|
|
82999
83101
|
var contextErrorMessage = isAmbientExternalModule
|
|
83000
83102
|
? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
|
|
83001
|
-
: ts.Diagnostics.
|
|
83103
|
+
: ts.Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
|
|
83002
83104
|
if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
|
|
83003
83105
|
// If we hit a module declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83004
83106
|
return;
|
|
@@ -83231,6 +83333,9 @@ var ts;
|
|
|
83231
83333
|
var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
|
|
83232
83334
|
addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
|
|
83233
83335
|
}
|
|
83336
|
+
if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
|
|
83337
|
+
error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
|
|
83338
|
+
}
|
|
83234
83339
|
break;
|
|
83235
83340
|
}
|
|
83236
83341
|
case 274 /* ExportSpecifier */: {
|
|
@@ -83314,7 +83419,7 @@ var ts;
|
|
|
83314
83419
|
}
|
|
83315
83420
|
}
|
|
83316
83421
|
function checkImportDeclaration(node) {
|
|
83317
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83422
|
+
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)) {
|
|
83318
83423
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83319
83424
|
return;
|
|
83320
83425
|
}
|
|
@@ -83347,7 +83452,7 @@ var ts;
|
|
|
83347
83452
|
checkAssertClause(node);
|
|
83348
83453
|
}
|
|
83349
83454
|
function checkImportEqualsDeclaration(node) {
|
|
83350
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83455
|
+
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)) {
|
|
83351
83456
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83352
83457
|
return;
|
|
83353
83458
|
}
|
|
@@ -83384,7 +83489,7 @@ var ts;
|
|
|
83384
83489
|
}
|
|
83385
83490
|
}
|
|
83386
83491
|
function checkExportDeclaration(node) {
|
|
83387
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83492
|
+
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)) {
|
|
83388
83493
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
83389
83494
|
return;
|
|
83390
83495
|
}
|
|
@@ -84618,7 +84723,7 @@ var ts;
|
|
|
84618
84723
|
return errorType;
|
|
84619
84724
|
}
|
|
84620
84725
|
if (ts.isBindingPattern(node)) {
|
|
84621
|
-
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
|
|
84726
|
+
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType;
|
|
84622
84727
|
}
|
|
84623
84728
|
if (isInRightSideOfImportOrExportAssignment(node)) {
|
|
84624
84729
|
var symbol = getSymbolAtLocation(node);
|
|
@@ -114365,9 +114470,9 @@ var ts;
|
|
|
114365
114470
|
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
|
|
114366
114471
|
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
|
114367
114472
|
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
|
114368
|
-
ts.Diagnostics.
|
|
114473
|
+
ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114369
114474
|
ts.Diagnostics.An_export_declaration_cannot_have_modifiers.code,
|
|
114370
|
-
ts.Diagnostics.
|
|
114475
|
+
ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114371
114476
|
ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
|
|
114372
114477
|
ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
|
|
114373
114478
|
ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
|
|
@@ -115435,7 +115540,7 @@ var ts;
|
|
|
115435
115540
|
ts.Debug.assert(!!sourceFile.bindDiagnostics);
|
|
115436
115541
|
var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
|
|
115437
115542
|
var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
|
|
115438
|
-
var isPlainJs =
|
|
115543
|
+
var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
|
|
115439
115544
|
var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
|
|
115440
115545
|
// By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
|
|
115441
115546
|
// - plain JS: .js files with no // ts-check and checkJs: undefined
|
|
@@ -130328,7 +130433,8 @@ var ts;
|
|
|
130328
130433
|
case 103 /* NewKeyword */:
|
|
130329
130434
|
return checker.getContextualType(parent);
|
|
130330
130435
|
case 82 /* CaseKeyword */:
|
|
130331
|
-
|
|
130436
|
+
var caseClause = ts.tryCast(parent, ts.isCaseClause);
|
|
130437
|
+
return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined;
|
|
130332
130438
|
case 18 /* OpenBraceToken */:
|
|
130333
130439
|
return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined;
|
|
130334
130440
|
default:
|
|
@@ -132973,7 +133079,24 @@ var ts;
|
|
|
132973
133079
|
function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
|
|
132974
133080
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
|
|
132975
133081
|
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
|
|
133082
|
+
var oldBucketCount = buckets.size;
|
|
132976
133083
|
var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
|
|
133084
|
+
if (ts.tracing) {
|
|
133085
|
+
if (buckets.size > oldBucketCount) {
|
|
133086
|
+
// It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
|
|
133087
|
+
// perhaps they are for two projects that don't have any overlap.
|
|
133088
|
+
// Bonus: these events can help us interpret the more interesting event below.
|
|
133089
|
+
ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
|
|
133090
|
+
}
|
|
133091
|
+
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
133092
|
+
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
133093
|
+
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
133094
|
+
var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
|
|
133095
|
+
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
|
|
133096
|
+
if (otherBucketKey) {
|
|
133097
|
+
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
|
|
133098
|
+
}
|
|
133099
|
+
}
|
|
132977
133100
|
var bucketEntry = bucket.get(path);
|
|
132978
133101
|
var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
132979
133102
|
if (!entry && externalCache) {
|
|
@@ -145109,6 +145232,8 @@ var ts;
|
|
|
145109
145232
|
case 179 /* ConstructorType */:
|
|
145110
145233
|
case 174 /* ConstructSignature */:
|
|
145111
145234
|
return getList(node.typeParameters) || getList(node.parameters);
|
|
145235
|
+
case 171 /* GetAccessor */:
|
|
145236
|
+
return getList(node.parameters);
|
|
145112
145237
|
case 256 /* ClassDeclaration */:
|
|
145113
145238
|
case 225 /* ClassExpression */:
|
|
145114
145239
|
case 257 /* InterfaceDeclaration */:
|
|
@@ -145729,8 +145854,18 @@ var ts;
|
|
|
145729
145854
|
var indent = sourceFile.text.slice(startPosition, fnStart);
|
|
145730
145855
|
this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
|
|
145731
145856
|
};
|
|
145857
|
+
ChangeTracker.prototype.createJSDocText = function (sourceFile, node) {
|
|
145858
|
+
var comments = ts.flatMap(node.jsDoc, function (jsDoc) {
|
|
145859
|
+
return ts.isString(jsDoc.comment) ? ts.factory.createJSDocText(jsDoc.comment) : jsDoc.comment;
|
|
145860
|
+
});
|
|
145861
|
+
var jsDoc = ts.singleOrUndefined(node.jsDoc);
|
|
145862
|
+
return jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && ts.length(comments) === 0 ? undefined :
|
|
145863
|
+
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
145864
|
+
};
|
|
145865
|
+
ChangeTracker.prototype.replaceJSDocComment = function (sourceFile, node, tags) {
|
|
145866
|
+
this.insertJsdocCommentBefore(sourceFile, updateJSDocHost(node), ts.factory.createJSDocComment(this.createJSDocText(sourceFile, node), ts.factory.createNodeArray(tags)));
|
|
145867
|
+
};
|
|
145732
145868
|
ChangeTracker.prototype.addJSDocTags = function (sourceFile, parent, newTags) {
|
|
145733
|
-
var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
|
|
145734
145869
|
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
145735
145870
|
var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags.some(function (tag, i) {
|
|
145736
145871
|
var merged = tryMergeJsdocTags(tag, newTag);
|
|
@@ -145738,20 +145873,10 @@ var ts;
|
|
|
145738
145873
|
oldTags[i] = merged;
|
|
145739
145874
|
return !!merged;
|
|
145740
145875
|
}); });
|
|
145741
|
-
|
|
145742
|
-
var jsDoc = ts.singleOrUndefined(parent.jsDoc);
|
|
145743
|
-
var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
|
|
145744
|
-
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
145745
|
-
var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
|
|
145746
|
-
var host = updateJSDocHost(parent);
|
|
145747
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
145876
|
+
this.replaceJSDocComment(sourceFile, parent, __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true));
|
|
145748
145877
|
};
|
|
145749
145878
|
ChangeTracker.prototype.filterJSDocTags = function (sourceFile, parent, predicate) {
|
|
145750
|
-
|
|
145751
|
-
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
145752
|
-
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)));
|
|
145753
|
-
var host = updateJSDocHost(parent);
|
|
145754
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
145879
|
+
this.replaceJSDocComment(sourceFile, parent, ts.filter(ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }), predicate));
|
|
145755
145880
|
};
|
|
145756
145881
|
ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) {
|
|
145757
145882
|
this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text });
|
|
@@ -149546,9 +149671,9 @@ var ts;
|
|
|
149546
149671
|
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
|
|
149547
149672
|
var checker = program.getTypeChecker();
|
|
149548
149673
|
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
|
|
149549
|
-
var
|
|
149674
|
+
var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
|
|
149550
149675
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149551
|
-
var fix = getImportFixForSymbol(sourceFile,
|
|
149676
|
+
var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
149552
149677
|
if (fix) {
|
|
149553
149678
|
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
149554
149679
|
}
|
|
@@ -149737,7 +149862,7 @@ var ts;
|
|
|
149737
149862
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
149738
149863
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
149739
149864
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
149740
|
-
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
|
|
149865
|
+
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
|
|
149741
149866
|
}
|
|
149742
149867
|
function codeFixActionToCodeAction(_a) {
|
|
149743
149868
|
var description = _a.description, changes = _a.changes, commands = _a.commands;
|
|
@@ -149797,7 +149922,7 @@ var ts;
|
|
|
149797
149922
|
/*position*/ undefined,
|
|
149798
149923
|
/*isValidTypeOnlyUseSite*/ false,
|
|
149799
149924
|
/*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
149800
|
-
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
|
|
149925
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
|
149801
149926
|
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
149802
149927
|
}
|
|
149803
149928
|
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
@@ -149967,7 +150092,7 @@ var ts;
|
|
|
149967
150092
|
// 5. Literally nothing to go on
|
|
149968
150093
|
return true;
|
|
149969
150094
|
}
|
|
149970
|
-
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire,
|
|
150095
|
+
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
|
|
149971
150096
|
var isJs = ts.isSourceFileJS(sourceFile);
|
|
149972
150097
|
var compilerOptions = program.getCompilerOptions();
|
|
149973
150098
|
var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
|
|
@@ -149976,7 +150101,7 @@ var ts;
|
|
|
149976
150101
|
? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
|
|
149977
150102
|
: function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
|
|
149978
150103
|
var computedWithoutCacheCount = 0;
|
|
149979
|
-
var fixes = ts.flatMap(
|
|
150104
|
+
var fixes = ts.flatMap(exportInfo, function (exportInfo, i) {
|
|
149980
150105
|
var checker = getChecker(exportInfo.isFromPackageJson);
|
|
149981
150106
|
var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
|
|
149982
150107
|
var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
|
|
@@ -149985,7 +150110,7 @@ var ts;
|
|
|
149985
150110
|
return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
|
|
149986
150111
|
// `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
|
|
149987
150112
|
return !importedSymbolHasValueMeaning && isJs && position !== undefined
|
|
149988
|
-
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo }
|
|
150113
|
+
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
|
|
149989
150114
|
: {
|
|
149990
150115
|
kind: 3 /* AddNew */,
|
|
149991
150116
|
moduleSpecifier: moduleSpecifier,
|
|
@@ -149993,6 +150118,7 @@ var ts;
|
|
|
149993
150118
|
useRequire: useRequire,
|
|
149994
150119
|
addAsTypeOnly: addAsTypeOnly,
|
|
149995
150120
|
exportInfo: exportInfo,
|
|
150121
|
+
isReExport: i > 0,
|
|
149996
150122
|
};
|
|
149997
150123
|
});
|
|
149998
150124
|
});
|
|
@@ -150030,12 +150156,13 @@ var ts;
|
|
|
150030
150156
|
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
150031
150157
|
}
|
|
150032
150158
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
150033
|
-
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
150159
|
+
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
|
|
150034
150160
|
}
|
|
150035
|
-
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150036
|
-
|
|
150161
|
+
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150162
|
+
var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
|
|
150163
|
+
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
|
|
150037
150164
|
}
|
|
150038
|
-
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150165
|
+
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150039
150166
|
if (!ts.some(fixes))
|
|
150040
150167
|
return;
|
|
150041
150168
|
// These will always be placed first if available, and are better than other kinds
|
|
@@ -150044,22 +150171,37 @@ var ts;
|
|
|
150044
150171
|
}
|
|
150045
150172
|
return fixes.reduce(function (best, fix) {
|
|
150046
150173
|
// Takes true branch of conditional if `fix` is better than `best`
|
|
150047
|
-
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
150174
|
+
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best;
|
|
150048
150175
|
});
|
|
150049
150176
|
}
|
|
150050
150177
|
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
150051
|
-
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
|
|
150178
|
+
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) {
|
|
150052
150179
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
150053
150180
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
150054
150181
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
150055
|
-
|| ts.compareBooleans(
|
|
150182
|
+
|| ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath))
|
|
150056
150183
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
150057
150184
|
}
|
|
150058
150185
|
return 0 /* EqualTo */;
|
|
150059
150186
|
}
|
|
150060
|
-
|
|
150061
|
-
|
|
150062
|
-
|
|
150187
|
+
// This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export.
|
|
150188
|
+
// E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`.
|
|
150189
|
+
// This can produce false positives or negatives if re-exports cross into sibling directories
|
|
150190
|
+
// (e.g. `export * from "../whatever"`) or are not named "index" (we don't even try to consider
|
|
150191
|
+
// this if we're in a resolution mode where you can't drop trailing "/index" from paths).
|
|
150192
|
+
function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath) {
|
|
150193
|
+
var _a;
|
|
150194
|
+
if (fix.isReExport &&
|
|
150195
|
+
((_a = fix.exportInfo) === null || _a === void 0 ? void 0 : _a.moduleFileName) &&
|
|
150196
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
|
|
150197
|
+
isIndexFileName(fix.exportInfo.moduleFileName)) {
|
|
150198
|
+
var reExportDir = toPath(ts.getDirectoryPath(fix.exportInfo.moduleFileName));
|
|
150199
|
+
return ts.startsWith((importingFile.path), reExportDir);
|
|
150200
|
+
}
|
|
150201
|
+
return false;
|
|
150202
|
+
}
|
|
150203
|
+
function isIndexFileName(fileName) {
|
|
150204
|
+
return ts.getBaseFileName(fileName, [".js", ".jsx", ".d.ts", ".ts", ".tsx"], /*ignoreCase*/ true) === "index";
|
|
150063
150205
|
}
|
|
150064
150206
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
150065
150207
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
@@ -150077,9 +150219,9 @@ var ts;
|
|
|
150077
150219
|
return undefined;
|
|
150078
150220
|
var symbol = checker.getAliasedSymbol(umdSymbol);
|
|
150079
150221
|
var symbolName = umdSymbol.name;
|
|
150080
|
-
var
|
|
150222
|
+
var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
150081
150223
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150082
|
-
var fixes = getImportFixes(
|
|
150224
|
+
var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
150083
150225
|
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
150084
150226
|
}
|
|
150085
150227
|
function getUmdSymbol(token, checker) {
|
|
@@ -150146,8 +150288,8 @@ var ts;
|
|
|
150146
150288
|
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
|
|
150147
150289
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
|
|
150148
150290
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150149
|
-
var
|
|
150150
|
-
var fixes = ts.arrayFrom(ts.flatMapIterator(
|
|
150291
|
+
var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150292
|
+
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
|
|
150151
150293
|
var _ = _a[0], exportInfos = _a[1];
|
|
150152
150294
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
150153
150295
|
}));
|
|
@@ -152248,6 +152390,95 @@ var ts;
|
|
|
152248
152390
|
})(ts || (ts = {}));
|
|
152249
152391
|
/* @internal */
|
|
152250
152392
|
var ts;
|
|
152393
|
+
(function (ts) {
|
|
152394
|
+
var codefix;
|
|
152395
|
+
(function (codefix) {
|
|
152396
|
+
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
152397
|
+
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
152398
|
+
var errorCodes = [
|
|
152399
|
+
ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code,
|
|
152400
|
+
];
|
|
152401
|
+
codefix.registerCodeFix({
|
|
152402
|
+
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
152403
|
+
errorCodes: errorCodes,
|
|
152404
|
+
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
152405
|
+
var sourceFile = context.sourceFile, span = context.span;
|
|
152406
|
+
var actions = [];
|
|
152407
|
+
var info = getInfo(sourceFile, span.start);
|
|
152408
|
+
if (info) {
|
|
152409
|
+
ts.append(actions, getDeleteAction(context, info));
|
|
152410
|
+
ts.append(actions, getRenameAction(context, info));
|
|
152411
|
+
return actions;
|
|
152412
|
+
}
|
|
152413
|
+
return undefined;
|
|
152414
|
+
},
|
|
152415
|
+
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
152416
|
+
var tagsToSignature = new ts.Map();
|
|
152417
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
152418
|
+
codefix.eachDiagnostic(context, errorCodes, function (_a) {
|
|
152419
|
+
var file = _a.file, start = _a.start;
|
|
152420
|
+
var info = getInfo(file, start);
|
|
152421
|
+
if (info) {
|
|
152422
|
+
tagsToSignature.set(info.signature, ts.append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
152423
|
+
}
|
|
152424
|
+
});
|
|
152425
|
+
tagsToSignature.forEach(function (tags, signature) {
|
|
152426
|
+
if (context.fixId === deleteUnmatchedParameter) {
|
|
152427
|
+
var tagsSet_1 = new ts.Set(tags);
|
|
152428
|
+
changes.filterJSDocTags(signature.getSourceFile(), signature, function (t) { return !tagsSet_1.has(t); });
|
|
152429
|
+
}
|
|
152430
|
+
});
|
|
152431
|
+
}));
|
|
152432
|
+
}
|
|
152433
|
+
});
|
|
152434
|
+
function getDeleteAction(context, _a) {
|
|
152435
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
152436
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
152437
|
+
return changeTracker.filterJSDocTags(context.sourceFile, signature, function (t) { return t !== jsDocParameterTag; });
|
|
152438
|
+
});
|
|
152439
|
+
return codefix.createCodeFixAction(deleteUnmatchedParameter, changes, [ts.Diagnostics.Delete_unused_param_tag_0, name.getText(context.sourceFile)], deleteUnmatchedParameter, ts.Diagnostics.Delete_all_unused_param_tags);
|
|
152440
|
+
}
|
|
152441
|
+
function getRenameAction(context, _a) {
|
|
152442
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
152443
|
+
if (!ts.length(signature.parameters))
|
|
152444
|
+
return undefined;
|
|
152445
|
+
var sourceFile = context.sourceFile;
|
|
152446
|
+
var tags = ts.getJSDocTags(signature);
|
|
152447
|
+
var names = new ts.Set();
|
|
152448
|
+
for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
|
|
152449
|
+
var tag = tags_2[_i];
|
|
152450
|
+
if (ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name)) {
|
|
152451
|
+
names.add(tag.name.escapedText);
|
|
152452
|
+
}
|
|
152453
|
+
}
|
|
152454
|
+
// @todo - match to all available names instead to the first parameter name
|
|
152455
|
+
// @see /codeFixRenameUnmatchedParameter3.ts
|
|
152456
|
+
var parameterName = ts.firstDefined(signature.parameters, function (p) {
|
|
152457
|
+
return ts.isIdentifier(p.name) && !names.has(p.name.escapedText) ? p.name.getText(sourceFile) : undefined;
|
|
152458
|
+
});
|
|
152459
|
+
if (parameterName === undefined)
|
|
152460
|
+
return undefined;
|
|
152461
|
+
var newJSDocParameterTag = ts.factory.updateJSDocParameterTag(jsDocParameterTag, jsDocParameterTag.tagName, ts.factory.createIdentifier(parameterName), jsDocParameterTag.isBracketed, jsDocParameterTag.typeExpression, jsDocParameterTag.isNameFirst, jsDocParameterTag.comment);
|
|
152462
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
152463
|
+
return changeTracker.replaceJSDocComment(sourceFile, signature, ts.map(tags, function (t) { return t === jsDocParameterTag ? newJSDocParameterTag : t; }));
|
|
152464
|
+
});
|
|
152465
|
+
return codefix.createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [ts.Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
|
|
152466
|
+
}
|
|
152467
|
+
function getInfo(sourceFile, pos) {
|
|
152468
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
152469
|
+
if (token.parent && ts.isJSDocParameterTag(token.parent) && ts.isIdentifier(token.parent.name)) {
|
|
152470
|
+
var jsDocParameterTag = token.parent;
|
|
152471
|
+
var signature = ts.getHostSignatureFromJSDoc(jsDocParameterTag);
|
|
152472
|
+
if (signature) {
|
|
152473
|
+
return { signature: signature, name: token.parent.name, jsDocParameterTag: jsDocParameterTag };
|
|
152474
|
+
}
|
|
152475
|
+
}
|
|
152476
|
+
return undefined;
|
|
152477
|
+
}
|
|
152478
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
152479
|
+
})(ts || (ts = {}));
|
|
152480
|
+
/* @internal */
|
|
152481
|
+
var ts;
|
|
152251
152482
|
(function (ts) {
|
|
152252
152483
|
var codefix;
|
|
152253
152484
|
(function (codefix) {
|
|
@@ -152545,6 +152776,9 @@ var ts;
|
|
|
152545
152776
|
case 172 /* SetAccessor */:
|
|
152546
152777
|
// Setter must have a parameter
|
|
152547
152778
|
return false;
|
|
152779
|
+
case 171 /* GetAccessor */:
|
|
152780
|
+
// Getter cannot have parameters
|
|
152781
|
+
return true;
|
|
152548
152782
|
default:
|
|
152549
152783
|
return ts.Debug.failBadSyntaxKind(parent);
|
|
152550
152784
|
}
|
|
@@ -155155,10 +155389,12 @@ var ts;
|
|
|
155155
155389
|
});
|
|
155156
155390
|
function getInfo(sourceFile, pos) {
|
|
155157
155391
|
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
155158
|
-
var indexSignature = ts.
|
|
155159
|
-
if (
|
|
155392
|
+
var indexSignature = ts.tryCast(token.parent.parent, ts.isIndexSignatureDeclaration);
|
|
155393
|
+
if (!indexSignature)
|
|
155394
|
+
return undefined;
|
|
155395
|
+
var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.tryCast(indexSignature.parent.parent, ts.isTypeAliasDeclaration);
|
|
155396
|
+
if (!container)
|
|
155160
155397
|
return undefined;
|
|
155161
|
-
var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.cast(indexSignature.parent.parent, ts.isTypeAliasDeclaration);
|
|
155162
155398
|
return { indexSignature: indexSignature, container: container };
|
|
155163
155399
|
}
|
|
155164
155400
|
function createTypeAliasFromInterface(declaration, type) {
|
|
@@ -156749,8 +156985,8 @@ var ts;
|
|
|
156749
156985
|
// but a super *method call* simply implies a 'this' reference
|
|
156750
156986
|
if (node.parent.kind === 207 /* CallExpression */) {
|
|
156751
156987
|
// Super constructor call
|
|
156752
|
-
var containingClass_1 = ts.getContainingClass(node);
|
|
156753
|
-
if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
|
|
156988
|
+
var containingClass_1 = ts.getContainingClass(node);
|
|
156989
|
+
if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
|
|
156754
156990
|
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper));
|
|
156755
156991
|
return true;
|
|
156756
156992
|
}
|
|
@@ -171569,9 +171805,10 @@ var ts;
|
|
|
171569
171805
|
var info = infos && ts.firstOrUndefined(infos);
|
|
171570
171806
|
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
|
171571
171807
|
}
|
|
171572
|
-
function combineProjectOutputForReferences(projects, defaultProject, initialLocation) {
|
|
171808
|
+
function combineProjectOutputForReferences(projects, defaultProject, initialLocation, logger) {
|
|
171573
171809
|
var outputs = [];
|
|
171574
171810
|
combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, getMappedLocation) {
|
|
171811
|
+
logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
|
|
171575
171812
|
var _loop_8 = function (outputReferencedSymbol) {
|
|
171576
171813
|
var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition));
|
|
171577
171814
|
var definition = mappedDefinitionFile === undefined ?
|
|
@@ -172929,7 +173166,7 @@ var ts;
|
|
|
172929
173166
|
var file = server.toNormalizedPath(args.file);
|
|
172930
173167
|
var projects = this.getProjects(args);
|
|
172931
173168
|
var position = this.getPositionInFile(args, file);
|
|
172932
|
-
var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position });
|
|
173169
|
+
var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
|
|
172933
173170
|
if (!simplifiedResult)
|
|
172934
173171
|
return references;
|
|
172935
173172
|
var defaultProject = this.getDefaultProject(args);
|