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/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220219";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -2423,7 +2423,7 @@ var ts;
|
|
|
2423
2423
|
Debug.checkEachDefined = checkEachDefined;
|
|
2424
2424
|
function assertNever(member, message, stackCrawlMark) {
|
|
2425
2425
|
if (message === void 0) { message = "Illegal value:"; }
|
|
2426
|
-
var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos")
|
|
2426
|
+
var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
|
|
2427
2427
|
return fail(message + " " + detail, stackCrawlMark || assertNever);
|
|
2428
2428
|
}
|
|
2429
2429
|
Debug.assertNever = assertNever;
|
|
@@ -4840,6 +4840,8 @@ var ts;
|
|
|
4840
4840
|
TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike";
|
|
4841
4841
|
TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike";
|
|
4842
4842
|
/* @internal */
|
|
4843
|
+
TypeFlags[TypeFlags["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
|
|
4844
|
+
/* @internal */
|
|
4843
4845
|
TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains";
|
|
4844
4846
|
TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
4845
4847
|
TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType";
|
|
@@ -4918,13 +4920,14 @@ var ts;
|
|
|
4918
4920
|
// Flags that require TypeFlags.Object
|
|
4919
4921
|
ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread";
|
|
4920
4922
|
ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType";
|
|
4923
|
+
ObjectFlags[ObjectFlags["InstantiationExpressionType"] = 16777216] = "InstantiationExpressionType";
|
|
4921
4924
|
/* @internal */
|
|
4922
|
-
ObjectFlags[ObjectFlags["IsClassInstanceClone"] =
|
|
4925
|
+
ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 33554432] = "IsClassInstanceClone";
|
|
4923
4926
|
// Flags that require TypeFlags.Object and ObjectFlags.Reference
|
|
4924
4927
|
/* @internal */
|
|
4925
|
-
ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] =
|
|
4928
|
+
ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 67108864] = "IdenticalBaseTypeCalculated";
|
|
4926
4929
|
/* @internal */
|
|
4927
|
-
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] =
|
|
4930
|
+
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 134217728] = "IdenticalBaseTypeExists";
|
|
4928
4931
|
// Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution
|
|
4929
4932
|
/* @internal */
|
|
4930
4933
|
ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 4194304] = "IsGenericTypeComputed";
|
|
@@ -5572,6 +5575,8 @@ var ts;
|
|
|
5572
5575
|
BundleFileSectionKind["NoDefaultLib"] = "no-default-lib";
|
|
5573
5576
|
BundleFileSectionKind["Reference"] = "reference";
|
|
5574
5577
|
BundleFileSectionKind["Type"] = "type";
|
|
5578
|
+
BundleFileSectionKind["TypeResolutionModeRequire"] = "type-require";
|
|
5579
|
+
BundleFileSectionKind["TypeResolutionModeImport"] = "type-import";
|
|
5575
5580
|
BundleFileSectionKind["Lib"] = "lib";
|
|
5576
5581
|
BundleFileSectionKind["Prepend"] = "prepend";
|
|
5577
5582
|
BundleFileSectionKind["Text"] = "text";
|
|
@@ -5688,7 +5693,8 @@ var ts;
|
|
|
5688
5693
|
{ name: "types", optional: true, captureSpan: true },
|
|
5689
5694
|
{ name: "lib", optional: true, captureSpan: true },
|
|
5690
5695
|
{ name: "path", optional: true, captureSpan: true },
|
|
5691
|
-
{ name: "no-default-lib", optional: true }
|
|
5696
|
+
{ name: "no-default-lib", optional: true },
|
|
5697
|
+
{ name: "resolution-mode", optional: true }
|
|
5692
5698
|
],
|
|
5693
5699
|
kind: 1 /* TripleSlashXML */
|
|
5694
5700
|
},
|
|
@@ -8069,6 +8075,8 @@ var ts;
|
|
|
8069
8075
|
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."),
|
|
8070
8076
|
An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
|
|
8071
8077
|
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."),
|
|
8078
|
+
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}'."),
|
|
8079
|
+
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'."),
|
|
8072
8080
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
8073
8081
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
8074
8082
|
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."),
|
|
@@ -8137,7 +8145,6 @@ var ts;
|
|
|
8137
8145
|
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 `}`?"),
|
|
8138
8146
|
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 `>`?"),
|
|
8139
8147
|
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'."),
|
|
8140
|
-
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."),
|
|
8141
8148
|
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."),
|
|
8142
8149
|
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."),
|
|
8143
8150
|
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."),
|
|
@@ -8202,6 +8209,8 @@ var ts;
|
|
|
8202
8209
|
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."),
|
|
8203
8210
|
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"),
|
|
8204
8211
|
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"),
|
|
8212
|
+
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`."),
|
|
8213
|
+
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`."),
|
|
8205
8214
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8206
8215
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8207
8216
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -8521,6 +8530,7 @@ var ts;
|
|
|
8521
8530
|
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."),
|
|
8522
8531
|
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"),
|
|
8523
8532
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8533
|
+
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."),
|
|
8524
8534
|
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."),
|
|
8525
8535
|
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."),
|
|
8526
8536
|
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."),
|
|
@@ -9566,7 +9576,7 @@ var ts;
|
|
|
9566
9576
|
Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
|
|
9567
9577
|
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"),
|
|
9568
9578
|
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"),
|
|
9569
|
-
|
|
9579
|
+
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"),
|
|
9570
9580
|
Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
|
|
9571
9581
|
Remove_braces_from_arrow_function_body: diag(95112, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_body_95112", "Remove braces from arrow function body"),
|
|
9572
9582
|
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"),
|
|
@@ -13412,6 +13422,7 @@ var ts;
|
|
|
13412
13422
|
case 110 /* TrueKeyword */:
|
|
13413
13423
|
case 106 /* SuperKeyword */:
|
|
13414
13424
|
case 229 /* NonNullExpression */:
|
|
13425
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
13415
13426
|
case 230 /* MetaProperty */:
|
|
13416
13427
|
case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression
|
|
13417
13428
|
return true;
|
|
@@ -14085,7 +14096,11 @@ var ts;
|
|
|
14085
14096
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14086
14097
|
for (var i = 0; i < names.length; i++) {
|
|
14087
14098
|
var newResolution = newResolutions[i];
|
|
14088
|
-
var
|
|
14099
|
+
var entry = names[i];
|
|
14100
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
14101
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
14102
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
|
|
14103
|
+
var oldResolution = oldResolutions && oldResolutions.get(name, mode);
|
|
14089
14104
|
var changed = oldResolution
|
|
14090
14105
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14091
14106
|
: newResolution;
|
|
@@ -15121,7 +15136,7 @@ var ts;
|
|
|
15121
15136
|
case 114 /* VoidKeyword */:
|
|
15122
15137
|
return node.parent.kind !== 216 /* VoidExpression */;
|
|
15123
15138
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15124
|
-
return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
15139
|
+
return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
15125
15140
|
case 162 /* TypeParameter */:
|
|
15126
15141
|
return node.parent.kind === 194 /* MappedType */ || node.parent.kind === 189 /* InferType */;
|
|
15127
15142
|
// Identifiers and qualified names may be type nodes, depending on their context. Climb
|
|
@@ -15158,7 +15173,7 @@ var ts;
|
|
|
15158
15173
|
}
|
|
15159
15174
|
switch (parent.kind) {
|
|
15160
15175
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15161
|
-
return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
15176
|
+
return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
15162
15177
|
case 162 /* TypeParameter */:
|
|
15163
15178
|
return node === parent.constraint;
|
|
15164
15179
|
case 342 /* JSDocTemplateTag */:
|
|
@@ -15861,7 +15876,7 @@ var ts;
|
|
|
15861
15876
|
case 296 /* SpreadAssignment */:
|
|
15862
15877
|
return true;
|
|
15863
15878
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15864
|
-
return parent.expression === node &&
|
|
15879
|
+
return parent.expression === node && !isPartOfTypeNode(parent);
|
|
15865
15880
|
case 295 /* ShorthandPropertyAssignment */:
|
|
15866
15881
|
return parent.objectAssignmentInitializer === node;
|
|
15867
15882
|
default:
|
|
@@ -22848,16 +22863,18 @@ var ts;
|
|
|
22848
22863
|
return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type);
|
|
22849
22864
|
}
|
|
22850
22865
|
// @api
|
|
22851
|
-
function createTypeQueryNode(exprName) {
|
|
22866
|
+
function createTypeQueryNode(exprName, typeArguments) {
|
|
22852
22867
|
var node = createBaseNode(180 /* TypeQuery */);
|
|
22853
22868
|
node.exprName = exprName;
|
|
22869
|
+
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
22854
22870
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
22855
22871
|
return node;
|
|
22856
22872
|
}
|
|
22857
22873
|
// @api
|
|
22858
|
-
function updateTypeQueryNode(node, exprName) {
|
|
22874
|
+
function updateTypeQueryNode(node, exprName, typeArguments) {
|
|
22859
22875
|
return node.exprName !== exprName
|
|
22860
|
-
|
|
22876
|
+
|| node.typeArguments !== typeArguments
|
|
22877
|
+
? update(createTypeQueryNode(exprName, typeArguments), node)
|
|
22861
22878
|
: node;
|
|
22862
22879
|
}
|
|
22863
22880
|
// @api
|
|
@@ -26680,7 +26697,13 @@ var ts;
|
|
|
26680
26697
|
referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
|
|
26681
26698
|
break;
|
|
26682
26699
|
case "type" /* Type */:
|
|
26683
|
-
typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
|
|
26700
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
26701
|
+
break;
|
|
26702
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26703
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
|
|
26704
|
+
break;
|
|
26705
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26706
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
|
|
26684
26707
|
break;
|
|
26685
26708
|
case "lib" /* Lib */:
|
|
26686
26709
|
libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
@@ -26739,6 +26762,8 @@ var ts;
|
|
|
26739
26762
|
case "no-default-lib" /* NoDefaultLib */:
|
|
26740
26763
|
case "reference" /* Reference */:
|
|
26741
26764
|
case "type" /* Type */:
|
|
26765
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26766
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26742
26767
|
case "lib" /* Lib */:
|
|
26743
26768
|
syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
|
|
26744
26769
|
break;
|
|
@@ -29973,7 +29998,8 @@ var ts;
|
|
|
29973
29998
|
visitNode(cbNode, node.parameterName) ||
|
|
29974
29999
|
visitNode(cbNode, node.type);
|
|
29975
30000
|
case 180 /* TypeQuery */:
|
|
29976
|
-
return visitNode(cbNode, node.exprName)
|
|
30001
|
+
return visitNode(cbNode, node.exprName) ||
|
|
30002
|
+
visitNodes(cbNode, cbNodes, node.typeArguments);
|
|
29977
30003
|
case 181 /* TypeLiteral */:
|
|
29978
30004
|
return visitNodes(cbNode, cbNodes, node.members);
|
|
29979
30005
|
case 182 /* ArrayType */:
|
|
@@ -30652,7 +30678,7 @@ var ts;
|
|
|
30652
30678
|
initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
|
|
30653
30679
|
// Prime the scanner.
|
|
30654
30680
|
nextToken();
|
|
30655
|
-
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
30681
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false);
|
|
30656
30682
|
var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
|
|
30657
30683
|
clearState();
|
|
30658
30684
|
return isInvalid ? entityName : undefined;
|
|
@@ -32229,7 +32255,7 @@ var ts;
|
|
|
32229
32255
|
}
|
|
32230
32256
|
return createMissingList();
|
|
32231
32257
|
}
|
|
32232
|
-
function parseEntityName(allowReservedWords, diagnosticMessage) {
|
|
32258
|
+
function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) {
|
|
32233
32259
|
var pos = getNodePos();
|
|
32234
32260
|
var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
|
|
32235
32261
|
var dotPos = getNodePos();
|
|
@@ -32240,7 +32266,7 @@ var ts;
|
|
|
32240
32266
|
break;
|
|
32241
32267
|
}
|
|
32242
32268
|
dotPos = getNodePos();
|
|
32243
|
-
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords,
|
|
32269
|
+
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos);
|
|
32244
32270
|
}
|
|
32245
32271
|
return entity;
|
|
32246
32272
|
}
|
|
@@ -32373,7 +32399,7 @@ var ts;
|
|
|
32373
32399
|
}
|
|
32374
32400
|
// TYPES
|
|
32375
32401
|
function parseEntityNameOfTypeReference() {
|
|
32376
|
-
return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
|
|
32402
|
+
return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected);
|
|
32377
32403
|
}
|
|
32378
32404
|
function parseTypeArgumentsOfTypeReference() {
|
|
32379
32405
|
if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) {
|
|
@@ -32506,7 +32532,9 @@ var ts;
|
|
|
32506
32532
|
function parseTypeQuery() {
|
|
32507
32533
|
var pos = getNodePos();
|
|
32508
32534
|
parseExpected(112 /* TypeOfKeyword */);
|
|
32509
|
-
|
|
32535
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true);
|
|
32536
|
+
var typeArguments = tryParseTypeArguments();
|
|
32537
|
+
return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
|
|
32510
32538
|
}
|
|
32511
32539
|
function parseTypeParameter() {
|
|
32512
32540
|
var pos = getNodePos();
|
|
@@ -34576,20 +34604,30 @@ var ts;
|
|
|
34576
34604
|
expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
|
|
34577
34605
|
continue;
|
|
34578
34606
|
}
|
|
34579
|
-
if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34580
|
-
nextToken();
|
|
34581
|
-
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34582
|
-
continue;
|
|
34583
|
-
}
|
|
34584
34607
|
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
|
34585
34608
|
if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) {
|
|
34586
34609
|
expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
|
|
34587
34610
|
continue;
|
|
34588
34611
|
}
|
|
34589
34612
|
if (isTemplateStartOfTaggedTemplate()) {
|
|
34590
|
-
|
|
34613
|
+
// Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments
|
|
34614
|
+
expression = !questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */ ?
|
|
34615
|
+
parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) :
|
|
34616
|
+
parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
|
|
34591
34617
|
continue;
|
|
34592
34618
|
}
|
|
34619
|
+
if (!questionDotToken) {
|
|
34620
|
+
if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34621
|
+
nextToken();
|
|
34622
|
+
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34623
|
+
continue;
|
|
34624
|
+
}
|
|
34625
|
+
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34626
|
+
if (typeArguments) {
|
|
34627
|
+
expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
34628
|
+
continue;
|
|
34629
|
+
}
|
|
34630
|
+
}
|
|
34593
34631
|
return expression;
|
|
34594
34632
|
}
|
|
34595
34633
|
}
|
|
@@ -34609,38 +34647,30 @@ var ts;
|
|
|
34609
34647
|
function parseCallExpressionRest(pos, expression) {
|
|
34610
34648
|
while (true) {
|
|
34611
34649
|
expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true);
|
|
34650
|
+
var typeArguments = void 0;
|
|
34612
34651
|
var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */);
|
|
34613
|
-
|
|
34614
|
-
|
|
34615
|
-
|
|
34616
|
-
|
|
34617
|
-
// keep checking for postfix expressions. Otherwise, it's just a '<' that's
|
|
34618
|
-
// part of an arithmetic expression. Break out so we consume it higher in the
|
|
34619
|
-
// stack.
|
|
34620
|
-
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34621
|
-
if (typeArguments) {
|
|
34622
|
-
if (isTemplateStartOfTaggedTemplate()) {
|
|
34623
|
-
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34624
|
-
continue;
|
|
34625
|
-
}
|
|
34626
|
-
var argumentList = parseArgumentList();
|
|
34627
|
-
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34628
|
-
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34629
|
-
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34630
|
-
expression = finishNode(callExpr, pos);
|
|
34652
|
+
if (questionDotToken) {
|
|
34653
|
+
typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34654
|
+
if (isTemplateStartOfTaggedTemplate()) {
|
|
34655
|
+
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34631
34656
|
continue;
|
|
34632
34657
|
}
|
|
34633
34658
|
}
|
|
34634
|
-
|
|
34659
|
+
if (typeArguments || token() === 20 /* OpenParenToken */) {
|
|
34660
|
+
// Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments
|
|
34661
|
+
if (!questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
34662
|
+
typeArguments = expression.typeArguments;
|
|
34663
|
+
expression = expression.expression;
|
|
34664
|
+
}
|
|
34635
34665
|
var argumentList = parseArgumentList();
|
|
34636
34666
|
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34637
|
-
factory.createCallChain(expression, questionDotToken,
|
|
34638
|
-
factory.createCallExpression(expression,
|
|
34667
|
+
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34668
|
+
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34639
34669
|
expression = finishNode(callExpr, pos);
|
|
34640
34670
|
continue;
|
|
34641
34671
|
}
|
|
34642
34672
|
if (questionDotToken) {
|
|
34643
|
-
// We failed to parse anything, so report a missing identifier here.
|
|
34673
|
+
// We parsed `?.` but then failed to parse anything, so report a missing identifier here.
|
|
34644
34674
|
var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected);
|
|
34645
34675
|
expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
|
|
34646
34676
|
}
|
|
@@ -34668,21 +34698,25 @@ var ts;
|
|
|
34668
34698
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
34669
34699
|
return undefined;
|
|
34670
34700
|
}
|
|
34671
|
-
//
|
|
34672
|
-
//
|
|
34673
|
-
|
|
34674
|
-
|
|
34675
|
-
|
|
34701
|
+
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
34702
|
+
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
34703
|
+
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
34704
|
+
// it as a relational expression.
|
|
34705
|
+
return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
|
|
34676
34706
|
}
|
|
34677
34707
|
function canFollowTypeArgumentsInExpression() {
|
|
34678
34708
|
switch (token()) {
|
|
34709
|
+
// These tokens can follow a type argument list in a call expression.
|
|
34679
34710
|
case 20 /* OpenParenToken */: // foo<x>(
|
|
34680
34711
|
case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
34681
34712
|
case 15 /* TemplateHead */: // foo<T> `...${100}...`
|
|
34682
|
-
//
|
|
34683
|
-
//
|
|
34713
|
+
// These tokens can't follow in a call expression, nor can they start an
|
|
34714
|
+
// expression. So, consider the type argument list part of an instantiation
|
|
34715
|
+
// expression.
|
|
34684
34716
|
// falls through
|
|
34717
|
+
case 27 /* CommaToken */: // foo<x>,
|
|
34685
34718
|
case 24 /* DotToken */: // foo<x>.
|
|
34719
|
+
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
34686
34720
|
case 21 /* CloseParenToken */: // foo<x>)
|
|
34687
34721
|
case 23 /* CloseBracketToken */: // foo<x>]
|
|
34688
34722
|
case 58 /* ColonToken */: // foo<x>:
|
|
@@ -34700,20 +34734,10 @@ var ts;
|
|
|
34700
34734
|
case 51 /* BarToken */: // foo<x> |
|
|
34701
34735
|
case 19 /* CloseBraceToken */: // foo<x> }
|
|
34702
34736
|
case 1 /* EndOfFileToken */: // foo<x>
|
|
34703
|
-
// these cases can't legally follow a type arg list. However, they're not legal
|
|
34704
|
-
// expressions either. The user is probably in the middle of a generic type. So
|
|
34705
|
-
// treat it as such.
|
|
34706
34737
|
return true;
|
|
34707
|
-
case 27 /* CommaToken */: // foo<x>,
|
|
34708
|
-
case 18 /* OpenBraceToken */: // foo<x> {
|
|
34709
|
-
// We don't want to treat these as type arguments. Otherwise we'll parse this
|
|
34710
|
-
// as an invocation expression. Instead, we want to parse out the expression
|
|
34711
|
-
// in isolation from the type arguments.
|
|
34712
|
-
// falls through
|
|
34713
|
-
default:
|
|
34714
|
-
// Anything else treat as an expression.
|
|
34715
|
-
return false;
|
|
34716
34738
|
}
|
|
34739
|
+
// Treat anything else as an expression.
|
|
34740
|
+
return false;
|
|
34717
34741
|
}
|
|
34718
34742
|
function parsePrimaryExpression() {
|
|
34719
34743
|
switch (token()) {
|
|
@@ -34894,26 +34918,15 @@ var ts;
|
|
|
34894
34918
|
return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos);
|
|
34895
34919
|
}
|
|
34896
34920
|
var expressionPos = getNodePos();
|
|
34897
|
-
var expression = parsePrimaryExpression();
|
|
34921
|
+
var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
|
|
34898
34922
|
var typeArguments;
|
|
34899
|
-
|
|
34900
|
-
|
|
34901
|
-
typeArguments =
|
|
34902
|
-
|
|
34903
|
-
ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
|
|
34904
|
-
expression = parseTaggedTemplateRest(expressionPos, expression, /*optionalChain*/ undefined, typeArguments);
|
|
34905
|
-
typeArguments = undefined;
|
|
34906
|
-
}
|
|
34907
|
-
break;
|
|
34908
|
-
}
|
|
34909
|
-
var argumentsArray;
|
|
34910
|
-
if (token() === 20 /* OpenParenToken */) {
|
|
34911
|
-
argumentsArray = parseArgumentList();
|
|
34912
|
-
}
|
|
34913
|
-
else if (typeArguments) {
|
|
34914
|
-
parseErrorAt(pos, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
|
|
34923
|
+
// Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments
|
|
34924
|
+
if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
34925
|
+
typeArguments = expression.typeArguments;
|
|
34926
|
+
expression = expression.expression;
|
|
34915
34927
|
}
|
|
34916
|
-
|
|
34928
|
+
var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
|
|
34929
|
+
return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
|
|
34917
34930
|
}
|
|
34918
34931
|
// STATEMENTS
|
|
34919
34932
|
function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
|
|
@@ -35077,11 +35090,12 @@ var ts;
|
|
|
35077
35090
|
}
|
|
35078
35091
|
function parseCaseClause() {
|
|
35079
35092
|
var pos = getNodePos();
|
|
35093
|
+
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35080
35094
|
parseExpected(82 /* CaseKeyword */);
|
|
35081
35095
|
var expression = allowInAnd(parseExpression);
|
|
35082
35096
|
parseExpected(58 /* ColonToken */);
|
|
35083
35097
|
var statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
|
|
35084
|
-
return finishNode(factory.createCaseClause(expression, statements), pos);
|
|
35098
|
+
return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
|
|
35085
35099
|
}
|
|
35086
35100
|
function parseDefaultClause() {
|
|
35087
35101
|
var pos = getNodePos();
|
|
@@ -36001,6 +36015,9 @@ var ts;
|
|
|
36001
36015
|
function parseExpressionWithTypeArguments() {
|
|
36002
36016
|
var pos = getNodePos();
|
|
36003
36017
|
var expression = parseLeftHandSideExpressionOrHigher();
|
|
36018
|
+
if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
36019
|
+
return expression;
|
|
36020
|
+
}
|
|
36004
36021
|
var typeArguments = tryParseTypeArguments();
|
|
36005
36022
|
return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
36006
36023
|
}
|
|
@@ -36244,7 +36261,7 @@ var ts;
|
|
|
36244
36261
|
function parseModuleReference() {
|
|
36245
36262
|
return isExternalModuleReference()
|
|
36246
36263
|
? parseExternalModuleReference()
|
|
36247
|
-
: parseEntityName(/*allowReservedWords*/ false);
|
|
36264
|
+
: parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36248
36265
|
}
|
|
36249
36266
|
function parseExternalModuleReference() {
|
|
36250
36267
|
var pos = getNodePos();
|
|
@@ -36526,7 +36543,7 @@ var ts;
|
|
|
36526
36543
|
var pos = getNodePos();
|
|
36527
36544
|
var hasBrace = parseOptional(18 /* OpenBraceToken */);
|
|
36528
36545
|
var p2 = getNodePos();
|
|
36529
|
-
var entityName = parseEntityName(/* allowReservedWords*/ false);
|
|
36546
|
+
var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36530
36547
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
36531
36548
|
reScanHashToken(); // rescan #id as # id
|
|
36532
36549
|
nextTokenJSDoc(); // then skip the #
|
|
@@ -36969,7 +36986,7 @@ var ts;
|
|
|
36969
36986
|
// parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
|
|
36970
36987
|
var p2 = getNodePos();
|
|
36971
36988
|
var name = ts.tokenIsIdentifierOrKeyword(token())
|
|
36972
|
-
? parseEntityName(/*allowReservedWords*/ true)
|
|
36989
|
+
? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false)
|
|
36973
36990
|
: undefined;
|
|
36974
36991
|
if (name) {
|
|
36975
36992
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
@@ -36994,11 +37011,13 @@ var ts;
|
|
|
36994
37011
|
&& nextTokenJSDoc() === 59 /* AtToken */
|
|
36995
37012
|
&& ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
|
|
36996
37013
|
var kind = scanner.getTokenValue();
|
|
36997
|
-
if (kind
|
|
37014
|
+
if (isJSDocLinkTag(kind))
|
|
36998
37015
|
return kind;
|
|
36999
|
-
}
|
|
37000
37016
|
}
|
|
37001
37017
|
}
|
|
37018
|
+
function isJSDocLinkTag(kind) {
|
|
37019
|
+
return kind === "link" || kind === "linkcode" || kind === "linkplain";
|
|
37020
|
+
}
|
|
37002
37021
|
function parseUnknownTag(start, tagName, indent, indentText) {
|
|
37003
37022
|
return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
|
|
37004
37023
|
}
|
|
@@ -37104,7 +37123,7 @@ var ts;
|
|
|
37104
37123
|
}
|
|
37105
37124
|
function parseSeeTag(start, tagName, indent, indentText) {
|
|
37106
37125
|
var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
|
|
37107
|
-
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue()
|
|
37126
|
+
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); });
|
|
37108
37127
|
var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
|
|
37109
37128
|
var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
|
|
37110
37129
|
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
|
|
@@ -37971,6 +37990,19 @@ var ts;
|
|
|
37971
37990
|
return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
|
|
37972
37991
|
}
|
|
37973
37992
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
37993
|
+
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
37994
|
+
if (!mode) {
|
|
37995
|
+
return undefined;
|
|
37996
|
+
}
|
|
37997
|
+
if (mode === "import") {
|
|
37998
|
+
return ts.ModuleKind.ESNext;
|
|
37999
|
+
}
|
|
38000
|
+
if (mode === "require") {
|
|
38001
|
+
return ts.ModuleKind.CommonJS;
|
|
38002
|
+
}
|
|
38003
|
+
reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
|
|
38004
|
+
return undefined;
|
|
38005
|
+
}
|
|
37974
38006
|
/*@internal*/
|
|
37975
38007
|
function processCommentPragmas(context, sourceText) {
|
|
37976
38008
|
var pragmas = [];
|
|
@@ -38013,12 +38045,13 @@ var ts;
|
|
|
38013
38045
|
var typeReferenceDirectives_1 = context.typeReferenceDirectives;
|
|
38014
38046
|
var libReferenceDirectives_1 = context.libReferenceDirectives;
|
|
38015
38047
|
ts.forEach(ts.toArray(entryOrList), function (arg) {
|
|
38016
|
-
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
|
|
38048
|
+
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
|
|
38017
38049
|
if (arg.arguments["no-default-lib"]) {
|
|
38018
38050
|
context.hasNoDefaultLib = true;
|
|
38019
38051
|
}
|
|
38020
38052
|
else if (types) {
|
|
38021
|
-
|
|
38053
|
+
var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
|
|
38054
|
+
typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
|
|
38022
38055
|
}
|
|
38023
38056
|
else if (lib) {
|
|
38024
38057
|
libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
|
|
@@ -40430,7 +40463,7 @@ var ts;
|
|
|
40430
40463
|
var result = [];
|
|
40431
40464
|
result.push("{");
|
|
40432
40465
|
result.push(tab + "\"compilerOptions\": {");
|
|
40433
|
-
result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.
|
|
40466
|
+
result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */");
|
|
40434
40467
|
result.push("");
|
|
40435
40468
|
// Print out each row, aligning all the descriptions on the same column.
|
|
40436
40469
|
for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
|
|
@@ -41596,14 +41629,14 @@ var ts;
|
|
|
41596
41629
|
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
|
41597
41630
|
* is assumed to be the same as root directory of the project.
|
|
41598
41631
|
*/
|
|
41599
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
|
|
41632
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
|
|
41600
41633
|
var traceEnabled = isTraceEnabled(options, host);
|
|
41601
41634
|
if (redirectedReference) {
|
|
41602
41635
|
options = redirectedReference.commandLine.options;
|
|
41603
41636
|
}
|
|
41604
41637
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41605
41638
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41606
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/
|
|
41639
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
|
|
41607
41640
|
if (result) {
|
|
41608
41641
|
if (traceEnabled) {
|
|
41609
41642
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41638,7 +41671,18 @@ var ts;
|
|
|
41638
41671
|
}
|
|
41639
41672
|
var failedLookupLocations = [];
|
|
41640
41673
|
var features = getDefaultNodeResolutionFeatures(options);
|
|
41641
|
-
|
|
41674
|
+
// Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
|
|
41675
|
+
// setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
|
|
41676
|
+
// set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports
|
|
41677
|
+
// 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,
|
|
41678
|
+
// 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
|
|
41679
|
+
// resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution
|
|
41680
|
+
// context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do).
|
|
41681
|
+
if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
|
|
41682
|
+
features |= NodeResolutionFeatures.EsmMode;
|
|
41683
|
+
}
|
|
41684
|
+
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
41685
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
|
|
41642
41686
|
var resolved = primaryLookup();
|
|
41643
41687
|
var primary = true;
|
|
41644
41688
|
if (!resolved) {
|
|
@@ -41658,7 +41702,7 @@ var ts;
|
|
|
41658
41702
|
};
|
|
41659
41703
|
}
|
|
41660
41704
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41661
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/
|
|
41705
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
41662
41706
|
if (traceEnabled)
|
|
41663
41707
|
traceResult(result);
|
|
41664
41708
|
return result;
|
|
@@ -41944,7 +41988,11 @@ var ts;
|
|
|
41944
41988
|
ts.Debug.assert(keys.length === values.length);
|
|
41945
41989
|
var map = createModeAwareCache();
|
|
41946
41990
|
for (var i = 0; i < keys.length; ++i) {
|
|
41947
|
-
|
|
41991
|
+
var entry = keys[i];
|
|
41992
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
41993
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
41994
|
+
var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
|
|
41995
|
+
map.set(name, mode, values[i]);
|
|
41948
41996
|
}
|
|
41949
41997
|
return map;
|
|
41950
41998
|
}
|
|
@@ -46964,8 +47012,7 @@ var ts;
|
|
|
46964
47012
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
46965
47013
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
46966
47014
|
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
46967
|
-
IntersectionState[IntersectionState["
|
|
46968
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
|
|
47015
|
+
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
46969
47016
|
})(IntersectionState || (IntersectionState = {}));
|
|
46970
47017
|
var RecursionFlags;
|
|
46971
47018
|
(function (RecursionFlags) {
|
|
@@ -50979,7 +51026,7 @@ var ts;
|
|
|
50979
51026
|
// get symbol of the first identifier of the entityName
|
|
50980
51027
|
var meaning;
|
|
50981
51028
|
if (entityName.parent.kind === 180 /* TypeQuery */ ||
|
|
50982
|
-
ts.
|
|
51029
|
+
entityName.parent.kind === 227 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) ||
|
|
50983
51030
|
entityName.parent.kind === 161 /* ComputedPropertyName */) {
|
|
50984
51031
|
// Typeof value
|
|
50985
51032
|
meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
|
|
@@ -51090,7 +51137,7 @@ var ts;
|
|
|
51090
51137
|
return flags & 814775659 /* NodeBuilderFlagsMask */;
|
|
51091
51138
|
}
|
|
51092
51139
|
function isClassInstanceSide(type) {
|
|
51093
|
-
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) &
|
|
51140
|
+
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 33554432 /* IsClassInstanceClone */)));
|
|
51094
51141
|
}
|
|
51095
51142
|
function createNodeBuilder() {
|
|
51096
51143
|
return {
|
|
@@ -55019,7 +55066,7 @@ var ts;
|
|
|
55019
55066
|
members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
|
|
55020
55067
|
result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag
|
|
55021
55068
|
if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
|
|
55022
|
-
result.objectFlags |=
|
|
55069
|
+
result.objectFlags |= 33554432 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
|
|
55023
55070
|
}
|
|
55024
55071
|
return result;
|
|
55025
55072
|
}
|
|
@@ -57065,87 +57112,87 @@ var ts;
|
|
|
57065
57112
|
* Converts an AnonymousType to a ResolvedType.
|
|
57066
57113
|
*/
|
|
57067
57114
|
function resolveAnonymousTypeMembers(type) {
|
|
57068
|
-
var symbol = getMergedSymbol(type.symbol);
|
|
57069
57115
|
if (type.target) {
|
|
57070
57116
|
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
57071
|
-
var
|
|
57117
|
+
var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
|
|
57072
57118
|
var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper);
|
|
57073
57119
|
var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper);
|
|
57074
|
-
var
|
|
57075
|
-
setStructuredTypeMembers(type,
|
|
57120
|
+
var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper);
|
|
57121
|
+
setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1);
|
|
57122
|
+
return;
|
|
57076
57123
|
}
|
|
57077
|
-
|
|
57124
|
+
var symbol = getMergedSymbol(type.symbol);
|
|
57125
|
+
if (symbol.flags & 2048 /* TypeLiteral */) {
|
|
57078
57126
|
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
57079
|
-
var
|
|
57080
|
-
var callSignatures = getSignaturesOfSymbol(
|
|
57081
|
-
var constructSignatures = getSignaturesOfSymbol(
|
|
57082
|
-
var
|
|
57083
|
-
setStructuredTypeMembers(type,
|
|
57127
|
+
var members_7 = getMembersOfSymbol(symbol);
|
|
57128
|
+
var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */));
|
|
57129
|
+
var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */));
|
|
57130
|
+
var indexInfos_2 = getIndexInfosOfSymbol(symbol);
|
|
57131
|
+
setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2);
|
|
57132
|
+
return;
|
|
57084
57133
|
}
|
|
57085
|
-
|
|
57086
|
-
|
|
57087
|
-
|
|
57088
|
-
|
|
57089
|
-
|
|
57090
|
-
|
|
57091
|
-
|
|
57092
|
-
|
|
57093
|
-
|
|
57094
|
-
|
|
57095
|
-
|
|
57096
|
-
|
|
57097
|
-
|
|
57098
|
-
members = varsOnly_1;
|
|
57099
|
-
}
|
|
57134
|
+
// Combinations of function, class, enum and module
|
|
57135
|
+
var members = emptySymbols;
|
|
57136
|
+
var indexInfos;
|
|
57137
|
+
if (symbol.exports) {
|
|
57138
|
+
members = getExportsOfSymbol(symbol);
|
|
57139
|
+
if (symbol === globalThisSymbol) {
|
|
57140
|
+
var varsOnly_1 = new ts.Map();
|
|
57141
|
+
members.forEach(function (p) {
|
|
57142
|
+
if (!(p.flags & 418 /* BlockScoped */)) {
|
|
57143
|
+
varsOnly_1.set(p.escapedName, p);
|
|
57144
|
+
}
|
|
57145
|
+
});
|
|
57146
|
+
members = varsOnly_1;
|
|
57100
57147
|
}
|
|
57101
|
-
|
|
57102
|
-
|
|
57103
|
-
|
|
57104
|
-
|
|
57105
|
-
|
|
57106
|
-
|
|
57107
|
-
|
|
57108
|
-
|
|
57109
|
-
|
|
57110
|
-
else if (baseConstructorType === anyType) {
|
|
57111
|
-
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
|
57112
|
-
}
|
|
57148
|
+
}
|
|
57149
|
+
var baseConstructorIndexInfo;
|
|
57150
|
+
setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
57151
|
+
if (symbol.flags & 32 /* Class */) {
|
|
57152
|
+
var classType = getDeclaredTypeOfClassOrInterface(symbol);
|
|
57153
|
+
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
|
57154
|
+
if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) {
|
|
57155
|
+
members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members));
|
|
57156
|
+
addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
|
|
57113
57157
|
}
|
|
57114
|
-
|
|
57115
|
-
|
|
57116
|
-
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
57158
|
+
else if (baseConstructorType === anyType) {
|
|
57159
|
+
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
|
57117
57160
|
}
|
|
57118
|
-
|
|
57119
|
-
|
|
57120
|
-
|
|
57121
|
-
|
|
57122
|
-
|
|
57123
|
-
|
|
57124
|
-
|
|
57125
|
-
|
|
57161
|
+
}
|
|
57162
|
+
var indexSymbol = getIndexSymbolFromSymbolTable(members);
|
|
57163
|
+
if (indexSymbol) {
|
|
57164
|
+
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
57165
|
+
}
|
|
57166
|
+
else {
|
|
57167
|
+
if (baseConstructorIndexInfo) {
|
|
57168
|
+
indexInfos = ts.append(indexInfos, baseConstructorIndexInfo);
|
|
57126
57169
|
}
|
|
57127
|
-
|
|
57128
|
-
|
|
57129
|
-
|
|
57130
|
-
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
|
57131
|
-
// will never be observed because a qualified name can't reference signatures.
|
|
57132
|
-
if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
|
|
57133
|
-
type.callSignatures = getSignaturesOfSymbol(symbol);
|
|
57170
|
+
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ ||
|
|
57171
|
+
ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) {
|
|
57172
|
+
indexInfos = ts.append(indexInfos, enumNumberIndexInfo);
|
|
57134
57173
|
}
|
|
57135
|
-
|
|
57136
|
-
|
|
57137
|
-
|
|
57138
|
-
|
|
57139
|
-
|
|
57140
|
-
|
|
57141
|
-
|
|
57142
|
-
|
|
57143
|
-
|
|
57144
|
-
|
|
57145
|
-
|
|
57146
|
-
|
|
57147
|
-
|
|
57174
|
+
}
|
|
57175
|
+
setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray);
|
|
57176
|
+
// We resolve the members before computing the signatures because a signature may use
|
|
57177
|
+
// typeof with a qualified name expression that circularly references the type we are
|
|
57178
|
+
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
|
57179
|
+
// will never be observed because a qualified name can't reference signatures.
|
|
57180
|
+
if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
|
|
57181
|
+
type.callSignatures = getSignaturesOfSymbol(symbol);
|
|
57182
|
+
}
|
|
57183
|
+
// And likewise for construct signatures for classes
|
|
57184
|
+
if (symbol.flags & 32 /* Class */) {
|
|
57185
|
+
var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
|
|
57186
|
+
var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray;
|
|
57187
|
+
if (symbol.flags & 16 /* Function */) {
|
|
57188
|
+
constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
|
|
57189
|
+
createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) :
|
|
57190
|
+
undefined; }));
|
|
57148
57191
|
}
|
|
57192
|
+
if (!constructSignatures.length) {
|
|
57193
|
+
constructSignatures = getDefaultConstructSignatures(classType_1);
|
|
57194
|
+
}
|
|
57195
|
+
type.constructSignatures = constructSignatures;
|
|
57149
57196
|
}
|
|
57150
57197
|
}
|
|
57151
57198
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
@@ -58146,8 +58193,8 @@ var ts;
|
|
|
58146
58193
|
var stringIndexInfo;
|
|
58147
58194
|
var applicableInfo;
|
|
58148
58195
|
var applicableInfos;
|
|
58149
|
-
for (var _i = 0,
|
|
58150
|
-
var info =
|
|
58196
|
+
for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
|
|
58197
|
+
var info = indexInfos_3[_i];
|
|
58151
58198
|
if (info.keyType === stringType) {
|
|
58152
58199
|
stringIndexInfo = info;
|
|
58153
58200
|
}
|
|
@@ -58686,13 +58733,15 @@ var ts;
|
|
|
58686
58733
|
return signature;
|
|
58687
58734
|
}
|
|
58688
58735
|
function getOrCreateTypeFromSignature(signature) {
|
|
58736
|
+
var _a;
|
|
58689
58737
|
// There are two ways to declare a construct signature, one is by declaring a class constructor
|
|
58690
58738
|
// using the constructor keyword, and the other is declaring a bare construct signature in an
|
|
58691
58739
|
// object type literal or interface (using the new keyword). Each way of declaring a constructor
|
|
58692
58740
|
// will result in a different declaration kind.
|
|
58693
58741
|
if (!signature.isolatedSignatureType) {
|
|
58694
|
-
var kind =
|
|
58695
|
-
|
|
58742
|
+
var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
|
|
58743
|
+
// If declaration is undefined, it is likely to be the signature of the default constructor.
|
|
58744
|
+
var isConstructor = kind === undefined || kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */;
|
|
58696
58745
|
var type = createObjectType(16 /* Anonymous */);
|
|
58697
58746
|
type.members = emptySymbols;
|
|
58698
58747
|
type.properties = ts.emptyArray;
|
|
@@ -58718,14 +58767,14 @@ var ts;
|
|
|
58718
58767
|
}
|
|
58719
58768
|
function getIndexInfosOfIndexSymbol(indexSymbol) {
|
|
58720
58769
|
if (indexSymbol.declarations) {
|
|
58721
|
-
var
|
|
58770
|
+
var indexInfos_4 = [];
|
|
58722
58771
|
var _loop_14 = function (declaration) {
|
|
58723
58772
|
if (declaration.parameters.length === 1) {
|
|
58724
58773
|
var parameter = declaration.parameters[0];
|
|
58725
58774
|
if (parameter.type) {
|
|
58726
58775
|
forEachType(getTypeFromTypeNode(parameter.type), function (keyType) {
|
|
58727
|
-
if (isValidIndexKeyType(keyType) && !findIndexInfo(
|
|
58728
|
-
|
|
58776
|
+
if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) {
|
|
58777
|
+
indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration));
|
|
58729
58778
|
}
|
|
58730
58779
|
});
|
|
58731
58780
|
}
|
|
@@ -58735,7 +58784,7 @@ var ts;
|
|
|
58735
58784
|
var declaration = _a[_i];
|
|
58736
58785
|
_loop_14(declaration);
|
|
58737
58786
|
}
|
|
58738
|
-
return
|
|
58787
|
+
return indexInfos_4;
|
|
58739
58788
|
}
|
|
58740
58789
|
return ts.emptyArray;
|
|
58741
58790
|
}
|
|
@@ -59283,7 +59332,7 @@ var ts;
|
|
|
59283
59332
|
// The expression is processed as an identifier expression (section 4.3)
|
|
59284
59333
|
// or property access expression(section 4.10),
|
|
59285
59334
|
// the widened type(section 3.9) of which becomes the result.
|
|
59286
|
-
var type =
|
|
59335
|
+
var type = checkExpressionWithTypeArguments(node);
|
|
59287
59336
|
links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(type));
|
|
59288
59337
|
}
|
|
59289
59338
|
return links.resolvedType;
|
|
@@ -59620,7 +59669,7 @@ var ts;
|
|
|
59620
59669
|
}
|
|
59621
59670
|
}
|
|
59622
59671
|
var fixedLength = properties.length;
|
|
59623
|
-
var lengthSymbol = createSymbol(4 /* Property */, "length");
|
|
59672
|
+
var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
|
|
59624
59673
|
if (combinedFlags & 12 /* Variable */) {
|
|
59625
59674
|
lengthSymbol.type = numberType;
|
|
59626
59675
|
}
|
|
@@ -61987,7 +62036,9 @@ var ts;
|
|
|
61987
62036
|
return result;
|
|
61988
62037
|
}
|
|
61989
62038
|
function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
61990
|
-
var declaration = type.objectFlags & 4 /* Reference */ ? type.node :
|
|
62039
|
+
var declaration = type.objectFlags & 4 /* Reference */ ? type.node :
|
|
62040
|
+
type.objectFlags & 16777216 /* InstantiationExpressionType */ ? type.node :
|
|
62041
|
+
type.symbol.declarations[0];
|
|
61991
62042
|
var links = getNodeLinks(declaration);
|
|
61992
62043
|
var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType :
|
|
61993
62044
|
type.objectFlags & 64 /* Instantiated */ ? type.target : type;
|
|
@@ -62003,8 +62054,8 @@ var ts;
|
|
|
62003
62054
|
outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
|
|
62004
62055
|
}
|
|
62005
62056
|
typeParameters = outerTypeParameters || ts.emptyArray;
|
|
62006
|
-
var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations;
|
|
62007
|
-
typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
|
|
62057
|
+
var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations;
|
|
62058
|
+
typeParameters = (target.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
|
|
62008
62059
|
ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) :
|
|
62009
62060
|
typeParameters;
|
|
62010
62061
|
links.outerTypeParameters = typeParameters;
|
|
@@ -62176,6 +62227,9 @@ var ts;
|
|
|
62176
62227
|
mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
|
|
62177
62228
|
freshTypeParameter.mapper = mapper;
|
|
62178
62229
|
}
|
|
62230
|
+
if (type.objectFlags & 16777216 /* InstantiationExpressionType */) {
|
|
62231
|
+
result.node = type.node;
|
|
62232
|
+
}
|
|
62179
62233
|
result.target = type;
|
|
62180
62234
|
result.mapper = mapper;
|
|
62181
62235
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
@@ -62941,10 +62995,6 @@ var ts;
|
|
|
62941
62995
|
if (sourceRestType || targetRestType) {
|
|
62942
62996
|
void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
|
|
62943
62997
|
}
|
|
62944
|
-
if (sourceRestType && targetRestType && sourceCount !== targetCount) {
|
|
62945
|
-
// We're not able to relate misaligned complex rest parameters
|
|
62946
|
-
return 0 /* False */;
|
|
62947
|
-
}
|
|
62948
62998
|
var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
|
|
62949
62999
|
var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 168 /* MethodDeclaration */ &&
|
|
62950
63000
|
kind !== 167 /* MethodSignature */ && kind !== 170 /* Constructor */;
|
|
@@ -63260,11 +63310,11 @@ var ts;
|
|
|
63260
63310
|
var overflow = false;
|
|
63261
63311
|
var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
|
|
63262
63312
|
var lastSkippedInfo;
|
|
63263
|
-
var incompatibleStack
|
|
63313
|
+
var incompatibleStack;
|
|
63264
63314
|
var inPropertyCheck = false;
|
|
63265
63315
|
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
63266
63316
|
var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
|
|
63267
|
-
if (incompatibleStack
|
|
63317
|
+
if (incompatibleStack) {
|
|
63268
63318
|
reportIncompatibleStack();
|
|
63269
63319
|
}
|
|
63270
63320
|
if (overflow) {
|
|
@@ -63321,19 +63371,19 @@ var ts;
|
|
|
63321
63371
|
return {
|
|
63322
63372
|
errorInfo: errorInfo,
|
|
63323
63373
|
lastSkippedInfo: lastSkippedInfo,
|
|
63324
|
-
incompatibleStack: incompatibleStack.slice(),
|
|
63374
|
+
incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
|
|
63325
63375
|
overrideNextErrorInfo: overrideNextErrorInfo,
|
|
63326
|
-
relatedInfo:
|
|
63376
|
+
relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
|
|
63327
63377
|
};
|
|
63328
63378
|
}
|
|
63329
63379
|
function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
|
|
63330
63380
|
overrideNextErrorInfo++; // Suppress the next relation error
|
|
63331
63381
|
lastSkippedInfo = undefined; // Reset skipped info cache
|
|
63332
|
-
incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
|
|
63382
|
+
(incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
|
|
63333
63383
|
}
|
|
63334
63384
|
function reportIncompatibleStack() {
|
|
63335
|
-
var stack = incompatibleStack;
|
|
63336
|
-
incompatibleStack =
|
|
63385
|
+
var stack = incompatibleStack || [];
|
|
63386
|
+
incompatibleStack = undefined;
|
|
63337
63387
|
var info = lastSkippedInfo;
|
|
63338
63388
|
lastSkippedInfo = undefined;
|
|
63339
63389
|
if (stack.length === 1) {
|
|
@@ -63439,7 +63489,7 @@ var ts;
|
|
|
63439
63489
|
}
|
|
63440
63490
|
function reportError(message, arg0, arg1, arg2, arg3) {
|
|
63441
63491
|
ts.Debug.assert(!!errorNode);
|
|
63442
|
-
if (incompatibleStack
|
|
63492
|
+
if (incompatibleStack)
|
|
63443
63493
|
reportIncompatibleStack();
|
|
63444
63494
|
if (message.elidedInCompatabilityPyramid)
|
|
63445
63495
|
return;
|
|
@@ -63455,7 +63505,7 @@ var ts;
|
|
|
63455
63505
|
}
|
|
63456
63506
|
}
|
|
63457
63507
|
function reportRelationError(message, source, target) {
|
|
63458
|
-
if (incompatibleStack
|
|
63508
|
+
if (incompatibleStack)
|
|
63459
63509
|
reportIncompatibleStack();
|
|
63460
63510
|
var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
|
|
63461
63511
|
var generalizedSource = source;
|
|
@@ -63567,7 +63617,9 @@ var ts;
|
|
|
63567
63617
|
if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
|
|
63568
63618
|
return -1 /* True */;
|
|
63569
63619
|
}
|
|
63570
|
-
|
|
63620
|
+
if (reportErrors) {
|
|
63621
|
+
reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
|
|
63622
|
+
}
|
|
63571
63623
|
return 0 /* False */;
|
|
63572
63624
|
}
|
|
63573
63625
|
// Normalize the source and target types: Turn fresh literal types into regular literal types,
|
|
@@ -63579,7 +63631,12 @@ var ts;
|
|
|
63579
63631
|
if (source === target)
|
|
63580
63632
|
return -1 /* True */;
|
|
63581
63633
|
if (relation === identityRelation) {
|
|
63582
|
-
|
|
63634
|
+
if (source.flags !== target.flags)
|
|
63635
|
+
return 0 /* False */;
|
|
63636
|
+
if (source.flags & 67358815 /* Singleton */)
|
|
63637
|
+
return -1 /* True */;
|
|
63638
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63639
|
+
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63583
63640
|
}
|
|
63584
63641
|
// We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
|
|
63585
63642
|
// and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
|
|
@@ -63589,163 +63646,130 @@ var ts;
|
|
|
63589
63646
|
if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
|
|
63590
63647
|
return -1 /* True */;
|
|
63591
63648
|
}
|
|
63592
|
-
//
|
|
63593
|
-
// If so,
|
|
63594
|
-
|
|
63595
|
-
|
|
63596
|
-
|
|
63597
|
-
|
|
63598
|
-
|
|
63599
|
-
|
|
63600
|
-
|
|
63601
|
-
|
|
63602
|
-
|
|
63603
|
-
|
|
63604
|
-
if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) {
|
|
63605
|
-
target = getNormalizedType(nullStrippedTarget, /*writing*/ true);
|
|
63606
|
-
}
|
|
63607
|
-
if (source === nullStrippedTarget)
|
|
63608
|
-
return -1 /* True */;
|
|
63649
|
+
// See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
|
|
63650
|
+
// plus a single non-nullable type. If so, remove null and/or undefined from the target type.
|
|
63651
|
+
if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
|
|
63652
|
+
var types = target.types;
|
|
63653
|
+
var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
|
|
63654
|
+
types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
|
|
63655
|
+
undefined;
|
|
63656
|
+
if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
|
|
63657
|
+
target = getNormalizedType(candidate, /*writing*/ true);
|
|
63658
|
+
if (source === target)
|
|
63659
|
+
return -1 /* True */;
|
|
63660
|
+
}
|
|
63609
63661
|
}
|
|
63610
63662
|
if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
|
|
63611
63663
|
isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
|
|
63612
63664
|
return -1 /* True */;
|
|
63613
|
-
|
|
63614
|
-
|
|
63615
|
-
|
|
63616
|
-
|
|
63665
|
+
if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
|
|
63666
|
+
var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
|
|
63667
|
+
if (isPerformingExcessPropertyChecks) {
|
|
63668
|
+
if (hasExcessProperties(source, target, reportErrors)) {
|
|
63669
|
+
if (reportErrors) {
|
|
63670
|
+
reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
|
|
63671
|
+
}
|
|
63672
|
+
return 0 /* False */;
|
|
63673
|
+
}
|
|
63674
|
+
}
|
|
63675
|
+
var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
|
|
63676
|
+
source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
|
|
63677
|
+
target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
|
|
63678
|
+
(getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
|
|
63679
|
+
var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
|
|
63680
|
+
if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
|
|
63617
63681
|
if (reportErrors) {
|
|
63618
|
-
|
|
63682
|
+
var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
|
|
63683
|
+
var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
|
|
63684
|
+
var calls = getSignaturesOfType(source, 0 /* Call */);
|
|
63685
|
+
var constructs = getSignaturesOfType(source, 1 /* Construct */);
|
|
63686
|
+
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
|
|
63687
|
+
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
63688
|
+
reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
|
|
63689
|
+
}
|
|
63690
|
+
else {
|
|
63691
|
+
reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
|
|
63692
|
+
}
|
|
63619
63693
|
}
|
|
63620
63694
|
return 0 /* False */;
|
|
63621
63695
|
}
|
|
63622
|
-
|
|
63623
|
-
|
|
63624
|
-
|
|
63625
|
-
|
|
63626
|
-
|
|
63627
|
-
|
|
63628
|
-
|
|
63629
|
-
|
|
63630
|
-
|
|
63631
|
-
|
|
63632
|
-
|
|
63633
|
-
|
|
63634
|
-
|
|
63635
|
-
|
|
63636
|
-
|
|
63637
|
-
|
|
63638
|
-
|
|
63639
|
-
|
|
63696
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63697
|
+
var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
|
|
63698
|
+
target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
|
|
63699
|
+
var result_7 = skipCaching ?
|
|
63700
|
+
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
63701
|
+
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
63702
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
63703
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
63704
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
63705
|
+
//
|
|
63706
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63707
|
+
//
|
|
63708
|
+
// declare let wrong: { a: { y: string } };
|
|
63709
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63710
|
+
//
|
|
63711
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63712
|
+
// x = y; // Mismatched property in source intersection
|
|
63713
|
+
// }
|
|
63714
|
+
//
|
|
63715
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63716
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63717
|
+
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63718
|
+
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 */); }))) {
|
|
63719
|
+
inPropertyCheck = true;
|
|
63720
|
+
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63721
|
+
inPropertyCheck = false;
|
|
63722
|
+
}
|
|
63723
|
+
if (result_7) {
|
|
63724
|
+
return result_7;
|
|
63640
63725
|
}
|
|
63641
|
-
return 0 /* False */;
|
|
63642
|
-
}
|
|
63643
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63644
|
-
var result = 0 /* False */;
|
|
63645
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
63646
|
-
if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
|
|
63647
|
-
// We skip caching when source or target is a union with no more than three constituents.
|
|
63648
|
-
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63649
63726
|
}
|
|
63650
|
-
|
|
63651
|
-
|
|
63727
|
+
if (reportErrors) {
|
|
63728
|
+
reportErrorResults(originalSource, originalTarget, source, target, headMessage);
|
|
63652
63729
|
}
|
|
63653
|
-
|
|
63654
|
-
|
|
63655
|
-
|
|
63730
|
+
return 0 /* False */;
|
|
63731
|
+
}
|
|
63732
|
+
function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
|
|
63733
|
+
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63734
|
+
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63735
|
+
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63736
|
+
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63737
|
+
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63738
|
+
if (maybeSuppress) {
|
|
63739
|
+
overrideNextErrorInfo--;
|
|
63740
|
+
}
|
|
63741
|
+
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63742
|
+
var currentError = errorInfo;
|
|
63743
|
+
tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
|
|
63744
|
+
if (errorInfo !== currentError) {
|
|
63745
|
+
maybeSuppress = !!errorInfo;
|
|
63746
|
+
}
|
|
63747
|
+
}
|
|
63748
|
+
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63749
|
+
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63750
|
+
}
|
|
63751
|
+
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63752
|
+
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63753
|
+
}
|
|
63754
|
+
else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
|
|
63755
|
+
var targetTypes = target.types;
|
|
63756
|
+
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63757
|
+
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63758
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63759
|
+
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63760
|
+
// do not report top error
|
|
63761
|
+
return;
|
|
63656
63762
|
}
|
|
63657
63763
|
}
|
|
63658
|
-
|
|
63659
|
-
|
|
63660
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
63661
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
63662
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
63663
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
63664
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
63665
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
63666
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
63667
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
63668
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
63669
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
63670
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
63671
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
63672
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
63673
|
-
if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
|
|
63674
|
-
if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
63675
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
63676
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63677
|
-
resetErrorInfo(saveErrorInfo);
|
|
63678
|
-
}
|
|
63679
|
-
}
|
|
63680
|
-
}
|
|
63764
|
+
else {
|
|
63765
|
+
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63681
63766
|
}
|
|
63682
|
-
|
|
63683
|
-
|
|
63684
|
-
|
|
63685
|
-
|
|
63686
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63687
|
-
//
|
|
63688
|
-
// declare let wrong: { a: { y: string } };
|
|
63689
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63690
|
-
//
|
|
63691
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63692
|
-
// x = y; // Mismatched property in source intersection
|
|
63693
|
-
// }
|
|
63694
|
-
//
|
|
63695
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63696
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63697
|
-
if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63698
|
-
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 */); }))) {
|
|
63699
|
-
inPropertyCheck = true;
|
|
63700
|
-
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63701
|
-
inPropertyCheck = false;
|
|
63702
|
-
}
|
|
63703
|
-
reportErrorResults(source, target, result, isComparingJsxAttributes);
|
|
63704
|
-
return result;
|
|
63705
|
-
function reportErrorResults(source, target, result, isComparingJsxAttributes) {
|
|
63706
|
-
if (!result && reportErrors) {
|
|
63707
|
-
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63708
|
-
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63709
|
-
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63710
|
-
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63711
|
-
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63712
|
-
if (maybeSuppress) {
|
|
63713
|
-
overrideNextErrorInfo--;
|
|
63714
|
-
}
|
|
63715
|
-
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63716
|
-
var currentError = errorInfo;
|
|
63717
|
-
tryElaborateArrayLikeErrors(source, target, reportErrors);
|
|
63718
|
-
if (errorInfo !== currentError) {
|
|
63719
|
-
maybeSuppress = !!errorInfo;
|
|
63720
|
-
}
|
|
63721
|
-
}
|
|
63722
|
-
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63723
|
-
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63724
|
-
}
|
|
63725
|
-
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63726
|
-
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63727
|
-
}
|
|
63728
|
-
else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) {
|
|
63729
|
-
var targetTypes = target.types;
|
|
63730
|
-
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63731
|
-
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63732
|
-
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63733
|
-
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63734
|
-
// do not report top error
|
|
63735
|
-
return result;
|
|
63736
|
-
}
|
|
63737
|
-
}
|
|
63738
|
-
else {
|
|
63739
|
-
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63740
|
-
}
|
|
63741
|
-
if (!headMessage && maybeSuppress) {
|
|
63742
|
-
lastSkippedInfo = [source, target];
|
|
63743
|
-
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63744
|
-
return result;
|
|
63745
|
-
}
|
|
63746
|
-
reportRelationError(headMessage, source, target);
|
|
63747
|
-
}
|
|
63767
|
+
if (!headMessage && maybeSuppress) {
|
|
63768
|
+
lastSkippedInfo = [source, target];
|
|
63769
|
+
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63770
|
+
return;
|
|
63748
63771
|
}
|
|
63772
|
+
reportRelationError(headMessage, source, target);
|
|
63749
63773
|
}
|
|
63750
63774
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
63751
63775
|
if (!ts.tracing) {
|
|
@@ -63772,21 +63796,6 @@ var ts;
|
|
|
63772
63796
|
}
|
|
63773
63797
|
}
|
|
63774
63798
|
}
|
|
63775
|
-
function isIdenticalTo(source, target, recursionFlags) {
|
|
63776
|
-
if (source.flags !== target.flags)
|
|
63777
|
-
return 0 /* False */;
|
|
63778
|
-
if (source.flags & 67358815 /* Singleton */)
|
|
63779
|
-
return -1 /* True */;
|
|
63780
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63781
|
-
if (source.flags & 3145728 /* UnionOrIntersection */) {
|
|
63782
|
-
var result_7 = eachTypeRelatedToSomeType(source, target);
|
|
63783
|
-
if (result_7) {
|
|
63784
|
-
result_7 &= eachTypeRelatedToSomeType(target, source);
|
|
63785
|
-
}
|
|
63786
|
-
return result_7;
|
|
63787
|
-
}
|
|
63788
|
-
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63789
|
-
}
|
|
63790
63799
|
function getTypeOfPropertyInTypes(types, name) {
|
|
63791
63800
|
var appendPropType = function (propTypes, type) {
|
|
63792
63801
|
var _a;
|
|
@@ -63885,6 +63894,41 @@ var ts;
|
|
|
63885
63894
|
function shouldCheckAsExcessProperty(prop, container) {
|
|
63886
63895
|
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
|
|
63887
63896
|
}
|
|
63897
|
+
function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
|
|
63898
|
+
// Note that these checks are specifically ordered to produce correct results. In particular,
|
|
63899
|
+
// we need to deconstruct unions before intersections (because unions are always at the top),
|
|
63900
|
+
// and we need to handle "each" relations before "some" relations for the same kind of type.
|
|
63901
|
+
if (source.flags & 1048576 /* Union */) {
|
|
63902
|
+
return relation === comparableRelation ?
|
|
63903
|
+
someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
|
|
63904
|
+
eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
|
|
63905
|
+
}
|
|
63906
|
+
if (target.flags & 1048576 /* Union */) {
|
|
63907
|
+
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
63908
|
+
}
|
|
63909
|
+
if (target.flags & 2097152 /* Intersection */) {
|
|
63910
|
+
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
63911
|
+
}
|
|
63912
|
+
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
63913
|
+
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
63914
|
+
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
63915
|
+
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
63916
|
+
// appear to be comparable to '2'.
|
|
63917
|
+
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
63918
|
+
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
63919
|
+
if (constraints !== source.types) {
|
|
63920
|
+
source = getIntersectionType(constraints);
|
|
63921
|
+
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
63922
|
+
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
63923
|
+
}
|
|
63924
|
+
}
|
|
63925
|
+
}
|
|
63926
|
+
// Check to see if any constituents of the intersection are immediately related to the target.
|
|
63927
|
+
// Don't report errors though. Elaborating on whether a source constituent is related to the target is
|
|
63928
|
+
// not actually useful and leads to some confusing error messages. Instead, we rely on the caller
|
|
63929
|
+
// checking whether the full intersection viewed as an object is related to the target.
|
|
63930
|
+
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
63931
|
+
}
|
|
63888
63932
|
function eachTypeRelatedToSomeType(source, target) {
|
|
63889
63933
|
var result = -1 /* True */;
|
|
63890
63934
|
var sourceTypes = source.types;
|
|
@@ -63920,8 +63964,11 @@ var ts;
|
|
|
63920
63964
|
}
|
|
63921
63965
|
}
|
|
63922
63966
|
if (reportErrors) {
|
|
63967
|
+
// Elaborate only if we can find a best matching type in the target union
|
|
63923
63968
|
var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
|
|
63924
|
-
|
|
63969
|
+
if (bestMatchingType) {
|
|
63970
|
+
isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
|
|
63971
|
+
}
|
|
63925
63972
|
}
|
|
63926
63973
|
return 0 /* False */;
|
|
63927
63974
|
}
|
|
@@ -64057,7 +64104,7 @@ var ts;
|
|
|
64057
64104
|
if (overflow) {
|
|
64058
64105
|
return 0 /* False */;
|
|
64059
64106
|
}
|
|
64060
|
-
var keyIntersectionState = intersectionState | (inPropertyCheck ?
|
|
64107
|
+
var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
|
|
64061
64108
|
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
64062
64109
|
var entry = relation.get(id);
|
|
64063
64110
|
if (entry !== undefined) {
|
|
@@ -64125,6 +64172,7 @@ var ts;
|
|
|
64125
64172
|
return originalHandler(onlyUnreliable);
|
|
64126
64173
|
};
|
|
64127
64174
|
}
|
|
64175
|
+
var result;
|
|
64128
64176
|
if (expandingFlags === 3 /* Both */) {
|
|
64129
64177
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
|
|
64130
64178
|
sourceId: source.id,
|
|
@@ -64134,8 +64182,13 @@ var ts;
|
|
|
64134
64182
|
depth: sourceDepth,
|
|
64135
64183
|
targetDepth: targetDepth
|
|
64136
64184
|
});
|
|
64185
|
+
result = 3 /* Maybe */;
|
|
64186
|
+
}
|
|
64187
|
+
else {
|
|
64188
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64189
|
+
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
|
|
64190
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64137
64191
|
}
|
|
64138
|
-
var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
|
|
64139
64192
|
if (outofbandVarianceMarkerHandler) {
|
|
64140
64193
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
64141
64194
|
}
|
|
@@ -64167,98 +64220,97 @@ var ts;
|
|
|
64167
64220
|
return result;
|
|
64168
64221
|
}
|
|
64169
64222
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
64170
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64171
|
-
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
|
|
64172
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64173
|
-
return result;
|
|
64174
|
-
}
|
|
64175
|
-
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
|
|
64176
64223
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
64177
64224
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
64178
64225
|
}
|
|
64179
|
-
|
|
64180
|
-
|
|
64181
|
-
|
|
64182
|
-
|
|
64183
|
-
|
|
64184
|
-
|
|
64185
|
-
|
|
64186
|
-
|
|
64187
|
-
|
|
64188
|
-
|
|
64189
|
-
|
|
64190
|
-
|
|
64191
|
-
if (target.flags & 2097152 /* Intersection */) {
|
|
64192
|
-
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
64193
|
-
}
|
|
64194
|
-
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
64195
|
-
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
64196
|
-
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
64197
|
-
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
64198
|
-
// appear to be comparable to '2'.
|
|
64199
|
-
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
64200
|
-
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
64201
|
-
if (constraints !== source.types) {
|
|
64202
|
-
source = getIntersectionType(constraints);
|
|
64203
|
-
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
64204
|
-
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
64205
|
-
}
|
|
64226
|
+
var result;
|
|
64227
|
+
var originalErrorInfo;
|
|
64228
|
+
var varianceCheckFailed = false;
|
|
64229
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
64230
|
+
var sourceFlags = source.flags;
|
|
64231
|
+
var targetFlags = target.flags;
|
|
64232
|
+
if (relation === identityRelation) {
|
|
64233
|
+
// We've already checked that source.flags and target.flags are identical
|
|
64234
|
+
if (sourceFlags & 3145728 /* UnionOrIntersection */) {
|
|
64235
|
+
var result_8 = eachTypeRelatedToSomeType(source, target);
|
|
64236
|
+
if (result_8) {
|
|
64237
|
+
result_8 &= eachTypeRelatedToSomeType(target, source);
|
|
64206
64238
|
}
|
|
64239
|
+
return result_8;
|
|
64207
64240
|
}
|
|
64208
|
-
|
|
64209
|
-
//
|
|
64210
|
-
// Don't report errors though. Checking whether a constituent is related to the source is not actually
|
|
64211
|
-
// useful and leads to some confusing error messages. Instead it is better to let the below checks
|
|
64212
|
-
// take care of this, or to not elaborate at all. For instance,
|
|
64213
|
-
//
|
|
64214
|
-
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
|
|
64215
|
-
//
|
|
64216
|
-
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
|
|
64217
|
-
// than to report that 'D' is not assignable to 'A' or 'B'.
|
|
64218
|
-
//
|
|
64219
|
-
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
|
|
64220
|
-
// breaking the intersection apart.
|
|
64221
|
-
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
64222
|
-
}
|
|
64223
|
-
var flags = source.flags & target.flags;
|
|
64224
|
-
if (relation === identityRelation && !(flags & 524288 /* Object */)) {
|
|
64225
|
-
if (flags & 4194304 /* Index */) {
|
|
64241
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64226
64242
|
return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
|
|
64227
64243
|
}
|
|
64228
|
-
|
|
64229
|
-
|
|
64230
|
-
|
|
64231
|
-
|
|
64232
|
-
return result_8;
|
|
64244
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64245
|
+
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64246
|
+
if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64247
|
+
return result;
|
|
64233
64248
|
}
|
|
64234
64249
|
}
|
|
64235
64250
|
}
|
|
64236
|
-
if (
|
|
64251
|
+
if (sourceFlags & 16777216 /* Conditional */) {
|
|
64237
64252
|
if (source.root.isDistributive === target.root.isDistributive) {
|
|
64238
|
-
if (
|
|
64239
|
-
if (
|
|
64240
|
-
if (
|
|
64241
|
-
if (
|
|
64242
|
-
return
|
|
64253
|
+
if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64254
|
+
if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64255
|
+
if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64256
|
+
if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64257
|
+
return result;
|
|
64243
64258
|
}
|
|
64244
64259
|
}
|
|
64245
64260
|
}
|
|
64246
64261
|
}
|
|
64247
64262
|
}
|
|
64248
64263
|
}
|
|
64249
|
-
if (
|
|
64264
|
+
if (sourceFlags & 33554432 /* Substitution */) {
|
|
64250
64265
|
return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
|
|
64251
64266
|
}
|
|
64252
|
-
|
|
64267
|
+
if (!(sourceFlags & 524288 /* Object */)) {
|
|
64268
|
+
return 0 /* False */;
|
|
64269
|
+
}
|
|
64270
|
+
}
|
|
64271
|
+
else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
|
|
64272
|
+
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
64273
|
+
return result;
|
|
64274
|
+
}
|
|
64275
|
+
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
64276
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
64277
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
64278
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
64279
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
64280
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
64281
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
64282
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
64283
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
64284
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
64285
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
64286
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
64287
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
64288
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
64289
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
64290
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
64291
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
64292
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
64293
|
+
resetErrorInfo(saveErrorInfo);
|
|
64294
|
+
return result;
|
|
64295
|
+
}
|
|
64296
|
+
}
|
|
64297
|
+
}
|
|
64298
|
+
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
64299
|
+
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
64300
|
+
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64301
|
+
// Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
|
|
64302
|
+
// Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64303
|
+
// Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
|
|
64304
|
+
if (!(sourceFlags & 465829888 /* Instantiable */ ||
|
|
64305
|
+
sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
|
|
64306
|
+
sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
|
|
64307
|
+
return 0 /* False */;
|
|
64308
|
+
}
|
|
64253
64309
|
}
|
|
64254
|
-
var result;
|
|
64255
|
-
var originalErrorInfo;
|
|
64256
|
-
var varianceCheckFailed = false;
|
|
64257
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
64258
64310
|
// We limit alias variance probing to only object and conditional types since their alias behavior
|
|
64259
64311
|
// is more predictable than other, interned types, which may or may not have an alias depending on
|
|
64260
64312
|
// the order in which things were checked.
|
|
64261
|
-
if (
|
|
64313
|
+
if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
|
|
64262
64314
|
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
|
|
64263
64315
|
!(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
|
|
64264
64316
|
var variances = getAliasVariances(source.aliasSymbol);
|
|
@@ -64276,7 +64328,7 @@ var ts;
|
|
|
64276
64328
|
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
|
|
64277
64329
|
return result;
|
|
64278
64330
|
}
|
|
64279
|
-
if (
|
|
64331
|
+
if (targetFlags & 262144 /* TypeParameter */) {
|
|
64280
64332
|
// 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].
|
|
64281
64333
|
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
|
|
64282
64334
|
if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
|
|
@@ -64288,10 +64340,10 @@ var ts;
|
|
|
64288
64340
|
}
|
|
64289
64341
|
}
|
|
64290
64342
|
}
|
|
64291
|
-
else if (
|
|
64343
|
+
else if (targetFlags & 4194304 /* Index */) {
|
|
64292
64344
|
var targetType_1 = target.type;
|
|
64293
64345
|
// A keyof S is related to a keyof T if T is related to S.
|
|
64294
|
-
if (
|
|
64346
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64295
64347
|
if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64296
64348
|
return result;
|
|
64297
64349
|
}
|
|
@@ -64342,8 +64394,8 @@ var ts;
|
|
|
64342
64394
|
}
|
|
64343
64395
|
}
|
|
64344
64396
|
}
|
|
64345
|
-
else if (
|
|
64346
|
-
if (
|
|
64397
|
+
else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
64398
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64347
64399
|
// Relate components directly before falling back to constraint relationships
|
|
64348
64400
|
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
|
|
64349
64401
|
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
|
|
@@ -64449,7 +64501,7 @@ var ts;
|
|
|
64449
64501
|
}
|
|
64450
64502
|
}
|
|
64451
64503
|
}
|
|
64452
|
-
else if (
|
|
64504
|
+
else if (targetFlags & 16777216 /* Conditional */) {
|
|
64453
64505
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64454
64506
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64455
64507
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
@@ -64474,8 +64526,8 @@ var ts;
|
|
|
64474
64526
|
}
|
|
64475
64527
|
}
|
|
64476
64528
|
}
|
|
64477
|
-
else if (
|
|
64478
|
-
if (
|
|
64529
|
+
else if (targetFlags & 134217728 /* TemplateLiteral */) {
|
|
64530
|
+
if (sourceFlags & 134217728 /* TemplateLiteral */) {
|
|
64479
64531
|
if (relation === comparableRelation) {
|
|
64480
64532
|
return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
|
|
64481
64533
|
}
|
|
@@ -64487,11 +64539,11 @@ var ts;
|
|
|
64487
64539
|
return -1 /* True */;
|
|
64488
64540
|
}
|
|
64489
64541
|
}
|
|
64490
|
-
if (
|
|
64491
|
-
// IndexedAccess comparisons are handled above in the `
|
|
64492
|
-
if (!(
|
|
64542
|
+
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
64543
|
+
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
64544
|
+
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
64493
64545
|
var constraint = getConstraintOfType(source);
|
|
64494
|
-
if (!constraint || (
|
|
64546
|
+
if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
64495
64547
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
64496
64548
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
64497
64549
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64504,7 +64556,7 @@ var ts;
|
|
|
64504
64556
|
return result;
|
|
64505
64557
|
}
|
|
64506
64558
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
64507
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(
|
|
64559
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
64508
64560
|
resetErrorInfo(saveErrorInfo);
|
|
64509
64561
|
return result;
|
|
64510
64562
|
}
|
|
@@ -64521,14 +64573,14 @@ var ts;
|
|
|
64521
64573
|
}
|
|
64522
64574
|
}
|
|
64523
64575
|
}
|
|
64524
|
-
else if (
|
|
64576
|
+
else if (sourceFlags & 4194304 /* Index */) {
|
|
64525
64577
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
64526
64578
|
resetErrorInfo(saveErrorInfo);
|
|
64527
64579
|
return result;
|
|
64528
64580
|
}
|
|
64529
64581
|
}
|
|
64530
|
-
else if (
|
|
64531
|
-
if (!(
|
|
64582
|
+
else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
64583
|
+
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
64532
64584
|
var constraint = getBaseConstraintOfType(source);
|
|
64533
64585
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
64534
64586
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64536,8 +64588,8 @@ var ts;
|
|
|
64536
64588
|
}
|
|
64537
64589
|
}
|
|
64538
64590
|
}
|
|
64539
|
-
else if (
|
|
64540
|
-
if (
|
|
64591
|
+
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
64592
|
+
if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
|
|
64541
64593
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
64542
64594
|
resetErrorInfo(saveErrorInfo);
|
|
64543
64595
|
return result;
|
|
@@ -64551,14 +64603,14 @@ var ts;
|
|
|
64551
64603
|
}
|
|
64552
64604
|
}
|
|
64553
64605
|
}
|
|
64554
|
-
else if (
|
|
64606
|
+
else if (sourceFlags & 16777216 /* Conditional */) {
|
|
64555
64607
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64556
64608
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64557
64609
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
64558
64610
|
resetErrorInfo(saveErrorInfo);
|
|
64559
64611
|
return 3 /* Maybe */;
|
|
64560
64612
|
}
|
|
64561
|
-
if (
|
|
64613
|
+
if (targetFlags & 16777216 /* Conditional */) {
|
|
64562
64614
|
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
|
|
64563
64615
|
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
|
|
64564
64616
|
// and Y1 is related to Y2.
|
|
@@ -64618,9 +64670,10 @@ var ts;
|
|
|
64618
64670
|
}
|
|
64619
64671
|
return 0 /* False */;
|
|
64620
64672
|
}
|
|
64621
|
-
var sourceIsPrimitive = !!(
|
|
64673
|
+
var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
|
|
64622
64674
|
if (relation !== identityRelation) {
|
|
64623
64675
|
source = getApparentType(source);
|
|
64676
|
+
sourceFlags = source.flags;
|
|
64624
64677
|
}
|
|
64625
64678
|
else if (isGenericMappedType(source)) {
|
|
64626
64679
|
return 0 /* False */;
|
|
@@ -64667,7 +64720,7 @@ var ts;
|
|
|
64667
64720
|
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
|
|
64668
64721
|
// to X. Failing both of those we want to check if the aggregation of A and B's members structurally
|
|
64669
64722
|
// relates to X. Thus, we include intersection types on the source side here.
|
|
64670
|
-
if (
|
|
64723
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
|
|
64671
64724
|
// Report structural errors only if we haven't reported any errors yet
|
|
64672
64725
|
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
|
|
64673
64726
|
result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
|
|
@@ -64691,7 +64744,7 @@ var ts;
|
|
|
64691
64744
|
// there exists a constituent of T for every combination of the discriminants of S
|
|
64692
64745
|
// with respect to T. We do not report errors here, as we will use the existing
|
|
64693
64746
|
// error result from checking each constituent of the union.
|
|
64694
|
-
if (
|
|
64747
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
|
|
64695
64748
|
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
|
|
64696
64749
|
if (objectOnlyTarget.flags & 1048576 /* Union */) {
|
|
64697
64750
|
var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
|
|
@@ -65215,7 +65268,6 @@ var ts;
|
|
|
65215
65268
|
}
|
|
65216
65269
|
}
|
|
65217
65270
|
var result = -1 /* True */;
|
|
65218
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
65219
65271
|
var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
|
|
65220
65272
|
var sourceObjectFlags = ts.getObjectFlags(source);
|
|
65221
65273
|
var targetObjectFlags = ts.getObjectFlags(target);
|
|
@@ -65256,6 +65308,7 @@ var ts;
|
|
|
65256
65308
|
else {
|
|
65257
65309
|
outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
|
|
65258
65310
|
var t = targetSignatures_1[_i];
|
|
65311
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
65259
65312
|
// Only elaborate errors from the first failure
|
|
65260
65313
|
var shouldElaborateErrors = reportErrors;
|
|
65261
65314
|
for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
|
|
@@ -65366,8 +65419,8 @@ var ts;
|
|
|
65366
65419
|
var indexInfos = getIndexInfosOfType(target);
|
|
65367
65420
|
var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; });
|
|
65368
65421
|
var result = -1 /* True */;
|
|
65369
|
-
for (var _i = 0,
|
|
65370
|
-
var targetInfo =
|
|
65422
|
+
for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) {
|
|
65423
|
+
var targetInfo = indexInfos_5[_i];
|
|
65371
65424
|
var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
|
|
65372
65425
|
isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
|
|
65373
65426
|
typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
|
|
@@ -65974,10 +66027,10 @@ var ts;
|
|
|
65974
66027
|
if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
65975
66028
|
return undefined;
|
|
65976
66029
|
}
|
|
65977
|
-
if (ts.getObjectFlags(type) &
|
|
65978
|
-
return ts.getObjectFlags(type) &
|
|
66030
|
+
if (ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeCalculated */) {
|
|
66031
|
+
return ts.getObjectFlags(type) & 134217728 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined;
|
|
65979
66032
|
}
|
|
65980
|
-
type.objectFlags |=
|
|
66033
|
+
type.objectFlags |= 67108864 /* IdenticalBaseTypeCalculated */;
|
|
65981
66034
|
var target = type.target;
|
|
65982
66035
|
if (ts.getObjectFlags(target) & 1 /* Class */) {
|
|
65983
66036
|
var baseTypeNode = getBaseTypeNodeOfClass(target);
|
|
@@ -65998,7 +66051,7 @@ var ts;
|
|
|
65998
66051
|
if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) {
|
|
65999
66052
|
instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type)));
|
|
66000
66053
|
}
|
|
66001
|
-
type.objectFlags |=
|
|
66054
|
+
type.objectFlags |= 134217728 /* IdenticalBaseTypeExists */;
|
|
66002
66055
|
return type.cachedEquivalentBaseType = instantiatedBase;
|
|
66003
66056
|
}
|
|
66004
66057
|
function isEmptyLiteralType(type) {
|
|
@@ -66662,7 +66715,7 @@ var ts;
|
|
|
66662
66715
|
var result = !!(type.flags & 465829888 /* Instantiable */ ||
|
|
66663
66716
|
type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
|
|
66664
66717
|
objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations ||
|
|
66665
|
-
objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) ||
|
|
66718
|
+
objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */ | 16777216 /* InstantiationExpressionType */)) ||
|
|
66666
66719
|
type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
|
|
66667
66720
|
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
66668
66721
|
type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0);
|
|
@@ -67579,8 +67632,8 @@ var ts;
|
|
|
67579
67632
|
var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0;
|
|
67580
67633
|
var indexInfos = getIndexInfosOfType(target);
|
|
67581
67634
|
if (isObjectTypeWithInferableIndex(source)) {
|
|
67582
|
-
for (var _i = 0,
|
|
67583
|
-
var targetInfo =
|
|
67635
|
+
for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) {
|
|
67636
|
+
var targetInfo = indexInfos_6[_i];
|
|
67584
67637
|
var propTypes = [];
|
|
67585
67638
|
for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) {
|
|
67586
67639
|
var prop = _b[_a];
|
|
@@ -67600,8 +67653,8 @@ var ts;
|
|
|
67600
67653
|
}
|
|
67601
67654
|
}
|
|
67602
67655
|
}
|
|
67603
|
-
for (var _e = 0,
|
|
67604
|
-
var targetInfo =
|
|
67656
|
+
for (var _e = 0, indexInfos_7 = indexInfos; _e < indexInfos_7.length; _e++) {
|
|
67657
|
+
var targetInfo = indexInfos_7[_e];
|
|
67605
67658
|
var sourceInfo = getApplicableIndexInfo(source, targetInfo.keyType);
|
|
67606
67659
|
if (sourceInfo) {
|
|
67607
67660
|
inferWithPriority(sourceInfo.type, targetInfo.type, priority);
|
|
@@ -68426,9 +68479,6 @@ var ts;
|
|
|
68426
68479
|
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
|
|
68427
68480
|
mapType(type, mapper);
|
|
68428
68481
|
}
|
|
68429
|
-
function getConstituentCount(type) {
|
|
68430
|
-
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
68431
|
-
}
|
|
68432
68482
|
function extractTypesOfKind(type, kind) {
|
|
68433
68483
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
68434
68484
|
}
|
|
@@ -70002,7 +70052,7 @@ var ts;
|
|
|
70002
70052
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
70003
70053
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
70004
70054
|
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
70005
|
-
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */
|
|
70055
|
+
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
|
|
70006
70056
|
}
|
|
70007
70057
|
function isExportOrExportExpression(location) {
|
|
70008
70058
|
return !!ts.findAncestor(location, function (n) {
|
|
@@ -73149,6 +73199,9 @@ var ts;
|
|
|
73149
73199
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
73150
73200
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
73151
73201
|
}
|
|
73202
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
|
|
73203
|
+
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
73204
|
+
}
|
|
73152
73205
|
}
|
|
73153
73206
|
else {
|
|
73154
73207
|
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
|
|
@@ -75765,6 +75818,72 @@ var ts;
|
|
|
75765
75818
|
return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) :
|
|
75766
75819
|
getNonNullableType(checkExpression(node.expression));
|
|
75767
75820
|
}
|
|
75821
|
+
function checkExpressionWithTypeArguments(node) {
|
|
75822
|
+
checkGrammarExpressionWithTypeArguments(node);
|
|
75823
|
+
var exprType = node.kind === 227 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) :
|
|
75824
|
+
ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
|
|
75825
|
+
checkExpression(node.exprName);
|
|
75826
|
+
var typeArguments = node.typeArguments;
|
|
75827
|
+
if (exprType === silentNeverType || isErrorType(exprType) || !ts.some(typeArguments)) {
|
|
75828
|
+
return exprType;
|
|
75829
|
+
}
|
|
75830
|
+
var hasSomeApplicableSignature = false;
|
|
75831
|
+
var nonApplicableType;
|
|
75832
|
+
var result = getInstantiatedType(exprType);
|
|
75833
|
+
var errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
|
|
75834
|
+
if (errorType) {
|
|
75835
|
+
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)));
|
|
75836
|
+
}
|
|
75837
|
+
return result;
|
|
75838
|
+
function getInstantiatedType(type) {
|
|
75839
|
+
var hasSignatures = false;
|
|
75840
|
+
var hasApplicableSignature = false;
|
|
75841
|
+
var result = getInstantiatedTypePart(type);
|
|
75842
|
+
hasSomeApplicableSignature || (hasSomeApplicableSignature = hasApplicableSignature);
|
|
75843
|
+
if (hasSignatures && !hasApplicableSignature) {
|
|
75844
|
+
nonApplicableType !== null && nonApplicableType !== void 0 ? nonApplicableType : (nonApplicableType = type);
|
|
75845
|
+
}
|
|
75846
|
+
return result;
|
|
75847
|
+
function getInstantiatedTypePart(type) {
|
|
75848
|
+
if (type.flags & 524288 /* Object */) {
|
|
75849
|
+
var resolved = resolveStructuredTypeMembers(type);
|
|
75850
|
+
var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
|
|
75851
|
+
var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
|
|
75852
|
+
hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
|
|
75853
|
+
hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
|
|
75854
|
+
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
|
|
75855
|
+
var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
|
|
75856
|
+
result_11.objectFlags |= 16777216 /* InstantiationExpressionType */;
|
|
75857
|
+
result_11.node = node;
|
|
75858
|
+
return result_11;
|
|
75859
|
+
}
|
|
75860
|
+
}
|
|
75861
|
+
else if (type.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
75862
|
+
var constraint = getBaseConstraintOfType(type);
|
|
75863
|
+
if (constraint) {
|
|
75864
|
+
var instantiated = getInstantiatedTypePart(constraint);
|
|
75865
|
+
if (instantiated !== constraint) {
|
|
75866
|
+
return instantiated;
|
|
75867
|
+
}
|
|
75868
|
+
}
|
|
75869
|
+
}
|
|
75870
|
+
else if (type.flags & 1048576 /* Union */) {
|
|
75871
|
+
return mapType(type, getInstantiatedType);
|
|
75872
|
+
}
|
|
75873
|
+
else if (type.flags & 2097152 /* Intersection */) {
|
|
75874
|
+
return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart));
|
|
75875
|
+
}
|
|
75876
|
+
return type;
|
|
75877
|
+
}
|
|
75878
|
+
}
|
|
75879
|
+
function getInstantiatedSignatures(signatures) {
|
|
75880
|
+
var applicableSignatures = ts.filter(signatures, function (sig) { return !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments); });
|
|
75881
|
+
return ts.sameMap(applicableSignatures, function (sig) {
|
|
75882
|
+
var typeArgumentTypes = checkTypeArguments(sig, typeArguments, /*reportErrors*/ true);
|
|
75883
|
+
return typeArgumentTypes ? getSignatureInstantiation(sig, typeArgumentTypes, ts.isInJSFile(sig.declaration)) : sig;
|
|
75884
|
+
});
|
|
75885
|
+
}
|
|
75886
|
+
}
|
|
75768
75887
|
function checkMetaProperty(node) {
|
|
75769
75888
|
checkGrammarMetaProperty(node);
|
|
75770
75889
|
if (node.keywordToken === 103 /* NewKeyword */) {
|
|
@@ -76094,21 +76213,22 @@ var ts;
|
|
|
76094
76213
|
if (links.type === unknownType) {
|
|
76095
76214
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
76096
76215
|
}
|
|
76097
|
-
assignBindingElementTypes(declaration.name);
|
|
76216
|
+
assignBindingElementTypes(declaration.name, links.type);
|
|
76098
76217
|
}
|
|
76099
76218
|
}
|
|
76100
76219
|
}
|
|
76101
76220
|
// When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
|
|
76102
76221
|
// the destructured type into the contained binding elements.
|
|
76103
|
-
function assignBindingElementTypes(pattern) {
|
|
76222
|
+
function assignBindingElementTypes(pattern, parentType) {
|
|
76104
76223
|
for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
|
|
76105
76224
|
var element = _a[_i];
|
|
76106
76225
|
if (!ts.isOmittedExpression(element)) {
|
|
76226
|
+
var type = getBindingElementTypeFromParentType(element, parentType);
|
|
76107
76227
|
if (element.name.kind === 79 /* Identifier */) {
|
|
76108
|
-
getSymbolLinks(getSymbolOfNode(element)).type =
|
|
76228
|
+
getSymbolLinks(getSymbolOfNode(element)).type = type;
|
|
76109
76229
|
}
|
|
76110
76230
|
else {
|
|
76111
|
-
assignBindingElementTypes(element.name);
|
|
76231
|
+
assignBindingElementTypes(element.name, type);
|
|
76112
76232
|
}
|
|
76113
76233
|
}
|
|
76114
76234
|
}
|
|
@@ -77253,7 +77373,7 @@ var ts;
|
|
|
77253
77373
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
77254
77374
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
77255
77375
|
var parent = ts.walkUpParenthesizedExpressions(node.parent);
|
|
77256
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.left,
|
|
77376
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
77257
77377
|
}
|
|
77258
77378
|
checkTruthinessOfType(leftType, node.left);
|
|
77259
77379
|
}
|
|
@@ -77760,8 +77880,8 @@ var ts;
|
|
|
77760
77880
|
return type;
|
|
77761
77881
|
}
|
|
77762
77882
|
function checkConditionalExpression(node, checkMode) {
|
|
77763
|
-
|
|
77764
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.condition,
|
|
77883
|
+
checkTruthinessExpression(node.condition);
|
|
77884
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue);
|
|
77765
77885
|
var type1 = checkExpression(node.whenTrue, checkMode);
|
|
77766
77886
|
var type2 = checkExpression(node.whenFalse, checkMode);
|
|
77767
77887
|
return getUnionType([type1, type2], 2 /* Subtype */);
|
|
@@ -78280,6 +78400,8 @@ var ts;
|
|
|
78280
78400
|
return checkAssertion(node);
|
|
78281
78401
|
case 229 /* NonNullExpression */:
|
|
78282
78402
|
return checkNonNullAssertion(node);
|
|
78403
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
78404
|
+
return checkExpressionWithTypeArguments(node);
|
|
78283
78405
|
case 230 /* MetaProperty */:
|
|
78284
78406
|
return checkMetaProperty(node);
|
|
78285
78407
|
case 214 /* DeleteExpression */:
|
|
@@ -79483,12 +79605,12 @@ var ts;
|
|
|
79483
79605
|
case 264 /* ImportEqualsDeclaration */:
|
|
79484
79606
|
case 267 /* NamespaceImport */:
|
|
79485
79607
|
case 266 /* ImportClause */:
|
|
79486
|
-
var
|
|
79608
|
+
var result_12 = 0 /* None */;
|
|
79487
79609
|
var target = resolveAlias(getSymbolOfNode(d));
|
|
79488
79610
|
ts.forEach(target.declarations, function (d) {
|
|
79489
|
-
|
|
79611
|
+
result_12 |= getDeclarationSpaces(d);
|
|
79490
79612
|
});
|
|
79491
|
-
return
|
|
79613
|
+
return result_12;
|
|
79492
79614
|
case 253 /* VariableDeclaration */:
|
|
79493
79615
|
case 202 /* BindingElement */:
|
|
79494
79616
|
case 255 /* FunctionDeclaration */:
|
|
@@ -79849,28 +79971,24 @@ var ts;
|
|
|
79849
79971
|
if (returnType.flags & 1 /* Any */) {
|
|
79850
79972
|
return;
|
|
79851
79973
|
}
|
|
79974
|
+
var headMessage;
|
|
79852
79975
|
var expectedReturnType;
|
|
79853
|
-
var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
|
79854
|
-
var errorInfo;
|
|
79855
79976
|
switch (node.parent.kind) {
|
|
79856
79977
|
case 256 /* ClassDeclaration */:
|
|
79978
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
79857
79979
|
var classSymbol = getSymbolOfNode(node.parent);
|
|
79858
79980
|
var classConstructorType = getTypeOfSymbol(classSymbol);
|
|
79859
79981
|
expectedReturnType = getUnionType([classConstructorType, voidType]);
|
|
79860
79982
|
break;
|
|
79983
|
+
case 166 /* PropertyDeclaration */:
|
|
79861
79984
|
case 163 /* Parameter */:
|
|
79985
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
|
|
79862
79986
|
expectedReturnType = voidType;
|
|
79863
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
79864
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
|
|
79865
|
-
break;
|
|
79866
|
-
case 166 /* PropertyDeclaration */:
|
|
79867
|
-
expectedReturnType = voidType;
|
|
79868
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
79869
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
|
|
79870
79987
|
break;
|
|
79871
79988
|
case 168 /* MethodDeclaration */:
|
|
79872
79989
|
case 171 /* GetAccessor */:
|
|
79873
79990
|
case 172 /* SetAccessor */:
|
|
79991
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
79874
79992
|
var methodType = getTypeOfNode(node.parent);
|
|
79875
79993
|
var descriptorType = createTypedPropertyDescriptorType(methodType);
|
|
79876
79994
|
expectedReturnType = getUnionType([descriptorType, voidType]);
|
|
@@ -79878,7 +79996,7 @@ var ts;
|
|
|
79878
79996
|
default:
|
|
79879
79997
|
return ts.Debug.fail();
|
|
79880
79998
|
}
|
|
79881
|
-
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage
|
|
79999
|
+
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
|
|
79882
80000
|
}
|
|
79883
80001
|
/**
|
|
79884
80002
|
* If a TypeNode can be resolved to a value symbol imported from an external module, it is
|
|
@@ -80919,50 +81037,59 @@ var ts;
|
|
|
80919
81037
|
function checkIfStatement(node) {
|
|
80920
81038
|
// Grammar checking
|
|
80921
81039
|
checkGrammarStatementInAmbientContext(node);
|
|
80922
|
-
|
|
80923
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.expression,
|
|
81040
|
+
checkTruthinessExpression(node.expression);
|
|
81041
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement);
|
|
80924
81042
|
checkSourceElement(node.thenStatement);
|
|
80925
81043
|
if (node.thenStatement.kind === 235 /* EmptyStatement */) {
|
|
80926
81044
|
error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
|
|
80927
81045
|
}
|
|
80928
81046
|
checkSourceElement(node.elseStatement);
|
|
80929
81047
|
}
|
|
80930
|
-
function checkTestingKnownTruthyCallableOrAwaitableType(condExpr,
|
|
81048
|
+
function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, body) {
|
|
80931
81049
|
if (!strictNullChecks)
|
|
80932
81050
|
return;
|
|
80933
|
-
|
|
80934
|
-
|
|
80935
|
-
|
|
80936
|
-
|
|
80937
|
-
|
|
80938
|
-
|
|
80939
|
-
|
|
80940
|
-
|
|
80941
|
-
|
|
80942
|
-
|
|
80943
|
-
|
|
80944
|
-
|
|
80945
|
-
|
|
80946
|
-
|
|
80947
|
-
|
|
80948
|
-
|
|
80949
|
-
|
|
80950
|
-
|
|
80951
|
-
|
|
80952
|
-
|
|
80953
|
-
|
|
80954
|
-
|
|
80955
|
-
|
|
80956
|
-
}
|
|
80957
|
-
var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|
|
80958
|
-
|| testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
|
|
80959
|
-
if (!isUsed) {
|
|
80960
|
-
if (isPromise) {
|
|
80961
|
-
errorAndMaybeSuggestAwait(location,
|
|
80962
|
-
/*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
|
|
81051
|
+
helper(condExpr, body);
|
|
81052
|
+
while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) {
|
|
81053
|
+
condExpr = condExpr.left;
|
|
81054
|
+
helper(condExpr, body);
|
|
81055
|
+
}
|
|
81056
|
+
function helper(condExpr, body) {
|
|
81057
|
+
var location = ts.isBinaryExpression(condExpr) &&
|
|
81058
|
+
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
81059
|
+
? condExpr.right
|
|
81060
|
+
: condExpr;
|
|
81061
|
+
var type = checkTruthinessExpression(location);
|
|
81062
|
+
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
81063
|
+
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
81064
|
+
return;
|
|
81065
|
+
// While it technically should be invalid for any known-truthy value
|
|
81066
|
+
// to be tested, we de-scope to functions and Promises unreferenced in
|
|
81067
|
+
// the block as a heuristic to identify the most common bugs. There
|
|
81068
|
+
// are too many false positives for values sourced from type
|
|
81069
|
+
// definitions without strictNullChecks otherwise.
|
|
81070
|
+
var callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
81071
|
+
var isPromise = !!getAwaitedTypeOfPromise(type);
|
|
81072
|
+
if (callSignatures.length === 0 && !isPromise) {
|
|
81073
|
+
return;
|
|
80963
81074
|
}
|
|
80964
|
-
|
|
80965
|
-
|
|
81075
|
+
var testedNode = ts.isIdentifier(location) ? location
|
|
81076
|
+
: ts.isPropertyAccessExpression(location) ? location.name
|
|
81077
|
+
: ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
|
|
81078
|
+
: undefined;
|
|
81079
|
+
var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
|
|
81080
|
+
if (!testedSymbol && !isPromise) {
|
|
81081
|
+
return;
|
|
81082
|
+
}
|
|
81083
|
+
var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|
|
81084
|
+
|| testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
|
|
81085
|
+
if (!isUsed) {
|
|
81086
|
+
if (isPromise) {
|
|
81087
|
+
errorAndMaybeSuggestAwait(location,
|
|
81088
|
+
/*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
|
|
81089
|
+
}
|
|
81090
|
+
else {
|
|
81091
|
+
error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
|
|
81092
|
+
}
|
|
80966
81093
|
}
|
|
80967
81094
|
}
|
|
80968
81095
|
}
|
|
@@ -82051,8 +82178,8 @@ var ts;
|
|
|
82051
82178
|
}
|
|
82052
82179
|
}
|
|
82053
82180
|
if (indexInfos.length > 1) {
|
|
82054
|
-
for (var _d = 0,
|
|
82055
|
-
var info =
|
|
82181
|
+
for (var _d = 0, indexInfos_8 = indexInfos; _d < indexInfos_8.length; _d++) {
|
|
82182
|
+
var info = indexInfos_8[_d];
|
|
82056
82183
|
checkIndexConstraintForIndexSignature(type, info);
|
|
82057
82184
|
}
|
|
82058
82185
|
}
|
|
@@ -82078,8 +82205,8 @@ var ts;
|
|
|
82078
82205
|
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));
|
|
82079
82206
|
}
|
|
82080
82207
|
};
|
|
82081
|
-
for (var _i = 0,
|
|
82082
|
-
var info =
|
|
82208
|
+
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
82209
|
+
var info = indexInfos_9[_i];
|
|
82083
82210
|
_loop_27(info);
|
|
82084
82211
|
}
|
|
82085
82212
|
}
|
|
@@ -82101,8 +82228,8 @@ var ts;
|
|
|
82101
82228
|
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));
|
|
82102
82229
|
}
|
|
82103
82230
|
};
|
|
82104
|
-
for (var _i = 0,
|
|
82105
|
-
var info =
|
|
82231
|
+
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
82232
|
+
var info = indexInfos_10[_i];
|
|
82106
82233
|
_loop_28(info);
|
|
82107
82234
|
}
|
|
82108
82235
|
}
|
|
@@ -82151,9 +82278,9 @@ var ts;
|
|
|
82151
82278
|
var containsArguments = containsArgumentsReference(node);
|
|
82152
82279
|
if (containsArguments) {
|
|
82153
82280
|
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82154
|
-
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82281
|
+
if (isJs && lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82155
82282
|
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82156
|
-
|
|
82283
|
+
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));
|
|
82157
82284
|
}
|
|
82158
82285
|
}
|
|
82159
82286
|
else {
|
|
@@ -82163,7 +82290,9 @@ var ts;
|
|
|
82163
82290
|
return;
|
|
82164
82291
|
}
|
|
82165
82292
|
if (ts.isQualifiedName(name)) {
|
|
82166
|
-
|
|
82293
|
+
if (isJs) {
|
|
82294
|
+
error(name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82295
|
+
}
|
|
82167
82296
|
}
|
|
82168
82297
|
else {
|
|
82169
82298
|
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
@@ -83756,10 +83885,10 @@ var ts;
|
|
|
83756
83885
|
}
|
|
83757
83886
|
// ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
|
|
83758
83887
|
// (TS Exceptions: namespaces, function overloads, enums, and interfaces)
|
|
83759
|
-
if (flags & (1920 /* Namespace */ |
|
|
83888
|
+
if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
|
|
83760
83889
|
return;
|
|
83761
83890
|
}
|
|
83762
|
-
var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
|
|
83891
|
+
var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
|
|
83763
83892
|
if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
|
|
83764
83893
|
// it is legal to merge type alias with other values
|
|
83765
83894
|
// so count should be either 1 (just type alias) or 2 (type alias + merged value)
|
|
@@ -85426,7 +85555,7 @@ var ts;
|
|
|
85426
85555
|
if (resolvedTypeReferenceDirectives) {
|
|
85427
85556
|
// populate reverse mapping: file path -> type reference directive that was resolved to this file
|
|
85428
85557
|
fileToDirective = new ts.Map();
|
|
85429
|
-
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
|
|
85558
|
+
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
|
|
85430
85559
|
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
|
|
85431
85560
|
return;
|
|
85432
85561
|
}
|
|
@@ -85434,7 +85563,7 @@ var ts;
|
|
|
85434
85563
|
if (file) {
|
|
85435
85564
|
// Add the transitive closure of path references loaded by this file (as long as they are not)
|
|
85436
85565
|
// part of an existing type reference.
|
|
85437
|
-
addReferencedFilesToTypeDirective(file, key);
|
|
85566
|
+
addReferencedFilesToTypeDirective(file, key, mode);
|
|
85438
85567
|
}
|
|
85439
85568
|
});
|
|
85440
85569
|
}
|
|
@@ -85628,16 +85757,16 @@ var ts;
|
|
|
85628
85757
|
}
|
|
85629
85758
|
return false;
|
|
85630
85759
|
}
|
|
85631
|
-
function addReferencedFilesToTypeDirective(file, key) {
|
|
85760
|
+
function addReferencedFilesToTypeDirective(file, key, mode) {
|
|
85632
85761
|
if (fileToDirective.has(file.path))
|
|
85633
85762
|
return;
|
|
85634
|
-
fileToDirective.set(file.path, key);
|
|
85763
|
+
fileToDirective.set(file.path, [key, mode]);
|
|
85635
85764
|
for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
|
|
85636
|
-
var
|
|
85765
|
+
var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
|
|
85637
85766
|
var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
|
|
85638
85767
|
var referencedFile = host.getSourceFile(resolvedFile);
|
|
85639
85768
|
if (referencedFile) {
|
|
85640
|
-
addReferencedFilesToTypeDirective(referencedFile, key);
|
|
85769
|
+
addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
|
|
85641
85770
|
}
|
|
85642
85771
|
}
|
|
85643
85772
|
}
|
|
@@ -87342,28 +87471,27 @@ var ts;
|
|
|
87342
87471
|
}
|
|
87343
87472
|
function findMostOverlappyType(source, unionTarget) {
|
|
87344
87473
|
var bestMatch;
|
|
87345
|
-
|
|
87346
|
-
|
|
87347
|
-
var
|
|
87348
|
-
|
|
87349
|
-
|
|
87350
|
-
|
|
87351
|
-
|
|
87352
|
-
|
|
87353
|
-
|
|
87354
|
-
|
|
87355
|
-
|
|
87356
|
-
|
|
87357
|
-
|
|
87358
|
-
|
|
87359
|
-
|
|
87360
|
-
|
|
87361
|
-
|
|
87362
|
-
|
|
87363
|
-
|
|
87364
|
-
|
|
87365
|
-
|
|
87366
|
-
matchingCount = 1;
|
|
87474
|
+
if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87475
|
+
var matchingCount = 0;
|
|
87476
|
+
for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
|
|
87477
|
+
var target = _a[_i];
|
|
87478
|
+
if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87479
|
+
var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
|
|
87480
|
+
if (overlap.flags & 4194304 /* Index */) {
|
|
87481
|
+
// perfect overlap of keys
|
|
87482
|
+
return target;
|
|
87483
|
+
}
|
|
87484
|
+
else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
|
|
87485
|
+
// We only want to account for literal types otherwise.
|
|
87486
|
+
// If we have a union of index types, it seems likely that we
|
|
87487
|
+
// needed to elaborate between two generic mapped types anyway.
|
|
87488
|
+
var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
|
|
87489
|
+
if (len >= matchingCount) {
|
|
87490
|
+
bestMatch = target;
|
|
87491
|
+
matchingCount = len;
|
|
87492
|
+
}
|
|
87493
|
+
}
|
|
87494
|
+
}
|
|
87367
87495
|
}
|
|
87368
87496
|
}
|
|
87369
87497
|
return bestMatch;
|
|
@@ -87736,7 +87864,7 @@ var ts;
|
|
|
87736
87864
|
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));
|
|
87737
87865
|
case 180 /* TypeQuery */:
|
|
87738
87866
|
ts.Debug.type(node);
|
|
87739
|
-
return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName));
|
|
87867
|
+
return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
|
|
87740
87868
|
case 181 /* TypeLiteral */:
|
|
87741
87869
|
ts.Debug.type(node);
|
|
87742
87870
|
return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
|
|
@@ -90628,8 +90756,8 @@ var ts;
|
|
|
90628
90756
|
function generateClassElementDecorationExpressions(node, isStatic) {
|
|
90629
90757
|
var members = getDecoratedClassElements(node, isStatic);
|
|
90630
90758
|
var expressions;
|
|
90631
|
-
for (var _i = 0,
|
|
90632
|
-
var member =
|
|
90759
|
+
for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
|
|
90760
|
+
var member = members_8[_i];
|
|
90633
90761
|
var expression = generateClassElementDecorationExpression(node, member);
|
|
90634
90762
|
if (expression) {
|
|
90635
90763
|
if (!expressions) {
|
|
@@ -95974,8 +96102,8 @@ var ts;
|
|
|
95974
96102
|
function convertJsxChildrenToChildrenPropAssignment(children) {
|
|
95975
96103
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
95976
96104
|
if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
|
|
95977
|
-
var
|
|
95978
|
-
return
|
|
96105
|
+
var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
|
|
96106
|
+
return result_13 && factory.createPropertyAssignment("children", result_13);
|
|
95979
96107
|
}
|
|
95980
96108
|
var result = ts.mapDefined(children, transformJsxChildToExpression);
|
|
95981
96109
|
return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
|
|
@@ -106406,7 +106534,7 @@ var ts;
|
|
|
106406
106534
|
var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
|
|
106407
106535
|
hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
|
|
106408
106536
|
collectReferences(sourceFile, refs);
|
|
106409
|
-
recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
|
|
106537
|
+
recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
|
|
106410
106538
|
collectLibs(sourceFile, libs);
|
|
106411
106539
|
return sourceFile;
|
|
106412
106540
|
}
|
|
@@ -106461,9 +106589,10 @@ var ts;
|
|
|
106461
106589
|
return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
|
|
106462
106590
|
}
|
|
106463
106591
|
function getFileReferencesForUsedTypeReferences() {
|
|
106464
|
-
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()),
|
|
106592
|
+
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
|
|
106465
106593
|
}
|
|
106466
|
-
function
|
|
106594
|
+
function getFileReferenceForSpecifierModeTuple(_a) {
|
|
106595
|
+
var typeName = _a[0], mode = _a[1];
|
|
106467
106596
|
// Elide type references for which we have imports
|
|
106468
106597
|
if (emittedImports) {
|
|
106469
106598
|
for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
|
|
@@ -106479,7 +106608,7 @@ var ts;
|
|
|
106479
106608
|
}
|
|
106480
106609
|
}
|
|
106481
106610
|
}
|
|
106482
|
-
return { fileName: typeName, pos: -1, end: -1 };
|
|
106611
|
+
return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
|
|
106483
106612
|
}
|
|
106484
106613
|
function mapReferencesIntoArray(references, outputFilePath) {
|
|
106485
106614
|
return function (file) {
|
|
@@ -106499,7 +106628,7 @@ var ts;
|
|
|
106499
106628
|
// If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration
|
|
106500
106629
|
// via a non-relative name, emit a type reference directive to that non-relative name, rather than
|
|
106501
106630
|
// a relative path to the declaration file
|
|
106502
|
-
recordTypeReferenceDirectivesIfNecessary([specifier]);
|
|
106631
|
+
recordTypeReferenceDirectivesIfNecessary([[specifier, /*mode*/ undefined]]);
|
|
106503
106632
|
return;
|
|
106504
106633
|
}
|
|
106505
106634
|
var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName,
|
|
@@ -109612,6 +109741,8 @@ var ts;
|
|
|
109612
109741
|
return emitAsExpression(node);
|
|
109613
109742
|
case 229 /* NonNullExpression */:
|
|
109614
109743
|
return emitNonNullExpression(node);
|
|
109744
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
109745
|
+
return emitExpressionWithTypeArguments(node);
|
|
109615
109746
|
case 230 /* MetaProperty */:
|
|
109616
109747
|
return emitMetaProperty(node);
|
|
109617
109748
|
case 231 /* SyntheticExpression */:
|
|
@@ -110056,6 +110187,7 @@ var ts;
|
|
|
110056
110187
|
writeKeyword("typeof");
|
|
110057
110188
|
writeSpace();
|
|
110058
110189
|
emit(node.exprName);
|
|
110190
|
+
emitTypeArguments(node, node.typeArguments);
|
|
110059
110191
|
}
|
|
110060
110192
|
function emitTypeLiteral(node) {
|
|
110061
110193
|
writePunctuation("{");
|
|
@@ -111611,9 +111743,12 @@ var ts;
|
|
|
111611
111743
|
for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
|
|
111612
111744
|
var directive = types_24[_d];
|
|
111613
111745
|
var pos = writer.getTextPos();
|
|
111614
|
-
|
|
111746
|
+
var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
|
|
111747
|
+
? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
|
|
111748
|
+
: "";
|
|
111749
|
+
writeComment("/// <reference types=\"" + directive.fileName + "\" " + resolutionMode + "/>");
|
|
111615
111750
|
if (bundleFileInfo)
|
|
111616
|
-
bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName });
|
|
111751
|
+
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 });
|
|
111617
111752
|
writeLine();
|
|
111618
111753
|
}
|
|
111619
111754
|
for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
|
|
@@ -114220,7 +114355,7 @@ var ts;
|
|
|
114220
114355
|
}
|
|
114221
114356
|
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
|
|
114222
114357
|
/* @internal */
|
|
114223
|
-
function
|
|
114358
|
+
function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
|
|
114224
114359
|
if (names.length === 0) {
|
|
114225
114360
|
return [];
|
|
114226
114361
|
}
|
|
@@ -114229,19 +114364,28 @@ var ts;
|
|
|
114229
114364
|
for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
|
|
114230
114365
|
var name = names_2[_i];
|
|
114231
114366
|
var result = void 0;
|
|
114232
|
-
|
|
114233
|
-
|
|
114367
|
+
var mode = getModeForFileReference(name, containingFileMode);
|
|
114368
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
114369
|
+
var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
|
|
114370
|
+
var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
|
|
114371
|
+
if (cache.has(cacheKey)) {
|
|
114372
|
+
result = cache.get(cacheKey);
|
|
114234
114373
|
}
|
|
114235
114374
|
else {
|
|
114236
|
-
cache.set(
|
|
114375
|
+
cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
|
|
114237
114376
|
}
|
|
114238
114377
|
resolutions.push(result);
|
|
114239
114378
|
}
|
|
114240
114379
|
return resolutions;
|
|
114241
114380
|
}
|
|
114242
|
-
ts.
|
|
114381
|
+
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
114243
114382
|
;
|
|
114244
114383
|
/* @internal */
|
|
114384
|
+
function getModeForFileReference(ref, containingFileMode) {
|
|
114385
|
+
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
114386
|
+
}
|
|
114387
|
+
ts.getModeForFileReference = getModeForFileReference;
|
|
114388
|
+
/* @internal */
|
|
114245
114389
|
function getModeForResolutionAtIndex(file, index) {
|
|
114246
114390
|
if (file.impliedNodeFormat === undefined)
|
|
114247
114391
|
return undefined;
|
|
@@ -114344,7 +114488,7 @@ var ts;
|
|
|
114344
114488
|
var _d, _e, _f, _g;
|
|
114345
114489
|
var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
|
|
114346
114490
|
var kind = ref.kind, index = ref.index;
|
|
114347
|
-
var pos, end, packageId;
|
|
114491
|
+
var pos, end, packageId, resolutionMode;
|
|
114348
114492
|
switch (kind) {
|
|
114349
114493
|
case ts.FileIncludeKind.Import:
|
|
114350
114494
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
@@ -114358,8 +114502,8 @@ var ts;
|
|
|
114358
114502
|
(_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
|
|
114359
114503
|
break;
|
|
114360
114504
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
114361
|
-
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
114362
|
-
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;
|
|
114505
|
+
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
|
|
114506
|
+
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;
|
|
114363
114507
|
break;
|
|
114364
114508
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
114365
114509
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -114603,7 +114747,7 @@ var ts;
|
|
|
114603
114747
|
var fileReasons = ts.createMultiMap();
|
|
114604
114748
|
var cachedBindAndCheckDiagnosticsForFile = {};
|
|
114605
114749
|
var cachedDeclarationDiagnosticsForFile = {};
|
|
114606
|
-
var resolvedTypeReferenceDirectives =
|
|
114750
|
+
var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
|
|
114607
114751
|
var fileProcessingDiagnostics;
|
|
114608
114752
|
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
|
|
114609
114753
|
// This works as imported modules are discovered recursively in a depth first manner, specifically:
|
|
@@ -114656,12 +114800,12 @@ var ts;
|
|
|
114656
114800
|
}
|
|
114657
114801
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
114658
114802
|
if (host.resolveTypeReferenceDirectives) {
|
|
114659
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
|
|
114803
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
|
|
114660
114804
|
}
|
|
114661
114805
|
else {
|
|
114662
114806
|
typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
114663
|
-
var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114664
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return
|
|
114807
|
+
var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114808
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
|
|
114665
114809
|
}
|
|
114666
114810
|
// Map from a stringified PackageId to the source file with that id.
|
|
114667
114811
|
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
|
|
@@ -114758,7 +114902,8 @@ var ts;
|
|
|
114758
114902
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
114759
114903
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
114760
114904
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
114761
|
-
|
|
114905
|
+
// under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
|
|
114906
|
+
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 });
|
|
114762
114907
|
}
|
|
114763
114908
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
114764
114909
|
}
|
|
@@ -114918,9 +115063,10 @@ var ts;
|
|
|
114918
115063
|
return [];
|
|
114919
115064
|
var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
|
|
114920
115065
|
var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
|
|
115066
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
114921
115067
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
|
|
114922
115068
|
ts.performance.mark("beforeResolveTypeReference");
|
|
114923
|
-
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
|
|
115069
|
+
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
|
|
114924
115070
|
ts.performance.mark("afterResolveTypeReference");
|
|
114925
115071
|
ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
|
|
114926
115072
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -115015,15 +115161,15 @@ var ts;
|
|
|
115015
115161
|
// which per above occurred during the current program creation.
|
|
115016
115162
|
// Since we assume the filesystem does not change during program creation,
|
|
115017
115163
|
// it is safe to reuse resolutions from the earlier call.
|
|
115018
|
-
var
|
|
115164
|
+
var result_14 = [];
|
|
115019
115165
|
var i = 0;
|
|
115020
115166
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
115021
115167
|
var moduleName = moduleNames_1[_i];
|
|
115022
115168
|
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
115023
115169
|
i++;
|
|
115024
|
-
|
|
115170
|
+
result_14.push(resolvedModule);
|
|
115025
115171
|
}
|
|
115026
|
-
return
|
|
115172
|
+
return result_14;
|
|
115027
115173
|
}
|
|
115028
115174
|
// At this point, we know at least one of the following hold:
|
|
115029
115175
|
// - file has local declarations for ambient modules
|
|
@@ -115312,8 +115458,7 @@ var ts;
|
|
|
115312
115458
|
else {
|
|
115313
115459
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
115314
115460
|
}
|
|
115315
|
-
|
|
115316
|
-
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
115461
|
+
var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
|
115317
115462
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
115318
115463
|
// ensure that types resolutions are still correct
|
|
115319
115464
|
var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
@@ -116392,8 +116537,7 @@ var ts;
|
|
|
116392
116537
|
});
|
|
116393
116538
|
}
|
|
116394
116539
|
function processTypeReferenceDirectives(file) {
|
|
116395
|
-
|
|
116396
|
-
var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
116540
|
+
var typeDirectives = file.typeReferenceDirectives;
|
|
116397
116541
|
if (!typeDirectives) {
|
|
116398
116542
|
return;
|
|
116399
116543
|
}
|
|
@@ -116404,17 +116548,21 @@ var ts;
|
|
|
116404
116548
|
// store resolved type directive on the file
|
|
116405
116549
|
var fileName = ts.toFileNameLowerCase(ref.fileName);
|
|
116406
116550
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
116407
|
-
|
|
116551
|
+
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
116552
|
+
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
116553
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext));
|
|
116554
|
+
}
|
|
116555
|
+
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
116408
116556
|
}
|
|
116409
116557
|
}
|
|
116410
|
-
function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116558
|
+
function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116411
116559
|
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 });
|
|
116412
|
-
processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
|
|
116560
|
+
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
|
|
116413
116561
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116414
116562
|
}
|
|
116415
|
-
function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116563
|
+
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116416
116564
|
// If we already found this library as a primary reference - nothing to do
|
|
116417
|
-
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
|
|
116565
|
+
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
|
|
116418
116566
|
if (previousResolution && previousResolution.primary) {
|
|
116419
116567
|
return;
|
|
116420
116568
|
}
|
|
@@ -116453,7 +116601,7 @@ var ts;
|
|
|
116453
116601
|
addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
|
|
116454
116602
|
}
|
|
116455
116603
|
if (saveResolution) {
|
|
116456
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
|
|
116604
|
+
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
|
|
116457
116605
|
}
|
|
116458
116606
|
}
|
|
116459
116607
|
function pathForLibFile(libFileName) {
|
|
@@ -119271,9 +119419,9 @@ var ts;
|
|
|
119271
119419
|
});
|
|
119272
119420
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
119273
119421
|
}
|
|
119274
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
|
|
119422
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
|
|
119275
119423
|
var _a;
|
|
119276
|
-
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
|
|
119424
|
+
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
|
|
119277
119425
|
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
|
|
119278
119426
|
if (!resolutionHost.getGlobalCache) {
|
|
119279
119427
|
return primaryResult;
|
|
@@ -119294,12 +119442,12 @@ var ts;
|
|
|
119294
119442
|
// Default return the result from the first pass
|
|
119295
119443
|
return primaryResult;
|
|
119296
119444
|
}
|
|
119297
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
|
|
119298
|
-
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
|
|
119445
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
|
|
119446
|
+
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
|
|
119299
119447
|
}
|
|
119300
119448
|
function resolveNamesWithLocalCache(_a) {
|
|
119301
119449
|
var _b, _c, _d;
|
|
119302
|
-
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;
|
|
119450
|
+
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;
|
|
119303
119451
|
var path = resolutionHost.toPath(containingFile);
|
|
119304
119452
|
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
119305
119453
|
var dirPath = ts.getDirectoryPath(path);
|
|
@@ -119321,8 +119469,15 @@ var ts;
|
|
|
119321
119469
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
119322
119470
|
var i = 0;
|
|
119323
119471
|
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
119324
|
-
var
|
|
119325
|
-
var
|
|
119472
|
+
var entry = names_4[_i];
|
|
119473
|
+
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
119474
|
+
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
119475
|
+
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
119476
|
+
// import's syntax may override the file's default mode.
|
|
119477
|
+
// Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
|
|
119478
|
+
// a default file mode override if applicable.
|
|
119479
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
|
|
119480
|
+
containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
119326
119481
|
i++;
|
|
119327
119482
|
var resolution = resolutionsInFile.get(name, mode);
|
|
119328
119483
|
// Resolution is valid if it is present and not invalidated
|
|
@@ -119351,7 +119506,7 @@ var ts;
|
|
|
119351
119506
|
}
|
|
119352
119507
|
}
|
|
119353
119508
|
else {
|
|
119354
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
119509
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
119355
119510
|
perDirectoryResolution.set(name, mode, resolution);
|
|
119356
119511
|
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
119357
119512
|
resolutionHost.onDiscoveredSymlink();
|
|
@@ -119415,7 +119570,7 @@ var ts;
|
|
|
119415
119570
|
return oldResult.resolvedFileName === newResult.resolvedFileName;
|
|
119416
119571
|
}
|
|
119417
119572
|
}
|
|
119418
|
-
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
|
|
119573
|
+
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
|
|
119419
119574
|
return resolveNamesWithLocalCache({
|
|
119420
119575
|
names: typeDirectiveNames,
|
|
119421
119576
|
containingFile: containingFile,
|
|
@@ -119425,6 +119580,7 @@ var ts;
|
|
|
119425
119580
|
loader: resolveTypeReferenceDirective,
|
|
119426
119581
|
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
|
|
119427
119582
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
119583
|
+
containingSourceFileMode: containingFileMode
|
|
119428
119584
|
});
|
|
119429
119585
|
}
|
|
119430
119586
|
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
@@ -120131,9 +120287,9 @@ var ts;
|
|
|
120131
120287
|
if (!preferSymlinks) {
|
|
120132
120288
|
// Symlinks inside ignored paths are already filtered out of the symlink cache,
|
|
120133
120289
|
// so we only need to remove them from the realpath filenames.
|
|
120134
|
-
var
|
|
120135
|
-
if (
|
|
120136
|
-
return
|
|
120290
|
+
var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
|
|
120291
|
+
if (result_15)
|
|
120292
|
+
return result_15;
|
|
120137
120293
|
}
|
|
120138
120294
|
var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
|
|
120139
120295
|
var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
|
|
@@ -120153,10 +120309,10 @@ var ts;
|
|
|
120153
120309
|
for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
|
|
120154
120310
|
var symlinkDirectory = symlinkDirectories_1[_i];
|
|
120155
120311
|
var option = ts.resolvePath(symlinkDirectory, relative);
|
|
120156
|
-
var
|
|
120312
|
+
var result_16 = cb(option, target === referenceRedirect);
|
|
120157
120313
|
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
|
|
120158
|
-
if (
|
|
120159
|
-
return
|
|
120314
|
+
if (result_16)
|
|
120315
|
+
return result_16;
|
|
120160
120316
|
}
|
|
120161
120317
|
});
|
|
120162
120318
|
});
|
|
@@ -121333,7 +121489,7 @@ var ts;
|
|
|
121333
121489
|
}
|
|
121334
121490
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
121335
121491
|
}) :
|
|
121336
|
-
(function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
|
|
121492
|
+
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
121337
121493
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
121338
121494
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
121339
121495
|
synchronizeProgram();
|
|
@@ -122069,9 +122225,9 @@ var ts;
|
|
|
122069
122225
|
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
122070
122226
|
}
|
|
122071
122227
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
122072
|
-
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|
|
122073
|
-
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
|
|
122074
|
-
return ts.
|
|
122228
|
+
var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
|
|
122229
|
+
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
122230
|
+
return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
|
|
122075
122231
|
};
|
|
122076
122232
|
}
|
|
122077
122233
|
var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
|
|
@@ -123997,7 +124153,7 @@ var ts;
|
|
|
123997
124153
|
case 199 /* ImportType */:
|
|
123998
124154
|
return !node.parent.isTypeOf;
|
|
123999
124155
|
case 227 /* ExpressionWithTypeArguments */:
|
|
124000
|
-
return
|
|
124156
|
+
return ts.isPartOfTypeNode(node.parent);
|
|
124001
124157
|
}
|
|
124002
124158
|
return false;
|
|
124003
124159
|
}
|
|
@@ -126024,14 +126180,15 @@ var ts;
|
|
|
126024
126180
|
: "linkplain";
|
|
126025
126181
|
var parts = [linkPart("{@" + prefix + " ")];
|
|
126026
126182
|
if (!link.name) {
|
|
126027
|
-
if (link.text)
|
|
126183
|
+
if (link.text) {
|
|
126028
126184
|
parts.push(linkTextPart(link.text));
|
|
126185
|
+
}
|
|
126029
126186
|
}
|
|
126030
126187
|
else {
|
|
126031
126188
|
var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
|
|
126032
126189
|
var suffix = findLinkNameEnd(link.text);
|
|
126033
126190
|
var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
|
|
126034
|
-
var text = link.text.slice(suffix);
|
|
126191
|
+
var text = skipSeparatorFromLinkText(link.text.slice(suffix));
|
|
126035
126192
|
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]);
|
|
126036
126193
|
if (decl) {
|
|
126037
126194
|
parts.push(linkNamePart(name, decl));
|
|
@@ -126046,6 +126203,15 @@ var ts;
|
|
|
126046
126203
|
return parts;
|
|
126047
126204
|
}
|
|
126048
126205
|
ts.buildLinkParts = buildLinkParts;
|
|
126206
|
+
function skipSeparatorFromLinkText(text) {
|
|
126207
|
+
var pos = 0;
|
|
126208
|
+
if (text.charCodeAt(pos++) === 124 /* bar */) {
|
|
126209
|
+
while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
|
|
126210
|
+
pos++;
|
|
126211
|
+
return text.slice(pos);
|
|
126212
|
+
}
|
|
126213
|
+
return text;
|
|
126214
|
+
}
|
|
126049
126215
|
function findLinkNameEnd(text) {
|
|
126050
126216
|
if (text.indexOf("()") === 0)
|
|
126051
126217
|
return 2;
|
|
@@ -130622,14 +130788,15 @@ var ts;
|
|
|
130622
130788
|
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
|
|
130623
130789
|
return { kind: 1 /* JsDocTagName */ };
|
|
130624
130790
|
}
|
|
130625
|
-
|
|
130791
|
+
var typeExpression = tryGetTypeExpressionFromTag(tag);
|
|
130792
|
+
if (typeExpression) {
|
|
130626
130793
|
currentToken = ts.getTokenAtPosition(sourceFile, position);
|
|
130627
130794
|
if (!currentToken ||
|
|
130628
130795
|
(!ts.isDeclarationName(currentToken) &&
|
|
130629
130796
|
(currentToken.parent.kind !== 345 /* JSDocPropertyTag */ ||
|
|
130630
130797
|
currentToken.parent.name !== currentToken))) {
|
|
130631
130798
|
// Use as type location if inside tag's type expression
|
|
130632
|
-
insideJsDocTagTypeExpression = isCurrentlyEditingNode(
|
|
130799
|
+
insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression);
|
|
130633
130800
|
}
|
|
130634
130801
|
}
|
|
130635
130802
|
if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) {
|
|
@@ -130886,10 +131053,19 @@ var ts;
|
|
|
130886
131053
|
case 341 /* JSDocTypeTag */:
|
|
130887
131054
|
case 343 /* JSDocTypedefTag */:
|
|
130888
131055
|
return true;
|
|
131056
|
+
case 342 /* JSDocTemplateTag */:
|
|
131057
|
+
return !!tag.constraint;
|
|
130889
131058
|
default:
|
|
130890
131059
|
return false;
|
|
130891
131060
|
}
|
|
130892
131061
|
}
|
|
131062
|
+
function tryGetTypeExpressionFromTag(tag) {
|
|
131063
|
+
if (isTagWithTypeExpression(tag)) {
|
|
131064
|
+
var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression;
|
|
131065
|
+
return typeExpression && typeExpression.kind === 307 /* JSDocTypeExpression */ ? typeExpression : undefined;
|
|
131066
|
+
}
|
|
131067
|
+
return undefined;
|
|
131068
|
+
}
|
|
130893
131069
|
function getTypeScriptMemberSymbols() {
|
|
130894
131070
|
// Right of dot member completion list
|
|
130895
131071
|
completionKind = 2 /* PropertyAccess */;
|
|
@@ -133645,7 +133821,7 @@ var ts;
|
|
|
133645
133821
|
}
|
|
133646
133822
|
for (var _c = 0, _d = referencingFile.typeReferenceDirectives; _c < _d.length; _c++) {
|
|
133647
133823
|
var ref = _d[_c];
|
|
133648
|
-
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName);
|
|
133824
|
+
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat);
|
|
133649
133825
|
if (referenced !== undefined && referenced.resolvedFileName === searchSourceFile.fileName) {
|
|
133650
133826
|
refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
|
|
133651
133827
|
}
|
|
@@ -136867,7 +137043,7 @@ var ts;
|
|
|
136867
137043
|
}
|
|
136868
137044
|
var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
|
136869
137045
|
if (typeReferenceDirective) {
|
|
136870
|
-
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
|
|
137046
|
+
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat);
|
|
136871
137047
|
var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217
|
|
136872
137048
|
return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false };
|
|
136873
137049
|
}
|
|
@@ -137272,9 +137448,18 @@ var ts;
|
|
|
137272
137448
|
JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations;
|
|
137273
137449
|
function getDisplayPartsFromComment(comment, checker) {
|
|
137274
137450
|
if (typeof comment === "string") {
|
|
137275
|
-
return [ts.textPart(comment)];
|
|
137451
|
+
return [ts.textPart(skipSeparatorFromComment(comment))];
|
|
137276
137452
|
}
|
|
137277
|
-
return ts.flatMap(comment, function (node) { return node.kind === 319 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); });
|
|
137453
|
+
return ts.flatMap(comment, function (node) { return node.kind === 319 /* JSDocText */ ? [ts.textPart(skipSeparatorFromComment(node.text))] : ts.buildLinkParts(node, checker); });
|
|
137454
|
+
}
|
|
137455
|
+
function skipSeparatorFromComment(text) {
|
|
137456
|
+
var pos = 0;
|
|
137457
|
+
if (text.charCodeAt(pos++) === 45 /* minus */) {
|
|
137458
|
+
while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
|
|
137459
|
+
pos++;
|
|
137460
|
+
return text.slice(pos);
|
|
137461
|
+
}
|
|
137462
|
+
return text;
|
|
137278
137463
|
}
|
|
137279
137464
|
function getCommentDisplayParts(tag, checker) {
|
|
137280
137465
|
var comment = tag.comment, kind = tag.kind;
|
|
@@ -154652,7 +154837,7 @@ var ts;
|
|
|
154652
154837
|
/*dotDotDotToken*/ undefined,
|
|
154653
154838
|
/*name*/ names && names[i] || "arg" + i,
|
|
154654
154839
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
154655
|
-
/*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(
|
|
154840
|
+
/*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */),
|
|
154656
154841
|
/*initializer*/ undefined);
|
|
154657
154842
|
parameters.push(newParameter);
|
|
154658
154843
|
}
|
|
@@ -154680,11 +154865,10 @@ var ts;
|
|
|
154680
154865
|
var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; });
|
|
154681
154866
|
var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false);
|
|
154682
154867
|
if (someSigHasRestParameter) {
|
|
154683
|
-
var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
|
|
154684
154868
|
var restParameter = ts.factory.createParameterDeclaration(
|
|
154685
154869
|
/*decorators*/ undefined,
|
|
154686
154870
|
/*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
|
|
154687
|
-
/*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
154871
|
+
/*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */)),
|
|
154688
154872
|
/*initializer*/ undefined);
|
|
154689
154873
|
parameters.push(restParameter);
|
|
154690
154874
|
}
|
|
@@ -156930,7 +157114,7 @@ var ts;
|
|
|
156930
157114
|
// cannot find either start or end node
|
|
156931
157115
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
156932
157116
|
}
|
|
156933
|
-
if (
|
|
157117
|
+
if (start.flags & 4194304 /* JSDoc */) {
|
|
156934
157118
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
|
|
156935
157119
|
}
|
|
156936
157120
|
if (start.parent !== end.parent) {
|
|
@@ -157053,7 +157237,7 @@ var ts;
|
|
|
157053
157237
|
ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)");
|
|
157054
157238
|
// For understanding how skipTrivia functioned:
|
|
157055
157239
|
ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)");
|
|
157056
|
-
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) {
|
|
157240
|
+
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
|
|
157057
157241
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
|
|
157058
157242
|
}
|
|
157059
157243
|
if (nodeToCheck.flags & 8388608 /* Ambient */) {
|
|
@@ -157233,13 +157417,16 @@ var ts;
|
|
|
157233
157417
|
if (ts.isStatement(node)) {
|
|
157234
157418
|
return [node];
|
|
157235
157419
|
}
|
|
157236
|
-
|
|
157420
|
+
if (ts.isExpressionNode(node)) {
|
|
157237
157421
|
// If our selection is the expression in an ExpressionStatement, expand
|
|
157238
157422
|
// the selection to include the enclosing Statement (this stops us
|
|
157239
157423
|
// from trying to care about the return value of the extracted function
|
|
157240
157424
|
// and eliminates double semicolon insertion in certain scenarios)
|
|
157241
157425
|
return ts.isExpressionStatement(node.parent) ? [node.parent] : node;
|
|
157242
157426
|
}
|
|
157427
|
+
if (isStringLiteralJsxAttribute(node)) {
|
|
157428
|
+
return node;
|
|
157429
|
+
}
|
|
157243
157430
|
return undefined;
|
|
157244
157431
|
}
|
|
157245
157432
|
function isScope(node) {
|
|
@@ -158049,7 +158236,7 @@ var ts;
|
|
|
158049
158236
|
// Unfortunately, this code takes advantage of the knowledge that the generated method
|
|
158050
158237
|
// will use the contextual type of an expression as the return type of the extracted
|
|
158051
158238
|
// method (and will therefore "use" all the types involved).
|
|
158052
|
-
if (inGenericContext && !isReadonlyArray(targetRange.range)) {
|
|
158239
|
+
if (inGenericContext && !isReadonlyArray(targetRange.range) && !ts.isJsxAttribute(targetRange.range)) {
|
|
158053
158240
|
var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217
|
|
158054
158241
|
recordTypeParameterUsages(contextualType);
|
|
158055
158242
|
}
|
|
@@ -158374,7 +158561,11 @@ var ts;
|
|
|
158374
158561
|
}
|
|
158375
158562
|
}
|
|
158376
158563
|
function isInJSXContent(node) {
|
|
158377
|
-
return (
|
|
158564
|
+
return isStringLiteralJsxAttribute(node) ||
|
|
158565
|
+
(ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
|
|
158566
|
+
}
|
|
158567
|
+
function isStringLiteralJsxAttribute(node) {
|
|
158568
|
+
return ts.isStringLiteral(node) && node.parent && ts.isJsxAttribute(node.parent);
|
|
158378
158569
|
}
|
|
158379
158570
|
})(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {}));
|
|
158380
158571
|
})(refactor = ts.refactor || (ts.refactor = {}));
|
|
@@ -163689,7 +163880,7 @@ var ts;
|
|
|
163689
163880
|
if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
|
|
163690
163881
|
this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) {
|
|
163691
163882
|
var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); // TODO: GH#18217
|
|
163692
|
-
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); });
|
|
163883
|
+
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, ts.isString(name) ? name : name.fileName.toLowerCase()); });
|
|
163693
163884
|
};
|
|
163694
163885
|
}
|
|
163695
163886
|
}
|
|
@@ -166388,8 +166579,8 @@ var ts;
|
|
|
166388
166579
|
Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile, resolutionMode) {
|
|
166389
166580
|
return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
|
|
166390
166581
|
};
|
|
166391
|
-
Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference) {
|
|
166392
|
-
return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference);
|
|
166582
|
+
Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
166583
|
+
return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode);
|
|
166393
166584
|
};
|
|
166394
166585
|
Project.prototype.directoryExists = function (path) {
|
|
166395
166586
|
return this.directoryStructureHost.directoryExists(path); // TODO: GH#18217
|
|
@@ -176881,6 +177072,7 @@ var ts;
|
|
|
176881
177072
|
})(server = ts.server || (ts.server = {}));
|
|
176882
177073
|
})(ts || (ts = {}));
|
|
176883
177074
|
/*@internal*/
|
|
177075
|
+
/// <reference lib="webworker" />
|
|
176884
177076
|
var ts;
|
|
176885
177077
|
(function (ts) {
|
|
176886
177078
|
var server;
|
|
@@ -176962,7 +177154,7 @@ var ts;
|
|
|
176962
177154
|
}
|
|
176963
177155
|
}
|
|
176964
177156
|
function hrtime(previous) {
|
|
176965
|
-
var now = self.performance.now(
|
|
177157
|
+
var now = self.performance.now() * 1e-3;
|
|
176966
177158
|
var seconds = Math.floor(now);
|
|
176967
177159
|
var nanoseconds = Math.floor((now % 1) * 1e9);
|
|
176968
177160
|
if (previous) {
|
|
@@ -176984,7 +177176,7 @@ var ts;
|
|
|
176984
177176
|
WorkerSession.prototype.exit = function () {
|
|
176985
177177
|
this.logger.info("Exiting...");
|
|
176986
177178
|
this.projectService.closeLog();
|
|
176987
|
-
close(
|
|
177179
|
+
close();
|
|
176988
177180
|
};
|
|
176989
177181
|
WorkerSession.prototype.listen = function () {
|
|
176990
177182
|
var _this = this;
|
|
@@ -177015,9 +177207,9 @@ var ts;
|
|
|
177015
177207
|
function getLogLevel(level) {
|
|
177016
177208
|
if (level) {
|
|
177017
177209
|
var l = level.toLowerCase();
|
|
177018
|
-
for (var
|
|
177019
|
-
if (isNaN(+
|
|
177020
|
-
return server.LogLevel[
|
|
177210
|
+
for (var name_1 in server.LogLevel) {
|
|
177211
|
+
if (isNaN(+name_1) && l === name_1.toLowerCase()) {
|
|
177212
|
+
return server.LogLevel[name_1];
|
|
177021
177213
|
}
|
|
177022
177214
|
}
|
|
177023
177215
|
}
|