typescript 4.7.0-dev.20220215 → 4.7.0-dev.20220219
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 +5 -1
- package/lib/de/diagnosticMessages.generated.json +4 -0
- package/lib/es/diagnosticMessages.generated.json +5 -1
- package/lib/fr/diagnosticMessages.generated.json +5 -1
- package/lib/it/diagnosticMessages.generated.json +5 -1
- package/lib/ja/diagnosticMessages.generated.json +5 -1
- package/lib/ko/diagnosticMessages.generated.json +5 -1
- package/lib/lib.es2015.core.d.ts +3 -3
- package/lib/lib.es2020.intl.d.ts +4 -0
- package/lib/lib.es2021.intl.d.ts +6 -6
- package/lib/lib.es5.d.ts +3 -1
- package/lib/lib.esnext.intl.d.ts +4 -1
- package/lib/pl/diagnosticMessages.generated.json +5 -1
- package/lib/protocol.d.ts +7 -0
- package/lib/pt-br/diagnosticMessages.generated.json +5 -1
- package/lib/ru/diagnosticMessages.generated.json +5 -1
- package/lib/tr/diagnosticMessages.generated.json +4 -0
- package/lib/tsc.js +670 -516
- package/lib/tsserver.js +840 -648
- package/lib/tsserverlibrary.d.ts +31 -25
- package/lib/tsserverlibrary.js +834 -643
- package/lib/typescript.d.ts +23 -24
- package/lib/typescript.js +832 -641
- package/lib/typescriptServices.d.ts +23 -24
- package/lib/typescriptServices.js +832 -641
- package/lib/typingsInstaller.js +779 -623
- package/lib/zh-cn/diagnosticMessages.generated.json +5 -1
- package/lib/zh-tw/diagnosticMessages.generated.json +4 -0
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220219";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -2617,7 +2617,7 @@ var ts;
|
|
|
2617
2617
|
Debug.checkEachDefined = checkEachDefined;
|
|
2618
2618
|
function assertNever(member, message, stackCrawlMark) {
|
|
2619
2619
|
if (message === void 0) { message = "Illegal value:"; }
|
|
2620
|
-
var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos")
|
|
2620
|
+
var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
|
|
2621
2621
|
return fail(message + " " + detail, stackCrawlMark || assertNever);
|
|
2622
2622
|
}
|
|
2623
2623
|
Debug.assertNever = assertNever;
|
|
@@ -5034,6 +5034,8 @@ var ts;
|
|
|
5034
5034
|
TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike";
|
|
5035
5035
|
TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike";
|
|
5036
5036
|
/* @internal */
|
|
5037
|
+
TypeFlags[TypeFlags["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
|
|
5038
|
+
/* @internal */
|
|
5037
5039
|
TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains";
|
|
5038
5040
|
TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
5039
5041
|
TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType";
|
|
@@ -5112,13 +5114,14 @@ var ts;
|
|
|
5112
5114
|
// Flags that require TypeFlags.Object
|
|
5113
5115
|
ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread";
|
|
5114
5116
|
ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType";
|
|
5117
|
+
ObjectFlags[ObjectFlags["InstantiationExpressionType"] = 16777216] = "InstantiationExpressionType";
|
|
5115
5118
|
/* @internal */
|
|
5116
|
-
ObjectFlags[ObjectFlags["IsClassInstanceClone"] =
|
|
5119
|
+
ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 33554432] = "IsClassInstanceClone";
|
|
5117
5120
|
// Flags that require TypeFlags.Object and ObjectFlags.Reference
|
|
5118
5121
|
/* @internal */
|
|
5119
|
-
ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] =
|
|
5122
|
+
ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 67108864] = "IdenticalBaseTypeCalculated";
|
|
5120
5123
|
/* @internal */
|
|
5121
|
-
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] =
|
|
5124
|
+
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 134217728] = "IdenticalBaseTypeExists";
|
|
5122
5125
|
// Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution
|
|
5123
5126
|
/* @internal */
|
|
5124
5127
|
ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 4194304] = "IsGenericTypeComputed";
|
|
@@ -5766,6 +5769,8 @@ var ts;
|
|
|
5766
5769
|
BundleFileSectionKind["NoDefaultLib"] = "no-default-lib";
|
|
5767
5770
|
BundleFileSectionKind["Reference"] = "reference";
|
|
5768
5771
|
BundleFileSectionKind["Type"] = "type";
|
|
5772
|
+
BundleFileSectionKind["TypeResolutionModeRequire"] = "type-require";
|
|
5773
|
+
BundleFileSectionKind["TypeResolutionModeImport"] = "type-import";
|
|
5769
5774
|
BundleFileSectionKind["Lib"] = "lib";
|
|
5770
5775
|
BundleFileSectionKind["Prepend"] = "prepend";
|
|
5771
5776
|
BundleFileSectionKind["Text"] = "text";
|
|
@@ -5882,7 +5887,8 @@ var ts;
|
|
|
5882
5887
|
{ name: "types", optional: true, captureSpan: true },
|
|
5883
5888
|
{ name: "lib", optional: true, captureSpan: true },
|
|
5884
5889
|
{ name: "path", optional: true, captureSpan: true },
|
|
5885
|
-
{ name: "no-default-lib", optional: true }
|
|
5890
|
+
{ name: "no-default-lib", optional: true },
|
|
5891
|
+
{ name: "resolution-mode", optional: true }
|
|
5886
5892
|
],
|
|
5887
5893
|
kind: 1 /* TripleSlashXML */
|
|
5888
5894
|
},
|
|
@@ -8263,6 +8269,8 @@ var ts;
|
|
|
8263
8269
|
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."),
|
|
8264
8270
|
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."),
|
|
8265
8271
|
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."),
|
|
8272
|
+
Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
|
|
8273
|
+
Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
|
|
8266
8274
|
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."),
|
|
8267
8275
|
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."),
|
|
8268
8276
|
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."),
|
|
@@ -8331,7 +8339,6 @@ var ts;
|
|
|
8331
8339
|
Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"),
|
|
8332
8340
|
Unexpected_token_Did_you_mean_or_gt: diag(1382, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `>`?"),
|
|
8333
8341
|
Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."),
|
|
8334
|
-
A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list: diag(1384, ts.DiagnosticCategory.Error, "A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list_1384", "A 'new' expression with type arguments must always be followed by a parenthesized argument list."),
|
|
8335
8342
|
Function_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1385, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_a_union_type_1385", "Function type notation must be parenthesized when used in a union type."),
|
|
8336
8343
|
Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1386, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386", "Constructor type notation must be parenthesized when used in a union type."),
|
|
8337
8344
|
Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."),
|
|
@@ -8396,6 +8403,8 @@ var ts;
|
|
|
8396
8403
|
Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
|
|
8397
8404
|
Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
|
|
8398
8405
|
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
|
|
8406
|
+
Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."),
|
|
8407
|
+
resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
|
|
8399
8408
|
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."),
|
|
8400
8409
|
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."),
|
|
8401
8410
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -8715,6 +8724,7 @@ var ts;
|
|
|
8715
8724
|
Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."),
|
|
8716
8725
|
JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"),
|
|
8717
8726
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8727
|
+
Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
|
|
8718
8728
|
Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
|
|
8719
8729
|
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
|
|
8720
8730
|
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
|
|
@@ -9760,7 +9770,7 @@ var ts;
|
|
|
9760
9770
|
Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
|
|
9761
9771
|
Wrap_invalid_character_in_an_expression_container: diag(95108, ts.DiagnosticCategory.Message, "Wrap_invalid_character_in_an_expression_container_95108", "Wrap invalid character in an expression container"),
|
|
9762
9772
|
Wrap_all_invalid_characters_in_an_expression_container: diag(95109, ts.DiagnosticCategory.Message, "Wrap_all_invalid_characters_in_an_expression_container_95109", "Wrap all invalid characters in an expression container"),
|
|
9763
|
-
|
|
9773
|
+
Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig to read more about this file"),
|
|
9764
9774
|
Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
|
|
9765
9775
|
Remove_braces_from_arrow_function_body: diag(95112, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_body_95112", "Remove braces from arrow function body"),
|
|
9766
9776
|
Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal: diag(95113, ts.DiagnosticCategory.Message, "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113", "Wrap the following body with parentheses which should be an object literal"),
|
|
@@ -13606,6 +13616,7 @@ var ts;
|
|
|
13606
13616
|
case 110 /* TrueKeyword */:
|
|
13607
13617
|
case 106 /* SuperKeyword */:
|
|
13608
13618
|
case 229 /* NonNullExpression */:
|
|
13619
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
13609
13620
|
case 230 /* MetaProperty */:
|
|
13610
13621
|
case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression
|
|
13611
13622
|
return true;
|
|
@@ -14279,7 +14290,11 @@ var ts;
|
|
|
14279
14290
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14280
14291
|
for (var i = 0; i < names.length; i++) {
|
|
14281
14292
|
var newResolution = newResolutions[i];
|
|
14282
|
-
var
|
|
14293
|
+
var entry = names[i];
|
|
14294
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
14295
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
14296
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
|
|
14297
|
+
var oldResolution = oldResolutions && oldResolutions.get(name, mode);
|
|
14283
14298
|
var changed = oldResolution
|
|
14284
14299
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14285
14300
|
: newResolution;
|
|
@@ -15315,7 +15330,7 @@ var ts;
|
|
|
15315
15330
|
case 114 /* VoidKeyword */:
|
|
15316
15331
|
return node.parent.kind !== 216 /* VoidExpression */;
|
|
15317
15332
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15318
|
-
return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
15333
|
+
return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
15319
15334
|
case 162 /* TypeParameter */:
|
|
15320
15335
|
return node.parent.kind === 194 /* MappedType */ || node.parent.kind === 189 /* InferType */;
|
|
15321
15336
|
// Identifiers and qualified names may be type nodes, depending on their context. Climb
|
|
@@ -15352,7 +15367,7 @@ var ts;
|
|
|
15352
15367
|
}
|
|
15353
15368
|
switch (parent.kind) {
|
|
15354
15369
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15355
|
-
return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
15370
|
+
return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
15356
15371
|
case 162 /* TypeParameter */:
|
|
15357
15372
|
return node === parent.constraint;
|
|
15358
15373
|
case 342 /* JSDocTemplateTag */:
|
|
@@ -16055,7 +16070,7 @@ var ts;
|
|
|
16055
16070
|
case 296 /* SpreadAssignment */:
|
|
16056
16071
|
return true;
|
|
16057
16072
|
case 227 /* ExpressionWithTypeArguments */:
|
|
16058
|
-
return parent.expression === node &&
|
|
16073
|
+
return parent.expression === node && !isPartOfTypeNode(parent);
|
|
16059
16074
|
case 295 /* ShorthandPropertyAssignment */:
|
|
16060
16075
|
return parent.objectAssignmentInitializer === node;
|
|
16061
16076
|
default:
|
|
@@ -23042,16 +23057,18 @@ var ts;
|
|
|
23042
23057
|
return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type);
|
|
23043
23058
|
}
|
|
23044
23059
|
// @api
|
|
23045
|
-
function createTypeQueryNode(exprName) {
|
|
23060
|
+
function createTypeQueryNode(exprName, typeArguments) {
|
|
23046
23061
|
var node = createBaseNode(180 /* TypeQuery */);
|
|
23047
23062
|
node.exprName = exprName;
|
|
23063
|
+
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
23048
23064
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23049
23065
|
return node;
|
|
23050
23066
|
}
|
|
23051
23067
|
// @api
|
|
23052
|
-
function updateTypeQueryNode(node, exprName) {
|
|
23068
|
+
function updateTypeQueryNode(node, exprName, typeArguments) {
|
|
23053
23069
|
return node.exprName !== exprName
|
|
23054
|
-
|
|
23070
|
+
|| node.typeArguments !== typeArguments
|
|
23071
|
+
? update(createTypeQueryNode(exprName, typeArguments), node)
|
|
23055
23072
|
: node;
|
|
23056
23073
|
}
|
|
23057
23074
|
// @api
|
|
@@ -26874,7 +26891,13 @@ var ts;
|
|
|
26874
26891
|
referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
|
|
26875
26892
|
break;
|
|
26876
26893
|
case "type" /* Type */:
|
|
26877
|
-
typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
|
|
26894
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
26895
|
+
break;
|
|
26896
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26897
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
|
|
26898
|
+
break;
|
|
26899
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26900
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
|
|
26878
26901
|
break;
|
|
26879
26902
|
case "lib" /* Lib */:
|
|
26880
26903
|
libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
@@ -26933,6 +26956,8 @@ var ts;
|
|
|
26933
26956
|
case "no-default-lib" /* NoDefaultLib */:
|
|
26934
26957
|
case "reference" /* Reference */:
|
|
26935
26958
|
case "type" /* Type */:
|
|
26959
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26960
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26936
26961
|
case "lib" /* Lib */:
|
|
26937
26962
|
syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
|
|
26938
26963
|
break;
|
|
@@ -30167,7 +30192,8 @@ var ts;
|
|
|
30167
30192
|
visitNode(cbNode, node.parameterName) ||
|
|
30168
30193
|
visitNode(cbNode, node.type);
|
|
30169
30194
|
case 180 /* TypeQuery */:
|
|
30170
|
-
return visitNode(cbNode, node.exprName)
|
|
30195
|
+
return visitNode(cbNode, node.exprName) ||
|
|
30196
|
+
visitNodes(cbNode, cbNodes, node.typeArguments);
|
|
30171
30197
|
case 181 /* TypeLiteral */:
|
|
30172
30198
|
return visitNodes(cbNode, cbNodes, node.members);
|
|
30173
30199
|
case 182 /* ArrayType */:
|
|
@@ -30846,7 +30872,7 @@ var ts;
|
|
|
30846
30872
|
initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
|
|
30847
30873
|
// Prime the scanner.
|
|
30848
30874
|
nextToken();
|
|
30849
|
-
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
30875
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false);
|
|
30850
30876
|
var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
|
|
30851
30877
|
clearState();
|
|
30852
30878
|
return isInvalid ? entityName : undefined;
|
|
@@ -32423,7 +32449,7 @@ var ts;
|
|
|
32423
32449
|
}
|
|
32424
32450
|
return createMissingList();
|
|
32425
32451
|
}
|
|
32426
|
-
function parseEntityName(allowReservedWords, diagnosticMessage) {
|
|
32452
|
+
function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) {
|
|
32427
32453
|
var pos = getNodePos();
|
|
32428
32454
|
var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
|
|
32429
32455
|
var dotPos = getNodePos();
|
|
@@ -32434,7 +32460,7 @@ var ts;
|
|
|
32434
32460
|
break;
|
|
32435
32461
|
}
|
|
32436
32462
|
dotPos = getNodePos();
|
|
32437
|
-
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords,
|
|
32463
|
+
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos);
|
|
32438
32464
|
}
|
|
32439
32465
|
return entity;
|
|
32440
32466
|
}
|
|
@@ -32567,7 +32593,7 @@ var ts;
|
|
|
32567
32593
|
}
|
|
32568
32594
|
// TYPES
|
|
32569
32595
|
function parseEntityNameOfTypeReference() {
|
|
32570
|
-
return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
|
|
32596
|
+
return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected);
|
|
32571
32597
|
}
|
|
32572
32598
|
function parseTypeArgumentsOfTypeReference() {
|
|
32573
32599
|
if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) {
|
|
@@ -32700,7 +32726,9 @@ var ts;
|
|
|
32700
32726
|
function parseTypeQuery() {
|
|
32701
32727
|
var pos = getNodePos();
|
|
32702
32728
|
parseExpected(112 /* TypeOfKeyword */);
|
|
32703
|
-
|
|
32729
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true);
|
|
32730
|
+
var typeArguments = tryParseTypeArguments();
|
|
32731
|
+
return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
|
|
32704
32732
|
}
|
|
32705
32733
|
function parseTypeParameter() {
|
|
32706
32734
|
var pos = getNodePos();
|
|
@@ -34770,20 +34798,30 @@ var ts;
|
|
|
34770
34798
|
expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
|
|
34771
34799
|
continue;
|
|
34772
34800
|
}
|
|
34773
|
-
if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34774
|
-
nextToken();
|
|
34775
|
-
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34776
|
-
continue;
|
|
34777
|
-
}
|
|
34778
34801
|
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
|
34779
34802
|
if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) {
|
|
34780
34803
|
expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
|
|
34781
34804
|
continue;
|
|
34782
34805
|
}
|
|
34783
34806
|
if (isTemplateStartOfTaggedTemplate()) {
|
|
34784
|
-
|
|
34807
|
+
// Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments
|
|
34808
|
+
expression = !questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */ ?
|
|
34809
|
+
parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) :
|
|
34810
|
+
parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
|
|
34785
34811
|
continue;
|
|
34786
34812
|
}
|
|
34813
|
+
if (!questionDotToken) {
|
|
34814
|
+
if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34815
|
+
nextToken();
|
|
34816
|
+
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34817
|
+
continue;
|
|
34818
|
+
}
|
|
34819
|
+
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34820
|
+
if (typeArguments) {
|
|
34821
|
+
expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
34822
|
+
continue;
|
|
34823
|
+
}
|
|
34824
|
+
}
|
|
34787
34825
|
return expression;
|
|
34788
34826
|
}
|
|
34789
34827
|
}
|
|
@@ -34803,38 +34841,30 @@ var ts;
|
|
|
34803
34841
|
function parseCallExpressionRest(pos, expression) {
|
|
34804
34842
|
while (true) {
|
|
34805
34843
|
expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true);
|
|
34844
|
+
var typeArguments = void 0;
|
|
34806
34845
|
var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */);
|
|
34807
|
-
|
|
34808
|
-
|
|
34809
|
-
|
|
34810
|
-
|
|
34811
|
-
// keep checking for postfix expressions. Otherwise, it's just a '<' that's
|
|
34812
|
-
// part of an arithmetic expression. Break out so we consume it higher in the
|
|
34813
|
-
// stack.
|
|
34814
|
-
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34815
|
-
if (typeArguments) {
|
|
34816
|
-
if (isTemplateStartOfTaggedTemplate()) {
|
|
34817
|
-
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34818
|
-
continue;
|
|
34819
|
-
}
|
|
34820
|
-
var argumentList = parseArgumentList();
|
|
34821
|
-
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34822
|
-
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34823
|
-
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34824
|
-
expression = finishNode(callExpr, pos);
|
|
34846
|
+
if (questionDotToken) {
|
|
34847
|
+
typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34848
|
+
if (isTemplateStartOfTaggedTemplate()) {
|
|
34849
|
+
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34825
34850
|
continue;
|
|
34826
34851
|
}
|
|
34827
34852
|
}
|
|
34828
|
-
|
|
34853
|
+
if (typeArguments || token() === 20 /* OpenParenToken */) {
|
|
34854
|
+
// Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments
|
|
34855
|
+
if (!questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
34856
|
+
typeArguments = expression.typeArguments;
|
|
34857
|
+
expression = expression.expression;
|
|
34858
|
+
}
|
|
34829
34859
|
var argumentList = parseArgumentList();
|
|
34830
34860
|
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34831
|
-
factory.createCallChain(expression, questionDotToken,
|
|
34832
|
-
factory.createCallExpression(expression,
|
|
34861
|
+
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34862
|
+
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34833
34863
|
expression = finishNode(callExpr, pos);
|
|
34834
34864
|
continue;
|
|
34835
34865
|
}
|
|
34836
34866
|
if (questionDotToken) {
|
|
34837
|
-
// We failed to parse anything, so report a missing identifier here.
|
|
34867
|
+
// We parsed `?.` but then failed to parse anything, so report a missing identifier here.
|
|
34838
34868
|
var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected);
|
|
34839
34869
|
expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
|
|
34840
34870
|
}
|
|
@@ -34862,21 +34892,25 @@ var ts;
|
|
|
34862
34892
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
34863
34893
|
return undefined;
|
|
34864
34894
|
}
|
|
34865
|
-
//
|
|
34866
|
-
//
|
|
34867
|
-
|
|
34868
|
-
|
|
34869
|
-
|
|
34895
|
+
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
34896
|
+
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
34897
|
+
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
34898
|
+
// it as a relational expression.
|
|
34899
|
+
return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
|
|
34870
34900
|
}
|
|
34871
34901
|
function canFollowTypeArgumentsInExpression() {
|
|
34872
34902
|
switch (token()) {
|
|
34903
|
+
// These tokens can follow a type argument list in a call expression.
|
|
34873
34904
|
case 20 /* OpenParenToken */: // foo<x>(
|
|
34874
34905
|
case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
34875
34906
|
case 15 /* TemplateHead */: // foo<T> `...${100}...`
|
|
34876
|
-
//
|
|
34877
|
-
//
|
|
34907
|
+
// These tokens can't follow in a call expression, nor can they start an
|
|
34908
|
+
// expression. So, consider the type argument list part of an instantiation
|
|
34909
|
+
// expression.
|
|
34878
34910
|
// falls through
|
|
34911
|
+
case 27 /* CommaToken */: // foo<x>,
|
|
34879
34912
|
case 24 /* DotToken */: // foo<x>.
|
|
34913
|
+
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
34880
34914
|
case 21 /* CloseParenToken */: // foo<x>)
|
|
34881
34915
|
case 23 /* CloseBracketToken */: // foo<x>]
|
|
34882
34916
|
case 58 /* ColonToken */: // foo<x>:
|
|
@@ -34894,20 +34928,10 @@ var ts;
|
|
|
34894
34928
|
case 51 /* BarToken */: // foo<x> |
|
|
34895
34929
|
case 19 /* CloseBraceToken */: // foo<x> }
|
|
34896
34930
|
case 1 /* EndOfFileToken */: // foo<x>
|
|
34897
|
-
// these cases can't legally follow a type arg list. However, they're not legal
|
|
34898
|
-
// expressions either. The user is probably in the middle of a generic type. So
|
|
34899
|
-
// treat it as such.
|
|
34900
34931
|
return true;
|
|
34901
|
-
case 27 /* CommaToken */: // foo<x>,
|
|
34902
|
-
case 18 /* OpenBraceToken */: // foo<x> {
|
|
34903
|
-
// We don't want to treat these as type arguments. Otherwise we'll parse this
|
|
34904
|
-
// as an invocation expression. Instead, we want to parse out the expression
|
|
34905
|
-
// in isolation from the type arguments.
|
|
34906
|
-
// falls through
|
|
34907
|
-
default:
|
|
34908
|
-
// Anything else treat as an expression.
|
|
34909
|
-
return false;
|
|
34910
34932
|
}
|
|
34933
|
+
// Treat anything else as an expression.
|
|
34934
|
+
return false;
|
|
34911
34935
|
}
|
|
34912
34936
|
function parsePrimaryExpression() {
|
|
34913
34937
|
switch (token()) {
|
|
@@ -35088,26 +35112,15 @@ var ts;
|
|
|
35088
35112
|
return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos);
|
|
35089
35113
|
}
|
|
35090
35114
|
var expressionPos = getNodePos();
|
|
35091
|
-
var expression = parsePrimaryExpression();
|
|
35115
|
+
var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
|
|
35092
35116
|
var typeArguments;
|
|
35093
|
-
|
|
35094
|
-
|
|
35095
|
-
typeArguments =
|
|
35096
|
-
|
|
35097
|
-
ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
|
|
35098
|
-
expression = parseTaggedTemplateRest(expressionPos, expression, /*optionalChain*/ undefined, typeArguments);
|
|
35099
|
-
typeArguments = undefined;
|
|
35100
|
-
}
|
|
35101
|
-
break;
|
|
35102
|
-
}
|
|
35103
|
-
var argumentsArray;
|
|
35104
|
-
if (token() === 20 /* OpenParenToken */) {
|
|
35105
|
-
argumentsArray = parseArgumentList();
|
|
35106
|
-
}
|
|
35107
|
-
else if (typeArguments) {
|
|
35108
|
-
parseErrorAt(pos, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
|
|
35117
|
+
// Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments
|
|
35118
|
+
if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
35119
|
+
typeArguments = expression.typeArguments;
|
|
35120
|
+
expression = expression.expression;
|
|
35109
35121
|
}
|
|
35110
|
-
|
|
35122
|
+
var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
|
|
35123
|
+
return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
|
|
35111
35124
|
}
|
|
35112
35125
|
// STATEMENTS
|
|
35113
35126
|
function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
|
|
@@ -35271,11 +35284,12 @@ var ts;
|
|
|
35271
35284
|
}
|
|
35272
35285
|
function parseCaseClause() {
|
|
35273
35286
|
var pos = getNodePos();
|
|
35287
|
+
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35274
35288
|
parseExpected(82 /* CaseKeyword */);
|
|
35275
35289
|
var expression = allowInAnd(parseExpression);
|
|
35276
35290
|
parseExpected(58 /* ColonToken */);
|
|
35277
35291
|
var statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
|
|
35278
|
-
return finishNode(factory.createCaseClause(expression, statements), pos);
|
|
35292
|
+
return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
|
|
35279
35293
|
}
|
|
35280
35294
|
function parseDefaultClause() {
|
|
35281
35295
|
var pos = getNodePos();
|
|
@@ -36195,6 +36209,9 @@ var ts;
|
|
|
36195
36209
|
function parseExpressionWithTypeArguments() {
|
|
36196
36210
|
var pos = getNodePos();
|
|
36197
36211
|
var expression = parseLeftHandSideExpressionOrHigher();
|
|
36212
|
+
if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
36213
|
+
return expression;
|
|
36214
|
+
}
|
|
36198
36215
|
var typeArguments = tryParseTypeArguments();
|
|
36199
36216
|
return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
36200
36217
|
}
|
|
@@ -36438,7 +36455,7 @@ var ts;
|
|
|
36438
36455
|
function parseModuleReference() {
|
|
36439
36456
|
return isExternalModuleReference()
|
|
36440
36457
|
? parseExternalModuleReference()
|
|
36441
|
-
: parseEntityName(/*allowReservedWords*/ false);
|
|
36458
|
+
: parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36442
36459
|
}
|
|
36443
36460
|
function parseExternalModuleReference() {
|
|
36444
36461
|
var pos = getNodePos();
|
|
@@ -36720,7 +36737,7 @@ var ts;
|
|
|
36720
36737
|
var pos = getNodePos();
|
|
36721
36738
|
var hasBrace = parseOptional(18 /* OpenBraceToken */);
|
|
36722
36739
|
var p2 = getNodePos();
|
|
36723
|
-
var entityName = parseEntityName(/* allowReservedWords*/ false);
|
|
36740
|
+
var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36724
36741
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
36725
36742
|
reScanHashToken(); // rescan #id as # id
|
|
36726
36743
|
nextTokenJSDoc(); // then skip the #
|
|
@@ -37163,7 +37180,7 @@ var ts;
|
|
|
37163
37180
|
// parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
|
|
37164
37181
|
var p2 = getNodePos();
|
|
37165
37182
|
var name = ts.tokenIsIdentifierOrKeyword(token())
|
|
37166
|
-
? parseEntityName(/*allowReservedWords*/ true)
|
|
37183
|
+
? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false)
|
|
37167
37184
|
: undefined;
|
|
37168
37185
|
if (name) {
|
|
37169
37186
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
@@ -37188,11 +37205,13 @@ var ts;
|
|
|
37188
37205
|
&& nextTokenJSDoc() === 59 /* AtToken */
|
|
37189
37206
|
&& ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
|
|
37190
37207
|
var kind = scanner.getTokenValue();
|
|
37191
|
-
if (kind
|
|
37208
|
+
if (isJSDocLinkTag(kind))
|
|
37192
37209
|
return kind;
|
|
37193
|
-
}
|
|
37194
37210
|
}
|
|
37195
37211
|
}
|
|
37212
|
+
function isJSDocLinkTag(kind) {
|
|
37213
|
+
return kind === "link" || kind === "linkcode" || kind === "linkplain";
|
|
37214
|
+
}
|
|
37196
37215
|
function parseUnknownTag(start, tagName, indent, indentText) {
|
|
37197
37216
|
return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
|
|
37198
37217
|
}
|
|
@@ -37298,7 +37317,7 @@ var ts;
|
|
|
37298
37317
|
}
|
|
37299
37318
|
function parseSeeTag(start, tagName, indent, indentText) {
|
|
37300
37319
|
var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
|
|
37301
|
-
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue()
|
|
37320
|
+
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); });
|
|
37302
37321
|
var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
|
|
37303
37322
|
var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
|
|
37304
37323
|
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
|
|
@@ -38165,6 +38184,19 @@ var ts;
|
|
|
38165
38184
|
return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
|
|
38166
38185
|
}
|
|
38167
38186
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
38187
|
+
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
38188
|
+
if (!mode) {
|
|
38189
|
+
return undefined;
|
|
38190
|
+
}
|
|
38191
|
+
if (mode === "import") {
|
|
38192
|
+
return ts.ModuleKind.ESNext;
|
|
38193
|
+
}
|
|
38194
|
+
if (mode === "require") {
|
|
38195
|
+
return ts.ModuleKind.CommonJS;
|
|
38196
|
+
}
|
|
38197
|
+
reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
|
|
38198
|
+
return undefined;
|
|
38199
|
+
}
|
|
38168
38200
|
/*@internal*/
|
|
38169
38201
|
function processCommentPragmas(context, sourceText) {
|
|
38170
38202
|
var pragmas = [];
|
|
@@ -38207,12 +38239,13 @@ var ts;
|
|
|
38207
38239
|
var typeReferenceDirectives_1 = context.typeReferenceDirectives;
|
|
38208
38240
|
var libReferenceDirectives_1 = context.libReferenceDirectives;
|
|
38209
38241
|
ts.forEach(ts.toArray(entryOrList), function (arg) {
|
|
38210
|
-
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
|
|
38242
|
+
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
|
|
38211
38243
|
if (arg.arguments["no-default-lib"]) {
|
|
38212
38244
|
context.hasNoDefaultLib = true;
|
|
38213
38245
|
}
|
|
38214
38246
|
else if (types) {
|
|
38215
|
-
|
|
38247
|
+
var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
|
|
38248
|
+
typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
|
|
38216
38249
|
}
|
|
38217
38250
|
else if (lib) {
|
|
38218
38251
|
libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
|
|
@@ -40624,7 +40657,7 @@ var ts;
|
|
|
40624
40657
|
var result = [];
|
|
40625
40658
|
result.push("{");
|
|
40626
40659
|
result.push(tab + "\"compilerOptions\": {");
|
|
40627
|
-
result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.
|
|
40660
|
+
result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */");
|
|
40628
40661
|
result.push("");
|
|
40629
40662
|
// Print out each row, aligning all the descriptions on the same column.
|
|
40630
40663
|
for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
|
|
@@ -41790,14 +41823,14 @@ var ts;
|
|
|
41790
41823
|
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
|
41791
41824
|
* is assumed to be the same as root directory of the project.
|
|
41792
41825
|
*/
|
|
41793
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
|
|
41826
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
|
|
41794
41827
|
var traceEnabled = isTraceEnabled(options, host);
|
|
41795
41828
|
if (redirectedReference) {
|
|
41796
41829
|
options = redirectedReference.commandLine.options;
|
|
41797
41830
|
}
|
|
41798
41831
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41799
41832
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41800
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/
|
|
41833
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
|
|
41801
41834
|
if (result) {
|
|
41802
41835
|
if (traceEnabled) {
|
|
41803
41836
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41832,7 +41865,18 @@ var ts;
|
|
|
41832
41865
|
}
|
|
41833
41866
|
var failedLookupLocations = [];
|
|
41834
41867
|
var features = getDefaultNodeResolutionFeatures(options);
|
|
41835
|
-
|
|
41868
|
+
// Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
|
|
41869
|
+
// setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
|
|
41870
|
+
// set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports
|
|
41871
|
+
// are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best,
|
|
41872
|
+
// in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern
|
|
41873
|
+
// resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution
|
|
41874
|
+
// context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do).
|
|
41875
|
+
if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
|
|
41876
|
+
features |= NodeResolutionFeatures.EsmMode;
|
|
41877
|
+
}
|
|
41878
|
+
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
41879
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
|
|
41836
41880
|
var resolved = primaryLookup();
|
|
41837
41881
|
var primary = true;
|
|
41838
41882
|
if (!resolved) {
|
|
@@ -41852,7 +41896,7 @@ var ts;
|
|
|
41852
41896
|
};
|
|
41853
41897
|
}
|
|
41854
41898
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41855
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/
|
|
41899
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
41856
41900
|
if (traceEnabled)
|
|
41857
41901
|
traceResult(result);
|
|
41858
41902
|
return result;
|
|
@@ -42138,7 +42182,11 @@ var ts;
|
|
|
42138
42182
|
ts.Debug.assert(keys.length === values.length);
|
|
42139
42183
|
var map = createModeAwareCache();
|
|
42140
42184
|
for (var i = 0; i < keys.length; ++i) {
|
|
42141
|
-
|
|
42185
|
+
var entry = keys[i];
|
|
42186
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
42187
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
42188
|
+
var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
|
|
42189
|
+
map.set(name, mode, values[i]);
|
|
42142
42190
|
}
|
|
42143
42191
|
return map;
|
|
42144
42192
|
}
|
|
@@ -47158,8 +47206,7 @@ var ts;
|
|
|
47158
47206
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
47159
47207
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
47160
47208
|
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
47161
|
-
IntersectionState[IntersectionState["
|
|
47162
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
|
|
47209
|
+
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
47163
47210
|
})(IntersectionState || (IntersectionState = {}));
|
|
47164
47211
|
var RecursionFlags;
|
|
47165
47212
|
(function (RecursionFlags) {
|
|
@@ -51173,7 +51220,7 @@ var ts;
|
|
|
51173
51220
|
// get symbol of the first identifier of the entityName
|
|
51174
51221
|
var meaning;
|
|
51175
51222
|
if (entityName.parent.kind === 180 /* TypeQuery */ ||
|
|
51176
|
-
ts.
|
|
51223
|
+
entityName.parent.kind === 227 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) ||
|
|
51177
51224
|
entityName.parent.kind === 161 /* ComputedPropertyName */) {
|
|
51178
51225
|
// Typeof value
|
|
51179
51226
|
meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
|
|
@@ -51284,7 +51331,7 @@ var ts;
|
|
|
51284
51331
|
return flags & 814775659 /* NodeBuilderFlagsMask */;
|
|
51285
51332
|
}
|
|
51286
51333
|
function isClassInstanceSide(type) {
|
|
51287
|
-
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) &
|
|
51334
|
+
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 33554432 /* IsClassInstanceClone */)));
|
|
51288
51335
|
}
|
|
51289
51336
|
function createNodeBuilder() {
|
|
51290
51337
|
return {
|
|
@@ -55213,7 +55260,7 @@ var ts;
|
|
|
55213
55260
|
members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
|
|
55214
55261
|
result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag
|
|
55215
55262
|
if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
|
|
55216
|
-
result.objectFlags |=
|
|
55263
|
+
result.objectFlags |= 33554432 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
|
|
55217
55264
|
}
|
|
55218
55265
|
return result;
|
|
55219
55266
|
}
|
|
@@ -57259,87 +57306,87 @@ var ts;
|
|
|
57259
57306
|
* Converts an AnonymousType to a ResolvedType.
|
|
57260
57307
|
*/
|
|
57261
57308
|
function resolveAnonymousTypeMembers(type) {
|
|
57262
|
-
var symbol = getMergedSymbol(type.symbol);
|
|
57263
57309
|
if (type.target) {
|
|
57264
57310
|
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
57265
|
-
var
|
|
57311
|
+
var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
|
|
57266
57312
|
var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper);
|
|
57267
57313
|
var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper);
|
|
57268
|
-
var
|
|
57269
|
-
setStructuredTypeMembers(type,
|
|
57314
|
+
var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper);
|
|
57315
|
+
setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1);
|
|
57316
|
+
return;
|
|
57270
57317
|
}
|
|
57271
|
-
|
|
57318
|
+
var symbol = getMergedSymbol(type.symbol);
|
|
57319
|
+
if (symbol.flags & 2048 /* TypeLiteral */) {
|
|
57272
57320
|
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
57273
|
-
var
|
|
57274
|
-
var callSignatures = getSignaturesOfSymbol(
|
|
57275
|
-
var constructSignatures = getSignaturesOfSymbol(
|
|
57276
|
-
var
|
|
57277
|
-
setStructuredTypeMembers(type,
|
|
57321
|
+
var members_7 = getMembersOfSymbol(symbol);
|
|
57322
|
+
var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */));
|
|
57323
|
+
var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */));
|
|
57324
|
+
var indexInfos_2 = getIndexInfosOfSymbol(symbol);
|
|
57325
|
+
setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2);
|
|
57326
|
+
return;
|
|
57278
57327
|
}
|
|
57279
|
-
|
|
57280
|
-
|
|
57281
|
-
|
|
57282
|
-
|
|
57283
|
-
|
|
57284
|
-
|
|
57285
|
-
|
|
57286
|
-
|
|
57287
|
-
|
|
57288
|
-
|
|
57289
|
-
|
|
57290
|
-
|
|
57291
|
-
|
|
57292
|
-
members = varsOnly_1;
|
|
57293
|
-
}
|
|
57328
|
+
// Combinations of function, class, enum and module
|
|
57329
|
+
var members = emptySymbols;
|
|
57330
|
+
var indexInfos;
|
|
57331
|
+
if (symbol.exports) {
|
|
57332
|
+
members = getExportsOfSymbol(symbol);
|
|
57333
|
+
if (symbol === globalThisSymbol) {
|
|
57334
|
+
var varsOnly_1 = new ts.Map();
|
|
57335
|
+
members.forEach(function (p) {
|
|
57336
|
+
if (!(p.flags & 418 /* BlockScoped */)) {
|
|
57337
|
+
varsOnly_1.set(p.escapedName, p);
|
|
57338
|
+
}
|
|
57339
|
+
});
|
|
57340
|
+
members = varsOnly_1;
|
|
57294
57341
|
}
|
|
57295
|
-
|
|
57296
|
-
|
|
57297
|
-
|
|
57298
|
-
|
|
57299
|
-
|
|
57300
|
-
|
|
57301
|
-
|
|
57302
|
-
|
|
57303
|
-
|
|
57304
|
-
else if (baseConstructorType === anyType) {
|
|
57305
|
-
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
|
57306
|
-
}
|
|
57342
|
+
}
|
|
57343
|
+
var baseConstructorIndexInfo;
|
|
57344
|
+
setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
57345
|
+
if (symbol.flags & 32 /* Class */) {
|
|
57346
|
+
var classType = getDeclaredTypeOfClassOrInterface(symbol);
|
|
57347
|
+
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
|
57348
|
+
if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) {
|
|
57349
|
+
members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members));
|
|
57350
|
+
addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
|
|
57307
57351
|
}
|
|
57308
|
-
|
|
57309
|
-
|
|
57310
|
-
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
57352
|
+
else if (baseConstructorType === anyType) {
|
|
57353
|
+
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
|
57311
57354
|
}
|
|
57312
|
-
|
|
57313
|
-
|
|
57314
|
-
|
|
57315
|
-
|
|
57316
|
-
|
|
57317
|
-
|
|
57318
|
-
|
|
57319
|
-
|
|
57355
|
+
}
|
|
57356
|
+
var indexSymbol = getIndexSymbolFromSymbolTable(members);
|
|
57357
|
+
if (indexSymbol) {
|
|
57358
|
+
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
57359
|
+
}
|
|
57360
|
+
else {
|
|
57361
|
+
if (baseConstructorIndexInfo) {
|
|
57362
|
+
indexInfos = ts.append(indexInfos, baseConstructorIndexInfo);
|
|
57320
57363
|
}
|
|
57321
|
-
|
|
57322
|
-
|
|
57323
|
-
|
|
57324
|
-
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
|
57325
|
-
// will never be observed because a qualified name can't reference signatures.
|
|
57326
|
-
if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
|
|
57327
|
-
type.callSignatures = getSignaturesOfSymbol(symbol);
|
|
57364
|
+
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ ||
|
|
57365
|
+
ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) {
|
|
57366
|
+
indexInfos = ts.append(indexInfos, enumNumberIndexInfo);
|
|
57328
57367
|
}
|
|
57329
|
-
|
|
57330
|
-
|
|
57331
|
-
|
|
57332
|
-
|
|
57333
|
-
|
|
57334
|
-
|
|
57335
|
-
|
|
57336
|
-
|
|
57337
|
-
|
|
57338
|
-
|
|
57339
|
-
|
|
57340
|
-
|
|
57341
|
-
|
|
57368
|
+
}
|
|
57369
|
+
setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray);
|
|
57370
|
+
// We resolve the members before computing the signatures because a signature may use
|
|
57371
|
+
// typeof with a qualified name expression that circularly references the type we are
|
|
57372
|
+
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
|
57373
|
+
// will never be observed because a qualified name can't reference signatures.
|
|
57374
|
+
if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
|
|
57375
|
+
type.callSignatures = getSignaturesOfSymbol(symbol);
|
|
57376
|
+
}
|
|
57377
|
+
// And likewise for construct signatures for classes
|
|
57378
|
+
if (symbol.flags & 32 /* Class */) {
|
|
57379
|
+
var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
|
|
57380
|
+
var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray;
|
|
57381
|
+
if (symbol.flags & 16 /* Function */) {
|
|
57382
|
+
constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
|
|
57383
|
+
createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) :
|
|
57384
|
+
undefined; }));
|
|
57342
57385
|
}
|
|
57386
|
+
if (!constructSignatures.length) {
|
|
57387
|
+
constructSignatures = getDefaultConstructSignatures(classType_1);
|
|
57388
|
+
}
|
|
57389
|
+
type.constructSignatures = constructSignatures;
|
|
57343
57390
|
}
|
|
57344
57391
|
}
|
|
57345
57392
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
@@ -58340,8 +58387,8 @@ var ts;
|
|
|
58340
58387
|
var stringIndexInfo;
|
|
58341
58388
|
var applicableInfo;
|
|
58342
58389
|
var applicableInfos;
|
|
58343
|
-
for (var _i = 0,
|
|
58344
|
-
var info =
|
|
58390
|
+
for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
|
|
58391
|
+
var info = indexInfos_3[_i];
|
|
58345
58392
|
if (info.keyType === stringType) {
|
|
58346
58393
|
stringIndexInfo = info;
|
|
58347
58394
|
}
|
|
@@ -58880,13 +58927,15 @@ var ts;
|
|
|
58880
58927
|
return signature;
|
|
58881
58928
|
}
|
|
58882
58929
|
function getOrCreateTypeFromSignature(signature) {
|
|
58930
|
+
var _a;
|
|
58883
58931
|
// There are two ways to declare a construct signature, one is by declaring a class constructor
|
|
58884
58932
|
// using the constructor keyword, and the other is declaring a bare construct signature in an
|
|
58885
58933
|
// object type literal or interface (using the new keyword). Each way of declaring a constructor
|
|
58886
58934
|
// will result in a different declaration kind.
|
|
58887
58935
|
if (!signature.isolatedSignatureType) {
|
|
58888
|
-
var kind =
|
|
58889
|
-
|
|
58936
|
+
var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
|
|
58937
|
+
// If declaration is undefined, it is likely to be the signature of the default constructor.
|
|
58938
|
+
var isConstructor = kind === undefined || kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */;
|
|
58890
58939
|
var type = createObjectType(16 /* Anonymous */);
|
|
58891
58940
|
type.members = emptySymbols;
|
|
58892
58941
|
type.properties = ts.emptyArray;
|
|
@@ -58912,14 +58961,14 @@ var ts;
|
|
|
58912
58961
|
}
|
|
58913
58962
|
function getIndexInfosOfIndexSymbol(indexSymbol) {
|
|
58914
58963
|
if (indexSymbol.declarations) {
|
|
58915
|
-
var
|
|
58964
|
+
var indexInfos_4 = [];
|
|
58916
58965
|
var _loop_14 = function (declaration) {
|
|
58917
58966
|
if (declaration.parameters.length === 1) {
|
|
58918
58967
|
var parameter = declaration.parameters[0];
|
|
58919
58968
|
if (parameter.type) {
|
|
58920
58969
|
forEachType(getTypeFromTypeNode(parameter.type), function (keyType) {
|
|
58921
|
-
if (isValidIndexKeyType(keyType) && !findIndexInfo(
|
|
58922
|
-
|
|
58970
|
+
if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) {
|
|
58971
|
+
indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration));
|
|
58923
58972
|
}
|
|
58924
58973
|
});
|
|
58925
58974
|
}
|
|
@@ -58929,7 +58978,7 @@ var ts;
|
|
|
58929
58978
|
var declaration = _a[_i];
|
|
58930
58979
|
_loop_14(declaration);
|
|
58931
58980
|
}
|
|
58932
|
-
return
|
|
58981
|
+
return indexInfos_4;
|
|
58933
58982
|
}
|
|
58934
58983
|
return ts.emptyArray;
|
|
58935
58984
|
}
|
|
@@ -59477,7 +59526,7 @@ var ts;
|
|
|
59477
59526
|
// The expression is processed as an identifier expression (section 4.3)
|
|
59478
59527
|
// or property access expression(section 4.10),
|
|
59479
59528
|
// the widened type(section 3.9) of which becomes the result.
|
|
59480
|
-
var type =
|
|
59529
|
+
var type = checkExpressionWithTypeArguments(node);
|
|
59481
59530
|
links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(type));
|
|
59482
59531
|
}
|
|
59483
59532
|
return links.resolvedType;
|
|
@@ -59814,7 +59863,7 @@ var ts;
|
|
|
59814
59863
|
}
|
|
59815
59864
|
}
|
|
59816
59865
|
var fixedLength = properties.length;
|
|
59817
|
-
var lengthSymbol = createSymbol(4 /* Property */, "length");
|
|
59866
|
+
var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
|
|
59818
59867
|
if (combinedFlags & 12 /* Variable */) {
|
|
59819
59868
|
lengthSymbol.type = numberType;
|
|
59820
59869
|
}
|
|
@@ -62181,7 +62230,9 @@ var ts;
|
|
|
62181
62230
|
return result;
|
|
62182
62231
|
}
|
|
62183
62232
|
function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
62184
|
-
var declaration = type.objectFlags & 4 /* Reference */ ? type.node :
|
|
62233
|
+
var declaration = type.objectFlags & 4 /* Reference */ ? type.node :
|
|
62234
|
+
type.objectFlags & 16777216 /* InstantiationExpressionType */ ? type.node :
|
|
62235
|
+
type.symbol.declarations[0];
|
|
62185
62236
|
var links = getNodeLinks(declaration);
|
|
62186
62237
|
var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType :
|
|
62187
62238
|
type.objectFlags & 64 /* Instantiated */ ? type.target : type;
|
|
@@ -62197,8 +62248,8 @@ var ts;
|
|
|
62197
62248
|
outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
|
|
62198
62249
|
}
|
|
62199
62250
|
typeParameters = outerTypeParameters || ts.emptyArray;
|
|
62200
|
-
var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations;
|
|
62201
|
-
typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
|
|
62251
|
+
var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations;
|
|
62252
|
+
typeParameters = (target.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
|
|
62202
62253
|
ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) :
|
|
62203
62254
|
typeParameters;
|
|
62204
62255
|
links.outerTypeParameters = typeParameters;
|
|
@@ -62370,6 +62421,9 @@ var ts;
|
|
|
62370
62421
|
mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
|
|
62371
62422
|
freshTypeParameter.mapper = mapper;
|
|
62372
62423
|
}
|
|
62424
|
+
if (type.objectFlags & 16777216 /* InstantiationExpressionType */) {
|
|
62425
|
+
result.node = type.node;
|
|
62426
|
+
}
|
|
62373
62427
|
result.target = type;
|
|
62374
62428
|
result.mapper = mapper;
|
|
62375
62429
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
@@ -63135,10 +63189,6 @@ var ts;
|
|
|
63135
63189
|
if (sourceRestType || targetRestType) {
|
|
63136
63190
|
void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
|
|
63137
63191
|
}
|
|
63138
|
-
if (sourceRestType && targetRestType && sourceCount !== targetCount) {
|
|
63139
|
-
// We're not able to relate misaligned complex rest parameters
|
|
63140
|
-
return 0 /* False */;
|
|
63141
|
-
}
|
|
63142
63192
|
var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
|
|
63143
63193
|
var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 168 /* MethodDeclaration */ &&
|
|
63144
63194
|
kind !== 167 /* MethodSignature */ && kind !== 170 /* Constructor */;
|
|
@@ -63454,11 +63504,11 @@ var ts;
|
|
|
63454
63504
|
var overflow = false;
|
|
63455
63505
|
var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
|
|
63456
63506
|
var lastSkippedInfo;
|
|
63457
|
-
var incompatibleStack
|
|
63507
|
+
var incompatibleStack;
|
|
63458
63508
|
var inPropertyCheck = false;
|
|
63459
63509
|
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
63460
63510
|
var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
|
|
63461
|
-
if (incompatibleStack
|
|
63511
|
+
if (incompatibleStack) {
|
|
63462
63512
|
reportIncompatibleStack();
|
|
63463
63513
|
}
|
|
63464
63514
|
if (overflow) {
|
|
@@ -63515,19 +63565,19 @@ var ts;
|
|
|
63515
63565
|
return {
|
|
63516
63566
|
errorInfo: errorInfo,
|
|
63517
63567
|
lastSkippedInfo: lastSkippedInfo,
|
|
63518
|
-
incompatibleStack: incompatibleStack.slice(),
|
|
63568
|
+
incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
|
|
63519
63569
|
overrideNextErrorInfo: overrideNextErrorInfo,
|
|
63520
|
-
relatedInfo:
|
|
63570
|
+
relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
|
|
63521
63571
|
};
|
|
63522
63572
|
}
|
|
63523
63573
|
function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
|
|
63524
63574
|
overrideNextErrorInfo++; // Suppress the next relation error
|
|
63525
63575
|
lastSkippedInfo = undefined; // Reset skipped info cache
|
|
63526
|
-
incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
|
|
63576
|
+
(incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
|
|
63527
63577
|
}
|
|
63528
63578
|
function reportIncompatibleStack() {
|
|
63529
|
-
var stack = incompatibleStack;
|
|
63530
|
-
incompatibleStack =
|
|
63579
|
+
var stack = incompatibleStack || [];
|
|
63580
|
+
incompatibleStack = undefined;
|
|
63531
63581
|
var info = lastSkippedInfo;
|
|
63532
63582
|
lastSkippedInfo = undefined;
|
|
63533
63583
|
if (stack.length === 1) {
|
|
@@ -63633,7 +63683,7 @@ var ts;
|
|
|
63633
63683
|
}
|
|
63634
63684
|
function reportError(message, arg0, arg1, arg2, arg3) {
|
|
63635
63685
|
ts.Debug.assert(!!errorNode);
|
|
63636
|
-
if (incompatibleStack
|
|
63686
|
+
if (incompatibleStack)
|
|
63637
63687
|
reportIncompatibleStack();
|
|
63638
63688
|
if (message.elidedInCompatabilityPyramid)
|
|
63639
63689
|
return;
|
|
@@ -63649,7 +63699,7 @@ var ts;
|
|
|
63649
63699
|
}
|
|
63650
63700
|
}
|
|
63651
63701
|
function reportRelationError(message, source, target) {
|
|
63652
|
-
if (incompatibleStack
|
|
63702
|
+
if (incompatibleStack)
|
|
63653
63703
|
reportIncompatibleStack();
|
|
63654
63704
|
var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
|
|
63655
63705
|
var generalizedSource = source;
|
|
@@ -63761,7 +63811,9 @@ var ts;
|
|
|
63761
63811
|
if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
|
|
63762
63812
|
return -1 /* True */;
|
|
63763
63813
|
}
|
|
63764
|
-
|
|
63814
|
+
if (reportErrors) {
|
|
63815
|
+
reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
|
|
63816
|
+
}
|
|
63765
63817
|
return 0 /* False */;
|
|
63766
63818
|
}
|
|
63767
63819
|
// Normalize the source and target types: Turn fresh literal types into regular literal types,
|
|
@@ -63773,7 +63825,12 @@ var ts;
|
|
|
63773
63825
|
if (source === target)
|
|
63774
63826
|
return -1 /* True */;
|
|
63775
63827
|
if (relation === identityRelation) {
|
|
63776
|
-
|
|
63828
|
+
if (source.flags !== target.flags)
|
|
63829
|
+
return 0 /* False */;
|
|
63830
|
+
if (source.flags & 67358815 /* Singleton */)
|
|
63831
|
+
return -1 /* True */;
|
|
63832
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63833
|
+
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63777
63834
|
}
|
|
63778
63835
|
// We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
|
|
63779
63836
|
// and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
|
|
@@ -63783,163 +63840,130 @@ var ts;
|
|
|
63783
63840
|
if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
|
|
63784
63841
|
return -1 /* True */;
|
|
63785
63842
|
}
|
|
63786
|
-
//
|
|
63787
|
-
// If so,
|
|
63788
|
-
|
|
63789
|
-
|
|
63790
|
-
|
|
63791
|
-
|
|
63792
|
-
|
|
63793
|
-
|
|
63794
|
-
|
|
63795
|
-
|
|
63796
|
-
|
|
63797
|
-
|
|
63798
|
-
if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) {
|
|
63799
|
-
target = getNormalizedType(nullStrippedTarget, /*writing*/ true);
|
|
63800
|
-
}
|
|
63801
|
-
if (source === nullStrippedTarget)
|
|
63802
|
-
return -1 /* True */;
|
|
63843
|
+
// See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
|
|
63844
|
+
// plus a single non-nullable type. If so, remove null and/or undefined from the target type.
|
|
63845
|
+
if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
|
|
63846
|
+
var types = target.types;
|
|
63847
|
+
var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
|
|
63848
|
+
types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
|
|
63849
|
+
undefined;
|
|
63850
|
+
if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
|
|
63851
|
+
target = getNormalizedType(candidate, /*writing*/ true);
|
|
63852
|
+
if (source === target)
|
|
63853
|
+
return -1 /* True */;
|
|
63854
|
+
}
|
|
63803
63855
|
}
|
|
63804
63856
|
if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
|
|
63805
63857
|
isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
|
|
63806
63858
|
return -1 /* True */;
|
|
63807
|
-
|
|
63808
|
-
|
|
63809
|
-
|
|
63810
|
-
|
|
63859
|
+
if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
|
|
63860
|
+
var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
|
|
63861
|
+
if (isPerformingExcessPropertyChecks) {
|
|
63862
|
+
if (hasExcessProperties(source, target, reportErrors)) {
|
|
63863
|
+
if (reportErrors) {
|
|
63864
|
+
reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
|
|
63865
|
+
}
|
|
63866
|
+
return 0 /* False */;
|
|
63867
|
+
}
|
|
63868
|
+
}
|
|
63869
|
+
var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
|
|
63870
|
+
source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
|
|
63871
|
+
target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
|
|
63872
|
+
(getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
|
|
63873
|
+
var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
|
|
63874
|
+
if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
|
|
63811
63875
|
if (reportErrors) {
|
|
63812
|
-
|
|
63876
|
+
var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
|
|
63877
|
+
var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
|
|
63878
|
+
var calls = getSignaturesOfType(source, 0 /* Call */);
|
|
63879
|
+
var constructs = getSignaturesOfType(source, 1 /* Construct */);
|
|
63880
|
+
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
|
|
63881
|
+
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
63882
|
+
reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
|
|
63883
|
+
}
|
|
63884
|
+
else {
|
|
63885
|
+
reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
|
|
63886
|
+
}
|
|
63813
63887
|
}
|
|
63814
63888
|
return 0 /* False */;
|
|
63815
63889
|
}
|
|
63816
|
-
|
|
63817
|
-
|
|
63818
|
-
|
|
63819
|
-
|
|
63820
|
-
|
|
63821
|
-
|
|
63822
|
-
|
|
63823
|
-
|
|
63824
|
-
|
|
63825
|
-
|
|
63826
|
-
|
|
63827
|
-
|
|
63828
|
-
|
|
63829
|
-
|
|
63830
|
-
|
|
63831
|
-
|
|
63832
|
-
|
|
63833
|
-
|
|
63890
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63891
|
+
var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
|
|
63892
|
+
target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
|
|
63893
|
+
var result_7 = skipCaching ?
|
|
63894
|
+
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
63895
|
+
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
63896
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
63897
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
63898
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
63899
|
+
//
|
|
63900
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63901
|
+
//
|
|
63902
|
+
// declare let wrong: { a: { y: string } };
|
|
63903
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63904
|
+
//
|
|
63905
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63906
|
+
// x = y; // Mismatched property in source intersection
|
|
63907
|
+
// }
|
|
63908
|
+
//
|
|
63909
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63910
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63911
|
+
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63912
|
+
isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
|
|
63913
|
+
inPropertyCheck = true;
|
|
63914
|
+
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63915
|
+
inPropertyCheck = false;
|
|
63916
|
+
}
|
|
63917
|
+
if (result_7) {
|
|
63918
|
+
return result_7;
|
|
63834
63919
|
}
|
|
63835
|
-
return 0 /* False */;
|
|
63836
|
-
}
|
|
63837
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63838
|
-
var result = 0 /* False */;
|
|
63839
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
63840
|
-
if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
|
|
63841
|
-
// We skip caching when source or target is a union with no more than three constituents.
|
|
63842
|
-
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63843
63920
|
}
|
|
63844
|
-
|
|
63845
|
-
|
|
63921
|
+
if (reportErrors) {
|
|
63922
|
+
reportErrorResults(originalSource, originalTarget, source, target, headMessage);
|
|
63846
63923
|
}
|
|
63847
|
-
|
|
63848
|
-
|
|
63849
|
-
|
|
63924
|
+
return 0 /* False */;
|
|
63925
|
+
}
|
|
63926
|
+
function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
|
|
63927
|
+
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63928
|
+
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63929
|
+
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63930
|
+
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63931
|
+
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63932
|
+
if (maybeSuppress) {
|
|
63933
|
+
overrideNextErrorInfo--;
|
|
63934
|
+
}
|
|
63935
|
+
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63936
|
+
var currentError = errorInfo;
|
|
63937
|
+
tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
|
|
63938
|
+
if (errorInfo !== currentError) {
|
|
63939
|
+
maybeSuppress = !!errorInfo;
|
|
63940
|
+
}
|
|
63941
|
+
}
|
|
63942
|
+
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63943
|
+
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63944
|
+
}
|
|
63945
|
+
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63946
|
+
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63947
|
+
}
|
|
63948
|
+
else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
|
|
63949
|
+
var targetTypes = target.types;
|
|
63950
|
+
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63951
|
+
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63952
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63953
|
+
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63954
|
+
// do not report top error
|
|
63955
|
+
return;
|
|
63850
63956
|
}
|
|
63851
63957
|
}
|
|
63852
|
-
|
|
63853
|
-
|
|
63854
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
63855
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
63856
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
63857
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
63858
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
63859
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
63860
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
63861
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
63862
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
63863
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
63864
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
63865
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
63866
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
63867
|
-
if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
|
|
63868
|
-
if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
63869
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
63870
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63871
|
-
resetErrorInfo(saveErrorInfo);
|
|
63872
|
-
}
|
|
63873
|
-
}
|
|
63874
|
-
}
|
|
63958
|
+
else {
|
|
63959
|
+
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63875
63960
|
}
|
|
63876
|
-
|
|
63877
|
-
|
|
63878
|
-
|
|
63879
|
-
|
|
63880
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63881
|
-
//
|
|
63882
|
-
// declare let wrong: { a: { y: string } };
|
|
63883
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63884
|
-
//
|
|
63885
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63886
|
-
// x = y; // Mismatched property in source intersection
|
|
63887
|
-
// }
|
|
63888
|
-
//
|
|
63889
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63890
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63891
|
-
if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63892
|
-
isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
|
|
63893
|
-
inPropertyCheck = true;
|
|
63894
|
-
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63895
|
-
inPropertyCheck = false;
|
|
63896
|
-
}
|
|
63897
|
-
reportErrorResults(source, target, result, isComparingJsxAttributes);
|
|
63898
|
-
return result;
|
|
63899
|
-
function reportErrorResults(source, target, result, isComparingJsxAttributes) {
|
|
63900
|
-
if (!result && reportErrors) {
|
|
63901
|
-
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63902
|
-
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63903
|
-
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63904
|
-
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63905
|
-
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63906
|
-
if (maybeSuppress) {
|
|
63907
|
-
overrideNextErrorInfo--;
|
|
63908
|
-
}
|
|
63909
|
-
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63910
|
-
var currentError = errorInfo;
|
|
63911
|
-
tryElaborateArrayLikeErrors(source, target, reportErrors);
|
|
63912
|
-
if (errorInfo !== currentError) {
|
|
63913
|
-
maybeSuppress = !!errorInfo;
|
|
63914
|
-
}
|
|
63915
|
-
}
|
|
63916
|
-
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63917
|
-
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63918
|
-
}
|
|
63919
|
-
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63920
|
-
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63921
|
-
}
|
|
63922
|
-
else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) {
|
|
63923
|
-
var targetTypes = target.types;
|
|
63924
|
-
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63925
|
-
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63926
|
-
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63927
|
-
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63928
|
-
// do not report top error
|
|
63929
|
-
return result;
|
|
63930
|
-
}
|
|
63931
|
-
}
|
|
63932
|
-
else {
|
|
63933
|
-
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63934
|
-
}
|
|
63935
|
-
if (!headMessage && maybeSuppress) {
|
|
63936
|
-
lastSkippedInfo = [source, target];
|
|
63937
|
-
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63938
|
-
return result;
|
|
63939
|
-
}
|
|
63940
|
-
reportRelationError(headMessage, source, target);
|
|
63941
|
-
}
|
|
63961
|
+
if (!headMessage && maybeSuppress) {
|
|
63962
|
+
lastSkippedInfo = [source, target];
|
|
63963
|
+
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63964
|
+
return;
|
|
63942
63965
|
}
|
|
63966
|
+
reportRelationError(headMessage, source, target);
|
|
63943
63967
|
}
|
|
63944
63968
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
63945
63969
|
if (!ts.tracing) {
|
|
@@ -63966,21 +63990,6 @@ var ts;
|
|
|
63966
63990
|
}
|
|
63967
63991
|
}
|
|
63968
63992
|
}
|
|
63969
|
-
function isIdenticalTo(source, target, recursionFlags) {
|
|
63970
|
-
if (source.flags !== target.flags)
|
|
63971
|
-
return 0 /* False */;
|
|
63972
|
-
if (source.flags & 67358815 /* Singleton */)
|
|
63973
|
-
return -1 /* True */;
|
|
63974
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63975
|
-
if (source.flags & 3145728 /* UnionOrIntersection */) {
|
|
63976
|
-
var result_7 = eachTypeRelatedToSomeType(source, target);
|
|
63977
|
-
if (result_7) {
|
|
63978
|
-
result_7 &= eachTypeRelatedToSomeType(target, source);
|
|
63979
|
-
}
|
|
63980
|
-
return result_7;
|
|
63981
|
-
}
|
|
63982
|
-
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63983
|
-
}
|
|
63984
63993
|
function getTypeOfPropertyInTypes(types, name) {
|
|
63985
63994
|
var appendPropType = function (propTypes, type) {
|
|
63986
63995
|
var _a;
|
|
@@ -64079,6 +64088,41 @@ var ts;
|
|
|
64079
64088
|
function shouldCheckAsExcessProperty(prop, container) {
|
|
64080
64089
|
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
|
|
64081
64090
|
}
|
|
64091
|
+
function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
|
|
64092
|
+
// Note that these checks are specifically ordered to produce correct results. In particular,
|
|
64093
|
+
// we need to deconstruct unions before intersections (because unions are always at the top),
|
|
64094
|
+
// and we need to handle "each" relations before "some" relations for the same kind of type.
|
|
64095
|
+
if (source.flags & 1048576 /* Union */) {
|
|
64096
|
+
return relation === comparableRelation ?
|
|
64097
|
+
someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
|
|
64098
|
+
eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
|
|
64099
|
+
}
|
|
64100
|
+
if (target.flags & 1048576 /* Union */) {
|
|
64101
|
+
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
64102
|
+
}
|
|
64103
|
+
if (target.flags & 2097152 /* Intersection */) {
|
|
64104
|
+
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
64105
|
+
}
|
|
64106
|
+
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
64107
|
+
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
64108
|
+
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
64109
|
+
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
64110
|
+
// appear to be comparable to '2'.
|
|
64111
|
+
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
64112
|
+
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
64113
|
+
if (constraints !== source.types) {
|
|
64114
|
+
source = getIntersectionType(constraints);
|
|
64115
|
+
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
64116
|
+
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
64117
|
+
}
|
|
64118
|
+
}
|
|
64119
|
+
}
|
|
64120
|
+
// Check to see if any constituents of the intersection are immediately related to the target.
|
|
64121
|
+
// Don't report errors though. Elaborating on whether a source constituent is related to the target is
|
|
64122
|
+
// not actually useful and leads to some confusing error messages. Instead, we rely on the caller
|
|
64123
|
+
// checking whether the full intersection viewed as an object is related to the target.
|
|
64124
|
+
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
64125
|
+
}
|
|
64082
64126
|
function eachTypeRelatedToSomeType(source, target) {
|
|
64083
64127
|
var result = -1 /* True */;
|
|
64084
64128
|
var sourceTypes = source.types;
|
|
@@ -64114,8 +64158,11 @@ var ts;
|
|
|
64114
64158
|
}
|
|
64115
64159
|
}
|
|
64116
64160
|
if (reportErrors) {
|
|
64161
|
+
// Elaborate only if we can find a best matching type in the target union
|
|
64117
64162
|
var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
|
|
64118
|
-
|
|
64163
|
+
if (bestMatchingType) {
|
|
64164
|
+
isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
|
|
64165
|
+
}
|
|
64119
64166
|
}
|
|
64120
64167
|
return 0 /* False */;
|
|
64121
64168
|
}
|
|
@@ -64251,7 +64298,7 @@ var ts;
|
|
|
64251
64298
|
if (overflow) {
|
|
64252
64299
|
return 0 /* False */;
|
|
64253
64300
|
}
|
|
64254
|
-
var keyIntersectionState = intersectionState | (inPropertyCheck ?
|
|
64301
|
+
var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
|
|
64255
64302
|
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
64256
64303
|
var entry = relation.get(id);
|
|
64257
64304
|
if (entry !== undefined) {
|
|
@@ -64319,6 +64366,7 @@ var ts;
|
|
|
64319
64366
|
return originalHandler(onlyUnreliable);
|
|
64320
64367
|
};
|
|
64321
64368
|
}
|
|
64369
|
+
var result;
|
|
64322
64370
|
if (expandingFlags === 3 /* Both */) {
|
|
64323
64371
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
|
|
64324
64372
|
sourceId: source.id,
|
|
@@ -64328,8 +64376,13 @@ var ts;
|
|
|
64328
64376
|
depth: sourceDepth,
|
|
64329
64377
|
targetDepth: targetDepth
|
|
64330
64378
|
});
|
|
64379
|
+
result = 3 /* Maybe */;
|
|
64380
|
+
}
|
|
64381
|
+
else {
|
|
64382
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64383
|
+
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
|
|
64384
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64331
64385
|
}
|
|
64332
|
-
var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
|
|
64333
64386
|
if (outofbandVarianceMarkerHandler) {
|
|
64334
64387
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
64335
64388
|
}
|
|
@@ -64361,98 +64414,97 @@ var ts;
|
|
|
64361
64414
|
return result;
|
|
64362
64415
|
}
|
|
64363
64416
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
64364
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64365
|
-
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
|
|
64366
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64367
|
-
return result;
|
|
64368
|
-
}
|
|
64369
|
-
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
|
|
64370
64417
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
64371
64418
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
64372
64419
|
}
|
|
64373
|
-
|
|
64374
|
-
|
|
64375
|
-
|
|
64376
|
-
|
|
64377
|
-
|
|
64378
|
-
|
|
64379
|
-
|
|
64380
|
-
|
|
64381
|
-
|
|
64382
|
-
|
|
64383
|
-
|
|
64384
|
-
|
|
64385
|
-
if (target.flags & 2097152 /* Intersection */) {
|
|
64386
|
-
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
64387
|
-
}
|
|
64388
|
-
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
64389
|
-
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
64390
|
-
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
64391
|
-
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
64392
|
-
// appear to be comparable to '2'.
|
|
64393
|
-
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
64394
|
-
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
64395
|
-
if (constraints !== source.types) {
|
|
64396
|
-
source = getIntersectionType(constraints);
|
|
64397
|
-
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
64398
|
-
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
64399
|
-
}
|
|
64420
|
+
var result;
|
|
64421
|
+
var originalErrorInfo;
|
|
64422
|
+
var varianceCheckFailed = false;
|
|
64423
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
64424
|
+
var sourceFlags = source.flags;
|
|
64425
|
+
var targetFlags = target.flags;
|
|
64426
|
+
if (relation === identityRelation) {
|
|
64427
|
+
// We've already checked that source.flags and target.flags are identical
|
|
64428
|
+
if (sourceFlags & 3145728 /* UnionOrIntersection */) {
|
|
64429
|
+
var result_8 = eachTypeRelatedToSomeType(source, target);
|
|
64430
|
+
if (result_8) {
|
|
64431
|
+
result_8 &= eachTypeRelatedToSomeType(target, source);
|
|
64400
64432
|
}
|
|
64433
|
+
return result_8;
|
|
64401
64434
|
}
|
|
64402
|
-
|
|
64403
|
-
//
|
|
64404
|
-
// Don't report errors though. Checking whether a constituent is related to the source is not actually
|
|
64405
|
-
// useful and leads to some confusing error messages. Instead it is better to let the below checks
|
|
64406
|
-
// take care of this, or to not elaborate at all. For instance,
|
|
64407
|
-
//
|
|
64408
|
-
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
|
|
64409
|
-
//
|
|
64410
|
-
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
|
|
64411
|
-
// than to report that 'D' is not assignable to 'A' or 'B'.
|
|
64412
|
-
//
|
|
64413
|
-
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
|
|
64414
|
-
// breaking the intersection apart.
|
|
64415
|
-
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
64416
|
-
}
|
|
64417
|
-
var flags = source.flags & target.flags;
|
|
64418
|
-
if (relation === identityRelation && !(flags & 524288 /* Object */)) {
|
|
64419
|
-
if (flags & 4194304 /* Index */) {
|
|
64435
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64420
64436
|
return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
|
|
64421
64437
|
}
|
|
64422
|
-
|
|
64423
|
-
|
|
64424
|
-
|
|
64425
|
-
|
|
64426
|
-
return result_8;
|
|
64438
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64439
|
+
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64440
|
+
if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64441
|
+
return result;
|
|
64427
64442
|
}
|
|
64428
64443
|
}
|
|
64429
64444
|
}
|
|
64430
|
-
if (
|
|
64445
|
+
if (sourceFlags & 16777216 /* Conditional */) {
|
|
64431
64446
|
if (source.root.isDistributive === target.root.isDistributive) {
|
|
64432
|
-
if (
|
|
64433
|
-
if (
|
|
64434
|
-
if (
|
|
64435
|
-
if (
|
|
64436
|
-
return
|
|
64447
|
+
if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64448
|
+
if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64449
|
+
if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64450
|
+
if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64451
|
+
return result;
|
|
64437
64452
|
}
|
|
64438
64453
|
}
|
|
64439
64454
|
}
|
|
64440
64455
|
}
|
|
64441
64456
|
}
|
|
64442
64457
|
}
|
|
64443
|
-
if (
|
|
64458
|
+
if (sourceFlags & 33554432 /* Substitution */) {
|
|
64444
64459
|
return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
|
|
64445
64460
|
}
|
|
64446
|
-
|
|
64461
|
+
if (!(sourceFlags & 524288 /* Object */)) {
|
|
64462
|
+
return 0 /* False */;
|
|
64463
|
+
}
|
|
64464
|
+
}
|
|
64465
|
+
else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
|
|
64466
|
+
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
64467
|
+
return result;
|
|
64468
|
+
}
|
|
64469
|
+
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
64470
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
64471
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
64472
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
64473
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
64474
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
64475
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
64476
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
64477
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
64478
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
64479
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
64480
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
64481
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
64482
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
64483
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
64484
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
64485
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
64486
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
64487
|
+
resetErrorInfo(saveErrorInfo);
|
|
64488
|
+
return result;
|
|
64489
|
+
}
|
|
64490
|
+
}
|
|
64491
|
+
}
|
|
64492
|
+
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
64493
|
+
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
64494
|
+
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64495
|
+
// Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
|
|
64496
|
+
// Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64497
|
+
// Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
|
|
64498
|
+
if (!(sourceFlags & 465829888 /* Instantiable */ ||
|
|
64499
|
+
sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
|
|
64500
|
+
sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
|
|
64501
|
+
return 0 /* False */;
|
|
64502
|
+
}
|
|
64447
64503
|
}
|
|
64448
|
-
var result;
|
|
64449
|
-
var originalErrorInfo;
|
|
64450
|
-
var varianceCheckFailed = false;
|
|
64451
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
64452
64504
|
// We limit alias variance probing to only object and conditional types since their alias behavior
|
|
64453
64505
|
// is more predictable than other, interned types, which may or may not have an alias depending on
|
|
64454
64506
|
// the order in which things were checked.
|
|
64455
|
-
if (
|
|
64507
|
+
if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
|
|
64456
64508
|
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
|
|
64457
64509
|
!(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
|
|
64458
64510
|
var variances = getAliasVariances(source.aliasSymbol);
|
|
@@ -64470,7 +64522,7 @@ var ts;
|
|
|
64470
64522
|
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
|
|
64471
64523
|
return result;
|
|
64472
64524
|
}
|
|
64473
|
-
if (
|
|
64525
|
+
if (targetFlags & 262144 /* TypeParameter */) {
|
|
64474
64526
|
// A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q].
|
|
64475
64527
|
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
|
|
64476
64528
|
if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
|
|
@@ -64482,10 +64534,10 @@ var ts;
|
|
|
64482
64534
|
}
|
|
64483
64535
|
}
|
|
64484
64536
|
}
|
|
64485
|
-
else if (
|
|
64537
|
+
else if (targetFlags & 4194304 /* Index */) {
|
|
64486
64538
|
var targetType_1 = target.type;
|
|
64487
64539
|
// A keyof S is related to a keyof T if T is related to S.
|
|
64488
|
-
if (
|
|
64540
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64489
64541
|
if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64490
64542
|
return result;
|
|
64491
64543
|
}
|
|
@@ -64536,8 +64588,8 @@ var ts;
|
|
|
64536
64588
|
}
|
|
64537
64589
|
}
|
|
64538
64590
|
}
|
|
64539
|
-
else if (
|
|
64540
|
-
if (
|
|
64591
|
+
else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
64592
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64541
64593
|
// Relate components directly before falling back to constraint relationships
|
|
64542
64594
|
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
|
|
64543
64595
|
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
|
|
@@ -64643,7 +64695,7 @@ var ts;
|
|
|
64643
64695
|
}
|
|
64644
64696
|
}
|
|
64645
64697
|
}
|
|
64646
|
-
else if (
|
|
64698
|
+
else if (targetFlags & 16777216 /* Conditional */) {
|
|
64647
64699
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64648
64700
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64649
64701
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
@@ -64668,8 +64720,8 @@ var ts;
|
|
|
64668
64720
|
}
|
|
64669
64721
|
}
|
|
64670
64722
|
}
|
|
64671
|
-
else if (
|
|
64672
|
-
if (
|
|
64723
|
+
else if (targetFlags & 134217728 /* TemplateLiteral */) {
|
|
64724
|
+
if (sourceFlags & 134217728 /* TemplateLiteral */) {
|
|
64673
64725
|
if (relation === comparableRelation) {
|
|
64674
64726
|
return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
|
|
64675
64727
|
}
|
|
@@ -64681,11 +64733,11 @@ var ts;
|
|
|
64681
64733
|
return -1 /* True */;
|
|
64682
64734
|
}
|
|
64683
64735
|
}
|
|
64684
|
-
if (
|
|
64685
|
-
// IndexedAccess comparisons are handled above in the `
|
|
64686
|
-
if (!(
|
|
64736
|
+
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
64737
|
+
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
64738
|
+
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
64687
64739
|
var constraint = getConstraintOfType(source);
|
|
64688
|
-
if (!constraint || (
|
|
64740
|
+
if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
64689
64741
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
64690
64742
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
64691
64743
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64698,7 +64750,7 @@ var ts;
|
|
|
64698
64750
|
return result;
|
|
64699
64751
|
}
|
|
64700
64752
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
64701
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(
|
|
64753
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
64702
64754
|
resetErrorInfo(saveErrorInfo);
|
|
64703
64755
|
return result;
|
|
64704
64756
|
}
|
|
@@ -64715,14 +64767,14 @@ var ts;
|
|
|
64715
64767
|
}
|
|
64716
64768
|
}
|
|
64717
64769
|
}
|
|
64718
|
-
else if (
|
|
64770
|
+
else if (sourceFlags & 4194304 /* Index */) {
|
|
64719
64771
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
64720
64772
|
resetErrorInfo(saveErrorInfo);
|
|
64721
64773
|
return result;
|
|
64722
64774
|
}
|
|
64723
64775
|
}
|
|
64724
|
-
else if (
|
|
64725
|
-
if (!(
|
|
64776
|
+
else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
64777
|
+
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
64726
64778
|
var constraint = getBaseConstraintOfType(source);
|
|
64727
64779
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
64728
64780
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64730,8 +64782,8 @@ var ts;
|
|
|
64730
64782
|
}
|
|
64731
64783
|
}
|
|
64732
64784
|
}
|
|
64733
|
-
else if (
|
|
64734
|
-
if (
|
|
64785
|
+
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
64786
|
+
if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
|
|
64735
64787
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
64736
64788
|
resetErrorInfo(saveErrorInfo);
|
|
64737
64789
|
return result;
|
|
@@ -64745,14 +64797,14 @@ var ts;
|
|
|
64745
64797
|
}
|
|
64746
64798
|
}
|
|
64747
64799
|
}
|
|
64748
|
-
else if (
|
|
64800
|
+
else if (sourceFlags & 16777216 /* Conditional */) {
|
|
64749
64801
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64750
64802
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64751
64803
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
64752
64804
|
resetErrorInfo(saveErrorInfo);
|
|
64753
64805
|
return 3 /* Maybe */;
|
|
64754
64806
|
}
|
|
64755
|
-
if (
|
|
64807
|
+
if (targetFlags & 16777216 /* Conditional */) {
|
|
64756
64808
|
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
|
|
64757
64809
|
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
|
|
64758
64810
|
// and Y1 is related to Y2.
|
|
@@ -64812,9 +64864,10 @@ var ts;
|
|
|
64812
64864
|
}
|
|
64813
64865
|
return 0 /* False */;
|
|
64814
64866
|
}
|
|
64815
|
-
var sourceIsPrimitive = !!(
|
|
64867
|
+
var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
|
|
64816
64868
|
if (relation !== identityRelation) {
|
|
64817
64869
|
source = getApparentType(source);
|
|
64870
|
+
sourceFlags = source.flags;
|
|
64818
64871
|
}
|
|
64819
64872
|
else if (isGenericMappedType(source)) {
|
|
64820
64873
|
return 0 /* False */;
|
|
@@ -64861,7 +64914,7 @@ var ts;
|
|
|
64861
64914
|
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
|
|
64862
64915
|
// to X. Failing both of those we want to check if the aggregation of A and B's members structurally
|
|
64863
64916
|
// relates to X. Thus, we include intersection types on the source side here.
|
|
64864
|
-
if (
|
|
64917
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
|
|
64865
64918
|
// Report structural errors only if we haven't reported any errors yet
|
|
64866
64919
|
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
|
|
64867
64920
|
result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
|
|
@@ -64885,7 +64938,7 @@ var ts;
|
|
|
64885
64938
|
// there exists a constituent of T for every combination of the discriminants of S
|
|
64886
64939
|
// with respect to T. We do not report errors here, as we will use the existing
|
|
64887
64940
|
// error result from checking each constituent of the union.
|
|
64888
|
-
if (
|
|
64941
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
|
|
64889
64942
|
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
|
|
64890
64943
|
if (objectOnlyTarget.flags & 1048576 /* Union */) {
|
|
64891
64944
|
var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
|
|
@@ -65409,7 +65462,6 @@ var ts;
|
|
|
65409
65462
|
}
|
|
65410
65463
|
}
|
|
65411
65464
|
var result = -1 /* True */;
|
|
65412
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
65413
65465
|
var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
|
|
65414
65466
|
var sourceObjectFlags = ts.getObjectFlags(source);
|
|
65415
65467
|
var targetObjectFlags = ts.getObjectFlags(target);
|
|
@@ -65450,6 +65502,7 @@ var ts;
|
|
|
65450
65502
|
else {
|
|
65451
65503
|
outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
|
|
65452
65504
|
var t = targetSignatures_1[_i];
|
|
65505
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
65453
65506
|
// Only elaborate errors from the first failure
|
|
65454
65507
|
var shouldElaborateErrors = reportErrors;
|
|
65455
65508
|
for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
|
|
@@ -65560,8 +65613,8 @@ var ts;
|
|
|
65560
65613
|
var indexInfos = getIndexInfosOfType(target);
|
|
65561
65614
|
var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; });
|
|
65562
65615
|
var result = -1 /* True */;
|
|
65563
|
-
for (var _i = 0,
|
|
65564
|
-
var targetInfo =
|
|
65616
|
+
for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) {
|
|
65617
|
+
var targetInfo = indexInfos_5[_i];
|
|
65565
65618
|
var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
|
|
65566
65619
|
isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
|
|
65567
65620
|
typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
|
|
@@ -66168,10 +66221,10 @@ var ts;
|
|
|
66168
66221
|
if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
66169
66222
|
return undefined;
|
|
66170
66223
|
}
|
|
66171
|
-
if (ts.getObjectFlags(type) &
|
|
66172
|
-
return ts.getObjectFlags(type) &
|
|
66224
|
+
if (ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeCalculated */) {
|
|
66225
|
+
return ts.getObjectFlags(type) & 134217728 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined;
|
|
66173
66226
|
}
|
|
66174
|
-
type.objectFlags |=
|
|
66227
|
+
type.objectFlags |= 67108864 /* IdenticalBaseTypeCalculated */;
|
|
66175
66228
|
var target = type.target;
|
|
66176
66229
|
if (ts.getObjectFlags(target) & 1 /* Class */) {
|
|
66177
66230
|
var baseTypeNode = getBaseTypeNodeOfClass(target);
|
|
@@ -66192,7 +66245,7 @@ var ts;
|
|
|
66192
66245
|
if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) {
|
|
66193
66246
|
instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type)));
|
|
66194
66247
|
}
|
|
66195
|
-
type.objectFlags |=
|
|
66248
|
+
type.objectFlags |= 134217728 /* IdenticalBaseTypeExists */;
|
|
66196
66249
|
return type.cachedEquivalentBaseType = instantiatedBase;
|
|
66197
66250
|
}
|
|
66198
66251
|
function isEmptyLiteralType(type) {
|
|
@@ -66856,7 +66909,7 @@ var ts;
|
|
|
66856
66909
|
var result = !!(type.flags & 465829888 /* Instantiable */ ||
|
|
66857
66910
|
type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
|
|
66858
66911
|
objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations ||
|
|
66859
|
-
objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) ||
|
|
66912
|
+
objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */ | 16777216 /* InstantiationExpressionType */)) ||
|
|
66860
66913
|
type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
|
|
66861
66914
|
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
66862
66915
|
type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0);
|
|
@@ -67773,8 +67826,8 @@ var ts;
|
|
|
67773
67826
|
var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0;
|
|
67774
67827
|
var indexInfos = getIndexInfosOfType(target);
|
|
67775
67828
|
if (isObjectTypeWithInferableIndex(source)) {
|
|
67776
|
-
for (var _i = 0,
|
|
67777
|
-
var targetInfo =
|
|
67829
|
+
for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) {
|
|
67830
|
+
var targetInfo = indexInfos_6[_i];
|
|
67778
67831
|
var propTypes = [];
|
|
67779
67832
|
for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) {
|
|
67780
67833
|
var prop = _b[_a];
|
|
@@ -67794,8 +67847,8 @@ var ts;
|
|
|
67794
67847
|
}
|
|
67795
67848
|
}
|
|
67796
67849
|
}
|
|
67797
|
-
for (var _e = 0,
|
|
67798
|
-
var targetInfo =
|
|
67850
|
+
for (var _e = 0, indexInfos_7 = indexInfos; _e < indexInfos_7.length; _e++) {
|
|
67851
|
+
var targetInfo = indexInfos_7[_e];
|
|
67799
67852
|
var sourceInfo = getApplicableIndexInfo(source, targetInfo.keyType);
|
|
67800
67853
|
if (sourceInfo) {
|
|
67801
67854
|
inferWithPriority(sourceInfo.type, targetInfo.type, priority);
|
|
@@ -68620,9 +68673,6 @@ var ts;
|
|
|
68620
68673
|
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
|
|
68621
68674
|
mapType(type, mapper);
|
|
68622
68675
|
}
|
|
68623
|
-
function getConstituentCount(type) {
|
|
68624
|
-
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
68625
|
-
}
|
|
68626
68676
|
function extractTypesOfKind(type, kind) {
|
|
68627
68677
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
68628
68678
|
}
|
|
@@ -70196,7 +70246,7 @@ var ts;
|
|
|
70196
70246
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
70197
70247
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
70198
70248
|
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
70199
|
-
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */
|
|
70249
|
+
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
|
|
70200
70250
|
}
|
|
70201
70251
|
function isExportOrExportExpression(location) {
|
|
70202
70252
|
return !!ts.findAncestor(location, function (n) {
|
|
@@ -73343,6 +73393,9 @@ var ts;
|
|
|
73343
73393
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
73344
73394
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
73345
73395
|
}
|
|
73396
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
|
|
73397
|
+
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
73398
|
+
}
|
|
73346
73399
|
}
|
|
73347
73400
|
else {
|
|
73348
73401
|
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
|
|
@@ -75959,6 +76012,72 @@ var ts;
|
|
|
75959
76012
|
return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) :
|
|
75960
76013
|
getNonNullableType(checkExpression(node.expression));
|
|
75961
76014
|
}
|
|
76015
|
+
function checkExpressionWithTypeArguments(node) {
|
|
76016
|
+
checkGrammarExpressionWithTypeArguments(node);
|
|
76017
|
+
var exprType = node.kind === 227 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) :
|
|
76018
|
+
ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
|
|
76019
|
+
checkExpression(node.exprName);
|
|
76020
|
+
var typeArguments = node.typeArguments;
|
|
76021
|
+
if (exprType === silentNeverType || isErrorType(exprType) || !ts.some(typeArguments)) {
|
|
76022
|
+
return exprType;
|
|
76023
|
+
}
|
|
76024
|
+
var hasSomeApplicableSignature = false;
|
|
76025
|
+
var nonApplicableType;
|
|
76026
|
+
var result = getInstantiatedType(exprType);
|
|
76027
|
+
var errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
|
|
76028
|
+
if (errorType) {
|
|
76029
|
+
diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType)));
|
|
76030
|
+
}
|
|
76031
|
+
return result;
|
|
76032
|
+
function getInstantiatedType(type) {
|
|
76033
|
+
var hasSignatures = false;
|
|
76034
|
+
var hasApplicableSignature = false;
|
|
76035
|
+
var result = getInstantiatedTypePart(type);
|
|
76036
|
+
hasSomeApplicableSignature || (hasSomeApplicableSignature = hasApplicableSignature);
|
|
76037
|
+
if (hasSignatures && !hasApplicableSignature) {
|
|
76038
|
+
nonApplicableType !== null && nonApplicableType !== void 0 ? nonApplicableType : (nonApplicableType = type);
|
|
76039
|
+
}
|
|
76040
|
+
return result;
|
|
76041
|
+
function getInstantiatedTypePart(type) {
|
|
76042
|
+
if (type.flags & 524288 /* Object */) {
|
|
76043
|
+
var resolved = resolveStructuredTypeMembers(type);
|
|
76044
|
+
var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
|
|
76045
|
+
var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
|
|
76046
|
+
hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
|
|
76047
|
+
hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
|
|
76048
|
+
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
|
|
76049
|
+
var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
|
|
76050
|
+
result_11.objectFlags |= 16777216 /* InstantiationExpressionType */;
|
|
76051
|
+
result_11.node = node;
|
|
76052
|
+
return result_11;
|
|
76053
|
+
}
|
|
76054
|
+
}
|
|
76055
|
+
else if (type.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
76056
|
+
var constraint = getBaseConstraintOfType(type);
|
|
76057
|
+
if (constraint) {
|
|
76058
|
+
var instantiated = getInstantiatedTypePart(constraint);
|
|
76059
|
+
if (instantiated !== constraint) {
|
|
76060
|
+
return instantiated;
|
|
76061
|
+
}
|
|
76062
|
+
}
|
|
76063
|
+
}
|
|
76064
|
+
else if (type.flags & 1048576 /* Union */) {
|
|
76065
|
+
return mapType(type, getInstantiatedType);
|
|
76066
|
+
}
|
|
76067
|
+
else if (type.flags & 2097152 /* Intersection */) {
|
|
76068
|
+
return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart));
|
|
76069
|
+
}
|
|
76070
|
+
return type;
|
|
76071
|
+
}
|
|
76072
|
+
}
|
|
76073
|
+
function getInstantiatedSignatures(signatures) {
|
|
76074
|
+
var applicableSignatures = ts.filter(signatures, function (sig) { return !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments); });
|
|
76075
|
+
return ts.sameMap(applicableSignatures, function (sig) {
|
|
76076
|
+
var typeArgumentTypes = checkTypeArguments(sig, typeArguments, /*reportErrors*/ true);
|
|
76077
|
+
return typeArgumentTypes ? getSignatureInstantiation(sig, typeArgumentTypes, ts.isInJSFile(sig.declaration)) : sig;
|
|
76078
|
+
});
|
|
76079
|
+
}
|
|
76080
|
+
}
|
|
75962
76081
|
function checkMetaProperty(node) {
|
|
75963
76082
|
checkGrammarMetaProperty(node);
|
|
75964
76083
|
if (node.keywordToken === 103 /* NewKeyword */) {
|
|
@@ -76288,21 +76407,22 @@ var ts;
|
|
|
76288
76407
|
if (links.type === unknownType) {
|
|
76289
76408
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
76290
76409
|
}
|
|
76291
|
-
assignBindingElementTypes(declaration.name);
|
|
76410
|
+
assignBindingElementTypes(declaration.name, links.type);
|
|
76292
76411
|
}
|
|
76293
76412
|
}
|
|
76294
76413
|
}
|
|
76295
76414
|
// When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
|
|
76296
76415
|
// the destructured type into the contained binding elements.
|
|
76297
|
-
function assignBindingElementTypes(pattern) {
|
|
76416
|
+
function assignBindingElementTypes(pattern, parentType) {
|
|
76298
76417
|
for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
|
|
76299
76418
|
var element = _a[_i];
|
|
76300
76419
|
if (!ts.isOmittedExpression(element)) {
|
|
76420
|
+
var type = getBindingElementTypeFromParentType(element, parentType);
|
|
76301
76421
|
if (element.name.kind === 79 /* Identifier */) {
|
|
76302
|
-
getSymbolLinks(getSymbolOfNode(element)).type =
|
|
76422
|
+
getSymbolLinks(getSymbolOfNode(element)).type = type;
|
|
76303
76423
|
}
|
|
76304
76424
|
else {
|
|
76305
|
-
assignBindingElementTypes(element.name);
|
|
76425
|
+
assignBindingElementTypes(element.name, type);
|
|
76306
76426
|
}
|
|
76307
76427
|
}
|
|
76308
76428
|
}
|
|
@@ -77447,7 +77567,7 @@ var ts;
|
|
|
77447
77567
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
77448
77568
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
77449
77569
|
var parent = ts.walkUpParenthesizedExpressions(node.parent);
|
|
77450
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.left,
|
|
77570
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
77451
77571
|
}
|
|
77452
77572
|
checkTruthinessOfType(leftType, node.left);
|
|
77453
77573
|
}
|
|
@@ -77954,8 +78074,8 @@ var ts;
|
|
|
77954
78074
|
return type;
|
|
77955
78075
|
}
|
|
77956
78076
|
function checkConditionalExpression(node, checkMode) {
|
|
77957
|
-
|
|
77958
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.condition,
|
|
78077
|
+
checkTruthinessExpression(node.condition);
|
|
78078
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue);
|
|
77959
78079
|
var type1 = checkExpression(node.whenTrue, checkMode);
|
|
77960
78080
|
var type2 = checkExpression(node.whenFalse, checkMode);
|
|
77961
78081
|
return getUnionType([type1, type2], 2 /* Subtype */);
|
|
@@ -78474,6 +78594,8 @@ var ts;
|
|
|
78474
78594
|
return checkAssertion(node);
|
|
78475
78595
|
case 229 /* NonNullExpression */:
|
|
78476
78596
|
return checkNonNullAssertion(node);
|
|
78597
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
78598
|
+
return checkExpressionWithTypeArguments(node);
|
|
78477
78599
|
case 230 /* MetaProperty */:
|
|
78478
78600
|
return checkMetaProperty(node);
|
|
78479
78601
|
case 214 /* DeleteExpression */:
|
|
@@ -79677,12 +79799,12 @@ var ts;
|
|
|
79677
79799
|
case 264 /* ImportEqualsDeclaration */:
|
|
79678
79800
|
case 267 /* NamespaceImport */:
|
|
79679
79801
|
case 266 /* ImportClause */:
|
|
79680
|
-
var
|
|
79802
|
+
var result_12 = 0 /* None */;
|
|
79681
79803
|
var target = resolveAlias(getSymbolOfNode(d));
|
|
79682
79804
|
ts.forEach(target.declarations, function (d) {
|
|
79683
|
-
|
|
79805
|
+
result_12 |= getDeclarationSpaces(d);
|
|
79684
79806
|
});
|
|
79685
|
-
return
|
|
79807
|
+
return result_12;
|
|
79686
79808
|
case 253 /* VariableDeclaration */:
|
|
79687
79809
|
case 202 /* BindingElement */:
|
|
79688
79810
|
case 255 /* FunctionDeclaration */:
|
|
@@ -80043,28 +80165,24 @@ var ts;
|
|
|
80043
80165
|
if (returnType.flags & 1 /* Any */) {
|
|
80044
80166
|
return;
|
|
80045
80167
|
}
|
|
80168
|
+
var headMessage;
|
|
80046
80169
|
var expectedReturnType;
|
|
80047
|
-
var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
|
80048
|
-
var errorInfo;
|
|
80049
80170
|
switch (node.parent.kind) {
|
|
80050
80171
|
case 256 /* ClassDeclaration */:
|
|
80172
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
80051
80173
|
var classSymbol = getSymbolOfNode(node.parent);
|
|
80052
80174
|
var classConstructorType = getTypeOfSymbol(classSymbol);
|
|
80053
80175
|
expectedReturnType = getUnionType([classConstructorType, voidType]);
|
|
80054
80176
|
break;
|
|
80177
|
+
case 166 /* PropertyDeclaration */:
|
|
80055
80178
|
case 163 /* Parameter */:
|
|
80179
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
|
|
80056
80180
|
expectedReturnType = voidType;
|
|
80057
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
80058
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
|
|
80059
|
-
break;
|
|
80060
|
-
case 166 /* PropertyDeclaration */:
|
|
80061
|
-
expectedReturnType = voidType;
|
|
80062
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
80063
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
|
|
80064
80181
|
break;
|
|
80065
80182
|
case 168 /* MethodDeclaration */:
|
|
80066
80183
|
case 171 /* GetAccessor */:
|
|
80067
80184
|
case 172 /* SetAccessor */:
|
|
80185
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
80068
80186
|
var methodType = getTypeOfNode(node.parent);
|
|
80069
80187
|
var descriptorType = createTypedPropertyDescriptorType(methodType);
|
|
80070
80188
|
expectedReturnType = getUnionType([descriptorType, voidType]);
|
|
@@ -80072,7 +80190,7 @@ var ts;
|
|
|
80072
80190
|
default:
|
|
80073
80191
|
return ts.Debug.fail();
|
|
80074
80192
|
}
|
|
80075
|
-
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage
|
|
80193
|
+
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
|
|
80076
80194
|
}
|
|
80077
80195
|
/**
|
|
80078
80196
|
* If a TypeNode can be resolved to a value symbol imported from an external module, it is
|
|
@@ -81113,50 +81231,59 @@ var ts;
|
|
|
81113
81231
|
function checkIfStatement(node) {
|
|
81114
81232
|
// Grammar checking
|
|
81115
81233
|
checkGrammarStatementInAmbientContext(node);
|
|
81116
|
-
|
|
81117
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.expression,
|
|
81234
|
+
checkTruthinessExpression(node.expression);
|
|
81235
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement);
|
|
81118
81236
|
checkSourceElement(node.thenStatement);
|
|
81119
81237
|
if (node.thenStatement.kind === 235 /* EmptyStatement */) {
|
|
81120
81238
|
error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
|
|
81121
81239
|
}
|
|
81122
81240
|
checkSourceElement(node.elseStatement);
|
|
81123
81241
|
}
|
|
81124
|
-
function checkTestingKnownTruthyCallableOrAwaitableType(condExpr,
|
|
81242
|
+
function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, body) {
|
|
81125
81243
|
if (!strictNullChecks)
|
|
81126
81244
|
return;
|
|
81127
|
-
|
|
81128
|
-
|
|
81129
|
-
|
|
81130
|
-
|
|
81131
|
-
|
|
81132
|
-
|
|
81133
|
-
|
|
81134
|
-
|
|
81135
|
-
|
|
81136
|
-
|
|
81137
|
-
|
|
81138
|
-
|
|
81139
|
-
|
|
81140
|
-
|
|
81141
|
-
|
|
81142
|
-
|
|
81143
|
-
|
|
81144
|
-
|
|
81145
|
-
|
|
81146
|
-
|
|
81147
|
-
|
|
81148
|
-
|
|
81149
|
-
|
|
81150
|
-
}
|
|
81151
|
-
var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|
|
81152
|
-
|| testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
|
|
81153
|
-
if (!isUsed) {
|
|
81154
|
-
if (isPromise) {
|
|
81155
|
-
errorAndMaybeSuggestAwait(location,
|
|
81156
|
-
/*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
|
|
81245
|
+
helper(condExpr, body);
|
|
81246
|
+
while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) {
|
|
81247
|
+
condExpr = condExpr.left;
|
|
81248
|
+
helper(condExpr, body);
|
|
81249
|
+
}
|
|
81250
|
+
function helper(condExpr, body) {
|
|
81251
|
+
var location = ts.isBinaryExpression(condExpr) &&
|
|
81252
|
+
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
81253
|
+
? condExpr.right
|
|
81254
|
+
: condExpr;
|
|
81255
|
+
var type = checkTruthinessExpression(location);
|
|
81256
|
+
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
81257
|
+
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
81258
|
+
return;
|
|
81259
|
+
// While it technically should be invalid for any known-truthy value
|
|
81260
|
+
// to be tested, we de-scope to functions and Promises unreferenced in
|
|
81261
|
+
// the block as a heuristic to identify the most common bugs. There
|
|
81262
|
+
// are too many false positives for values sourced from type
|
|
81263
|
+
// definitions without strictNullChecks otherwise.
|
|
81264
|
+
var callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
81265
|
+
var isPromise = !!getAwaitedTypeOfPromise(type);
|
|
81266
|
+
if (callSignatures.length === 0 && !isPromise) {
|
|
81267
|
+
return;
|
|
81157
81268
|
}
|
|
81158
|
-
|
|
81159
|
-
|
|
81269
|
+
var testedNode = ts.isIdentifier(location) ? location
|
|
81270
|
+
: ts.isPropertyAccessExpression(location) ? location.name
|
|
81271
|
+
: ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
|
|
81272
|
+
: undefined;
|
|
81273
|
+
var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
|
|
81274
|
+
if (!testedSymbol && !isPromise) {
|
|
81275
|
+
return;
|
|
81276
|
+
}
|
|
81277
|
+
var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|
|
81278
|
+
|| testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
|
|
81279
|
+
if (!isUsed) {
|
|
81280
|
+
if (isPromise) {
|
|
81281
|
+
errorAndMaybeSuggestAwait(location,
|
|
81282
|
+
/*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
|
|
81283
|
+
}
|
|
81284
|
+
else {
|
|
81285
|
+
error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
|
|
81286
|
+
}
|
|
81160
81287
|
}
|
|
81161
81288
|
}
|
|
81162
81289
|
}
|
|
@@ -82245,8 +82372,8 @@ var ts;
|
|
|
82245
82372
|
}
|
|
82246
82373
|
}
|
|
82247
82374
|
if (indexInfos.length > 1) {
|
|
82248
|
-
for (var _d = 0,
|
|
82249
|
-
var info =
|
|
82375
|
+
for (var _d = 0, indexInfos_8 = indexInfos; _d < indexInfos_8.length; _d++) {
|
|
82376
|
+
var info = indexInfos_8[_d];
|
|
82250
82377
|
checkIndexConstraintForIndexSignature(type, info);
|
|
82251
82378
|
}
|
|
82252
82379
|
}
|
|
@@ -82272,8 +82399,8 @@ var ts;
|
|
|
82272
82399
|
error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
|
|
82273
82400
|
}
|
|
82274
82401
|
};
|
|
82275
|
-
for (var _i = 0,
|
|
82276
|
-
var info =
|
|
82402
|
+
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
82403
|
+
var info = indexInfos_9[_i];
|
|
82277
82404
|
_loop_27(info);
|
|
82278
82405
|
}
|
|
82279
82406
|
}
|
|
@@ -82295,8 +82422,8 @@ var ts;
|
|
|
82295
82422
|
error(errorNode, ts.Diagnostics._0_index_type_1_is_not_assignable_to_2_index_type_3, typeToString(checkInfo.keyType), typeToString(checkInfo.type), typeToString(info.keyType), typeToString(info.type));
|
|
82296
82423
|
}
|
|
82297
82424
|
};
|
|
82298
|
-
for (var _i = 0,
|
|
82299
|
-
var info =
|
|
82425
|
+
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
82426
|
+
var info = indexInfos_10[_i];
|
|
82300
82427
|
_loop_28(info);
|
|
82301
82428
|
}
|
|
82302
82429
|
}
|
|
@@ -82345,9 +82472,9 @@ var ts;
|
|
|
82345
82472
|
var containsArguments = containsArgumentsReference(node);
|
|
82346
82473
|
if (containsArguments) {
|
|
82347
82474
|
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82348
|
-
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82475
|
+
if (isJs && lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82349
82476
|
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82350
|
-
|
|
82477
|
+
error(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));
|
|
82351
82478
|
}
|
|
82352
82479
|
}
|
|
82353
82480
|
else {
|
|
@@ -82357,7 +82484,9 @@ var ts;
|
|
|
82357
82484
|
return;
|
|
82358
82485
|
}
|
|
82359
82486
|
if (ts.isQualifiedName(name)) {
|
|
82360
|
-
|
|
82487
|
+
if (isJs) {
|
|
82488
|
+
error(name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82489
|
+
}
|
|
82361
82490
|
}
|
|
82362
82491
|
else {
|
|
82363
82492
|
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
@@ -83950,10 +84079,10 @@ var ts;
|
|
|
83950
84079
|
}
|
|
83951
84080
|
// ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
|
|
83952
84081
|
// (TS Exceptions: namespaces, function overloads, enums, and interfaces)
|
|
83953
|
-
if (flags & (1920 /* Namespace */ |
|
|
84082
|
+
if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
|
|
83954
84083
|
return;
|
|
83955
84084
|
}
|
|
83956
|
-
var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
|
|
84085
|
+
var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
|
|
83957
84086
|
if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
|
|
83958
84087
|
// it is legal to merge type alias with other values
|
|
83959
84088
|
// so count should be either 1 (just type alias) or 2 (type alias + merged value)
|
|
@@ -85620,7 +85749,7 @@ var ts;
|
|
|
85620
85749
|
if (resolvedTypeReferenceDirectives) {
|
|
85621
85750
|
// populate reverse mapping: file path -> type reference directive that was resolved to this file
|
|
85622
85751
|
fileToDirective = new ts.Map();
|
|
85623
|
-
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
|
|
85752
|
+
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
|
|
85624
85753
|
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
|
|
85625
85754
|
return;
|
|
85626
85755
|
}
|
|
@@ -85628,7 +85757,7 @@ var ts;
|
|
|
85628
85757
|
if (file) {
|
|
85629
85758
|
// Add the transitive closure of path references loaded by this file (as long as they are not)
|
|
85630
85759
|
// part of an existing type reference.
|
|
85631
|
-
addReferencedFilesToTypeDirective(file, key);
|
|
85760
|
+
addReferencedFilesToTypeDirective(file, key, mode);
|
|
85632
85761
|
}
|
|
85633
85762
|
});
|
|
85634
85763
|
}
|
|
@@ -85822,16 +85951,16 @@ var ts;
|
|
|
85822
85951
|
}
|
|
85823
85952
|
return false;
|
|
85824
85953
|
}
|
|
85825
|
-
function addReferencedFilesToTypeDirective(file, key) {
|
|
85954
|
+
function addReferencedFilesToTypeDirective(file, key, mode) {
|
|
85826
85955
|
if (fileToDirective.has(file.path))
|
|
85827
85956
|
return;
|
|
85828
|
-
fileToDirective.set(file.path, key);
|
|
85957
|
+
fileToDirective.set(file.path, [key, mode]);
|
|
85829
85958
|
for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
|
|
85830
|
-
var
|
|
85959
|
+
var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
|
|
85831
85960
|
var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
|
|
85832
85961
|
var referencedFile = host.getSourceFile(resolvedFile);
|
|
85833
85962
|
if (referencedFile) {
|
|
85834
|
-
addReferencedFilesToTypeDirective(referencedFile, key);
|
|
85963
|
+
addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
|
|
85835
85964
|
}
|
|
85836
85965
|
}
|
|
85837
85966
|
}
|
|
@@ -87536,28 +87665,27 @@ var ts;
|
|
|
87536
87665
|
}
|
|
87537
87666
|
function findMostOverlappyType(source, unionTarget) {
|
|
87538
87667
|
var bestMatch;
|
|
87539
|
-
|
|
87540
|
-
|
|
87541
|
-
var
|
|
87542
|
-
|
|
87543
|
-
|
|
87544
|
-
|
|
87545
|
-
|
|
87546
|
-
|
|
87547
|
-
|
|
87548
|
-
|
|
87549
|
-
|
|
87550
|
-
|
|
87551
|
-
|
|
87552
|
-
|
|
87553
|
-
|
|
87554
|
-
|
|
87555
|
-
|
|
87556
|
-
|
|
87557
|
-
|
|
87558
|
-
|
|
87559
|
-
|
|
87560
|
-
matchingCount = 1;
|
|
87668
|
+
if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87669
|
+
var matchingCount = 0;
|
|
87670
|
+
for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
|
|
87671
|
+
var target = _a[_i];
|
|
87672
|
+
if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87673
|
+
var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
|
|
87674
|
+
if (overlap.flags & 4194304 /* Index */) {
|
|
87675
|
+
// perfect overlap of keys
|
|
87676
|
+
return target;
|
|
87677
|
+
}
|
|
87678
|
+
else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
|
|
87679
|
+
// We only want to account for literal types otherwise.
|
|
87680
|
+
// If we have a union of index types, it seems likely that we
|
|
87681
|
+
// needed to elaborate between two generic mapped types anyway.
|
|
87682
|
+
var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
|
|
87683
|
+
if (len >= matchingCount) {
|
|
87684
|
+
bestMatch = target;
|
|
87685
|
+
matchingCount = len;
|
|
87686
|
+
}
|
|
87687
|
+
}
|
|
87688
|
+
}
|
|
87561
87689
|
}
|
|
87562
87690
|
}
|
|
87563
87691
|
return bestMatch;
|
|
@@ -87930,7 +88058,7 @@ var ts;
|
|
|
87930
88058
|
return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
87931
88059
|
case 180 /* TypeQuery */:
|
|
87932
88060
|
ts.Debug.type(node);
|
|
87933
|
-
return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName));
|
|
88061
|
+
return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
|
|
87934
88062
|
case 181 /* TypeLiteral */:
|
|
87935
88063
|
ts.Debug.type(node);
|
|
87936
88064
|
return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
|
|
@@ -90822,8 +90950,8 @@ var ts;
|
|
|
90822
90950
|
function generateClassElementDecorationExpressions(node, isStatic) {
|
|
90823
90951
|
var members = getDecoratedClassElements(node, isStatic);
|
|
90824
90952
|
var expressions;
|
|
90825
|
-
for (var _i = 0,
|
|
90826
|
-
var member =
|
|
90953
|
+
for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
|
|
90954
|
+
var member = members_8[_i];
|
|
90827
90955
|
var expression = generateClassElementDecorationExpression(node, member);
|
|
90828
90956
|
if (expression) {
|
|
90829
90957
|
if (!expressions) {
|
|
@@ -96168,8 +96296,8 @@ var ts;
|
|
|
96168
96296
|
function convertJsxChildrenToChildrenPropAssignment(children) {
|
|
96169
96297
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
96170
96298
|
if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
|
|
96171
|
-
var
|
|
96172
|
-
return
|
|
96299
|
+
var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
|
|
96300
|
+
return result_13 && factory.createPropertyAssignment("children", result_13);
|
|
96173
96301
|
}
|
|
96174
96302
|
var result = ts.mapDefined(children, transformJsxChildToExpression);
|
|
96175
96303
|
return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
|
|
@@ -106600,7 +106728,7 @@ var ts;
|
|
|
106600
106728
|
var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
|
|
106601
106729
|
hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
|
|
106602
106730
|
collectReferences(sourceFile, refs);
|
|
106603
|
-
recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
|
|
106731
|
+
recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
|
|
106604
106732
|
collectLibs(sourceFile, libs);
|
|
106605
106733
|
return sourceFile;
|
|
106606
106734
|
}
|
|
@@ -106655,9 +106783,10 @@ var ts;
|
|
|
106655
106783
|
return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
|
|
106656
106784
|
}
|
|
106657
106785
|
function getFileReferencesForUsedTypeReferences() {
|
|
106658
|
-
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()),
|
|
106786
|
+
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
|
|
106659
106787
|
}
|
|
106660
|
-
function
|
|
106788
|
+
function getFileReferenceForSpecifierModeTuple(_a) {
|
|
106789
|
+
var typeName = _a[0], mode = _a[1];
|
|
106661
106790
|
// Elide type references for which we have imports
|
|
106662
106791
|
if (emittedImports) {
|
|
106663
106792
|
for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
|
|
@@ -106673,7 +106802,7 @@ var ts;
|
|
|
106673
106802
|
}
|
|
106674
106803
|
}
|
|
106675
106804
|
}
|
|
106676
|
-
return { fileName: typeName, pos: -1, end: -1 };
|
|
106805
|
+
return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
|
|
106677
106806
|
}
|
|
106678
106807
|
function mapReferencesIntoArray(references, outputFilePath) {
|
|
106679
106808
|
return function (file) {
|
|
@@ -106693,7 +106822,7 @@ var ts;
|
|
|
106693
106822
|
// If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration
|
|
106694
106823
|
// via a non-relative name, emit a type reference directive to that non-relative name, rather than
|
|
106695
106824
|
// a relative path to the declaration file
|
|
106696
|
-
recordTypeReferenceDirectivesIfNecessary([specifier]);
|
|
106825
|
+
recordTypeReferenceDirectivesIfNecessary([[specifier, /*mode*/ undefined]]);
|
|
106697
106826
|
return;
|
|
106698
106827
|
}
|
|
106699
106828
|
var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName,
|
|
@@ -109806,6 +109935,8 @@ var ts;
|
|
|
109806
109935
|
return emitAsExpression(node);
|
|
109807
109936
|
case 229 /* NonNullExpression */:
|
|
109808
109937
|
return emitNonNullExpression(node);
|
|
109938
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
109939
|
+
return emitExpressionWithTypeArguments(node);
|
|
109809
109940
|
case 230 /* MetaProperty */:
|
|
109810
109941
|
return emitMetaProperty(node);
|
|
109811
109942
|
case 231 /* SyntheticExpression */:
|
|
@@ -110250,6 +110381,7 @@ var ts;
|
|
|
110250
110381
|
writeKeyword("typeof");
|
|
110251
110382
|
writeSpace();
|
|
110252
110383
|
emit(node.exprName);
|
|
110384
|
+
emitTypeArguments(node, node.typeArguments);
|
|
110253
110385
|
}
|
|
110254
110386
|
function emitTypeLiteral(node) {
|
|
110255
110387
|
writePunctuation("{");
|
|
@@ -111805,9 +111937,12 @@ var ts;
|
|
|
111805
111937
|
for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
|
|
111806
111938
|
var directive = types_24[_d];
|
|
111807
111939
|
var pos = writer.getTextPos();
|
|
111808
|
-
|
|
111940
|
+
var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
|
|
111941
|
+
? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
|
|
111942
|
+
: "";
|
|
111943
|
+
writeComment("/// <reference types=\"" + directive.fileName + "\" " + resolutionMode + "/>");
|
|
111809
111944
|
if (bundleFileInfo)
|
|
111810
|
-
bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName });
|
|
111945
|
+
bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName });
|
|
111811
111946
|
writeLine();
|
|
111812
111947
|
}
|
|
111813
111948
|
for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
|
|
@@ -114414,7 +114549,7 @@ var ts;
|
|
|
114414
114549
|
}
|
|
114415
114550
|
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
|
|
114416
114551
|
/* @internal */
|
|
114417
|
-
function
|
|
114552
|
+
function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
|
|
114418
114553
|
if (names.length === 0) {
|
|
114419
114554
|
return [];
|
|
114420
114555
|
}
|
|
@@ -114423,19 +114558,28 @@ var ts;
|
|
|
114423
114558
|
for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
|
|
114424
114559
|
var name = names_2[_i];
|
|
114425
114560
|
var result = void 0;
|
|
114426
|
-
|
|
114427
|
-
|
|
114561
|
+
var mode = getModeForFileReference(name, containingFileMode);
|
|
114562
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
114563
|
+
var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
|
|
114564
|
+
var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
|
|
114565
|
+
if (cache.has(cacheKey)) {
|
|
114566
|
+
result = cache.get(cacheKey);
|
|
114428
114567
|
}
|
|
114429
114568
|
else {
|
|
114430
|
-
cache.set(
|
|
114569
|
+
cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
|
|
114431
114570
|
}
|
|
114432
114571
|
resolutions.push(result);
|
|
114433
114572
|
}
|
|
114434
114573
|
return resolutions;
|
|
114435
114574
|
}
|
|
114436
|
-
ts.
|
|
114575
|
+
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
114437
114576
|
;
|
|
114438
114577
|
/* @internal */
|
|
114578
|
+
function getModeForFileReference(ref, containingFileMode) {
|
|
114579
|
+
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
114580
|
+
}
|
|
114581
|
+
ts.getModeForFileReference = getModeForFileReference;
|
|
114582
|
+
/* @internal */
|
|
114439
114583
|
function getModeForResolutionAtIndex(file, index) {
|
|
114440
114584
|
if (file.impliedNodeFormat === undefined)
|
|
114441
114585
|
return undefined;
|
|
@@ -114538,7 +114682,7 @@ var ts;
|
|
|
114538
114682
|
var _d, _e, _f, _g;
|
|
114539
114683
|
var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
|
|
114540
114684
|
var kind = ref.kind, index = ref.index;
|
|
114541
|
-
var pos, end, packageId;
|
|
114685
|
+
var pos, end, packageId, resolutionMode;
|
|
114542
114686
|
switch (kind) {
|
|
114543
114687
|
case ts.FileIncludeKind.Import:
|
|
114544
114688
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
@@ -114552,8 +114696,8 @@ var ts;
|
|
|
114552
114696
|
(_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
|
|
114553
114697
|
break;
|
|
114554
114698
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
114555
|
-
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
114556
|
-
packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
|
|
114699
|
+
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
|
|
114700
|
+
packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
|
|
114557
114701
|
break;
|
|
114558
114702
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
114559
114703
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -114797,7 +114941,7 @@ var ts;
|
|
|
114797
114941
|
var fileReasons = ts.createMultiMap();
|
|
114798
114942
|
var cachedBindAndCheckDiagnosticsForFile = {};
|
|
114799
114943
|
var cachedDeclarationDiagnosticsForFile = {};
|
|
114800
|
-
var resolvedTypeReferenceDirectives =
|
|
114944
|
+
var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
|
|
114801
114945
|
var fileProcessingDiagnostics;
|
|
114802
114946
|
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
|
|
114803
114947
|
// This works as imported modules are discovered recursively in a depth first manner, specifically:
|
|
@@ -114850,12 +114994,12 @@ var ts;
|
|
|
114850
114994
|
}
|
|
114851
114995
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
114852
114996
|
if (host.resolveTypeReferenceDirectives) {
|
|
114853
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
|
|
114997
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
|
|
114854
114998
|
}
|
|
114855
114999
|
else {
|
|
114856
115000
|
typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
114857
|
-
var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114858
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return
|
|
115001
|
+
var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
115002
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
|
|
114859
115003
|
}
|
|
114860
115004
|
// Map from a stringified PackageId to the source file with that id.
|
|
114861
115005
|
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
|
|
@@ -114952,7 +115096,8 @@ var ts;
|
|
|
114952
115096
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
114953
115097
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
114954
115098
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
114955
|
-
|
|
115099
|
+
// under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
|
|
115100
|
+
processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
|
|
114956
115101
|
}
|
|
114957
115102
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
114958
115103
|
}
|
|
@@ -115112,9 +115257,10 @@ var ts;
|
|
|
115112
115257
|
return [];
|
|
115113
115258
|
var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
|
|
115114
115259
|
var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
|
|
115260
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
115115
115261
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
|
|
115116
115262
|
ts.performance.mark("beforeResolveTypeReference");
|
|
115117
|
-
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
|
|
115263
|
+
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
|
|
115118
115264
|
ts.performance.mark("afterResolveTypeReference");
|
|
115119
115265
|
ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
|
|
115120
115266
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -115209,15 +115355,15 @@ var ts;
|
|
|
115209
115355
|
// which per above occurred during the current program creation.
|
|
115210
115356
|
// Since we assume the filesystem does not change during program creation,
|
|
115211
115357
|
// it is safe to reuse resolutions from the earlier call.
|
|
115212
|
-
var
|
|
115358
|
+
var result_14 = [];
|
|
115213
115359
|
var i = 0;
|
|
115214
115360
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
115215
115361
|
var moduleName = moduleNames_1[_i];
|
|
115216
115362
|
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
115217
115363
|
i++;
|
|
115218
|
-
|
|
115364
|
+
result_14.push(resolvedModule);
|
|
115219
115365
|
}
|
|
115220
|
-
return
|
|
115366
|
+
return result_14;
|
|
115221
115367
|
}
|
|
115222
115368
|
// At this point, we know at least one of the following hold:
|
|
115223
115369
|
// - file has local declarations for ambient modules
|
|
@@ -115506,8 +115652,7 @@ var ts;
|
|
|
115506
115652
|
else {
|
|
115507
115653
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
115508
115654
|
}
|
|
115509
|
-
|
|
115510
|
-
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
115655
|
+
var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
|
115511
115656
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
115512
115657
|
// ensure that types resolutions are still correct
|
|
115513
115658
|
var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
@@ -116586,8 +116731,7 @@ var ts;
|
|
|
116586
116731
|
});
|
|
116587
116732
|
}
|
|
116588
116733
|
function processTypeReferenceDirectives(file) {
|
|
116589
|
-
|
|
116590
|
-
var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
116734
|
+
var typeDirectives = file.typeReferenceDirectives;
|
|
116591
116735
|
if (!typeDirectives) {
|
|
116592
116736
|
return;
|
|
116593
116737
|
}
|
|
@@ -116598,17 +116742,21 @@ var ts;
|
|
|
116598
116742
|
// store resolved type directive on the file
|
|
116599
116743
|
var fileName = ts.toFileNameLowerCase(ref.fileName);
|
|
116600
116744
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
116601
|
-
|
|
116745
|
+
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
116746
|
+
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
116747
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext));
|
|
116748
|
+
}
|
|
116749
|
+
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
116602
116750
|
}
|
|
116603
116751
|
}
|
|
116604
|
-
function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116752
|
+
function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116605
116753
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
|
|
116606
|
-
processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
|
|
116754
|
+
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
|
|
116607
116755
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116608
116756
|
}
|
|
116609
|
-
function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116757
|
+
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116610
116758
|
// If we already found this library as a primary reference - nothing to do
|
|
116611
|
-
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
|
|
116759
|
+
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
|
|
116612
116760
|
if (previousResolution && previousResolution.primary) {
|
|
116613
116761
|
return;
|
|
116614
116762
|
}
|
|
@@ -116647,7 +116795,7 @@ var ts;
|
|
|
116647
116795
|
addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
|
|
116648
116796
|
}
|
|
116649
116797
|
if (saveResolution) {
|
|
116650
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
|
|
116798
|
+
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
|
|
116651
116799
|
}
|
|
116652
116800
|
}
|
|
116653
116801
|
function pathForLibFile(libFileName) {
|
|
@@ -119465,9 +119613,9 @@ var ts;
|
|
|
119465
119613
|
});
|
|
119466
119614
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
119467
119615
|
}
|
|
119468
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
|
|
119616
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
|
|
119469
119617
|
var _a;
|
|
119470
|
-
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
|
|
119618
|
+
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
|
|
119471
119619
|
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
|
|
119472
119620
|
if (!resolutionHost.getGlobalCache) {
|
|
119473
119621
|
return primaryResult;
|
|
@@ -119488,12 +119636,12 @@ var ts;
|
|
|
119488
119636
|
// Default return the result from the first pass
|
|
119489
119637
|
return primaryResult;
|
|
119490
119638
|
}
|
|
119491
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
|
|
119492
|
-
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
|
|
119639
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
|
|
119640
|
+
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
|
|
119493
119641
|
}
|
|
119494
119642
|
function resolveNamesWithLocalCache(_a) {
|
|
119495
119643
|
var _b, _c, _d;
|
|
119496
|
-
var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile;
|
|
119644
|
+
var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
|
|
119497
119645
|
var path = resolutionHost.toPath(containingFile);
|
|
119498
119646
|
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
119499
119647
|
var dirPath = ts.getDirectoryPath(path);
|
|
@@ -119515,8 +119663,15 @@ var ts;
|
|
|
119515
119663
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
119516
119664
|
var i = 0;
|
|
119517
119665
|
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
119518
|
-
var
|
|
119519
|
-
var
|
|
119666
|
+
var entry = names_4[_i];
|
|
119667
|
+
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
119668
|
+
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
119669
|
+
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
119670
|
+
// import's syntax may override the file's default mode.
|
|
119671
|
+
// Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
|
|
119672
|
+
// a default file mode override if applicable.
|
|
119673
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
|
|
119674
|
+
containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
119520
119675
|
i++;
|
|
119521
119676
|
var resolution = resolutionsInFile.get(name, mode);
|
|
119522
119677
|
// Resolution is valid if it is present and not invalidated
|
|
@@ -119545,7 +119700,7 @@ var ts;
|
|
|
119545
119700
|
}
|
|
119546
119701
|
}
|
|
119547
119702
|
else {
|
|
119548
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
119703
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
119549
119704
|
perDirectoryResolution.set(name, mode, resolution);
|
|
119550
119705
|
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
119551
119706
|
resolutionHost.onDiscoveredSymlink();
|
|
@@ -119609,7 +119764,7 @@ var ts;
|
|
|
119609
119764
|
return oldResult.resolvedFileName === newResult.resolvedFileName;
|
|
119610
119765
|
}
|
|
119611
119766
|
}
|
|
119612
|
-
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
|
|
119767
|
+
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
|
|
119613
119768
|
return resolveNamesWithLocalCache({
|
|
119614
119769
|
names: typeDirectiveNames,
|
|
119615
119770
|
containingFile: containingFile,
|
|
@@ -119619,6 +119774,7 @@ var ts;
|
|
|
119619
119774
|
loader: resolveTypeReferenceDirective,
|
|
119620
119775
|
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
|
|
119621
119776
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
119777
|
+
containingSourceFileMode: containingFileMode
|
|
119622
119778
|
});
|
|
119623
119779
|
}
|
|
119624
119780
|
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
@@ -120325,9 +120481,9 @@ var ts;
|
|
|
120325
120481
|
if (!preferSymlinks) {
|
|
120326
120482
|
// Symlinks inside ignored paths are already filtered out of the symlink cache,
|
|
120327
120483
|
// so we only need to remove them from the realpath filenames.
|
|
120328
|
-
var
|
|
120329
|
-
if (
|
|
120330
|
-
return
|
|
120484
|
+
var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
|
|
120485
|
+
if (result_15)
|
|
120486
|
+
return result_15;
|
|
120331
120487
|
}
|
|
120332
120488
|
var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
|
|
120333
120489
|
var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
|
|
@@ -120347,10 +120503,10 @@ var ts;
|
|
|
120347
120503
|
for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
|
|
120348
120504
|
var symlinkDirectory = symlinkDirectories_1[_i];
|
|
120349
120505
|
var option = ts.resolvePath(symlinkDirectory, relative);
|
|
120350
|
-
var
|
|
120506
|
+
var result_16 = cb(option, target === referenceRedirect);
|
|
120351
120507
|
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
|
|
120352
|
-
if (
|
|
120353
|
-
return
|
|
120508
|
+
if (result_16)
|
|
120509
|
+
return result_16;
|
|
120354
120510
|
}
|
|
120355
120511
|
});
|
|
120356
120512
|
});
|
|
@@ -121527,7 +121683,7 @@ var ts;
|
|
|
121527
121683
|
}
|
|
121528
121684
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
121529
121685
|
}) :
|
|
121530
|
-
(function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
|
|
121686
|
+
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
121531
121687
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
121532
121688
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
121533
121689
|
synchronizeProgram();
|
|
@@ -122263,9 +122419,9 @@ var ts;
|
|
|
122263
122419
|
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
122264
122420
|
}
|
|
122265
122421
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
122266
|
-
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|
|
122267
|
-
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
|
|
122268
|
-
return ts.
|
|
122422
|
+
var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
|
|
122423
|
+
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
122424
|
+
return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
|
|
122269
122425
|
};
|
|
122270
122426
|
}
|
|
122271
122427
|
var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
|
|
@@ -124608,7 +124764,7 @@ var ts;
|
|
|
124608
124764
|
case 199 /* ImportType */:
|
|
124609
124765
|
return !node.parent.isTypeOf;
|
|
124610
124766
|
case 227 /* ExpressionWithTypeArguments */:
|
|
124611
|
-
return
|
|
124767
|
+
return ts.isPartOfTypeNode(node.parent);
|
|
124612
124768
|
}
|
|
124613
124769
|
return false;
|
|
124614
124770
|
}
|
|
@@ -126635,14 +126791,15 @@ var ts;
|
|
|
126635
126791
|
: "linkplain";
|
|
126636
126792
|
var parts = [linkPart("{@" + prefix + " ")];
|
|
126637
126793
|
if (!link.name) {
|
|
126638
|
-
if (link.text)
|
|
126794
|
+
if (link.text) {
|
|
126639
126795
|
parts.push(linkTextPart(link.text));
|
|
126796
|
+
}
|
|
126640
126797
|
}
|
|
126641
126798
|
else {
|
|
126642
126799
|
var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
|
|
126643
126800
|
var suffix = findLinkNameEnd(link.text);
|
|
126644
126801
|
var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
|
|
126645
|
-
var text = link.text.slice(suffix);
|
|
126802
|
+
var text = skipSeparatorFromLinkText(link.text.slice(suffix));
|
|
126646
126803
|
var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]);
|
|
126647
126804
|
if (decl) {
|
|
126648
126805
|
parts.push(linkNamePart(name, decl));
|
|
@@ -126657,6 +126814,15 @@ var ts;
|
|
|
126657
126814
|
return parts;
|
|
126658
126815
|
}
|
|
126659
126816
|
ts.buildLinkParts = buildLinkParts;
|
|
126817
|
+
function skipSeparatorFromLinkText(text) {
|
|
126818
|
+
var pos = 0;
|
|
126819
|
+
if (text.charCodeAt(pos++) === 124 /* bar */) {
|
|
126820
|
+
while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
|
|
126821
|
+
pos++;
|
|
126822
|
+
return text.slice(pos);
|
|
126823
|
+
}
|
|
126824
|
+
return text;
|
|
126825
|
+
}
|
|
126660
126826
|
function findLinkNameEnd(text) {
|
|
126661
126827
|
if (text.indexOf("()") === 0)
|
|
126662
126828
|
return 2;
|
|
@@ -131233,14 +131399,15 @@ var ts;
|
|
|
131233
131399
|
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
|
|
131234
131400
|
return { kind: 1 /* JsDocTagName */ };
|
|
131235
131401
|
}
|
|
131236
|
-
|
|
131402
|
+
var typeExpression = tryGetTypeExpressionFromTag(tag);
|
|
131403
|
+
if (typeExpression) {
|
|
131237
131404
|
currentToken = ts.getTokenAtPosition(sourceFile, position);
|
|
131238
131405
|
if (!currentToken ||
|
|
131239
131406
|
(!ts.isDeclarationName(currentToken) &&
|
|
131240
131407
|
(currentToken.parent.kind !== 345 /* JSDocPropertyTag */ ||
|
|
131241
131408
|
currentToken.parent.name !== currentToken))) {
|
|
131242
131409
|
// Use as type location if inside tag's type expression
|
|
131243
|
-
insideJsDocTagTypeExpression = isCurrentlyEditingNode(
|
|
131410
|
+
insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression);
|
|
131244
131411
|
}
|
|
131245
131412
|
}
|
|
131246
131413
|
if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) {
|
|
@@ -131497,10 +131664,19 @@ var ts;
|
|
|
131497
131664
|
case 341 /* JSDocTypeTag */:
|
|
131498
131665
|
case 343 /* JSDocTypedefTag */:
|
|
131499
131666
|
return true;
|
|
131667
|
+
case 342 /* JSDocTemplateTag */:
|
|
131668
|
+
return !!tag.constraint;
|
|
131500
131669
|
default:
|
|
131501
131670
|
return false;
|
|
131502
131671
|
}
|
|
131503
131672
|
}
|
|
131673
|
+
function tryGetTypeExpressionFromTag(tag) {
|
|
131674
|
+
if (isTagWithTypeExpression(tag)) {
|
|
131675
|
+
var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression;
|
|
131676
|
+
return typeExpression && typeExpression.kind === 307 /* JSDocTypeExpression */ ? typeExpression : undefined;
|
|
131677
|
+
}
|
|
131678
|
+
return undefined;
|
|
131679
|
+
}
|
|
131504
131680
|
function getTypeScriptMemberSymbols() {
|
|
131505
131681
|
// Right of dot member completion list
|
|
131506
131682
|
completionKind = 2 /* PropertyAccess */;
|
|
@@ -134256,7 +134432,7 @@ var ts;
|
|
|
134256
134432
|
}
|
|
134257
134433
|
for (var _c = 0, _d = referencingFile.typeReferenceDirectives; _c < _d.length; _c++) {
|
|
134258
134434
|
var ref = _d[_c];
|
|
134259
|
-
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName);
|
|
134435
|
+
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat);
|
|
134260
134436
|
if (referenced !== undefined && referenced.resolvedFileName === searchSourceFile.fileName) {
|
|
134261
134437
|
refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
|
|
134262
134438
|
}
|
|
@@ -137478,7 +137654,7 @@ var ts;
|
|
|
137478
137654
|
}
|
|
137479
137655
|
var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
|
137480
137656
|
if (typeReferenceDirective) {
|
|
137481
|
-
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
|
|
137657
|
+
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat);
|
|
137482
137658
|
var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217
|
|
137483
137659
|
return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false };
|
|
137484
137660
|
}
|
|
@@ -137883,9 +138059,18 @@ var ts;
|
|
|
137883
138059
|
JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations;
|
|
137884
138060
|
function getDisplayPartsFromComment(comment, checker) {
|
|
137885
138061
|
if (typeof comment === "string") {
|
|
137886
|
-
return [ts.textPart(comment)];
|
|
138062
|
+
return [ts.textPart(skipSeparatorFromComment(comment))];
|
|
137887
138063
|
}
|
|
137888
|
-
return ts.flatMap(comment, function (node) { return node.kind === 319 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); });
|
|
138064
|
+
return ts.flatMap(comment, function (node) { return node.kind === 319 /* JSDocText */ ? [ts.textPart(skipSeparatorFromComment(node.text))] : ts.buildLinkParts(node, checker); });
|
|
138065
|
+
}
|
|
138066
|
+
function skipSeparatorFromComment(text) {
|
|
138067
|
+
var pos = 0;
|
|
138068
|
+
if (text.charCodeAt(pos++) === 45 /* minus */) {
|
|
138069
|
+
while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
|
|
138070
|
+
pos++;
|
|
138071
|
+
return text.slice(pos);
|
|
138072
|
+
}
|
|
138073
|
+
return text;
|
|
137889
138074
|
}
|
|
137890
138075
|
function getCommentDisplayParts(tag, checker) {
|
|
137891
138076
|
var comment = tag.comment, kind = tag.kind;
|
|
@@ -155263,7 +155448,7 @@ var ts;
|
|
|
155263
155448
|
/*dotDotDotToken*/ undefined,
|
|
155264
155449
|
/*name*/ names && names[i] || "arg" + i,
|
|
155265
155450
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
155266
|
-
/*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(
|
|
155451
|
+
/*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */),
|
|
155267
155452
|
/*initializer*/ undefined);
|
|
155268
155453
|
parameters.push(newParameter);
|
|
155269
155454
|
}
|
|
@@ -155291,11 +155476,10 @@ var ts;
|
|
|
155291
155476
|
var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; });
|
|
155292
155477
|
var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false);
|
|
155293
155478
|
if (someSigHasRestParameter) {
|
|
155294
|
-
var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
|
|
155295
155479
|
var restParameter = ts.factory.createParameterDeclaration(
|
|
155296
155480
|
/*decorators*/ undefined,
|
|
155297
155481
|
/*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
|
|
155298
|
-
/*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
155482
|
+
/*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */)),
|
|
155299
155483
|
/*initializer*/ undefined);
|
|
155300
155484
|
parameters.push(restParameter);
|
|
155301
155485
|
}
|
|
@@ -157541,7 +157725,7 @@ var ts;
|
|
|
157541
157725
|
// cannot find either start or end node
|
|
157542
157726
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
157543
157727
|
}
|
|
157544
|
-
if (
|
|
157728
|
+
if (start.flags & 4194304 /* JSDoc */) {
|
|
157545
157729
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
|
|
157546
157730
|
}
|
|
157547
157731
|
if (start.parent !== end.parent) {
|
|
@@ -157664,7 +157848,7 @@ var ts;
|
|
|
157664
157848
|
ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)");
|
|
157665
157849
|
// For understanding how skipTrivia functioned:
|
|
157666
157850
|
ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)");
|
|
157667
|
-
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) {
|
|
157851
|
+
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
|
|
157668
157852
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
|
|
157669
157853
|
}
|
|
157670
157854
|
if (nodeToCheck.flags & 8388608 /* Ambient */) {
|
|
@@ -157844,13 +158028,16 @@ var ts;
|
|
|
157844
158028
|
if (ts.isStatement(node)) {
|
|
157845
158029
|
return [node];
|
|
157846
158030
|
}
|
|
157847
|
-
|
|
158031
|
+
if (ts.isExpressionNode(node)) {
|
|
157848
158032
|
// If our selection is the expression in an ExpressionStatement, expand
|
|
157849
158033
|
// the selection to include the enclosing Statement (this stops us
|
|
157850
158034
|
// from trying to care about the return value of the extracted function
|
|
157851
158035
|
// and eliminates double semicolon insertion in certain scenarios)
|
|
157852
158036
|
return ts.isExpressionStatement(node.parent) ? [node.parent] : node;
|
|
157853
158037
|
}
|
|
158038
|
+
if (isStringLiteralJsxAttribute(node)) {
|
|
158039
|
+
return node;
|
|
158040
|
+
}
|
|
157854
158041
|
return undefined;
|
|
157855
158042
|
}
|
|
157856
158043
|
function isScope(node) {
|
|
@@ -158660,7 +158847,7 @@ var ts;
|
|
|
158660
158847
|
// Unfortunately, this code takes advantage of the knowledge that the generated method
|
|
158661
158848
|
// will use the contextual type of an expression as the return type of the extracted
|
|
158662
158849
|
// method (and will therefore "use" all the types involved).
|
|
158663
|
-
if (inGenericContext && !isReadonlyArray(targetRange.range)) {
|
|
158850
|
+
if (inGenericContext && !isReadonlyArray(targetRange.range) && !ts.isJsxAttribute(targetRange.range)) {
|
|
158664
158851
|
var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217
|
|
158665
158852
|
recordTypeParameterUsages(contextualType);
|
|
158666
158853
|
}
|
|
@@ -158985,7 +159172,11 @@ var ts;
|
|
|
158985
159172
|
}
|
|
158986
159173
|
}
|
|
158987
159174
|
function isInJSXContent(node) {
|
|
158988
|
-
return (
|
|
159175
|
+
return isStringLiteralJsxAttribute(node) ||
|
|
159176
|
+
(ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
|
|
159177
|
+
}
|
|
159178
|
+
function isStringLiteralJsxAttribute(node) {
|
|
159179
|
+
return ts.isStringLiteral(node) && node.parent && ts.isJsxAttribute(node.parent);
|
|
158989
159180
|
}
|
|
158990
159181
|
})(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {}));
|
|
158991
159182
|
})(refactor = ts.refactor || (ts.refactor = {}));
|
|
@@ -164300,7 +164491,7 @@ var ts;
|
|
|
164300
164491
|
if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
|
|
164301
164492
|
this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) {
|
|
164302
164493
|
var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); // TODO: GH#18217
|
|
164303
|
-
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); });
|
|
164494
|
+
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, ts.isString(name) ? name : name.fileName.toLowerCase()); });
|
|
164304
164495
|
};
|
|
164305
164496
|
}
|
|
164306
164497
|
}
|
|
@@ -166582,8 +166773,8 @@ var ts;
|
|
|
166582
166773
|
Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile, resolutionMode) {
|
|
166583
166774
|
return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
|
|
166584
166775
|
};
|
|
166585
|
-
Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference) {
|
|
166586
|
-
return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference);
|
|
166776
|
+
Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
166777
|
+
return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode);
|
|
166587
166778
|
};
|
|
166588
166779
|
Project.prototype.directoryExists = function (path) {
|
|
166589
166780
|
return this.directoryStructureHost.directoryExists(path); // TODO: GH#18217
|