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/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220211";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -8034,10 +8034,10 @@ var ts;
|
|
|
8034
8034
|
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."),
|
|
8035
8035
|
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."),
|
|
8036
8036
|
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."),
|
|
8037
|
-
|
|
8038
|
-
|
|
8037
|
+
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."),
|
|
8038
|
+
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."),
|
|
8039
8039
|
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."),
|
|
8040
|
-
|
|
8040
|
+
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."),
|
|
8041
8041
|
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'."),
|
|
8042
8042
|
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'."),
|
|
8043
8043
|
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."),
|
|
@@ -8069,6 +8069,7 @@ var ts;
|
|
|
8069
8069
|
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."),
|
|
8070
8070
|
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."),
|
|
8071
8071
|
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."),
|
|
8072
|
+
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."),
|
|
8072
8073
|
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."),
|
|
8073
8074
|
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."),
|
|
8074
8075
|
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."),
|
|
@@ -8205,6 +8206,8 @@ var ts;
|
|
|
8205
8206
|
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."),
|
|
8206
8207
|
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."),
|
|
8207
8208
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8209
|
+
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."),
|
|
8210
|
+
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."),
|
|
8208
8211
|
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."),
|
|
8209
8212
|
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."),
|
|
8210
8213
|
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),
|
|
@@ -9625,6 +9628,9 @@ var ts;
|
|
|
9625
9628
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9626
9629
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9627
9630
|
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9631
|
+
Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
|
|
9632
|
+
Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
|
|
9633
|
+
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}'"),
|
|
9628
9634
|
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."),
|
|
9629
9635
|
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'."),
|
|
9630
9636
|
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?"),
|
|
@@ -13886,6 +13892,10 @@ var ts;
|
|
|
13886
13892
|
return undefined;
|
|
13887
13893
|
}
|
|
13888
13894
|
ts.getDeclarationOfKind = getDeclarationOfKind;
|
|
13895
|
+
function getDeclarationsOfKind(symbol, kind) {
|
|
13896
|
+
return ts.filter(symbol.declarations || ts.emptyArray, function (d) { return d.kind === kind; });
|
|
13897
|
+
}
|
|
13898
|
+
ts.getDeclarationsOfKind = getDeclarationsOfKind;
|
|
13889
13899
|
function createSymbolTable(symbols) {
|
|
13890
13900
|
var result = new ts.Map();
|
|
13891
13901
|
if (symbols) {
|
|
@@ -14121,6 +14131,10 @@ var ts;
|
|
|
14121
14131
|
return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
|
|
14122
14132
|
}
|
|
14123
14133
|
ts.getSourceFileOfModule = getSourceFileOfModule;
|
|
14134
|
+
function isPlainJsFile(file, checkJs) {
|
|
14135
|
+
return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined;
|
|
14136
|
+
}
|
|
14137
|
+
ts.isPlainJsFile = isPlainJsFile;
|
|
14124
14138
|
function isStatementWithLocals(node) {
|
|
14125
14139
|
switch (node.kind) {
|
|
14126
14140
|
case 234 /* Block */:
|
|
@@ -46898,6 +46912,9 @@ var ts;
|
|
|
46898
46912
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
46899
46913
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
46900
46914
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
46915
|
+
CheckMode[CheckMode["RestBindingElement"] = 32] = "RestBindingElement";
|
|
46916
|
+
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
46917
|
+
// we need to preserve generic types instead of substituting them for constraints
|
|
46901
46918
|
})(CheckMode || (CheckMode = {}));
|
|
46902
46919
|
var SignatureCheckMode;
|
|
46903
46920
|
(function (SignatureCheckMode) {
|
|
@@ -47950,13 +47967,13 @@ var ts;
|
|
|
47950
47967
|
else { // error
|
|
47951
47968
|
var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
|
|
47952
47969
|
var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
|
|
47953
|
-
var message = isEitherEnum
|
|
47954
|
-
? ts.Diagnostics.
|
|
47955
|
-
: isEitherBlockScoped_1
|
|
47956
|
-
? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
47970
|
+
var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
|
|
47971
|
+
: isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
47957
47972
|
: ts.Diagnostics.Duplicate_identifier_0;
|
|
47958
47973
|
var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
|
|
47959
47974
|
var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
|
|
47975
|
+
var isSourcePlainJs = ts.isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
|
|
47976
|
+
var isTargetPlainJs = ts.isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
|
|
47960
47977
|
var symbolName_1 = symbolToString(source);
|
|
47961
47978
|
// Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch
|
|
47962
47979
|
if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
|
|
@@ -47968,12 +47985,16 @@ var ts;
|
|
|
47968
47985
|
var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
|
|
47969
47986
|
return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
|
|
47970
47987
|
});
|
|
47971
|
-
|
|
47972
|
-
|
|
47988
|
+
if (!isSourcePlainJs)
|
|
47989
|
+
addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
|
|
47990
|
+
if (!isTargetPlainJs)
|
|
47991
|
+
addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
|
|
47973
47992
|
}
|
|
47974
47993
|
else {
|
|
47975
|
-
|
|
47976
|
-
|
|
47994
|
+
if (!isSourcePlainJs)
|
|
47995
|
+
addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
|
|
47996
|
+
if (!isTargetPlainJs)
|
|
47997
|
+
addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
|
|
47977
47998
|
}
|
|
47978
47999
|
}
|
|
47979
48000
|
return target;
|
|
@@ -48430,6 +48451,8 @@ var ts;
|
|
|
48430
48451
|
// type parameters are visible in parameter list, return type and type parameter list
|
|
48431
48452
|
? lastLocation === location.type ||
|
|
48432
48453
|
lastLocation.kind === 163 /* Parameter */ ||
|
|
48454
|
+
lastLocation.kind === 338 /* JSDocParameterTag */ ||
|
|
48455
|
+
lastLocation.kind === 339 /* JSDocReturnTag */ ||
|
|
48433
48456
|
lastLocation.kind === 162 /* TypeParameter */
|
|
48434
48457
|
// local types not visible outside the function body
|
|
48435
48458
|
: false;
|
|
@@ -48689,9 +48712,9 @@ var ts;
|
|
|
48689
48712
|
lastSelfReferenceLocation = location;
|
|
48690
48713
|
}
|
|
48691
48714
|
lastLocation = location;
|
|
48692
|
-
location = ts.isJSDocTemplateTag(location) ?
|
|
48693
|
-
ts.
|
|
48694
|
-
|
|
48715
|
+
location = ts.isJSDocTemplateTag(location) ? ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
|
|
48716
|
+
ts.isJSDocParameterTag(location) || ts.isJSDocReturnTag(location) ? ts.getHostSignatureFromJSDoc(location) || location.parent :
|
|
48717
|
+
location.parent;
|
|
48695
48718
|
}
|
|
48696
48719
|
// We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
|
|
48697
48720
|
// If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself.
|
|
@@ -49825,16 +49848,20 @@ var ts;
|
|
|
49825
49848
|
return;
|
|
49826
49849
|
}
|
|
49827
49850
|
var host = ts.getJSDocHost(node);
|
|
49828
|
-
if (host &&
|
|
49829
|
-
|
|
49830
|
-
ts.isBinaryExpression(host.expression) &&
|
|
49831
|
-
ts.getAssignmentDeclarationKind(host.expression) === 3 /* PrototypeProperty */) {
|
|
49832
|
-
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
49851
|
+
if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
|
|
49852
|
+
// /** @param {K} p */ X.prototype.m = function () { } <-- look for K on X's declaration
|
|
49833
49853
|
var symbol = getSymbolOfNode(host.expression.left);
|
|
49834
49854
|
if (symbol) {
|
|
49835
49855
|
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
49836
49856
|
}
|
|
49837
49857
|
}
|
|
49858
|
+
if (host && ts.isFunctionExpression(host) && ts.isPrototypePropertyAssignment(host.parent) && ts.isExpressionStatement(host.parent.parent)) {
|
|
49859
|
+
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
49860
|
+
var symbol = getSymbolOfNode(host.parent.left);
|
|
49861
|
+
if (symbol) {
|
|
49862
|
+
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
49863
|
+
}
|
|
49864
|
+
}
|
|
49838
49865
|
if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
|
|
49839
49866
|
ts.isBinaryExpression(host.parent.parent) &&
|
|
49840
49867
|
ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) {
|
|
@@ -54321,9 +54348,12 @@ var ts;
|
|
|
54321
54348
|
}
|
|
54322
54349
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
54323
54350
|
// assigned by contextual typing.
|
|
54324
|
-
function getTypeForBindingElementParent(node) {
|
|
54351
|
+
function getTypeForBindingElementParent(node, checkMode) {
|
|
54352
|
+
if (checkMode !== 0 /* Normal */) {
|
|
54353
|
+
return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54354
|
+
}
|
|
54325
54355
|
var symbol = getSymbolOfNode(node);
|
|
54326
|
-
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
|
|
54356
|
+
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54327
54357
|
}
|
|
54328
54358
|
function getRestType(source, properties, symbol) {
|
|
54329
54359
|
source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
@@ -54441,7 +54471,8 @@ var ts;
|
|
|
54441
54471
|
}
|
|
54442
54472
|
/** Return the inferred type for a binding element */
|
|
54443
54473
|
function getTypeForBindingElement(declaration) {
|
|
54444
|
-
var
|
|
54474
|
+
var checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
54475
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
54445
54476
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
54446
54477
|
}
|
|
54447
54478
|
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
@@ -54513,9 +54544,9 @@ var ts;
|
|
|
54513
54544
|
if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
|
|
54514
54545
|
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
|
54515
54546
|
// undefined from the final type.
|
|
54516
|
-
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54547
|
+
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54517
54548
|
}
|
|
54518
|
-
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
|
|
54549
|
+
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
54519
54550
|
}
|
|
54520
54551
|
function getTypeForDeclarationFromJSDocComment(declaration) {
|
|
54521
54552
|
var jsdocType = ts.getJSDocType(declaration);
|
|
@@ -54538,11 +54569,11 @@ var ts;
|
|
|
54538
54569
|
return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
|
|
54539
54570
|
}
|
|
54540
54571
|
// Return the inferred type for a variable, parameter, or property declaration
|
|
54541
|
-
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
|
54572
|
+
function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
|
|
54542
54573
|
// A variable declared in a for..in statement is of type string, or of type keyof T when the
|
|
54543
54574
|
// right hand expression is of a type parameter type.
|
|
54544
54575
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
|
|
54545
|
-
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
|
|
54576
|
+
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode)));
|
|
54546
54577
|
return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
|
|
54547
54578
|
}
|
|
54548
54579
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
|
|
@@ -54597,12 +54628,9 @@ var ts;
|
|
|
54597
54628
|
}
|
|
54598
54629
|
}
|
|
54599
54630
|
if (ts.isInJSFile(declaration)) {
|
|
54600
|
-
var
|
|
54601
|
-
if (
|
|
54602
|
-
|
|
54603
|
-
var pos = func.parameters.indexOf(declaration);
|
|
54604
|
-
return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
54605
|
-
}
|
|
54631
|
+
var type_1 = getParameterTypeOfTypeTag(func, declaration);
|
|
54632
|
+
if (type_1)
|
|
54633
|
+
return type_1;
|
|
54606
54634
|
}
|
|
54607
54635
|
// Use contextual parameter type if one is available
|
|
54608
54636
|
var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
|
|
@@ -54619,7 +54647,7 @@ var ts;
|
|
|
54619
54647
|
return containerObjectType;
|
|
54620
54648
|
}
|
|
54621
54649
|
}
|
|
54622
|
-
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
|
|
54650
|
+
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
|
|
54623
54651
|
return addOptionality(type, isProperty, isOptional);
|
|
54624
54652
|
}
|
|
54625
54653
|
if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
|
|
@@ -54991,7 +55019,7 @@ var ts;
|
|
|
54991
55019
|
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
|
|
54992
55020
|
// pattern.
|
|
54993
55021
|
var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
|
|
54994
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
|
|
55022
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
54995
55023
|
}
|
|
54996
55024
|
if (ts.isBindingPattern(element.name)) {
|
|
54997
55025
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
|
|
@@ -55080,7 +55108,7 @@ var ts;
|
|
|
55080
55108
|
// binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
|
|
55081
55109
|
// tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
|
|
55082
55110
|
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
|
55083
|
-
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
|
|
55111
|
+
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors);
|
|
55084
55112
|
}
|
|
55085
55113
|
function isGlobalSymbolConstructor(node) {
|
|
55086
55114
|
var symbol = getSymbolOfNode(node);
|
|
@@ -55169,9 +55197,9 @@ var ts;
|
|
|
55169
55197
|
if (typeNode === undefined) {
|
|
55170
55198
|
return useUnknownInCatchVariables ? unknownType : anyType;
|
|
55171
55199
|
}
|
|
55172
|
-
var
|
|
55200
|
+
var type_2 = getTypeOfNode(typeNode);
|
|
55173
55201
|
// an errorType will make `checkTryStatement` issue an error
|
|
55174
|
-
return isTypeAny(
|
|
55202
|
+
return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
|
|
55175
55203
|
}
|
|
55176
55204
|
// Handle export default expressions
|
|
55177
55205
|
if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
|
|
@@ -55309,10 +55337,12 @@ var ts;
|
|
|
55309
55337
|
if (writing === void 0) { writing = false; }
|
|
55310
55338
|
var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
|
|
55311
55339
|
var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */);
|
|
55312
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
55313
55340
|
// For write operations, prioritize type annotations on the setter
|
|
55314
|
-
if (writing
|
|
55315
|
-
|
|
55341
|
+
if (writing) {
|
|
55342
|
+
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
55343
|
+
if (setterType_1) {
|
|
55344
|
+
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
55345
|
+
}
|
|
55316
55346
|
}
|
|
55317
55347
|
// Else defer to the getter type
|
|
55318
55348
|
if (getter && ts.isInJSFile(getter)) {
|
|
@@ -55327,6 +55357,7 @@ var ts;
|
|
|
55327
55357
|
return instantiateTypeIfNeeded(getterType, symbol);
|
|
55328
55358
|
}
|
|
55329
55359
|
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
55360
|
+
var setterType = getAnnotatedAccessorType(setter);
|
|
55330
55361
|
if (setterType) {
|
|
55331
55362
|
return setterType;
|
|
55332
55363
|
}
|
|
@@ -55397,11 +55428,11 @@ var ts;
|
|
|
55397
55428
|
return errorType;
|
|
55398
55429
|
}
|
|
55399
55430
|
var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
|
|
55400
|
-
var
|
|
55431
|
+
var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
|
55401
55432
|
if (!popTypeResolution()) {
|
|
55402
55433
|
return reportCircularityError(symbol);
|
|
55403
55434
|
}
|
|
55404
|
-
return
|
|
55435
|
+
return type_3;
|
|
55405
55436
|
}
|
|
55406
55437
|
}
|
|
55407
55438
|
var type = createObjectType(16 /* Anonymous */, symbol);
|
|
@@ -55475,6 +55506,39 @@ var ts;
|
|
|
55475
55506
|
}
|
|
55476
55507
|
return links.type;
|
|
55477
55508
|
}
|
|
55509
|
+
function getWriteTypeOfSymbolWithDeferredType(symbol) {
|
|
55510
|
+
var links = getSymbolLinks(symbol);
|
|
55511
|
+
if (!links.writeType && links.deferralWriteConstituents) {
|
|
55512
|
+
ts.Debug.assertIsDefined(links.deferralParent);
|
|
55513
|
+
ts.Debug.assertIsDefined(links.deferralConstituents);
|
|
55514
|
+
links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
|
|
55515
|
+
}
|
|
55516
|
+
return links.writeType;
|
|
55517
|
+
}
|
|
55518
|
+
/**
|
|
55519
|
+
* Distinct write types come only from set accessors, but union and intersection
|
|
55520
|
+
* properties deriving from set accessors will either pre-compute or defer the
|
|
55521
|
+
* union or intersection of the writeTypes of their constituents. To account for
|
|
55522
|
+
* this, we will assume that any deferred type or transient symbol may have a
|
|
55523
|
+
* `writeType` (or a deferred write type ready to be computed) that should be
|
|
55524
|
+
* used before looking for set accessor declarations.
|
|
55525
|
+
*/
|
|
55526
|
+
function getWriteTypeOfSymbol(symbol) {
|
|
55527
|
+
var checkFlags = ts.getCheckFlags(symbol);
|
|
55528
|
+
if (checkFlags & 65536 /* DeferredType */) {
|
|
55529
|
+
var writeType = getWriteTypeOfSymbolWithDeferredType(symbol);
|
|
55530
|
+
if (writeType) {
|
|
55531
|
+
return writeType;
|
|
55532
|
+
}
|
|
55533
|
+
}
|
|
55534
|
+
if (symbol.flags & 33554432 /* Transient */) {
|
|
55535
|
+
var writeType = symbol.writeType;
|
|
55536
|
+
if (writeType) {
|
|
55537
|
+
return writeType;
|
|
55538
|
+
}
|
|
55539
|
+
}
|
|
55540
|
+
return getSetAccessorTypeOfSymbol(symbol);
|
|
55541
|
+
}
|
|
55478
55542
|
function getSetAccessorTypeOfSymbol(symbol) {
|
|
55479
55543
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
55480
55544
|
var type = getTypeOfSetAccessor(symbol);
|
|
@@ -57600,10 +57664,10 @@ var ts;
|
|
|
57600
57664
|
var baseTypes = [];
|
|
57601
57665
|
var different = false;
|
|
57602
57666
|
for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
|
|
57603
|
-
var
|
|
57604
|
-
var baseType = getBaseConstraint(
|
|
57667
|
+
var type_4 = types_7[_i];
|
|
57668
|
+
var baseType = getBaseConstraint(type_4);
|
|
57605
57669
|
if (baseType) {
|
|
57606
|
-
if (baseType !==
|
|
57670
|
+
if (baseType !== type_4) {
|
|
57607
57671
|
different = true;
|
|
57608
57672
|
}
|
|
57609
57673
|
baseTypes.push(baseType);
|
|
@@ -57845,6 +57909,7 @@ var ts;
|
|
|
57845
57909
|
var firstType;
|
|
57846
57910
|
var nameType;
|
|
57847
57911
|
var propTypes = [];
|
|
57912
|
+
var writeTypes;
|
|
57848
57913
|
var firstValueDeclaration;
|
|
57849
57914
|
var hasNonUniformValueDeclaration = false;
|
|
57850
57915
|
for (var _d = 0, props_1 = props; _d < props_1.length; _d++) {
|
|
@@ -57861,6 +57926,10 @@ var ts;
|
|
|
57861
57926
|
firstType = type;
|
|
57862
57927
|
nameType = getSymbolLinks(prop).nameType;
|
|
57863
57928
|
}
|
|
57929
|
+
var writeType = getWriteTypeOfSymbol(prop);
|
|
57930
|
+
if (writeTypes || writeType !== type) {
|
|
57931
|
+
writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType);
|
|
57932
|
+
}
|
|
57864
57933
|
else if (type !== firstType) {
|
|
57865
57934
|
checkFlags |= 64 /* HasNonUniformType */;
|
|
57866
57935
|
}
|
|
@@ -57889,9 +57958,13 @@ var ts;
|
|
|
57889
57958
|
result.checkFlags |= 65536 /* DeferredType */;
|
|
57890
57959
|
result.deferralParent = containingType;
|
|
57891
57960
|
result.deferralConstituents = propTypes;
|
|
57961
|
+
result.deferralWriteConstituents = writeTypes;
|
|
57892
57962
|
}
|
|
57893
57963
|
else {
|
|
57894
57964
|
result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
|
|
57965
|
+
if (writeTypes) {
|
|
57966
|
+
result.writeType = isUnion ? getUnionType(writeTypes) : getIntersectionType(writeTypes);
|
|
57967
|
+
}
|
|
57895
57968
|
}
|
|
57896
57969
|
return result;
|
|
57897
57970
|
}
|
|
@@ -58307,6 +58380,13 @@ var ts;
|
|
|
58307
58380
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
58308
58381
|
return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
58309
58382
|
}
|
|
58383
|
+
function getParameterTypeOfTypeTag(func, parameter) {
|
|
58384
|
+
var signature = getSignatureOfTypeTag(func);
|
|
58385
|
+
if (!signature)
|
|
58386
|
+
return undefined;
|
|
58387
|
+
var pos = func.parameters.indexOf(parameter);
|
|
58388
|
+
return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
58389
|
+
}
|
|
58310
58390
|
function getReturnTypeOfTypeTag(node) {
|
|
58311
58391
|
var signature = getSignatureOfTypeTag(node);
|
|
58312
58392
|
return signature && getReturnTypeOfSignature(signature);
|
|
@@ -59033,7 +59113,7 @@ var ts;
|
|
|
59033
59113
|
}
|
|
59034
59114
|
function getImpliedConstraint(type, checkNode, extendsNode) {
|
|
59035
59115
|
return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
|
|
59036
|
-
getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
|
|
59116
|
+
getActualTypeVariable(getTypeFromTypeNode(checkNode)) === getActualTypeVariable(type) ? getTypeFromTypeNode(extendsNode) :
|
|
59037
59117
|
undefined;
|
|
59038
59118
|
}
|
|
59039
59119
|
function getConditionalFlowTypeOfType(type, node) {
|
|
@@ -69842,12 +69922,16 @@ var ts;
|
|
|
69842
69922
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
69843
69923
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
69844
69924
|
}
|
|
69845
|
-
function
|
|
69925
|
+
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
69846
69926
|
// Computing the contextual type for a child of a JSX element involves resolving the type of the
|
|
69847
69927
|
// element's tag name, so we exclude that here to avoid circularities.
|
|
69928
|
+
// If check mode has `CheckMode.RestBindingElement`, we skip binding pattern contextual types,
|
|
69929
|
+
// as we want the type of a rest element to be generic when possible.
|
|
69848
69930
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
69849
69931
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
69850
|
-
|
|
69932
|
+
(checkMode && checkMode & 32 /* RestBindingElement */ ?
|
|
69933
|
+
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
69934
|
+
: getContextualType(node));
|
|
69851
69935
|
return contextualType && !isGenericType(contextualType);
|
|
69852
69936
|
}
|
|
69853
69937
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -69860,7 +69944,7 @@ var ts;
|
|
|
69860
69944
|
// 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
|
|
69861
69945
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
69862
69946
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
69863
|
-
(isConstraintPosition(type, reference) ||
|
|
69947
|
+
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
69864
69948
|
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
|
|
69865
69949
|
}
|
|
69866
69950
|
function isExportOrExportExpression(location) {
|
|
@@ -69928,7 +70012,7 @@ var ts;
|
|
|
69928
70012
|
var links = getNodeLinks(location);
|
|
69929
70013
|
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
69930
70014
|
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
69931
|
-
var parentType = getTypeForBindingElementParent(parent);
|
|
70015
|
+
var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
|
|
69932
70016
|
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
69933
70017
|
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
69934
70018
|
var pattern = declaration.parent;
|
|
@@ -70781,7 +70865,7 @@ var ts;
|
|
|
70781
70865
|
var parent = declaration.parent.parent;
|
|
70782
70866
|
var name = declaration.propertyName || declaration.name;
|
|
70783
70867
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
70784
|
-
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
|
|
70868
|
+
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
|
|
70785
70869
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
70786
70870
|
return undefined;
|
|
70787
70871
|
if (parent.name.kind === 201 /* ArrayBindingPattern */) {
|
|
@@ -73022,7 +73106,7 @@ var ts;
|
|
|
73022
73106
|
error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
|
|
73023
73107
|
return errorType;
|
|
73024
73108
|
}
|
|
73025
|
-
propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ?
|
|
73109
|
+
propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getWriteTypeOfSymbol(prop) : getTypeOfSymbol(prop);
|
|
73026
73110
|
}
|
|
73027
73111
|
return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode);
|
|
73028
73112
|
}
|
|
@@ -75492,8 +75576,8 @@ var ts;
|
|
|
75492
75576
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75493
75577
|
var synthType = type;
|
|
75494
75578
|
if (!synthType.defaultOnlyType) {
|
|
75495
|
-
var
|
|
75496
|
-
synthType.defaultOnlyType =
|
|
75579
|
+
var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75580
|
+
synthType.defaultOnlyType = type_5;
|
|
75497
75581
|
}
|
|
75498
75582
|
return synthType.defaultOnlyType;
|
|
75499
75583
|
}
|
|
@@ -75947,7 +76031,7 @@ var ts;
|
|
|
75947
76031
|
var links = getSymbolLinks(parameter);
|
|
75948
76032
|
if (!links.type) {
|
|
75949
76033
|
var declaration = parameter.valueDeclaration;
|
|
75950
|
-
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*
|
|
76034
|
+
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
|
|
75951
76035
|
if (declaration.name.kind !== 79 /* Identifier */) {
|
|
75952
76036
|
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
|
|
75953
76037
|
if (links.type === unknownType) {
|
|
@@ -76220,12 +76304,12 @@ var ts;
|
|
|
76220
76304
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
76221
76305
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
76222
76306
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
76223
|
-
var
|
|
76307
|
+
var type_6 = getBaseConstraintOfType(operandType) || operandType;
|
|
76224
76308
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
76225
|
-
if (
|
|
76309
|
+
if (type_6.flags & 3 /* AnyOrUnknown */) {
|
|
76226
76310
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
76227
76311
|
}
|
|
76228
|
-
return !!(filterType(
|
|
76312
|
+
return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
76229
76313
|
}
|
|
76230
76314
|
var type = getTypeOfExpression(node.expression);
|
|
76231
76315
|
if (!isLiteralType(type)) {
|
|
@@ -77678,11 +77762,11 @@ var ts;
|
|
|
77678
77762
|
}
|
|
77679
77763
|
}
|
|
77680
77764
|
function checkExpressionCached(node, checkMode) {
|
|
77765
|
+
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77766
|
+
return checkExpression(node, checkMode);
|
|
77767
|
+
}
|
|
77681
77768
|
var links = getNodeLinks(node);
|
|
77682
77769
|
if (!links.resolvedType) {
|
|
77683
|
-
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77684
|
-
return checkExpression(node, checkMode);
|
|
77685
|
-
}
|
|
77686
77770
|
// When computing a type that we're going to cache, we need to ignore any ongoing control flow
|
|
77687
77771
|
// analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
|
|
77688
77772
|
// to the top of the stack ensures all transient types are computed from a known point.
|
|
@@ -77702,10 +77786,12 @@ var ts;
|
|
|
77702
77786
|
node.kind === 228 /* AsExpression */ ||
|
|
77703
77787
|
ts.isJSDocTypeAssertion(node);
|
|
77704
77788
|
}
|
|
77705
|
-
function checkDeclarationInitializer(declaration, contextualType) {
|
|
77789
|
+
function checkDeclarationInitializer(declaration, checkMode, contextualType) {
|
|
77706
77790
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
77707
77791
|
var type = getQuickTypeOfExpression(initializer) ||
|
|
77708
|
-
(contextualType ?
|
|
77792
|
+
(contextualType ?
|
|
77793
|
+
checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
|
|
77794
|
+
: checkExpressionCached(initializer, checkMode));
|
|
77709
77795
|
return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
|
|
77710
77796
|
isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
|
|
77711
77797
|
padTupleType(type, declaration.name) : type;
|
|
@@ -78345,6 +78431,7 @@ var ts;
|
|
|
78345
78431
|
}
|
|
78346
78432
|
}
|
|
78347
78433
|
checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
|
|
78434
|
+
checkUnmatchedJSDocParameters(node);
|
|
78348
78435
|
ts.forEach(node.parameters, checkParameter);
|
|
78349
78436
|
// TODO(rbuckton): Should we start checking JSDoc types?
|
|
78350
78437
|
if (node.type) {
|
|
@@ -79916,31 +80003,6 @@ var ts;
|
|
|
79916
80003
|
}
|
|
79917
80004
|
function checkJSDocParameterTag(node) {
|
|
79918
80005
|
checkSourceElement(node.typeExpression);
|
|
79919
|
-
if (!ts.getParameterSymbolFromJSDoc(node)) {
|
|
79920
|
-
var decl = ts.getHostSignatureFromJSDoc(node);
|
|
79921
|
-
// don't issue an error for invalid hosts -- just functions --
|
|
79922
|
-
// and give a better error message when the host function mentions `arguments`
|
|
79923
|
-
// but the tag doesn't have an array type
|
|
79924
|
-
if (decl) {
|
|
79925
|
-
var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
|
|
79926
|
-
if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
|
|
79927
|
-
return;
|
|
79928
|
-
}
|
|
79929
|
-
if (!containsArgumentsReference(decl)) {
|
|
79930
|
-
if (ts.isQualifiedName(node.name)) {
|
|
79931
|
-
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));
|
|
79932
|
-
}
|
|
79933
|
-
else {
|
|
79934
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
|
|
79935
|
-
}
|
|
79936
|
-
}
|
|
79937
|
-
else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
|
|
79938
|
-
node.typeExpression && node.typeExpression.type &&
|
|
79939
|
-
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
|
|
79940
|
-
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));
|
|
79941
|
-
}
|
|
79942
|
-
}
|
|
79943
|
-
}
|
|
79944
80006
|
}
|
|
79945
80007
|
function checkJSDocPropertyTag(node) {
|
|
79946
80008
|
checkSourceElement(node.typeExpression);
|
|
@@ -80642,7 +80704,8 @@ var ts;
|
|
|
80642
80704
|
}
|
|
80643
80705
|
// check private/protected variable access
|
|
80644
80706
|
var parent = node.parent.parent;
|
|
80645
|
-
var
|
|
80707
|
+
var parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
80708
|
+
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
80646
80709
|
var name = node.propertyName || node.name;
|
|
80647
80710
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
80648
80711
|
var exprType = getLiteralTypeFromPropertyName(name);
|
|
@@ -81881,7 +81944,7 @@ var ts;
|
|
|
81881
81944
|
var declaration = catchClause.variableDeclaration;
|
|
81882
81945
|
var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
|
|
81883
81946
|
if (typeNode) {
|
|
81884
|
-
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
|
|
81947
|
+
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */);
|
|
81885
81948
|
if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
|
|
81886
81949
|
grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
|
|
81887
81950
|
}
|
|
@@ -82012,6 +82075,45 @@ var ts;
|
|
|
82012
82075
|
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
|
|
82013
82076
|
}
|
|
82014
82077
|
}
|
|
82078
|
+
function checkUnmatchedJSDocParameters(node) {
|
|
82079
|
+
var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
|
|
82080
|
+
if (!ts.length(jsdocParameters))
|
|
82081
|
+
return;
|
|
82082
|
+
var isJs = ts.isInJSFile(node);
|
|
82083
|
+
var parameters = new ts.Set();
|
|
82084
|
+
var excludedParameters = new ts.Set();
|
|
82085
|
+
ts.forEach(node.parameters, function (_a, index) {
|
|
82086
|
+
var name = _a.name;
|
|
82087
|
+
if (ts.isIdentifier(name)) {
|
|
82088
|
+
parameters.add(name.escapedText);
|
|
82089
|
+
}
|
|
82090
|
+
if (ts.isBindingPattern(name)) {
|
|
82091
|
+
excludedParameters.add(index);
|
|
82092
|
+
}
|
|
82093
|
+
});
|
|
82094
|
+
var containsArguments = containsArgumentsReference(node);
|
|
82095
|
+
if (containsArguments) {
|
|
82096
|
+
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82097
|
+
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82098
|
+
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82099
|
+
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));
|
|
82100
|
+
}
|
|
82101
|
+
}
|
|
82102
|
+
else {
|
|
82103
|
+
ts.forEach(jsdocParameters, function (_a, index) {
|
|
82104
|
+
var name = _a.name;
|
|
82105
|
+
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
82106
|
+
return;
|
|
82107
|
+
}
|
|
82108
|
+
if (ts.isQualifiedName(name)) {
|
|
82109
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82110
|
+
}
|
|
82111
|
+
else {
|
|
82112
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
82113
|
+
}
|
|
82114
|
+
});
|
|
82115
|
+
}
|
|
82116
|
+
}
|
|
82015
82117
|
/**
|
|
82016
82118
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
82017
82119
|
*/
|
|
@@ -82987,7 +83089,7 @@ var ts;
|
|
|
82987
83089
|
var isAmbientExternalModule = ts.isAmbientModule(node);
|
|
82988
83090
|
var contextErrorMessage = isAmbientExternalModule
|
|
82989
83091
|
? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
|
|
82990
|
-
: ts.Diagnostics.
|
|
83092
|
+
: ts.Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
|
|
82991
83093
|
if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
|
|
82992
83094
|
// If we hit a module declaration in an illegal context, just bail out to avoid cascading errors.
|
|
82993
83095
|
return;
|
|
@@ -83220,6 +83322,9 @@ var ts;
|
|
|
83220
83322
|
var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
|
|
83221
83323
|
addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
|
|
83222
83324
|
}
|
|
83325
|
+
if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
|
|
83326
|
+
error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
|
|
83327
|
+
}
|
|
83223
83328
|
break;
|
|
83224
83329
|
}
|
|
83225
83330
|
case 274 /* ExportSpecifier */: {
|
|
@@ -83303,7 +83408,7 @@ var ts;
|
|
|
83303
83408
|
}
|
|
83304
83409
|
}
|
|
83305
83410
|
function checkImportDeclaration(node) {
|
|
83306
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83411
|
+
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)) {
|
|
83307
83412
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83308
83413
|
return;
|
|
83309
83414
|
}
|
|
@@ -83336,7 +83441,7 @@ var ts;
|
|
|
83336
83441
|
checkAssertClause(node);
|
|
83337
83442
|
}
|
|
83338
83443
|
function checkImportEqualsDeclaration(node) {
|
|
83339
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83444
|
+
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)) {
|
|
83340
83445
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83341
83446
|
return;
|
|
83342
83447
|
}
|
|
@@ -83373,7 +83478,7 @@ var ts;
|
|
|
83373
83478
|
}
|
|
83374
83479
|
}
|
|
83375
83480
|
function checkExportDeclaration(node) {
|
|
83376
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83481
|
+
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)) {
|
|
83377
83482
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
83378
83483
|
return;
|
|
83379
83484
|
}
|
|
@@ -84607,7 +84712,7 @@ var ts;
|
|
|
84607
84712
|
return errorType;
|
|
84608
84713
|
}
|
|
84609
84714
|
if (ts.isBindingPattern(node)) {
|
|
84610
|
-
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
|
|
84715
|
+
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType;
|
|
84611
84716
|
}
|
|
84612
84717
|
if (isInRightSideOfImportOrExportAssignment(node)) {
|
|
84613
84718
|
var symbol = getSymbolAtLocation(node);
|
|
@@ -114354,9 +114459,9 @@ var ts;
|
|
|
114354
114459
|
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
|
|
114355
114460
|
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
|
114356
114461
|
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
|
114357
|
-
ts.Diagnostics.
|
|
114462
|
+
ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114358
114463
|
ts.Diagnostics.An_export_declaration_cannot_have_modifiers.code,
|
|
114359
|
-
ts.Diagnostics.
|
|
114464
|
+
ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114360
114465
|
ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
|
|
114361
114466
|
ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
|
|
114362
114467
|
ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
|
|
@@ -115424,7 +115529,7 @@ var ts;
|
|
|
115424
115529
|
ts.Debug.assert(!!sourceFile.bindDiagnostics);
|
|
115425
115530
|
var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
|
|
115426
115531
|
var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
|
|
115427
|
-
var isPlainJs =
|
|
115532
|
+
var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
|
|
115428
115533
|
var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
|
|
115429
115534
|
// By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
|
|
115430
115535
|
// - plain JS: .js files with no // ts-check and checkJs: undefined
|