typescript 4.6.0-dev.20220211 → 4.7.0-dev.20220217
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 +9 -3
- package/lib/de/diagnosticMessages.generated.json +9 -3
- package/lib/es/diagnosticMessages.generated.json +9 -3
- package/lib/fr/diagnosticMessages.generated.json +9 -3
- package/lib/it/diagnosticMessages.generated.json +9 -3
- package/lib/ja/diagnosticMessages.generated.json +9 -3
- package/lib/ko/diagnosticMessages.generated.json +9 -3
- package/lib/lib.es2020.intl.d.ts +4 -0
- package/lib/lib.esnext.intl.d.ts +4 -1
- package/lib/pl/diagnosticMessages.generated.json +9 -3
- package/lib/protocol.d.ts +7 -0
- package/lib/pt-br/diagnosticMessages.generated.json +9 -3
- package/lib/ru/diagnosticMessages.generated.json +9 -3
- package/lib/tr/diagnosticMessages.generated.json +9 -3
- package/lib/tsc.js +658 -490
- package/lib/tsserver.js +883 -611
- package/lib/tsserverlibrary.d.ts +32 -26
- package/lib/tsserverlibrary.js +883 -611
- package/lib/typescript.d.ts +24 -25
- package/lib/typescript.js +881 -609
- package/lib/typescriptServices.d.ts +24 -25
- package/lib/typescriptServices.js +881 -609
- package/lib/typingsInstaller.js +788 -593
- package/lib/zh-cn/diagnosticMessages.generated.json +9 -3
- package/lib/zh-tw/diagnosticMessages.generated.json +9 -3
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -290,11 +290,11 @@ var ts;
|
|
|
290
290
|
(function (ts) {
|
|
291
291
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
292
292
|
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
|
293
|
-
ts.versionMajorMinor = "4.
|
|
293
|
+
ts.versionMajorMinor = "4.7";
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220217";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -5034,6 +5034,8 @@ var ts;
|
|
|
5034
5034
|
TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike";
|
|
5035
5035
|
TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike";
|
|
5036
5036
|
/* @internal */
|
|
5037
|
+
TypeFlags[TypeFlags["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
|
|
5038
|
+
/* @internal */
|
|
5037
5039
|
TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains";
|
|
5038
5040
|
TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
5039
5041
|
TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType";
|
|
@@ -5112,13 +5114,14 @@ var ts;
|
|
|
5112
5114
|
// Flags that require TypeFlags.Object
|
|
5113
5115
|
ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread";
|
|
5114
5116
|
ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType";
|
|
5117
|
+
ObjectFlags[ObjectFlags["InstantiationExpressionType"] = 16777216] = "InstantiationExpressionType";
|
|
5115
5118
|
/* @internal */
|
|
5116
|
-
ObjectFlags[ObjectFlags["IsClassInstanceClone"] =
|
|
5119
|
+
ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 33554432] = "IsClassInstanceClone";
|
|
5117
5120
|
// Flags that require TypeFlags.Object and ObjectFlags.Reference
|
|
5118
5121
|
/* @internal */
|
|
5119
|
-
ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] =
|
|
5122
|
+
ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 67108864] = "IdenticalBaseTypeCalculated";
|
|
5120
5123
|
/* @internal */
|
|
5121
|
-
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] =
|
|
5124
|
+
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 134217728] = "IdenticalBaseTypeExists";
|
|
5122
5125
|
// Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution
|
|
5123
5126
|
/* @internal */
|
|
5124
5127
|
ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 4194304] = "IsGenericTypeComputed";
|
|
@@ -5766,6 +5769,8 @@ var ts;
|
|
|
5766
5769
|
BundleFileSectionKind["NoDefaultLib"] = "no-default-lib";
|
|
5767
5770
|
BundleFileSectionKind["Reference"] = "reference";
|
|
5768
5771
|
BundleFileSectionKind["Type"] = "type";
|
|
5772
|
+
BundleFileSectionKind["TypeResolutionModeRequire"] = "type-require";
|
|
5773
|
+
BundleFileSectionKind["TypeResolutionModeImport"] = "type-import";
|
|
5769
5774
|
BundleFileSectionKind["Lib"] = "lib";
|
|
5770
5775
|
BundleFileSectionKind["Prepend"] = "prepend";
|
|
5771
5776
|
BundleFileSectionKind["Text"] = "text";
|
|
@@ -5882,7 +5887,8 @@ var ts;
|
|
|
5882
5887
|
{ name: "types", optional: true, captureSpan: true },
|
|
5883
5888
|
{ name: "lib", optional: true, captureSpan: true },
|
|
5884
5889
|
{ name: "path", optional: true, captureSpan: true },
|
|
5885
|
-
{ name: "no-default-lib", optional: true }
|
|
5890
|
+
{ name: "no-default-lib", optional: true },
|
|
5891
|
+
{ name: "resolution-mode", optional: true }
|
|
5886
5892
|
],
|
|
5887
5893
|
kind: 1 /* TripleSlashXML */
|
|
5888
5894
|
},
|
|
@@ -7830,18 +7836,6 @@ var ts;
|
|
|
7830
7836
|
return getCanonicalFileName(nonCanonicalizedPath);
|
|
7831
7837
|
}
|
|
7832
7838
|
ts.toPath = toPath;
|
|
7833
|
-
function normalizePathAndParts(path) {
|
|
7834
|
-
path = normalizeSlashes(path);
|
|
7835
|
-
var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
|
|
7836
|
-
if (parts.length) {
|
|
7837
|
-
var joinedParts = root + parts.join(ts.directorySeparator);
|
|
7838
|
-
return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
|
|
7839
|
-
}
|
|
7840
|
-
else {
|
|
7841
|
-
return { path: root, parts: parts };
|
|
7842
|
-
}
|
|
7843
|
-
}
|
|
7844
|
-
ts.normalizePathAndParts = normalizePathAndParts;
|
|
7845
7839
|
function removeTrailingDirectorySeparator(path) {
|
|
7846
7840
|
if (hasTrailingDirectorySeparator(path)) {
|
|
7847
7841
|
return path.substr(0, path.length - 1);
|
|
@@ -8275,6 +8269,8 @@ var ts;
|
|
|
8275
8269
|
Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
|
|
8276
8270
|
An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
|
|
8277
8271
|
Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
|
|
8272
|
+
Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
|
|
8273
|
+
Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
|
|
8278
8274
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
8279
8275
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
8280
8276
|
Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
|
|
@@ -8343,7 +8339,6 @@ var ts;
|
|
|
8343
8339
|
Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"),
|
|
8344
8340
|
Unexpected_token_Did_you_mean_or_gt: diag(1382, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `>`?"),
|
|
8345
8341
|
Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."),
|
|
8346
|
-
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."),
|
|
8347
8342
|
Function_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1385, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_a_union_type_1385", "Function type notation must be parenthesized when used in a union type."),
|
|
8348
8343
|
Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1386, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386", "Constructor type notation must be parenthesized when used in a union type."),
|
|
8349
8344
|
Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."),
|
|
@@ -8408,6 +8403,8 @@ var ts;
|
|
|
8408
8403
|
Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
|
|
8409
8404
|
Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
|
|
8410
8405
|
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
|
|
8406
|
+
Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."),
|
|
8407
|
+
resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
|
|
8411
8408
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8412
8409
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8413
8410
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -8727,6 +8724,7 @@ var ts;
|
|
|
8727
8724
|
Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."),
|
|
8728
8725
|
JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"),
|
|
8729
8726
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8727
|
+
Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
|
|
8730
8728
|
Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
|
|
8731
8729
|
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
|
|
8732
8730
|
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
|
|
@@ -13618,6 +13616,7 @@ var ts;
|
|
|
13618
13616
|
case 110 /* TrueKeyword */:
|
|
13619
13617
|
case 106 /* SuperKeyword */:
|
|
13620
13618
|
case 229 /* NonNullExpression */:
|
|
13619
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
13621
13620
|
case 230 /* MetaProperty */:
|
|
13622
13621
|
case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression
|
|
13623
13622
|
return true;
|
|
@@ -14291,7 +14290,11 @@ var ts;
|
|
|
14291
14290
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14292
14291
|
for (var i = 0; i < names.length; i++) {
|
|
14293
14292
|
var newResolution = newResolutions[i];
|
|
14294
|
-
var
|
|
14293
|
+
var entry = names[i];
|
|
14294
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
14295
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
14296
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
|
|
14297
|
+
var oldResolution = oldResolutions && oldResolutions.get(name, mode);
|
|
14295
14298
|
var changed = oldResolution
|
|
14296
14299
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14297
14300
|
: newResolution;
|
|
@@ -15327,7 +15330,7 @@ var ts;
|
|
|
15327
15330
|
case 114 /* VoidKeyword */:
|
|
15328
15331
|
return node.parent.kind !== 216 /* VoidExpression */;
|
|
15329
15332
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15330
|
-
return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
15333
|
+
return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
15331
15334
|
case 162 /* TypeParameter */:
|
|
15332
15335
|
return node.parent.kind === 194 /* MappedType */ || node.parent.kind === 189 /* InferType */;
|
|
15333
15336
|
// Identifiers and qualified names may be type nodes, depending on their context. Climb
|
|
@@ -15364,7 +15367,7 @@ var ts;
|
|
|
15364
15367
|
}
|
|
15365
15368
|
switch (parent.kind) {
|
|
15366
15369
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15367
|
-
return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
15370
|
+
return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
15368
15371
|
case 162 /* TypeParameter */:
|
|
15369
15372
|
return node === parent.constraint;
|
|
15370
15373
|
case 342 /* JSDocTemplateTag */:
|
|
@@ -16067,7 +16070,7 @@ var ts;
|
|
|
16067
16070
|
case 296 /* SpreadAssignment */:
|
|
16068
16071
|
return true;
|
|
16069
16072
|
case 227 /* ExpressionWithTypeArguments */:
|
|
16070
|
-
return parent.expression === node &&
|
|
16073
|
+
return parent.expression === node && !isPartOfTypeNode(parent);
|
|
16071
16074
|
case 295 /* ShorthandPropertyAssignment */:
|
|
16072
16075
|
return parent.objectAssignmentInitializer === node;
|
|
16073
16076
|
default:
|
|
@@ -23054,16 +23057,18 @@ var ts;
|
|
|
23054
23057
|
return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type);
|
|
23055
23058
|
}
|
|
23056
23059
|
// @api
|
|
23057
|
-
function createTypeQueryNode(exprName) {
|
|
23060
|
+
function createTypeQueryNode(exprName, typeArguments) {
|
|
23058
23061
|
var node = createBaseNode(180 /* TypeQuery */);
|
|
23059
23062
|
node.exprName = exprName;
|
|
23063
|
+
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
23060
23064
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23061
23065
|
return node;
|
|
23062
23066
|
}
|
|
23063
23067
|
// @api
|
|
23064
|
-
function updateTypeQueryNode(node, exprName) {
|
|
23068
|
+
function updateTypeQueryNode(node, exprName, typeArguments) {
|
|
23065
23069
|
return node.exprName !== exprName
|
|
23066
|
-
|
|
23070
|
+
|| node.typeArguments !== typeArguments
|
|
23071
|
+
? update(createTypeQueryNode(exprName, typeArguments), node)
|
|
23067
23072
|
: node;
|
|
23068
23073
|
}
|
|
23069
23074
|
// @api
|
|
@@ -26886,7 +26891,13 @@ var ts;
|
|
|
26886
26891
|
referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
|
|
26887
26892
|
break;
|
|
26888
26893
|
case "type" /* Type */:
|
|
26889
|
-
typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
|
|
26894
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
26895
|
+
break;
|
|
26896
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26897
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
|
|
26898
|
+
break;
|
|
26899
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26900
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
|
|
26890
26901
|
break;
|
|
26891
26902
|
case "lib" /* Lib */:
|
|
26892
26903
|
libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
@@ -26945,6 +26956,8 @@ var ts;
|
|
|
26945
26956
|
case "no-default-lib" /* NoDefaultLib */:
|
|
26946
26957
|
case "reference" /* Reference */:
|
|
26947
26958
|
case "type" /* Type */:
|
|
26959
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26960
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26948
26961
|
case "lib" /* Lib */:
|
|
26949
26962
|
syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
|
|
26950
26963
|
break;
|
|
@@ -30179,7 +30192,8 @@ var ts;
|
|
|
30179
30192
|
visitNode(cbNode, node.parameterName) ||
|
|
30180
30193
|
visitNode(cbNode, node.type);
|
|
30181
30194
|
case 180 /* TypeQuery */:
|
|
30182
|
-
return visitNode(cbNode, node.exprName)
|
|
30195
|
+
return visitNode(cbNode, node.exprName) ||
|
|
30196
|
+
visitNodes(cbNode, cbNodes, node.typeArguments);
|
|
30183
30197
|
case 181 /* TypeLiteral */:
|
|
30184
30198
|
return visitNodes(cbNode, cbNodes, node.members);
|
|
30185
30199
|
case 182 /* ArrayType */:
|
|
@@ -30858,7 +30872,7 @@ var ts;
|
|
|
30858
30872
|
initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
|
|
30859
30873
|
// Prime the scanner.
|
|
30860
30874
|
nextToken();
|
|
30861
|
-
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
30875
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false);
|
|
30862
30876
|
var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
|
|
30863
30877
|
clearState();
|
|
30864
30878
|
return isInvalid ? entityName : undefined;
|
|
@@ -32435,7 +32449,7 @@ var ts;
|
|
|
32435
32449
|
}
|
|
32436
32450
|
return createMissingList();
|
|
32437
32451
|
}
|
|
32438
|
-
function parseEntityName(allowReservedWords, diagnosticMessage) {
|
|
32452
|
+
function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) {
|
|
32439
32453
|
var pos = getNodePos();
|
|
32440
32454
|
var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
|
|
32441
32455
|
var dotPos = getNodePos();
|
|
@@ -32446,7 +32460,7 @@ var ts;
|
|
|
32446
32460
|
break;
|
|
32447
32461
|
}
|
|
32448
32462
|
dotPos = getNodePos();
|
|
32449
|
-
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords,
|
|
32463
|
+
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos);
|
|
32450
32464
|
}
|
|
32451
32465
|
return entity;
|
|
32452
32466
|
}
|
|
@@ -32579,7 +32593,7 @@ var ts;
|
|
|
32579
32593
|
}
|
|
32580
32594
|
// TYPES
|
|
32581
32595
|
function parseEntityNameOfTypeReference() {
|
|
32582
|
-
return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
|
|
32596
|
+
return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected);
|
|
32583
32597
|
}
|
|
32584
32598
|
function parseTypeArgumentsOfTypeReference() {
|
|
32585
32599
|
if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) {
|
|
@@ -32712,7 +32726,9 @@ var ts;
|
|
|
32712
32726
|
function parseTypeQuery() {
|
|
32713
32727
|
var pos = getNodePos();
|
|
32714
32728
|
parseExpected(112 /* TypeOfKeyword */);
|
|
32715
|
-
|
|
32729
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true);
|
|
32730
|
+
var typeArguments = tryParseTypeArguments();
|
|
32731
|
+
return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
|
|
32716
32732
|
}
|
|
32717
32733
|
function parseTypeParameter() {
|
|
32718
32734
|
var pos = getNodePos();
|
|
@@ -34782,20 +34798,30 @@ var ts;
|
|
|
34782
34798
|
expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
|
|
34783
34799
|
continue;
|
|
34784
34800
|
}
|
|
34785
|
-
if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34786
|
-
nextToken();
|
|
34787
|
-
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34788
|
-
continue;
|
|
34789
|
-
}
|
|
34790
34801
|
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
|
34791
34802
|
if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) {
|
|
34792
34803
|
expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
|
|
34793
34804
|
continue;
|
|
34794
34805
|
}
|
|
34795
34806
|
if (isTemplateStartOfTaggedTemplate()) {
|
|
34796
|
-
|
|
34807
|
+
// Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments
|
|
34808
|
+
expression = !questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */ ?
|
|
34809
|
+
parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) :
|
|
34810
|
+
parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
|
|
34797
34811
|
continue;
|
|
34798
34812
|
}
|
|
34813
|
+
if (!questionDotToken) {
|
|
34814
|
+
if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34815
|
+
nextToken();
|
|
34816
|
+
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34817
|
+
continue;
|
|
34818
|
+
}
|
|
34819
|
+
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34820
|
+
if (typeArguments) {
|
|
34821
|
+
expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
34822
|
+
continue;
|
|
34823
|
+
}
|
|
34824
|
+
}
|
|
34799
34825
|
return expression;
|
|
34800
34826
|
}
|
|
34801
34827
|
}
|
|
@@ -34815,38 +34841,30 @@ var ts;
|
|
|
34815
34841
|
function parseCallExpressionRest(pos, expression) {
|
|
34816
34842
|
while (true) {
|
|
34817
34843
|
expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true);
|
|
34844
|
+
var typeArguments = void 0;
|
|
34818
34845
|
var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */);
|
|
34819
|
-
|
|
34820
|
-
|
|
34821
|
-
|
|
34822
|
-
|
|
34823
|
-
// keep checking for postfix expressions. Otherwise, it's just a '<' that's
|
|
34824
|
-
// part of an arithmetic expression. Break out so we consume it higher in the
|
|
34825
|
-
// stack.
|
|
34826
|
-
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34827
|
-
if (typeArguments) {
|
|
34828
|
-
if (isTemplateStartOfTaggedTemplate()) {
|
|
34829
|
-
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34830
|
-
continue;
|
|
34831
|
-
}
|
|
34832
|
-
var argumentList = parseArgumentList();
|
|
34833
|
-
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34834
|
-
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34835
|
-
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34836
|
-
expression = finishNode(callExpr, pos);
|
|
34846
|
+
if (questionDotToken) {
|
|
34847
|
+
typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34848
|
+
if (isTemplateStartOfTaggedTemplate()) {
|
|
34849
|
+
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34837
34850
|
continue;
|
|
34838
34851
|
}
|
|
34839
34852
|
}
|
|
34840
|
-
|
|
34853
|
+
if (typeArguments || token() === 20 /* OpenParenToken */) {
|
|
34854
|
+
// Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments
|
|
34855
|
+
if (!questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
34856
|
+
typeArguments = expression.typeArguments;
|
|
34857
|
+
expression = expression.expression;
|
|
34858
|
+
}
|
|
34841
34859
|
var argumentList = parseArgumentList();
|
|
34842
34860
|
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34843
|
-
factory.createCallChain(expression, questionDotToken,
|
|
34844
|
-
factory.createCallExpression(expression,
|
|
34861
|
+
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34862
|
+
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34845
34863
|
expression = finishNode(callExpr, pos);
|
|
34846
34864
|
continue;
|
|
34847
34865
|
}
|
|
34848
34866
|
if (questionDotToken) {
|
|
34849
|
-
// We failed to parse anything, so report a missing identifier here.
|
|
34867
|
+
// We parsed `?.` but then failed to parse anything, so report a missing identifier here.
|
|
34850
34868
|
var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected);
|
|
34851
34869
|
expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
|
|
34852
34870
|
}
|
|
@@ -34874,21 +34892,25 @@ var ts;
|
|
|
34874
34892
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
34875
34893
|
return undefined;
|
|
34876
34894
|
}
|
|
34877
|
-
//
|
|
34878
|
-
//
|
|
34879
|
-
|
|
34880
|
-
|
|
34881
|
-
|
|
34895
|
+
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
34896
|
+
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
34897
|
+
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
34898
|
+
// it as a relational expression.
|
|
34899
|
+
return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
|
|
34882
34900
|
}
|
|
34883
34901
|
function canFollowTypeArgumentsInExpression() {
|
|
34884
34902
|
switch (token()) {
|
|
34903
|
+
// These tokens can follow a type argument list in a call expression.
|
|
34885
34904
|
case 20 /* OpenParenToken */: // foo<x>(
|
|
34886
34905
|
case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
34887
34906
|
case 15 /* TemplateHead */: // foo<T> `...${100}...`
|
|
34888
|
-
//
|
|
34889
|
-
//
|
|
34907
|
+
// These tokens can't follow in a call expression, nor can they start an
|
|
34908
|
+
// expression. So, consider the type argument list part of an instantiation
|
|
34909
|
+
// expression.
|
|
34890
34910
|
// falls through
|
|
34911
|
+
case 27 /* CommaToken */: // foo<x>,
|
|
34891
34912
|
case 24 /* DotToken */: // foo<x>.
|
|
34913
|
+
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
34892
34914
|
case 21 /* CloseParenToken */: // foo<x>)
|
|
34893
34915
|
case 23 /* CloseBracketToken */: // foo<x>]
|
|
34894
34916
|
case 58 /* ColonToken */: // foo<x>:
|
|
@@ -34906,20 +34928,10 @@ var ts;
|
|
|
34906
34928
|
case 51 /* BarToken */: // foo<x> |
|
|
34907
34929
|
case 19 /* CloseBraceToken */: // foo<x> }
|
|
34908
34930
|
case 1 /* EndOfFileToken */: // foo<x>
|
|
34909
|
-
// these cases can't legally follow a type arg list. However, they're not legal
|
|
34910
|
-
// expressions either. The user is probably in the middle of a generic type. So
|
|
34911
|
-
// treat it as such.
|
|
34912
34931
|
return true;
|
|
34913
|
-
case 27 /* CommaToken */: // foo<x>,
|
|
34914
|
-
case 18 /* OpenBraceToken */: // foo<x> {
|
|
34915
|
-
// We don't want to treat these as type arguments. Otherwise we'll parse this
|
|
34916
|
-
// as an invocation expression. Instead, we want to parse out the expression
|
|
34917
|
-
// in isolation from the type arguments.
|
|
34918
|
-
// falls through
|
|
34919
|
-
default:
|
|
34920
|
-
// Anything else treat as an expression.
|
|
34921
|
-
return false;
|
|
34922
34932
|
}
|
|
34933
|
+
// Treat anything else as an expression.
|
|
34934
|
+
return false;
|
|
34923
34935
|
}
|
|
34924
34936
|
function parsePrimaryExpression() {
|
|
34925
34937
|
switch (token()) {
|
|
@@ -35100,26 +35112,15 @@ var ts;
|
|
|
35100
35112
|
return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos);
|
|
35101
35113
|
}
|
|
35102
35114
|
var expressionPos = getNodePos();
|
|
35103
|
-
var expression = parsePrimaryExpression();
|
|
35115
|
+
var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
|
|
35104
35116
|
var typeArguments;
|
|
35105
|
-
|
|
35106
|
-
|
|
35107
|
-
typeArguments =
|
|
35108
|
-
|
|
35109
|
-
ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
|
|
35110
|
-
expression = parseTaggedTemplateRest(expressionPos, expression, /*optionalChain*/ undefined, typeArguments);
|
|
35111
|
-
typeArguments = undefined;
|
|
35112
|
-
}
|
|
35113
|
-
break;
|
|
35114
|
-
}
|
|
35115
|
-
var argumentsArray;
|
|
35116
|
-
if (token() === 20 /* OpenParenToken */) {
|
|
35117
|
-
argumentsArray = parseArgumentList();
|
|
35117
|
+
// Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments
|
|
35118
|
+
if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
35119
|
+
typeArguments = expression.typeArguments;
|
|
35120
|
+
expression = expression.expression;
|
|
35118
35121
|
}
|
|
35119
|
-
|
|
35120
|
-
|
|
35121
|
-
}
|
|
35122
|
-
return finishNode(factory.createNewExpression(expression, typeArguments, argumentsArray), pos);
|
|
35122
|
+
var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
|
|
35123
|
+
return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
|
|
35123
35124
|
}
|
|
35124
35125
|
// STATEMENTS
|
|
35125
35126
|
function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
|
|
@@ -35283,11 +35284,12 @@ var ts;
|
|
|
35283
35284
|
}
|
|
35284
35285
|
function parseCaseClause() {
|
|
35285
35286
|
var pos = getNodePos();
|
|
35287
|
+
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35286
35288
|
parseExpected(82 /* CaseKeyword */);
|
|
35287
35289
|
var expression = allowInAnd(parseExpression);
|
|
35288
35290
|
parseExpected(58 /* ColonToken */);
|
|
35289
35291
|
var statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
|
|
35290
|
-
return finishNode(factory.createCaseClause(expression, statements), pos);
|
|
35292
|
+
return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
|
|
35291
35293
|
}
|
|
35292
35294
|
function parseDefaultClause() {
|
|
35293
35295
|
var pos = getNodePos();
|
|
@@ -36207,6 +36209,9 @@ var ts;
|
|
|
36207
36209
|
function parseExpressionWithTypeArguments() {
|
|
36208
36210
|
var pos = getNodePos();
|
|
36209
36211
|
var expression = parseLeftHandSideExpressionOrHigher();
|
|
36212
|
+
if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
36213
|
+
return expression;
|
|
36214
|
+
}
|
|
36210
36215
|
var typeArguments = tryParseTypeArguments();
|
|
36211
36216
|
return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
36212
36217
|
}
|
|
@@ -36450,7 +36455,7 @@ var ts;
|
|
|
36450
36455
|
function parseModuleReference() {
|
|
36451
36456
|
return isExternalModuleReference()
|
|
36452
36457
|
? parseExternalModuleReference()
|
|
36453
|
-
: parseEntityName(/*allowReservedWords*/ false);
|
|
36458
|
+
: parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36454
36459
|
}
|
|
36455
36460
|
function parseExternalModuleReference() {
|
|
36456
36461
|
var pos = getNodePos();
|
|
@@ -36732,7 +36737,7 @@ var ts;
|
|
|
36732
36737
|
var pos = getNodePos();
|
|
36733
36738
|
var hasBrace = parseOptional(18 /* OpenBraceToken */);
|
|
36734
36739
|
var p2 = getNodePos();
|
|
36735
|
-
var entityName = parseEntityName(/* allowReservedWords*/ false);
|
|
36740
|
+
var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36736
36741
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
36737
36742
|
reScanHashToken(); // rescan #id as # id
|
|
36738
36743
|
nextTokenJSDoc(); // then skip the #
|
|
@@ -37175,7 +37180,7 @@ var ts;
|
|
|
37175
37180
|
// parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
|
|
37176
37181
|
var p2 = getNodePos();
|
|
37177
37182
|
var name = ts.tokenIsIdentifierOrKeyword(token())
|
|
37178
|
-
? parseEntityName(/*allowReservedWords*/ true)
|
|
37183
|
+
? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false)
|
|
37179
37184
|
: undefined;
|
|
37180
37185
|
if (name) {
|
|
37181
37186
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
@@ -37200,11 +37205,13 @@ var ts;
|
|
|
37200
37205
|
&& nextTokenJSDoc() === 59 /* AtToken */
|
|
37201
37206
|
&& ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
|
|
37202
37207
|
var kind = scanner.getTokenValue();
|
|
37203
|
-
if (kind
|
|
37208
|
+
if (isJSDocLinkTag(kind))
|
|
37204
37209
|
return kind;
|
|
37205
|
-
}
|
|
37206
37210
|
}
|
|
37207
37211
|
}
|
|
37212
|
+
function isJSDocLinkTag(kind) {
|
|
37213
|
+
return kind === "link" || kind === "linkcode" || kind === "linkplain";
|
|
37214
|
+
}
|
|
37208
37215
|
function parseUnknownTag(start, tagName, indent, indentText) {
|
|
37209
37216
|
return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
|
|
37210
37217
|
}
|
|
@@ -37310,7 +37317,7 @@ var ts;
|
|
|
37310
37317
|
}
|
|
37311
37318
|
function parseSeeTag(start, tagName, indent, indentText) {
|
|
37312
37319
|
var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
|
|
37313
|
-
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue()
|
|
37320
|
+
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); });
|
|
37314
37321
|
var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
|
|
37315
37322
|
var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
|
|
37316
37323
|
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
|
|
@@ -38177,6 +38184,19 @@ var ts;
|
|
|
38177
38184
|
return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
|
|
38178
38185
|
}
|
|
38179
38186
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
38187
|
+
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
38188
|
+
if (!mode) {
|
|
38189
|
+
return undefined;
|
|
38190
|
+
}
|
|
38191
|
+
if (mode === "import") {
|
|
38192
|
+
return ts.ModuleKind.ESNext;
|
|
38193
|
+
}
|
|
38194
|
+
if (mode === "require") {
|
|
38195
|
+
return ts.ModuleKind.CommonJS;
|
|
38196
|
+
}
|
|
38197
|
+
reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
|
|
38198
|
+
return undefined;
|
|
38199
|
+
}
|
|
38180
38200
|
/*@internal*/
|
|
38181
38201
|
function processCommentPragmas(context, sourceText) {
|
|
38182
38202
|
var pragmas = [];
|
|
@@ -38219,12 +38239,13 @@ var ts;
|
|
|
38219
38239
|
var typeReferenceDirectives_1 = context.typeReferenceDirectives;
|
|
38220
38240
|
var libReferenceDirectives_1 = context.libReferenceDirectives;
|
|
38221
38241
|
ts.forEach(ts.toArray(entryOrList), function (arg) {
|
|
38222
|
-
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
|
|
38242
|
+
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
|
|
38223
38243
|
if (arg.arguments["no-default-lib"]) {
|
|
38224
38244
|
context.hasNoDefaultLib = true;
|
|
38225
38245
|
}
|
|
38226
38246
|
else if (types) {
|
|
38227
|
-
|
|
38247
|
+
var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
|
|
38248
|
+
typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
|
|
38228
38249
|
}
|
|
38229
38250
|
else if (lib) {
|
|
38230
38251
|
libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
|
|
@@ -41802,14 +41823,14 @@ var ts;
|
|
|
41802
41823
|
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
|
41803
41824
|
* is assumed to be the same as root directory of the project.
|
|
41804
41825
|
*/
|
|
41805
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
|
|
41826
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
|
|
41806
41827
|
var traceEnabled = isTraceEnabled(options, host);
|
|
41807
41828
|
if (redirectedReference) {
|
|
41808
41829
|
options = redirectedReference.commandLine.options;
|
|
41809
41830
|
}
|
|
41810
41831
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41811
41832
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41812
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/
|
|
41833
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
|
|
41813
41834
|
if (result) {
|
|
41814
41835
|
if (traceEnabled) {
|
|
41815
41836
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41844,7 +41865,18 @@ var ts;
|
|
|
41844
41865
|
}
|
|
41845
41866
|
var failedLookupLocations = [];
|
|
41846
41867
|
var features = getDefaultNodeResolutionFeatures(options);
|
|
41847
|
-
|
|
41868
|
+
// Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
|
|
41869
|
+
// setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
|
|
41870
|
+
// set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports
|
|
41871
|
+
// are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best,
|
|
41872
|
+
// in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern
|
|
41873
|
+
// resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution
|
|
41874
|
+
// context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do).
|
|
41875
|
+
if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
|
|
41876
|
+
features |= NodeResolutionFeatures.EsmMode;
|
|
41877
|
+
}
|
|
41878
|
+
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
41879
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
|
|
41848
41880
|
var resolved = primaryLookup();
|
|
41849
41881
|
var primary = true;
|
|
41850
41882
|
if (!resolved) {
|
|
@@ -41864,7 +41896,7 @@ var ts;
|
|
|
41864
41896
|
};
|
|
41865
41897
|
}
|
|
41866
41898
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41867
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/
|
|
41899
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
41868
41900
|
if (traceEnabled)
|
|
41869
41901
|
traceResult(result);
|
|
41870
41902
|
return result;
|
|
@@ -41915,7 +41947,7 @@ var ts;
|
|
|
41915
41947
|
result_4 = searchResult && searchResult.value;
|
|
41916
41948
|
}
|
|
41917
41949
|
else {
|
|
41918
|
-
var candidate =
|
|
41950
|
+
var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
|
|
41919
41951
|
result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
|
|
41920
41952
|
}
|
|
41921
41953
|
return resolvedTypeScriptOnly(result_4);
|
|
@@ -42150,7 +42182,11 @@ var ts;
|
|
|
42150
42182
|
ts.Debug.assert(keys.length === values.length);
|
|
42151
42183
|
var map = createModeAwareCache();
|
|
42152
42184
|
for (var i = 0; i < keys.length; ++i) {
|
|
42153
|
-
|
|
42185
|
+
var entry = keys[i];
|
|
42186
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
42187
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
42188
|
+
var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
|
|
42189
|
+
map.set(name, mode, values[i]);
|
|
42154
42190
|
}
|
|
42155
42191
|
return map;
|
|
42156
42192
|
}
|
|
@@ -42618,13 +42654,25 @@ var ts;
|
|
|
42618
42654
|
return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
|
|
42619
42655
|
}
|
|
42620
42656
|
else {
|
|
42621
|
-
var _a =
|
|
42657
|
+
var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
|
|
42622
42658
|
var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
|
|
42623
42659
|
// Treat explicit "node_modules" import as an external library import.
|
|
42624
42660
|
return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
|
|
42625
42661
|
}
|
|
42626
42662
|
}
|
|
42627
42663
|
}
|
|
42664
|
+
// If you import from "." inside a containing directory "/foo", the result of `normalizePath`
|
|
42665
|
+
// would be "/foo", but this loses the information that `foo` is a directory and we intended
|
|
42666
|
+
// to look inside of it. The Node CommonJS resolution algorithm doesn't call this out
|
|
42667
|
+
// (https://nodejs.org/api/modules.html#all-together), but it seems that module paths ending
|
|
42668
|
+
// in `.` are actually normalized to `./` before proceeding with the resolution algorithm.
|
|
42669
|
+
function normalizePathForCJSResolution(containingDirectory, moduleName) {
|
|
42670
|
+
var combined = ts.combinePaths(containingDirectory, moduleName);
|
|
42671
|
+
var parts = ts.getPathComponents(combined);
|
|
42672
|
+
var lastPart = ts.lastOrUndefined(parts);
|
|
42673
|
+
var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
|
|
42674
|
+
return { path: path, parts: parts };
|
|
42675
|
+
}
|
|
42628
42676
|
function realPath(path, host, traceEnabled) {
|
|
42629
42677
|
if (!host.realpath) {
|
|
42630
42678
|
return path;
|
|
@@ -42666,7 +42714,13 @@ var ts;
|
|
|
42666
42714
|
onlyRecordFailures = true;
|
|
42667
42715
|
}
|
|
42668
42716
|
}
|
|
42669
|
-
|
|
42717
|
+
// esm mode relative imports shouldn't do any directory lookups (either inside `package.json`
|
|
42718
|
+
// files or implicit `index.js`es). This is a notable depature from cjs norms, where `./foo/pkg`
|
|
42719
|
+
// could have been redirected by `./foo/pkg/package.json` to an arbitrary location!
|
|
42720
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42721
|
+
return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
|
|
42722
|
+
}
|
|
42723
|
+
return undefined;
|
|
42670
42724
|
}
|
|
42671
42725
|
/*@internal*/
|
|
42672
42726
|
ts.nodeModulesPathPart = "/node_modules/";
|
|
@@ -43033,7 +43087,16 @@ var ts;
|
|
|
43033
43087
|
// Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types"
|
|
43034
43088
|
var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
|
|
43035
43089
|
// Don't do package.json lookup recursively, because Node.js' package lookup doesn't.
|
|
43036
|
-
|
|
43090
|
+
// Disable `EsmMode` for the resolution of the package path for cjs-mode packages (so the `main` field can omit extensions)
|
|
43091
|
+
// (technically it only emits a deprecation warning in esm packages right now, but that's probably
|
|
43092
|
+
// enough to mean we don't need to support it)
|
|
43093
|
+
var features = state.features;
|
|
43094
|
+
if ((jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.type) !== "module") {
|
|
43095
|
+
state.features &= ~NodeResolutionFeatures.EsmMode;
|
|
43096
|
+
}
|
|
43097
|
+
var result = nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ false);
|
|
43098
|
+
state.features = features;
|
|
43099
|
+
return result;
|
|
43037
43100
|
};
|
|
43038
43101
|
var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
|
|
43039
43102
|
var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
|
|
@@ -43378,6 +43441,14 @@ var ts;
|
|
|
43378
43441
|
}
|
|
43379
43442
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
43380
43443
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
43444
|
+
if (!pathAndExtension && packageInfo
|
|
43445
|
+
&& packageInfo.packageJsonContent.exports === undefined
|
|
43446
|
+
&& packageInfo.packageJsonContent.main === undefined
|
|
43447
|
+
&& state.features & NodeResolutionFeatures.EsmMode) {
|
|
43448
|
+
// EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
|
|
43449
|
+
// a default `index.js` entrypoint if no `main` or `exports` are present
|
|
43450
|
+
pathAndExtension = loadModuleFromFile(extensions, ts.combinePaths(candidate, "index.js"), onlyRecordFailures, state);
|
|
43451
|
+
}
|
|
43381
43452
|
return withPackageId(packageInfo, pathAndExtension);
|
|
43382
43453
|
};
|
|
43383
43454
|
if (rest !== "") { // If "rest" is empty, we just did this search above.
|
|
@@ -47135,8 +47206,7 @@ var ts;
|
|
|
47135
47206
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
47136
47207
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
47137
47208
|
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
47138
|
-
IntersectionState[IntersectionState["
|
|
47139
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
|
|
47209
|
+
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
47140
47210
|
})(IntersectionState || (IntersectionState = {}));
|
|
47141
47211
|
var RecursionFlags;
|
|
47142
47212
|
(function (RecursionFlags) {
|
|
@@ -50595,8 +50665,15 @@ var ts;
|
|
|
50595
50665
|
return res;
|
|
50596
50666
|
}
|
|
50597
50667
|
var candidates = ts.mapDefined(symbol.declarations, function (d) {
|
|
50598
|
-
if (!ts.isAmbientModule(d) && d.parent
|
|
50599
|
-
|
|
50668
|
+
if (!ts.isAmbientModule(d) && d.parent) {
|
|
50669
|
+
// direct children of a module
|
|
50670
|
+
if (hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
|
|
50671
|
+
return getSymbolOfNode(d.parent);
|
|
50672
|
+
}
|
|
50673
|
+
// export ='d member of an ambient module
|
|
50674
|
+
if (ts.isModuleBlock(d.parent) && d.parent.parent && resolveExternalModuleSymbol(getSymbolOfNode(d.parent.parent)) === symbol) {
|
|
50675
|
+
return getSymbolOfNode(d.parent.parent);
|
|
50676
|
+
}
|
|
50600
50677
|
}
|
|
50601
50678
|
if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
|
|
50602
50679
|
if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
|
|
@@ -51143,7 +51220,7 @@ var ts;
|
|
|
51143
51220
|
// get symbol of the first identifier of the entityName
|
|
51144
51221
|
var meaning;
|
|
51145
51222
|
if (entityName.parent.kind === 180 /* TypeQuery */ ||
|
|
51146
|
-
ts.
|
|
51223
|
+
entityName.parent.kind === 227 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) ||
|
|
51147
51224
|
entityName.parent.kind === 161 /* ComputedPropertyName */) {
|
|
51148
51225
|
// Typeof value
|
|
51149
51226
|
meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
|
|
@@ -51254,7 +51331,7 @@ var ts;
|
|
|
51254
51331
|
return flags & 814775659 /* NodeBuilderFlagsMask */;
|
|
51255
51332
|
}
|
|
51256
51333
|
function isClassInstanceSide(type) {
|
|
51257
|
-
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) &
|
|
51334
|
+
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 33554432 /* IsClassInstanceClone */)));
|
|
51258
51335
|
}
|
|
51259
51336
|
function createNodeBuilder() {
|
|
51260
51337
|
return {
|
|
@@ -55183,7 +55260,7 @@ var ts;
|
|
|
55183
55260
|
members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
|
|
55184
55261
|
result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag
|
|
55185
55262
|
if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
|
|
55186
|
-
result.objectFlags |=
|
|
55263
|
+
result.objectFlags |= 33554432 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
|
|
55187
55264
|
}
|
|
55188
55265
|
return result;
|
|
55189
55266
|
}
|
|
@@ -57229,87 +57306,87 @@ var ts;
|
|
|
57229
57306
|
* Converts an AnonymousType to a ResolvedType.
|
|
57230
57307
|
*/
|
|
57231
57308
|
function resolveAnonymousTypeMembers(type) {
|
|
57232
|
-
var symbol = getMergedSymbol(type.symbol);
|
|
57233
57309
|
if (type.target) {
|
|
57234
57310
|
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
57235
|
-
var
|
|
57311
|
+
var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
|
|
57236
57312
|
var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper);
|
|
57237
57313
|
var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper);
|
|
57238
|
-
var
|
|
57239
|
-
setStructuredTypeMembers(type,
|
|
57314
|
+
var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper);
|
|
57315
|
+
setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1);
|
|
57316
|
+
return;
|
|
57240
57317
|
}
|
|
57241
|
-
|
|
57318
|
+
var symbol = getMergedSymbol(type.symbol);
|
|
57319
|
+
if (symbol.flags & 2048 /* TypeLiteral */) {
|
|
57242
57320
|
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
57243
|
-
var
|
|
57244
|
-
var callSignatures = getSignaturesOfSymbol(
|
|
57245
|
-
var constructSignatures = getSignaturesOfSymbol(
|
|
57246
|
-
var
|
|
57247
|
-
setStructuredTypeMembers(type,
|
|
57321
|
+
var members_7 = getMembersOfSymbol(symbol);
|
|
57322
|
+
var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */));
|
|
57323
|
+
var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */));
|
|
57324
|
+
var indexInfos_2 = getIndexInfosOfSymbol(symbol);
|
|
57325
|
+
setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2);
|
|
57326
|
+
return;
|
|
57248
57327
|
}
|
|
57249
|
-
|
|
57250
|
-
|
|
57251
|
-
|
|
57252
|
-
|
|
57253
|
-
|
|
57254
|
-
|
|
57255
|
-
|
|
57256
|
-
|
|
57257
|
-
|
|
57258
|
-
|
|
57259
|
-
|
|
57260
|
-
|
|
57261
|
-
|
|
57262
|
-
members = varsOnly_1;
|
|
57263
|
-
}
|
|
57328
|
+
// Combinations of function, class, enum and module
|
|
57329
|
+
var members = emptySymbols;
|
|
57330
|
+
var indexInfos;
|
|
57331
|
+
if (symbol.exports) {
|
|
57332
|
+
members = getExportsOfSymbol(symbol);
|
|
57333
|
+
if (symbol === globalThisSymbol) {
|
|
57334
|
+
var varsOnly_1 = new ts.Map();
|
|
57335
|
+
members.forEach(function (p) {
|
|
57336
|
+
if (!(p.flags & 418 /* BlockScoped */)) {
|
|
57337
|
+
varsOnly_1.set(p.escapedName, p);
|
|
57338
|
+
}
|
|
57339
|
+
});
|
|
57340
|
+
members = varsOnly_1;
|
|
57264
57341
|
}
|
|
57265
|
-
|
|
57266
|
-
|
|
57267
|
-
|
|
57268
|
-
|
|
57269
|
-
|
|
57270
|
-
|
|
57271
|
-
|
|
57272
|
-
|
|
57273
|
-
|
|
57274
|
-
else if (baseConstructorType === anyType) {
|
|
57275
|
-
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
|
57276
|
-
}
|
|
57342
|
+
}
|
|
57343
|
+
var baseConstructorIndexInfo;
|
|
57344
|
+
setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
57345
|
+
if (symbol.flags & 32 /* Class */) {
|
|
57346
|
+
var classType = getDeclaredTypeOfClassOrInterface(symbol);
|
|
57347
|
+
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
|
57348
|
+
if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) {
|
|
57349
|
+
members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members));
|
|
57350
|
+
addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
|
|
57277
57351
|
}
|
|
57278
|
-
|
|
57279
|
-
|
|
57280
|
-
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
57352
|
+
else if (baseConstructorType === anyType) {
|
|
57353
|
+
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
|
57281
57354
|
}
|
|
57282
|
-
|
|
57283
|
-
|
|
57284
|
-
|
|
57285
|
-
|
|
57286
|
-
|
|
57287
|
-
|
|
57288
|
-
|
|
57289
|
-
|
|
57355
|
+
}
|
|
57356
|
+
var indexSymbol = getIndexSymbolFromSymbolTable(members);
|
|
57357
|
+
if (indexSymbol) {
|
|
57358
|
+
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
57359
|
+
}
|
|
57360
|
+
else {
|
|
57361
|
+
if (baseConstructorIndexInfo) {
|
|
57362
|
+
indexInfos = ts.append(indexInfos, baseConstructorIndexInfo);
|
|
57290
57363
|
}
|
|
57291
|
-
|
|
57292
|
-
|
|
57293
|
-
|
|
57294
|
-
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
|
57295
|
-
// will never be observed because a qualified name can't reference signatures.
|
|
57296
|
-
if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
|
|
57297
|
-
type.callSignatures = getSignaturesOfSymbol(symbol);
|
|
57364
|
+
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ ||
|
|
57365
|
+
ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) {
|
|
57366
|
+
indexInfos = ts.append(indexInfos, enumNumberIndexInfo);
|
|
57298
57367
|
}
|
|
57299
|
-
|
|
57300
|
-
|
|
57301
|
-
|
|
57302
|
-
|
|
57303
|
-
|
|
57304
|
-
|
|
57305
|
-
|
|
57306
|
-
|
|
57307
|
-
|
|
57308
|
-
|
|
57309
|
-
|
|
57310
|
-
|
|
57311
|
-
|
|
57368
|
+
}
|
|
57369
|
+
setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray);
|
|
57370
|
+
// We resolve the members before computing the signatures because a signature may use
|
|
57371
|
+
// typeof with a qualified name expression that circularly references the type we are
|
|
57372
|
+
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
|
57373
|
+
// will never be observed because a qualified name can't reference signatures.
|
|
57374
|
+
if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
|
|
57375
|
+
type.callSignatures = getSignaturesOfSymbol(symbol);
|
|
57376
|
+
}
|
|
57377
|
+
// And likewise for construct signatures for classes
|
|
57378
|
+
if (symbol.flags & 32 /* Class */) {
|
|
57379
|
+
var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
|
|
57380
|
+
var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray;
|
|
57381
|
+
if (symbol.flags & 16 /* Function */) {
|
|
57382
|
+
constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
|
|
57383
|
+
createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) :
|
|
57384
|
+
undefined; }));
|
|
57385
|
+
}
|
|
57386
|
+
if (!constructSignatures.length) {
|
|
57387
|
+
constructSignatures = getDefaultConstructSignatures(classType_1);
|
|
57312
57388
|
}
|
|
57389
|
+
type.constructSignatures = constructSignatures;
|
|
57313
57390
|
}
|
|
57314
57391
|
}
|
|
57315
57392
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
@@ -58310,8 +58387,8 @@ var ts;
|
|
|
58310
58387
|
var stringIndexInfo;
|
|
58311
58388
|
var applicableInfo;
|
|
58312
58389
|
var applicableInfos;
|
|
58313
|
-
for (var _i = 0,
|
|
58314
|
-
var info =
|
|
58390
|
+
for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
|
|
58391
|
+
var info = indexInfos_3[_i];
|
|
58315
58392
|
if (info.keyType === stringType) {
|
|
58316
58393
|
stringIndexInfo = info;
|
|
58317
58394
|
}
|
|
@@ -58850,13 +58927,15 @@ var ts;
|
|
|
58850
58927
|
return signature;
|
|
58851
58928
|
}
|
|
58852
58929
|
function getOrCreateTypeFromSignature(signature) {
|
|
58930
|
+
var _a;
|
|
58853
58931
|
// There are two ways to declare a construct signature, one is by declaring a class constructor
|
|
58854
58932
|
// using the constructor keyword, and the other is declaring a bare construct signature in an
|
|
58855
58933
|
// object type literal or interface (using the new keyword). Each way of declaring a constructor
|
|
58856
58934
|
// will result in a different declaration kind.
|
|
58857
58935
|
if (!signature.isolatedSignatureType) {
|
|
58858
|
-
var kind =
|
|
58859
|
-
|
|
58936
|
+
var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
|
|
58937
|
+
// If declaration is undefined, it is likely to be the signature of the default constructor.
|
|
58938
|
+
var isConstructor = kind === undefined || kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */;
|
|
58860
58939
|
var type = createObjectType(16 /* Anonymous */);
|
|
58861
58940
|
type.members = emptySymbols;
|
|
58862
58941
|
type.properties = ts.emptyArray;
|
|
@@ -58882,14 +58961,14 @@ var ts;
|
|
|
58882
58961
|
}
|
|
58883
58962
|
function getIndexInfosOfIndexSymbol(indexSymbol) {
|
|
58884
58963
|
if (indexSymbol.declarations) {
|
|
58885
|
-
var
|
|
58964
|
+
var indexInfos_4 = [];
|
|
58886
58965
|
var _loop_14 = function (declaration) {
|
|
58887
58966
|
if (declaration.parameters.length === 1) {
|
|
58888
58967
|
var parameter = declaration.parameters[0];
|
|
58889
58968
|
if (parameter.type) {
|
|
58890
58969
|
forEachType(getTypeFromTypeNode(parameter.type), function (keyType) {
|
|
58891
|
-
if (isValidIndexKeyType(keyType) && !findIndexInfo(
|
|
58892
|
-
|
|
58970
|
+
if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) {
|
|
58971
|
+
indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration));
|
|
58893
58972
|
}
|
|
58894
58973
|
});
|
|
58895
58974
|
}
|
|
@@ -58899,7 +58978,7 @@ var ts;
|
|
|
58899
58978
|
var declaration = _a[_i];
|
|
58900
58979
|
_loop_14(declaration);
|
|
58901
58980
|
}
|
|
58902
|
-
return
|
|
58981
|
+
return indexInfos_4;
|
|
58903
58982
|
}
|
|
58904
58983
|
return ts.emptyArray;
|
|
58905
58984
|
}
|
|
@@ -59447,7 +59526,7 @@ var ts;
|
|
|
59447
59526
|
// The expression is processed as an identifier expression (section 4.3)
|
|
59448
59527
|
// or property access expression(section 4.10),
|
|
59449
59528
|
// the widened type(section 3.9) of which becomes the result.
|
|
59450
|
-
var type =
|
|
59529
|
+
var type = checkExpressionWithTypeArguments(node);
|
|
59451
59530
|
links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(type));
|
|
59452
59531
|
}
|
|
59453
59532
|
return links.resolvedType;
|
|
@@ -59784,7 +59863,7 @@ var ts;
|
|
|
59784
59863
|
}
|
|
59785
59864
|
}
|
|
59786
59865
|
var fixedLength = properties.length;
|
|
59787
|
-
var lengthSymbol = createSymbol(4 /* Property */, "length");
|
|
59866
|
+
var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
|
|
59788
59867
|
if (combinedFlags & 12 /* Variable */) {
|
|
59789
59868
|
lengthSymbol.type = numberType;
|
|
59790
59869
|
}
|
|
@@ -62151,7 +62230,9 @@ var ts;
|
|
|
62151
62230
|
return result;
|
|
62152
62231
|
}
|
|
62153
62232
|
function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
62154
|
-
var declaration = type.objectFlags & 4 /* Reference */ ? type.node :
|
|
62233
|
+
var declaration = type.objectFlags & 4 /* Reference */ ? type.node :
|
|
62234
|
+
type.objectFlags & 16777216 /* InstantiationExpressionType */ ? type.node :
|
|
62235
|
+
type.symbol.declarations[0];
|
|
62155
62236
|
var links = getNodeLinks(declaration);
|
|
62156
62237
|
var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType :
|
|
62157
62238
|
type.objectFlags & 64 /* Instantiated */ ? type.target : type;
|
|
@@ -62167,8 +62248,8 @@ var ts;
|
|
|
62167
62248
|
outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
|
|
62168
62249
|
}
|
|
62169
62250
|
typeParameters = outerTypeParameters || ts.emptyArray;
|
|
62170
|
-
var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations;
|
|
62171
|
-
typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
|
|
62251
|
+
var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations;
|
|
62252
|
+
typeParameters = (target.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
|
|
62172
62253
|
ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) :
|
|
62173
62254
|
typeParameters;
|
|
62174
62255
|
links.outerTypeParameters = typeParameters;
|
|
@@ -62340,6 +62421,9 @@ var ts;
|
|
|
62340
62421
|
mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
|
|
62341
62422
|
freshTypeParameter.mapper = mapper;
|
|
62342
62423
|
}
|
|
62424
|
+
if (type.objectFlags & 16777216 /* InstantiationExpressionType */) {
|
|
62425
|
+
result.node = type.node;
|
|
62426
|
+
}
|
|
62343
62427
|
result.target = type;
|
|
62344
62428
|
result.mapper = mapper;
|
|
62345
62429
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
@@ -63331,9 +63415,11 @@ var ts;
|
|
|
63331
63415
|
isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
|
|
63332
63416
|
return true;
|
|
63333
63417
|
}
|
|
63334
|
-
|
|
63418
|
+
// In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`.
|
|
63419
|
+
// Since unions and intersections may reduce to `never`, we exclude them here.
|
|
63420
|
+
if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */)))
|
|
63335
63421
|
return true;
|
|
63336
|
-
if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */))
|
|
63422
|
+
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
63337
63423
|
return true;
|
|
63338
63424
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
|
|
63339
63425
|
return true;
|
|
@@ -63422,11 +63508,11 @@ var ts;
|
|
|
63422
63508
|
var overflow = false;
|
|
63423
63509
|
var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
|
|
63424
63510
|
var lastSkippedInfo;
|
|
63425
|
-
var incompatibleStack
|
|
63511
|
+
var incompatibleStack;
|
|
63426
63512
|
var inPropertyCheck = false;
|
|
63427
63513
|
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
63428
63514
|
var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
|
|
63429
|
-
if (incompatibleStack
|
|
63515
|
+
if (incompatibleStack) {
|
|
63430
63516
|
reportIncompatibleStack();
|
|
63431
63517
|
}
|
|
63432
63518
|
if (overflow) {
|
|
@@ -63483,19 +63569,19 @@ var ts;
|
|
|
63483
63569
|
return {
|
|
63484
63570
|
errorInfo: errorInfo,
|
|
63485
63571
|
lastSkippedInfo: lastSkippedInfo,
|
|
63486
|
-
incompatibleStack: incompatibleStack.slice(),
|
|
63572
|
+
incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
|
|
63487
63573
|
overrideNextErrorInfo: overrideNextErrorInfo,
|
|
63488
|
-
relatedInfo:
|
|
63574
|
+
relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
|
|
63489
63575
|
};
|
|
63490
63576
|
}
|
|
63491
63577
|
function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
|
|
63492
63578
|
overrideNextErrorInfo++; // Suppress the next relation error
|
|
63493
63579
|
lastSkippedInfo = undefined; // Reset skipped info cache
|
|
63494
|
-
incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
|
|
63580
|
+
(incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
|
|
63495
63581
|
}
|
|
63496
63582
|
function reportIncompatibleStack() {
|
|
63497
|
-
var stack = incompatibleStack;
|
|
63498
|
-
incompatibleStack =
|
|
63583
|
+
var stack = incompatibleStack || [];
|
|
63584
|
+
incompatibleStack = undefined;
|
|
63499
63585
|
var info = lastSkippedInfo;
|
|
63500
63586
|
lastSkippedInfo = undefined;
|
|
63501
63587
|
if (stack.length === 1) {
|
|
@@ -63601,7 +63687,7 @@ var ts;
|
|
|
63601
63687
|
}
|
|
63602
63688
|
function reportError(message, arg0, arg1, arg2, arg3) {
|
|
63603
63689
|
ts.Debug.assert(!!errorNode);
|
|
63604
|
-
if (incompatibleStack
|
|
63690
|
+
if (incompatibleStack)
|
|
63605
63691
|
reportIncompatibleStack();
|
|
63606
63692
|
if (message.elidedInCompatabilityPyramid)
|
|
63607
63693
|
return;
|
|
@@ -63617,7 +63703,7 @@ var ts;
|
|
|
63617
63703
|
}
|
|
63618
63704
|
}
|
|
63619
63705
|
function reportRelationError(message, source, target) {
|
|
63620
|
-
if (incompatibleStack
|
|
63706
|
+
if (incompatibleStack)
|
|
63621
63707
|
reportIncompatibleStack();
|
|
63622
63708
|
var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
|
|
63623
63709
|
var generalizedSource = source;
|
|
@@ -63729,7 +63815,9 @@ var ts;
|
|
|
63729
63815
|
if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
|
|
63730
63816
|
return -1 /* True */;
|
|
63731
63817
|
}
|
|
63732
|
-
|
|
63818
|
+
if (reportErrors) {
|
|
63819
|
+
reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
|
|
63820
|
+
}
|
|
63733
63821
|
return 0 /* False */;
|
|
63734
63822
|
}
|
|
63735
63823
|
// Normalize the source and target types: Turn fresh literal types into regular literal types,
|
|
@@ -63741,7 +63829,12 @@ var ts;
|
|
|
63741
63829
|
if (source === target)
|
|
63742
63830
|
return -1 /* True */;
|
|
63743
63831
|
if (relation === identityRelation) {
|
|
63744
|
-
|
|
63832
|
+
if (source.flags !== target.flags)
|
|
63833
|
+
return 0 /* False */;
|
|
63834
|
+
if (source.flags & 67358815 /* Singleton */)
|
|
63835
|
+
return -1 /* True */;
|
|
63836
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63837
|
+
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63745
63838
|
}
|
|
63746
63839
|
// We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
|
|
63747
63840
|
// and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
|
|
@@ -63751,163 +63844,130 @@ var ts;
|
|
|
63751
63844
|
if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
|
|
63752
63845
|
return -1 /* True */;
|
|
63753
63846
|
}
|
|
63754
|
-
//
|
|
63755
|
-
// If so,
|
|
63756
|
-
|
|
63757
|
-
|
|
63758
|
-
|
|
63759
|
-
|
|
63760
|
-
|
|
63761
|
-
|
|
63762
|
-
|
|
63763
|
-
|
|
63764
|
-
|
|
63765
|
-
|
|
63766
|
-
if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) {
|
|
63767
|
-
target = getNormalizedType(nullStrippedTarget, /*writing*/ true);
|
|
63768
|
-
}
|
|
63769
|
-
if (source === nullStrippedTarget)
|
|
63770
|
-
return -1 /* True */;
|
|
63847
|
+
// See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
|
|
63848
|
+
// plus a single non-nullable type. If so, remove null and/or undefined from the target type.
|
|
63849
|
+
if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
|
|
63850
|
+
var types = target.types;
|
|
63851
|
+
var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
|
|
63852
|
+
types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
|
|
63853
|
+
undefined;
|
|
63854
|
+
if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
|
|
63855
|
+
target = getNormalizedType(candidate, /*writing*/ true);
|
|
63856
|
+
if (source === target)
|
|
63857
|
+
return -1 /* True */;
|
|
63858
|
+
}
|
|
63771
63859
|
}
|
|
63772
63860
|
if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
|
|
63773
63861
|
isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
|
|
63774
63862
|
return -1 /* True */;
|
|
63775
|
-
|
|
63776
|
-
|
|
63777
|
-
|
|
63778
|
-
|
|
63863
|
+
if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
|
|
63864
|
+
var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
|
|
63865
|
+
if (isPerformingExcessPropertyChecks) {
|
|
63866
|
+
if (hasExcessProperties(source, target, reportErrors)) {
|
|
63867
|
+
if (reportErrors) {
|
|
63868
|
+
reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
|
|
63869
|
+
}
|
|
63870
|
+
return 0 /* False */;
|
|
63871
|
+
}
|
|
63872
|
+
}
|
|
63873
|
+
var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
|
|
63874
|
+
source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
|
|
63875
|
+
target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
|
|
63876
|
+
(getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
|
|
63877
|
+
var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
|
|
63878
|
+
if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
|
|
63779
63879
|
if (reportErrors) {
|
|
63780
|
-
|
|
63880
|
+
var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
|
|
63881
|
+
var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
|
|
63882
|
+
var calls = getSignaturesOfType(source, 0 /* Call */);
|
|
63883
|
+
var constructs = getSignaturesOfType(source, 1 /* Construct */);
|
|
63884
|
+
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
|
|
63885
|
+
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
63886
|
+
reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
|
|
63887
|
+
}
|
|
63888
|
+
else {
|
|
63889
|
+
reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
|
|
63890
|
+
}
|
|
63781
63891
|
}
|
|
63782
63892
|
return 0 /* False */;
|
|
63783
63893
|
}
|
|
63784
|
-
|
|
63785
|
-
|
|
63786
|
-
|
|
63787
|
-
|
|
63788
|
-
|
|
63789
|
-
|
|
63790
|
-
|
|
63791
|
-
|
|
63792
|
-
|
|
63793
|
-
|
|
63794
|
-
|
|
63795
|
-
|
|
63796
|
-
|
|
63797
|
-
|
|
63798
|
-
|
|
63799
|
-
|
|
63800
|
-
|
|
63801
|
-
|
|
63894
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63895
|
+
var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
|
|
63896
|
+
target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
|
|
63897
|
+
var result_7 = skipCaching ?
|
|
63898
|
+
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
63899
|
+
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
63900
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
63901
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
63902
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
63903
|
+
//
|
|
63904
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63905
|
+
//
|
|
63906
|
+
// declare let wrong: { a: { y: string } };
|
|
63907
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63908
|
+
//
|
|
63909
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63910
|
+
// x = y; // Mismatched property in source intersection
|
|
63911
|
+
// }
|
|
63912
|
+
//
|
|
63913
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63914
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63915
|
+
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63916
|
+
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 */); }))) {
|
|
63917
|
+
inPropertyCheck = true;
|
|
63918
|
+
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63919
|
+
inPropertyCheck = false;
|
|
63920
|
+
}
|
|
63921
|
+
if (result_7) {
|
|
63922
|
+
return result_7;
|
|
63802
63923
|
}
|
|
63803
|
-
return 0 /* False */;
|
|
63804
|
-
}
|
|
63805
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63806
|
-
var result = 0 /* False */;
|
|
63807
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
63808
|
-
if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
|
|
63809
|
-
// We skip caching when source or target is a union with no more than three constituents.
|
|
63810
|
-
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63811
63924
|
}
|
|
63812
|
-
|
|
63813
|
-
|
|
63925
|
+
if (reportErrors) {
|
|
63926
|
+
reportErrorResults(originalSource, originalTarget, source, target, headMessage);
|
|
63814
63927
|
}
|
|
63815
|
-
|
|
63816
|
-
|
|
63817
|
-
|
|
63928
|
+
return 0 /* False */;
|
|
63929
|
+
}
|
|
63930
|
+
function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
|
|
63931
|
+
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63932
|
+
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63933
|
+
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63934
|
+
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63935
|
+
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63936
|
+
if (maybeSuppress) {
|
|
63937
|
+
overrideNextErrorInfo--;
|
|
63938
|
+
}
|
|
63939
|
+
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63940
|
+
var currentError = errorInfo;
|
|
63941
|
+
tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
|
|
63942
|
+
if (errorInfo !== currentError) {
|
|
63943
|
+
maybeSuppress = !!errorInfo;
|
|
63944
|
+
}
|
|
63945
|
+
}
|
|
63946
|
+
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63947
|
+
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63948
|
+
}
|
|
63949
|
+
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63950
|
+
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63951
|
+
}
|
|
63952
|
+
else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
|
|
63953
|
+
var targetTypes = target.types;
|
|
63954
|
+
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63955
|
+
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63956
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63957
|
+
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63958
|
+
// do not report top error
|
|
63959
|
+
return;
|
|
63818
63960
|
}
|
|
63819
63961
|
}
|
|
63820
|
-
|
|
63821
|
-
|
|
63822
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
63823
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
63824
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
63825
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
63826
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
63827
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
63828
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
63829
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
63830
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
63831
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
63832
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
63833
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
63834
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
63835
|
-
if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
|
|
63836
|
-
if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
63837
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
63838
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63839
|
-
resetErrorInfo(saveErrorInfo);
|
|
63840
|
-
}
|
|
63841
|
-
}
|
|
63842
|
-
}
|
|
63962
|
+
else {
|
|
63963
|
+
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63843
63964
|
}
|
|
63844
|
-
|
|
63845
|
-
|
|
63846
|
-
|
|
63847
|
-
|
|
63848
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63849
|
-
//
|
|
63850
|
-
// declare let wrong: { a: { y: string } };
|
|
63851
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63852
|
-
//
|
|
63853
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63854
|
-
// x = y; // Mismatched property in source intersection
|
|
63855
|
-
// }
|
|
63856
|
-
//
|
|
63857
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63858
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63859
|
-
if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63860
|
-
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 */); }))) {
|
|
63861
|
-
inPropertyCheck = true;
|
|
63862
|
-
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63863
|
-
inPropertyCheck = false;
|
|
63864
|
-
}
|
|
63865
|
-
reportErrorResults(source, target, result, isComparingJsxAttributes);
|
|
63866
|
-
return result;
|
|
63867
|
-
function reportErrorResults(source, target, result, isComparingJsxAttributes) {
|
|
63868
|
-
if (!result && reportErrors) {
|
|
63869
|
-
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63870
|
-
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63871
|
-
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63872
|
-
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63873
|
-
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63874
|
-
if (maybeSuppress) {
|
|
63875
|
-
overrideNextErrorInfo--;
|
|
63876
|
-
}
|
|
63877
|
-
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63878
|
-
var currentError = errorInfo;
|
|
63879
|
-
tryElaborateArrayLikeErrors(source, target, reportErrors);
|
|
63880
|
-
if (errorInfo !== currentError) {
|
|
63881
|
-
maybeSuppress = !!errorInfo;
|
|
63882
|
-
}
|
|
63883
|
-
}
|
|
63884
|
-
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63885
|
-
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63886
|
-
}
|
|
63887
|
-
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63888
|
-
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63889
|
-
}
|
|
63890
|
-
else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) {
|
|
63891
|
-
var targetTypes = target.types;
|
|
63892
|
-
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63893
|
-
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63894
|
-
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63895
|
-
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63896
|
-
// do not report top error
|
|
63897
|
-
return result;
|
|
63898
|
-
}
|
|
63899
|
-
}
|
|
63900
|
-
else {
|
|
63901
|
-
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63902
|
-
}
|
|
63903
|
-
if (!headMessage && maybeSuppress) {
|
|
63904
|
-
lastSkippedInfo = [source, target];
|
|
63905
|
-
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63906
|
-
return result;
|
|
63907
|
-
}
|
|
63908
|
-
reportRelationError(headMessage, source, target);
|
|
63909
|
-
}
|
|
63965
|
+
if (!headMessage && maybeSuppress) {
|
|
63966
|
+
lastSkippedInfo = [source, target];
|
|
63967
|
+
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63968
|
+
return;
|
|
63910
63969
|
}
|
|
63970
|
+
reportRelationError(headMessage, source, target);
|
|
63911
63971
|
}
|
|
63912
63972
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
63913
63973
|
if (!ts.tracing) {
|
|
@@ -63934,21 +63994,6 @@ var ts;
|
|
|
63934
63994
|
}
|
|
63935
63995
|
}
|
|
63936
63996
|
}
|
|
63937
|
-
function isIdenticalTo(source, target, recursionFlags) {
|
|
63938
|
-
if (source.flags !== target.flags)
|
|
63939
|
-
return 0 /* False */;
|
|
63940
|
-
if (source.flags & 67358815 /* Singleton */)
|
|
63941
|
-
return -1 /* True */;
|
|
63942
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63943
|
-
if (source.flags & 3145728 /* UnionOrIntersection */) {
|
|
63944
|
-
var result_7 = eachTypeRelatedToSomeType(source, target);
|
|
63945
|
-
if (result_7) {
|
|
63946
|
-
result_7 &= eachTypeRelatedToSomeType(target, source);
|
|
63947
|
-
}
|
|
63948
|
-
return result_7;
|
|
63949
|
-
}
|
|
63950
|
-
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63951
|
-
}
|
|
63952
63997
|
function getTypeOfPropertyInTypes(types, name) {
|
|
63953
63998
|
var appendPropType = function (propTypes, type) {
|
|
63954
63999
|
var _a;
|
|
@@ -64047,6 +64092,41 @@ var ts;
|
|
|
64047
64092
|
function shouldCheckAsExcessProperty(prop, container) {
|
|
64048
64093
|
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
|
|
64049
64094
|
}
|
|
64095
|
+
function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
|
|
64096
|
+
// Note that these checks are specifically ordered to produce correct results. In particular,
|
|
64097
|
+
// we need to deconstruct unions before intersections (because unions are always at the top),
|
|
64098
|
+
// and we need to handle "each" relations before "some" relations for the same kind of type.
|
|
64099
|
+
if (source.flags & 1048576 /* Union */) {
|
|
64100
|
+
return relation === comparableRelation ?
|
|
64101
|
+
someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
|
|
64102
|
+
eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
|
|
64103
|
+
}
|
|
64104
|
+
if (target.flags & 1048576 /* Union */) {
|
|
64105
|
+
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
64106
|
+
}
|
|
64107
|
+
if (target.flags & 2097152 /* Intersection */) {
|
|
64108
|
+
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
64109
|
+
}
|
|
64110
|
+
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
64111
|
+
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
64112
|
+
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
64113
|
+
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
64114
|
+
// appear to be comparable to '2'.
|
|
64115
|
+
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
64116
|
+
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
64117
|
+
if (constraints !== source.types) {
|
|
64118
|
+
source = getIntersectionType(constraints);
|
|
64119
|
+
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
64120
|
+
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
64121
|
+
}
|
|
64122
|
+
}
|
|
64123
|
+
}
|
|
64124
|
+
// Check to see if any constituents of the intersection are immediately related to the target.
|
|
64125
|
+
// Don't report errors though. Elaborating on whether a source constituent is related to the target is
|
|
64126
|
+
// not actually useful and leads to some confusing error messages. Instead, we rely on the caller
|
|
64127
|
+
// checking whether the full intersection viewed as an object is related to the target.
|
|
64128
|
+
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
64129
|
+
}
|
|
64050
64130
|
function eachTypeRelatedToSomeType(source, target) {
|
|
64051
64131
|
var result = -1 /* True */;
|
|
64052
64132
|
var sourceTypes = source.types;
|
|
@@ -64082,8 +64162,11 @@ var ts;
|
|
|
64082
64162
|
}
|
|
64083
64163
|
}
|
|
64084
64164
|
if (reportErrors) {
|
|
64165
|
+
// Elaborate only if we can find a best matching type in the target union
|
|
64085
64166
|
var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
|
|
64086
|
-
|
|
64167
|
+
if (bestMatchingType) {
|
|
64168
|
+
isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
|
|
64169
|
+
}
|
|
64087
64170
|
}
|
|
64088
64171
|
return 0 /* False */;
|
|
64089
64172
|
}
|
|
@@ -64219,7 +64302,7 @@ var ts;
|
|
|
64219
64302
|
if (overflow) {
|
|
64220
64303
|
return 0 /* False */;
|
|
64221
64304
|
}
|
|
64222
|
-
var keyIntersectionState = intersectionState | (inPropertyCheck ?
|
|
64305
|
+
var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
|
|
64223
64306
|
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
64224
64307
|
var entry = relation.get(id);
|
|
64225
64308
|
if (entry !== undefined) {
|
|
@@ -64287,6 +64370,7 @@ var ts;
|
|
|
64287
64370
|
return originalHandler(onlyUnreliable);
|
|
64288
64371
|
};
|
|
64289
64372
|
}
|
|
64373
|
+
var result;
|
|
64290
64374
|
if (expandingFlags === 3 /* Both */) {
|
|
64291
64375
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
|
|
64292
64376
|
sourceId: source.id,
|
|
@@ -64296,8 +64380,13 @@ var ts;
|
|
|
64296
64380
|
depth: sourceDepth,
|
|
64297
64381
|
targetDepth: targetDepth
|
|
64298
64382
|
});
|
|
64383
|
+
result = 3 /* Maybe */;
|
|
64384
|
+
}
|
|
64385
|
+
else {
|
|
64386
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64387
|
+
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
|
|
64388
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64299
64389
|
}
|
|
64300
|
-
var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
|
|
64301
64390
|
if (outofbandVarianceMarkerHandler) {
|
|
64302
64391
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
64303
64392
|
}
|
|
@@ -64329,98 +64418,97 @@ var ts;
|
|
|
64329
64418
|
return result;
|
|
64330
64419
|
}
|
|
64331
64420
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
64332
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64333
|
-
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
|
|
64334
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64335
|
-
return result;
|
|
64336
|
-
}
|
|
64337
|
-
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
|
|
64338
64421
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
64339
64422
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
64340
64423
|
}
|
|
64341
|
-
|
|
64342
|
-
|
|
64343
|
-
|
|
64344
|
-
|
|
64345
|
-
|
|
64346
|
-
|
|
64347
|
-
|
|
64348
|
-
|
|
64349
|
-
|
|
64350
|
-
|
|
64351
|
-
|
|
64352
|
-
|
|
64353
|
-
if (target.flags & 2097152 /* Intersection */) {
|
|
64354
|
-
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
64355
|
-
}
|
|
64356
|
-
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
64357
|
-
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
64358
|
-
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
64359
|
-
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
64360
|
-
// appear to be comparable to '2'.
|
|
64361
|
-
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
64362
|
-
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
64363
|
-
if (constraints !== source.types) {
|
|
64364
|
-
source = getIntersectionType(constraints);
|
|
64365
|
-
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
64366
|
-
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
64367
|
-
}
|
|
64424
|
+
var result;
|
|
64425
|
+
var originalErrorInfo;
|
|
64426
|
+
var varianceCheckFailed = false;
|
|
64427
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
64428
|
+
var sourceFlags = source.flags;
|
|
64429
|
+
var targetFlags = target.flags;
|
|
64430
|
+
if (relation === identityRelation) {
|
|
64431
|
+
// We've already checked that source.flags and target.flags are identical
|
|
64432
|
+
if (sourceFlags & 3145728 /* UnionOrIntersection */) {
|
|
64433
|
+
var result_8 = eachTypeRelatedToSomeType(source, target);
|
|
64434
|
+
if (result_8) {
|
|
64435
|
+
result_8 &= eachTypeRelatedToSomeType(target, source);
|
|
64368
64436
|
}
|
|
64437
|
+
return result_8;
|
|
64369
64438
|
}
|
|
64370
|
-
|
|
64371
|
-
//
|
|
64372
|
-
// Don't report errors though. Checking whether a constituent is related to the source is not actually
|
|
64373
|
-
// useful and leads to some confusing error messages. Instead it is better to let the below checks
|
|
64374
|
-
// take care of this, or to not elaborate at all. For instance,
|
|
64375
|
-
//
|
|
64376
|
-
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
|
|
64377
|
-
//
|
|
64378
|
-
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
|
|
64379
|
-
// than to report that 'D' is not assignable to 'A' or 'B'.
|
|
64380
|
-
//
|
|
64381
|
-
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
|
|
64382
|
-
// breaking the intersection apart.
|
|
64383
|
-
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
64384
|
-
}
|
|
64385
|
-
var flags = source.flags & target.flags;
|
|
64386
|
-
if (relation === identityRelation && !(flags & 524288 /* Object */)) {
|
|
64387
|
-
if (flags & 4194304 /* Index */) {
|
|
64439
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64388
64440
|
return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
|
|
64389
64441
|
}
|
|
64390
|
-
|
|
64391
|
-
|
|
64392
|
-
|
|
64393
|
-
|
|
64394
|
-
return result_8;
|
|
64442
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64443
|
+
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64444
|
+
if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64445
|
+
return result;
|
|
64395
64446
|
}
|
|
64396
64447
|
}
|
|
64397
64448
|
}
|
|
64398
|
-
if (
|
|
64449
|
+
if (sourceFlags & 16777216 /* Conditional */) {
|
|
64399
64450
|
if (source.root.isDistributive === target.root.isDistributive) {
|
|
64400
|
-
if (
|
|
64401
|
-
if (
|
|
64402
|
-
if (
|
|
64403
|
-
if (
|
|
64404
|
-
return
|
|
64451
|
+
if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64452
|
+
if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64453
|
+
if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64454
|
+
if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64455
|
+
return result;
|
|
64405
64456
|
}
|
|
64406
64457
|
}
|
|
64407
64458
|
}
|
|
64408
64459
|
}
|
|
64409
64460
|
}
|
|
64410
64461
|
}
|
|
64411
|
-
if (
|
|
64462
|
+
if (sourceFlags & 33554432 /* Substitution */) {
|
|
64412
64463
|
return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
|
|
64413
64464
|
}
|
|
64414
|
-
|
|
64465
|
+
if (!(sourceFlags & 524288 /* Object */)) {
|
|
64466
|
+
return 0 /* False */;
|
|
64467
|
+
}
|
|
64468
|
+
}
|
|
64469
|
+
else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
|
|
64470
|
+
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
64471
|
+
return result;
|
|
64472
|
+
}
|
|
64473
|
+
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
64474
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
64475
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
64476
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
64477
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
64478
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
64479
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
64480
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
64481
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
64482
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
64483
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
64484
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
64485
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
64486
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
64487
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
64488
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
64489
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
64490
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
64491
|
+
resetErrorInfo(saveErrorInfo);
|
|
64492
|
+
return result;
|
|
64493
|
+
}
|
|
64494
|
+
}
|
|
64495
|
+
}
|
|
64496
|
+
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
64497
|
+
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
64498
|
+
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64499
|
+
// Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
|
|
64500
|
+
// Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64501
|
+
// Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
|
|
64502
|
+
if (!(sourceFlags & 465829888 /* Instantiable */ ||
|
|
64503
|
+
sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
|
|
64504
|
+
sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
|
|
64505
|
+
return 0 /* False */;
|
|
64506
|
+
}
|
|
64415
64507
|
}
|
|
64416
|
-
var result;
|
|
64417
|
-
var originalErrorInfo;
|
|
64418
|
-
var varianceCheckFailed = false;
|
|
64419
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
64420
64508
|
// We limit alias variance probing to only object and conditional types since their alias behavior
|
|
64421
64509
|
// is more predictable than other, interned types, which may or may not have an alias depending on
|
|
64422
64510
|
// the order in which things were checked.
|
|
64423
|
-
if (
|
|
64511
|
+
if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
|
|
64424
64512
|
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
|
|
64425
64513
|
!(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
|
|
64426
64514
|
var variances = getAliasVariances(source.aliasSymbol);
|
|
@@ -64438,7 +64526,7 @@ var ts;
|
|
|
64438
64526
|
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
|
|
64439
64527
|
return result;
|
|
64440
64528
|
}
|
|
64441
|
-
if (
|
|
64529
|
+
if (targetFlags & 262144 /* TypeParameter */) {
|
|
64442
64530
|
// 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].
|
|
64443
64531
|
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
|
|
64444
64532
|
if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
|
|
@@ -64450,10 +64538,10 @@ var ts;
|
|
|
64450
64538
|
}
|
|
64451
64539
|
}
|
|
64452
64540
|
}
|
|
64453
|
-
else if (
|
|
64541
|
+
else if (targetFlags & 4194304 /* Index */) {
|
|
64454
64542
|
var targetType_1 = target.type;
|
|
64455
64543
|
// A keyof S is related to a keyof T if T is related to S.
|
|
64456
|
-
if (
|
|
64544
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64457
64545
|
if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64458
64546
|
return result;
|
|
64459
64547
|
}
|
|
@@ -64504,8 +64592,8 @@ var ts;
|
|
|
64504
64592
|
}
|
|
64505
64593
|
}
|
|
64506
64594
|
}
|
|
64507
|
-
else if (
|
|
64508
|
-
if (
|
|
64595
|
+
else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
64596
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64509
64597
|
// Relate components directly before falling back to constraint relationships
|
|
64510
64598
|
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
|
|
64511
64599
|
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
|
|
@@ -64611,7 +64699,7 @@ var ts;
|
|
|
64611
64699
|
}
|
|
64612
64700
|
}
|
|
64613
64701
|
}
|
|
64614
|
-
else if (
|
|
64702
|
+
else if (targetFlags & 16777216 /* Conditional */) {
|
|
64615
64703
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64616
64704
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64617
64705
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
@@ -64636,8 +64724,8 @@ var ts;
|
|
|
64636
64724
|
}
|
|
64637
64725
|
}
|
|
64638
64726
|
}
|
|
64639
|
-
else if (
|
|
64640
|
-
if (
|
|
64727
|
+
else if (targetFlags & 134217728 /* TemplateLiteral */) {
|
|
64728
|
+
if (sourceFlags & 134217728 /* TemplateLiteral */) {
|
|
64641
64729
|
if (relation === comparableRelation) {
|
|
64642
64730
|
return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
|
|
64643
64731
|
}
|
|
@@ -64649,11 +64737,11 @@ var ts;
|
|
|
64649
64737
|
return -1 /* True */;
|
|
64650
64738
|
}
|
|
64651
64739
|
}
|
|
64652
|
-
if (
|
|
64653
|
-
// IndexedAccess comparisons are handled above in the `
|
|
64654
|
-
if (!(
|
|
64740
|
+
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
64741
|
+
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
64742
|
+
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
64655
64743
|
var constraint = getConstraintOfType(source);
|
|
64656
|
-
if (!constraint || (
|
|
64744
|
+
if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
64657
64745
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
64658
64746
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
64659
64747
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64666,7 +64754,7 @@ var ts;
|
|
|
64666
64754
|
return result;
|
|
64667
64755
|
}
|
|
64668
64756
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
64669
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(
|
|
64757
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
64670
64758
|
resetErrorInfo(saveErrorInfo);
|
|
64671
64759
|
return result;
|
|
64672
64760
|
}
|
|
@@ -64683,14 +64771,14 @@ var ts;
|
|
|
64683
64771
|
}
|
|
64684
64772
|
}
|
|
64685
64773
|
}
|
|
64686
|
-
else if (
|
|
64774
|
+
else if (sourceFlags & 4194304 /* Index */) {
|
|
64687
64775
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
64688
64776
|
resetErrorInfo(saveErrorInfo);
|
|
64689
64777
|
return result;
|
|
64690
64778
|
}
|
|
64691
64779
|
}
|
|
64692
|
-
else if (
|
|
64693
|
-
if (!(
|
|
64780
|
+
else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
64781
|
+
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
64694
64782
|
var constraint = getBaseConstraintOfType(source);
|
|
64695
64783
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
64696
64784
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64698,8 +64786,8 @@ var ts;
|
|
|
64698
64786
|
}
|
|
64699
64787
|
}
|
|
64700
64788
|
}
|
|
64701
|
-
else if (
|
|
64702
|
-
if (
|
|
64789
|
+
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
64790
|
+
if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
|
|
64703
64791
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
64704
64792
|
resetErrorInfo(saveErrorInfo);
|
|
64705
64793
|
return result;
|
|
@@ -64713,14 +64801,14 @@ var ts;
|
|
|
64713
64801
|
}
|
|
64714
64802
|
}
|
|
64715
64803
|
}
|
|
64716
|
-
else if (
|
|
64804
|
+
else if (sourceFlags & 16777216 /* Conditional */) {
|
|
64717
64805
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64718
64806
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64719
64807
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
64720
64808
|
resetErrorInfo(saveErrorInfo);
|
|
64721
64809
|
return 3 /* Maybe */;
|
|
64722
64810
|
}
|
|
64723
|
-
if (
|
|
64811
|
+
if (targetFlags & 16777216 /* Conditional */) {
|
|
64724
64812
|
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
|
|
64725
64813
|
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
|
|
64726
64814
|
// and Y1 is related to Y2.
|
|
@@ -64780,15 +64868,21 @@ var ts;
|
|
|
64780
64868
|
}
|
|
64781
64869
|
return 0 /* False */;
|
|
64782
64870
|
}
|
|
64783
|
-
var sourceIsPrimitive = !!(
|
|
64871
|
+
var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
|
|
64784
64872
|
if (relation !== identityRelation) {
|
|
64785
64873
|
source = getApparentType(source);
|
|
64874
|
+
sourceFlags = source.flags;
|
|
64786
64875
|
}
|
|
64787
64876
|
else if (isGenericMappedType(source)) {
|
|
64788
64877
|
return 0 /* False */;
|
|
64789
64878
|
}
|
|
64790
64879
|
if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target &&
|
|
64791
64880
|
!isTupleType(source) && !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) {
|
|
64881
|
+
// When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType,
|
|
64882
|
+
// and an empty array literal wouldn't be assignable to a `never[]` without this check.
|
|
64883
|
+
if (isEmptyArrayLiteralType(source)) {
|
|
64884
|
+
return -1 /* True */;
|
|
64885
|
+
}
|
|
64792
64886
|
// We have type references to the same generic type, and the type references are not marker
|
|
64793
64887
|
// type references (which are intended by be compared structurally). Obtain the variance
|
|
64794
64888
|
// information for the type parameters and relate the type arguments accordingly.
|
|
@@ -64824,7 +64918,7 @@ var ts;
|
|
|
64824
64918
|
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
|
|
64825
64919
|
// to X. Failing both of those we want to check if the aggregation of A and B's members structurally
|
|
64826
64920
|
// relates to X. Thus, we include intersection types on the source side here.
|
|
64827
|
-
if (
|
|
64921
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
|
|
64828
64922
|
// Report structural errors only if we haven't reported any errors yet
|
|
64829
64923
|
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
|
|
64830
64924
|
result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
|
|
@@ -64848,7 +64942,7 @@ var ts;
|
|
|
64848
64942
|
// there exists a constituent of T for every combination of the discriminants of S
|
|
64849
64943
|
// with respect to T. We do not report errors here, as we will use the existing
|
|
64850
64944
|
// error result from checking each constituent of the union.
|
|
64851
|
-
if (
|
|
64945
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
|
|
64852
64946
|
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
|
|
64853
64947
|
if (objectOnlyTarget.flags & 1048576 /* Union */) {
|
|
64854
64948
|
var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
|
|
@@ -65095,6 +65189,15 @@ var ts;
|
|
|
65095
65189
|
}
|
|
65096
65190
|
return 0 /* False */;
|
|
65097
65191
|
}
|
|
65192
|
+
// Ensure {readonly a: whatever} is not a subtype of {a: whatever},
|
|
65193
|
+
// while {a: whatever} is a subtype of {readonly a: whatever}.
|
|
65194
|
+
// This ensures the subtype relationship is ordered, and preventing declaration order
|
|
65195
|
+
// from deciding which type "wins" in union subtype reduction.
|
|
65196
|
+
// They're still assignable to one another, since `readonly` doesn't affect assignability.
|
|
65197
|
+
if ((relation === subtypeRelation || relation === strictSubtypeRelation) &&
|
|
65198
|
+
!!(sourcePropFlags & 64 /* Readonly */) && !(targetPropFlags & 64 /* Readonly */)) {
|
|
65199
|
+
return 0 /* False */;
|
|
65200
|
+
}
|
|
65098
65201
|
// If the target comes from a partial union prop, allow `undefined` in the target type
|
|
65099
65202
|
var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
|
|
65100
65203
|
if (!related) {
|
|
@@ -65363,7 +65466,6 @@ var ts;
|
|
|
65363
65466
|
}
|
|
65364
65467
|
}
|
|
65365
65468
|
var result = -1 /* True */;
|
|
65366
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
65367
65469
|
var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
|
|
65368
65470
|
var sourceObjectFlags = ts.getObjectFlags(source);
|
|
65369
65471
|
var targetObjectFlags = ts.getObjectFlags(target);
|
|
@@ -65404,6 +65506,7 @@ var ts;
|
|
|
65404
65506
|
else {
|
|
65405
65507
|
outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
|
|
65406
65508
|
var t = targetSignatures_1[_i];
|
|
65509
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
65407
65510
|
// Only elaborate errors from the first failure
|
|
65408
65511
|
var shouldElaborateErrors = reportErrors;
|
|
65409
65512
|
for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
|
|
@@ -65514,8 +65617,8 @@ var ts;
|
|
|
65514
65617
|
var indexInfos = getIndexInfosOfType(target);
|
|
65515
65618
|
var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; });
|
|
65516
65619
|
var result = -1 /* True */;
|
|
65517
|
-
for (var _i = 0,
|
|
65518
|
-
var targetInfo =
|
|
65620
|
+
for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) {
|
|
65621
|
+
var targetInfo = indexInfos_5[_i];
|
|
65519
65622
|
var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
|
|
65520
65623
|
isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
|
|
65521
65624
|
typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
|
|
@@ -66122,10 +66225,10 @@ var ts;
|
|
|
66122
66225
|
if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
66123
66226
|
return undefined;
|
|
66124
66227
|
}
|
|
66125
|
-
if (ts.getObjectFlags(type) &
|
|
66126
|
-
return ts.getObjectFlags(type) &
|
|
66228
|
+
if (ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeCalculated */) {
|
|
66229
|
+
return ts.getObjectFlags(type) & 134217728 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined;
|
|
66127
66230
|
}
|
|
66128
|
-
type.objectFlags |=
|
|
66231
|
+
type.objectFlags |= 67108864 /* IdenticalBaseTypeCalculated */;
|
|
66129
66232
|
var target = type.target;
|
|
66130
66233
|
if (ts.getObjectFlags(target) & 1 /* Class */) {
|
|
66131
66234
|
var baseTypeNode = getBaseTypeNodeOfClass(target);
|
|
@@ -66146,7 +66249,7 @@ var ts;
|
|
|
66146
66249
|
if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) {
|
|
66147
66250
|
instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type)));
|
|
66148
66251
|
}
|
|
66149
|
-
type.objectFlags |=
|
|
66252
|
+
type.objectFlags |= 134217728 /* IdenticalBaseTypeExists */;
|
|
66150
66253
|
return type.cachedEquivalentBaseType = instantiatedBase;
|
|
66151
66254
|
}
|
|
66152
66255
|
function isEmptyLiteralType(type) {
|
|
@@ -66810,7 +66913,7 @@ var ts;
|
|
|
66810
66913
|
var result = !!(type.flags & 465829888 /* Instantiable */ ||
|
|
66811
66914
|
type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
|
|
66812
66915
|
objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations ||
|
|
66813
|
-
objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) ||
|
|
66916
|
+
objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */ | 16777216 /* InstantiationExpressionType */)) ||
|
|
66814
66917
|
type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
|
|
66815
66918
|
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
66816
66919
|
type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0);
|
|
@@ -67727,8 +67830,8 @@ var ts;
|
|
|
67727
67830
|
var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0;
|
|
67728
67831
|
var indexInfos = getIndexInfosOfType(target);
|
|
67729
67832
|
if (isObjectTypeWithInferableIndex(source)) {
|
|
67730
|
-
for (var _i = 0,
|
|
67731
|
-
var targetInfo =
|
|
67833
|
+
for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) {
|
|
67834
|
+
var targetInfo = indexInfos_6[_i];
|
|
67732
67835
|
var propTypes = [];
|
|
67733
67836
|
for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) {
|
|
67734
67837
|
var prop = _b[_a];
|
|
@@ -67748,8 +67851,8 @@ var ts;
|
|
|
67748
67851
|
}
|
|
67749
67852
|
}
|
|
67750
67853
|
}
|
|
67751
|
-
for (var _e = 0,
|
|
67752
|
-
var targetInfo =
|
|
67854
|
+
for (var _e = 0, indexInfos_7 = indexInfos; _e < indexInfos_7.length; _e++) {
|
|
67855
|
+
var targetInfo = indexInfos_7[_e];
|
|
67753
67856
|
var sourceInfo = getApplicableIndexInfo(source, targetInfo.keyType);
|
|
67754
67857
|
if (sourceInfo) {
|
|
67755
67858
|
inferWithPriority(sourceInfo.type, targetInfo.type, priority);
|
|
@@ -68574,9 +68677,6 @@ var ts;
|
|
|
68574
68677
|
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
|
|
68575
68678
|
mapType(type, mapper);
|
|
68576
68679
|
}
|
|
68577
|
-
function getConstituentCount(type) {
|
|
68578
|
-
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
68579
|
-
}
|
|
68580
68680
|
function extractTypesOfKind(type, kind) {
|
|
68581
68681
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
68582
68682
|
}
|
|
@@ -73297,6 +73397,9 @@ var ts;
|
|
|
73297
73397
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
73298
73398
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
73299
73399
|
}
|
|
73400
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
|
|
73401
|
+
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
73402
|
+
}
|
|
73300
73403
|
}
|
|
73301
73404
|
else {
|
|
73302
73405
|
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
|
|
@@ -75913,6 +76016,72 @@ var ts;
|
|
|
75913
76016
|
return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) :
|
|
75914
76017
|
getNonNullableType(checkExpression(node.expression));
|
|
75915
76018
|
}
|
|
76019
|
+
function checkExpressionWithTypeArguments(node) {
|
|
76020
|
+
checkGrammarExpressionWithTypeArguments(node);
|
|
76021
|
+
var exprType = node.kind === 227 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) :
|
|
76022
|
+
ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
|
|
76023
|
+
checkExpression(node.exprName);
|
|
76024
|
+
var typeArguments = node.typeArguments;
|
|
76025
|
+
if (exprType === silentNeverType || isErrorType(exprType) || !ts.some(typeArguments)) {
|
|
76026
|
+
return exprType;
|
|
76027
|
+
}
|
|
76028
|
+
var hasSomeApplicableSignature = false;
|
|
76029
|
+
var nonApplicableType;
|
|
76030
|
+
var result = getInstantiatedType(exprType);
|
|
76031
|
+
var errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
|
|
76032
|
+
if (errorType) {
|
|
76033
|
+
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)));
|
|
76034
|
+
}
|
|
76035
|
+
return result;
|
|
76036
|
+
function getInstantiatedType(type) {
|
|
76037
|
+
var hasSignatures = false;
|
|
76038
|
+
var hasApplicableSignature = false;
|
|
76039
|
+
var result = getInstantiatedTypePart(type);
|
|
76040
|
+
hasSomeApplicableSignature || (hasSomeApplicableSignature = hasApplicableSignature);
|
|
76041
|
+
if (hasSignatures && !hasApplicableSignature) {
|
|
76042
|
+
nonApplicableType !== null && nonApplicableType !== void 0 ? nonApplicableType : (nonApplicableType = type);
|
|
76043
|
+
}
|
|
76044
|
+
return result;
|
|
76045
|
+
function getInstantiatedTypePart(type) {
|
|
76046
|
+
if (type.flags & 524288 /* Object */) {
|
|
76047
|
+
var resolved = resolveStructuredTypeMembers(type);
|
|
76048
|
+
var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
|
|
76049
|
+
var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
|
|
76050
|
+
hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
|
|
76051
|
+
hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
|
|
76052
|
+
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
|
|
76053
|
+
var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
|
|
76054
|
+
result_11.objectFlags |= 16777216 /* InstantiationExpressionType */;
|
|
76055
|
+
result_11.node = node;
|
|
76056
|
+
return result_11;
|
|
76057
|
+
}
|
|
76058
|
+
}
|
|
76059
|
+
else if (type.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
76060
|
+
var constraint = getBaseConstraintOfType(type);
|
|
76061
|
+
if (constraint) {
|
|
76062
|
+
var instantiated = getInstantiatedTypePart(constraint);
|
|
76063
|
+
if (instantiated !== constraint) {
|
|
76064
|
+
return instantiated;
|
|
76065
|
+
}
|
|
76066
|
+
}
|
|
76067
|
+
}
|
|
76068
|
+
else if (type.flags & 1048576 /* Union */) {
|
|
76069
|
+
return mapType(type, getInstantiatedType);
|
|
76070
|
+
}
|
|
76071
|
+
else if (type.flags & 2097152 /* Intersection */) {
|
|
76072
|
+
return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart));
|
|
76073
|
+
}
|
|
76074
|
+
return type;
|
|
76075
|
+
}
|
|
76076
|
+
}
|
|
76077
|
+
function getInstantiatedSignatures(signatures) {
|
|
76078
|
+
var applicableSignatures = ts.filter(signatures, function (sig) { return !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments); });
|
|
76079
|
+
return ts.sameMap(applicableSignatures, function (sig) {
|
|
76080
|
+
var typeArgumentTypes = checkTypeArguments(sig, typeArguments, /*reportErrors*/ true);
|
|
76081
|
+
return typeArgumentTypes ? getSignatureInstantiation(sig, typeArgumentTypes, ts.isInJSFile(sig.declaration)) : sig;
|
|
76082
|
+
});
|
|
76083
|
+
}
|
|
76084
|
+
}
|
|
75916
76085
|
function checkMetaProperty(node) {
|
|
75917
76086
|
checkGrammarMetaProperty(node);
|
|
75918
76087
|
if (node.keywordToken === 103 /* NewKeyword */) {
|
|
@@ -76242,21 +76411,22 @@ var ts;
|
|
|
76242
76411
|
if (links.type === unknownType) {
|
|
76243
76412
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
76244
76413
|
}
|
|
76245
|
-
assignBindingElementTypes(declaration.name);
|
|
76414
|
+
assignBindingElementTypes(declaration.name, links.type);
|
|
76246
76415
|
}
|
|
76247
76416
|
}
|
|
76248
76417
|
}
|
|
76249
76418
|
// When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
|
|
76250
76419
|
// the destructured type into the contained binding elements.
|
|
76251
|
-
function assignBindingElementTypes(pattern) {
|
|
76420
|
+
function assignBindingElementTypes(pattern, parentType) {
|
|
76252
76421
|
for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
|
|
76253
76422
|
var element = _a[_i];
|
|
76254
76423
|
if (!ts.isOmittedExpression(element)) {
|
|
76424
|
+
var type = getBindingElementTypeFromParentType(element, parentType);
|
|
76255
76425
|
if (element.name.kind === 79 /* Identifier */) {
|
|
76256
|
-
getSymbolLinks(getSymbolOfNode(element)).type =
|
|
76426
|
+
getSymbolLinks(getSymbolOfNode(element)).type = type;
|
|
76257
76427
|
}
|
|
76258
76428
|
else {
|
|
76259
|
-
assignBindingElementTypes(element.name);
|
|
76429
|
+
assignBindingElementTypes(element.name, type);
|
|
76260
76430
|
}
|
|
76261
76431
|
}
|
|
76262
76432
|
}
|
|
@@ -78428,6 +78598,8 @@ var ts;
|
|
|
78428
78598
|
return checkAssertion(node);
|
|
78429
78599
|
case 229 /* NonNullExpression */:
|
|
78430
78600
|
return checkNonNullAssertion(node);
|
|
78601
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
78602
|
+
return checkExpressionWithTypeArguments(node);
|
|
78431
78603
|
case 230 /* MetaProperty */:
|
|
78432
78604
|
return checkMetaProperty(node);
|
|
78433
78605
|
case 214 /* DeleteExpression */:
|
|
@@ -79631,12 +79803,12 @@ var ts;
|
|
|
79631
79803
|
case 264 /* ImportEqualsDeclaration */:
|
|
79632
79804
|
case 267 /* NamespaceImport */:
|
|
79633
79805
|
case 266 /* ImportClause */:
|
|
79634
|
-
var
|
|
79806
|
+
var result_12 = 0 /* None */;
|
|
79635
79807
|
var target = resolveAlias(getSymbolOfNode(d));
|
|
79636
79808
|
ts.forEach(target.declarations, function (d) {
|
|
79637
|
-
|
|
79809
|
+
result_12 |= getDeclarationSpaces(d);
|
|
79638
79810
|
});
|
|
79639
|
-
return
|
|
79811
|
+
return result_12;
|
|
79640
79812
|
case 253 /* VariableDeclaration */:
|
|
79641
79813
|
case 202 /* BindingElement */:
|
|
79642
79814
|
case 255 /* FunctionDeclaration */:
|
|
@@ -79997,28 +80169,24 @@ var ts;
|
|
|
79997
80169
|
if (returnType.flags & 1 /* Any */) {
|
|
79998
80170
|
return;
|
|
79999
80171
|
}
|
|
80172
|
+
var headMessage;
|
|
80000
80173
|
var expectedReturnType;
|
|
80001
|
-
var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
|
80002
|
-
var errorInfo;
|
|
80003
80174
|
switch (node.parent.kind) {
|
|
80004
80175
|
case 256 /* ClassDeclaration */:
|
|
80176
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
80005
80177
|
var classSymbol = getSymbolOfNode(node.parent);
|
|
80006
80178
|
var classConstructorType = getTypeOfSymbol(classSymbol);
|
|
80007
80179
|
expectedReturnType = getUnionType([classConstructorType, voidType]);
|
|
80008
80180
|
break;
|
|
80009
|
-
case 163 /* Parameter */:
|
|
80010
|
-
expectedReturnType = voidType;
|
|
80011
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
80012
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
|
|
80013
|
-
break;
|
|
80014
80181
|
case 166 /* PropertyDeclaration */:
|
|
80182
|
+
case 163 /* Parameter */:
|
|
80183
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
|
|
80015
80184
|
expectedReturnType = voidType;
|
|
80016
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
80017
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
|
|
80018
80185
|
break;
|
|
80019
80186
|
case 168 /* MethodDeclaration */:
|
|
80020
80187
|
case 171 /* GetAccessor */:
|
|
80021
80188
|
case 172 /* SetAccessor */:
|
|
80189
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
80022
80190
|
var methodType = getTypeOfNode(node.parent);
|
|
80023
80191
|
var descriptorType = createTypedPropertyDescriptorType(methodType);
|
|
80024
80192
|
expectedReturnType = getUnionType([descriptorType, voidType]);
|
|
@@ -80026,7 +80194,7 @@ var ts;
|
|
|
80026
80194
|
default:
|
|
80027
80195
|
return ts.Debug.fail();
|
|
80028
80196
|
}
|
|
80029
|
-
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage
|
|
80197
|
+
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
|
|
80030
80198
|
}
|
|
80031
80199
|
/**
|
|
80032
80200
|
* If a TypeNode can be resolved to a value symbol imported from an external module, it is
|
|
@@ -82199,8 +82367,8 @@ var ts;
|
|
|
82199
82367
|
}
|
|
82200
82368
|
}
|
|
82201
82369
|
if (indexInfos.length > 1) {
|
|
82202
|
-
for (var _d = 0,
|
|
82203
|
-
var info =
|
|
82370
|
+
for (var _d = 0, indexInfos_8 = indexInfos; _d < indexInfos_8.length; _d++) {
|
|
82371
|
+
var info = indexInfos_8[_d];
|
|
82204
82372
|
checkIndexConstraintForIndexSignature(type, info);
|
|
82205
82373
|
}
|
|
82206
82374
|
}
|
|
@@ -82226,8 +82394,8 @@ var ts;
|
|
|
82226
82394
|
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));
|
|
82227
82395
|
}
|
|
82228
82396
|
};
|
|
82229
|
-
for (var _i = 0,
|
|
82230
|
-
var info =
|
|
82397
|
+
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
82398
|
+
var info = indexInfos_9[_i];
|
|
82231
82399
|
_loop_27(info);
|
|
82232
82400
|
}
|
|
82233
82401
|
}
|
|
@@ -82249,8 +82417,8 @@ var ts;
|
|
|
82249
82417
|
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));
|
|
82250
82418
|
}
|
|
82251
82419
|
};
|
|
82252
|
-
for (var _i = 0,
|
|
82253
|
-
var info =
|
|
82420
|
+
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
82421
|
+
var info = indexInfos_10[_i];
|
|
82254
82422
|
_loop_28(info);
|
|
82255
82423
|
}
|
|
82256
82424
|
}
|
|
@@ -85574,7 +85742,7 @@ var ts;
|
|
|
85574
85742
|
if (resolvedTypeReferenceDirectives) {
|
|
85575
85743
|
// populate reverse mapping: file path -> type reference directive that was resolved to this file
|
|
85576
85744
|
fileToDirective = new ts.Map();
|
|
85577
|
-
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
|
|
85745
|
+
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
|
|
85578
85746
|
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
|
|
85579
85747
|
return;
|
|
85580
85748
|
}
|
|
@@ -85582,7 +85750,7 @@ var ts;
|
|
|
85582
85750
|
if (file) {
|
|
85583
85751
|
// Add the transitive closure of path references loaded by this file (as long as they are not)
|
|
85584
85752
|
// part of an existing type reference.
|
|
85585
|
-
addReferencedFilesToTypeDirective(file, key);
|
|
85753
|
+
addReferencedFilesToTypeDirective(file, key, mode);
|
|
85586
85754
|
}
|
|
85587
85755
|
});
|
|
85588
85756
|
}
|
|
@@ -85776,16 +85944,16 @@ var ts;
|
|
|
85776
85944
|
}
|
|
85777
85945
|
return false;
|
|
85778
85946
|
}
|
|
85779
|
-
function addReferencedFilesToTypeDirective(file, key) {
|
|
85947
|
+
function addReferencedFilesToTypeDirective(file, key, mode) {
|
|
85780
85948
|
if (fileToDirective.has(file.path))
|
|
85781
85949
|
return;
|
|
85782
|
-
fileToDirective.set(file.path, key);
|
|
85950
|
+
fileToDirective.set(file.path, [key, mode]);
|
|
85783
85951
|
for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
|
|
85784
|
-
var
|
|
85952
|
+
var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
|
|
85785
85953
|
var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
|
|
85786
85954
|
var referencedFile = host.getSourceFile(resolvedFile);
|
|
85787
85955
|
if (referencedFile) {
|
|
85788
|
-
addReferencedFilesToTypeDirective(referencedFile, key);
|
|
85956
|
+
addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
|
|
85789
85957
|
}
|
|
85790
85958
|
}
|
|
85791
85959
|
}
|
|
@@ -87490,28 +87658,27 @@ var ts;
|
|
|
87490
87658
|
}
|
|
87491
87659
|
function findMostOverlappyType(source, unionTarget) {
|
|
87492
87660
|
var bestMatch;
|
|
87493
|
-
|
|
87494
|
-
|
|
87495
|
-
var
|
|
87496
|
-
|
|
87497
|
-
|
|
87498
|
-
|
|
87499
|
-
|
|
87500
|
-
|
|
87501
|
-
|
|
87502
|
-
|
|
87503
|
-
|
|
87504
|
-
|
|
87505
|
-
|
|
87506
|
-
|
|
87507
|
-
|
|
87508
|
-
|
|
87509
|
-
|
|
87510
|
-
|
|
87511
|
-
|
|
87512
|
-
|
|
87513
|
-
|
|
87514
|
-
matchingCount = 1;
|
|
87661
|
+
if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87662
|
+
var matchingCount = 0;
|
|
87663
|
+
for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
|
|
87664
|
+
var target = _a[_i];
|
|
87665
|
+
if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87666
|
+
var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
|
|
87667
|
+
if (overlap.flags & 4194304 /* Index */) {
|
|
87668
|
+
// perfect overlap of keys
|
|
87669
|
+
return target;
|
|
87670
|
+
}
|
|
87671
|
+
else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
|
|
87672
|
+
// We only want to account for literal types otherwise.
|
|
87673
|
+
// If we have a union of index types, it seems likely that we
|
|
87674
|
+
// needed to elaborate between two generic mapped types anyway.
|
|
87675
|
+
var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
|
|
87676
|
+
if (len >= matchingCount) {
|
|
87677
|
+
bestMatch = target;
|
|
87678
|
+
matchingCount = len;
|
|
87679
|
+
}
|
|
87680
|
+
}
|
|
87681
|
+
}
|
|
87515
87682
|
}
|
|
87516
87683
|
}
|
|
87517
87684
|
return bestMatch;
|
|
@@ -87884,7 +88051,7 @@ var ts;
|
|
|
87884
88051
|
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));
|
|
87885
88052
|
case 180 /* TypeQuery */:
|
|
87886
88053
|
ts.Debug.type(node);
|
|
87887
|
-
return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName));
|
|
88054
|
+
return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
|
|
87888
88055
|
case 181 /* TypeLiteral */:
|
|
87889
88056
|
ts.Debug.type(node);
|
|
87890
88057
|
return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
|
|
@@ -90776,8 +90943,8 @@ var ts;
|
|
|
90776
90943
|
function generateClassElementDecorationExpressions(node, isStatic) {
|
|
90777
90944
|
var members = getDecoratedClassElements(node, isStatic);
|
|
90778
90945
|
var expressions;
|
|
90779
|
-
for (var _i = 0,
|
|
90780
|
-
var member =
|
|
90946
|
+
for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
|
|
90947
|
+
var member = members_8[_i];
|
|
90781
90948
|
var expression = generateClassElementDecorationExpression(node, member);
|
|
90782
90949
|
if (expression) {
|
|
90783
90950
|
if (!expressions) {
|
|
@@ -96122,8 +96289,8 @@ var ts;
|
|
|
96122
96289
|
function convertJsxChildrenToChildrenPropAssignment(children) {
|
|
96123
96290
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
96124
96291
|
if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
|
|
96125
|
-
var
|
|
96126
|
-
return
|
|
96292
|
+
var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
|
|
96293
|
+
return result_13 && factory.createPropertyAssignment("children", result_13);
|
|
96127
96294
|
}
|
|
96128
96295
|
var result = ts.mapDefined(children, transformJsxChildToExpression);
|
|
96129
96296
|
return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
|
|
@@ -106554,7 +106721,7 @@ var ts;
|
|
|
106554
106721
|
var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
|
|
106555
106722
|
hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
|
|
106556
106723
|
collectReferences(sourceFile, refs);
|
|
106557
|
-
recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
|
|
106724
|
+
recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
|
|
106558
106725
|
collectLibs(sourceFile, libs);
|
|
106559
106726
|
return sourceFile;
|
|
106560
106727
|
}
|
|
@@ -106609,9 +106776,10 @@ var ts;
|
|
|
106609
106776
|
return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
|
|
106610
106777
|
}
|
|
106611
106778
|
function getFileReferencesForUsedTypeReferences() {
|
|
106612
|
-
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()),
|
|
106779
|
+
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
|
|
106613
106780
|
}
|
|
106614
|
-
function
|
|
106781
|
+
function getFileReferenceForSpecifierModeTuple(_a) {
|
|
106782
|
+
var typeName = _a[0], mode = _a[1];
|
|
106615
106783
|
// Elide type references for which we have imports
|
|
106616
106784
|
if (emittedImports) {
|
|
106617
106785
|
for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
|
|
@@ -106627,7 +106795,7 @@ var ts;
|
|
|
106627
106795
|
}
|
|
106628
106796
|
}
|
|
106629
106797
|
}
|
|
106630
|
-
return { fileName: typeName, pos: -1, end: -1 };
|
|
106798
|
+
return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
|
|
106631
106799
|
}
|
|
106632
106800
|
function mapReferencesIntoArray(references, outputFilePath) {
|
|
106633
106801
|
return function (file) {
|
|
@@ -106647,7 +106815,7 @@ var ts;
|
|
|
106647
106815
|
// If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration
|
|
106648
106816
|
// via a non-relative name, emit a type reference directive to that non-relative name, rather than
|
|
106649
106817
|
// a relative path to the declaration file
|
|
106650
|
-
recordTypeReferenceDirectivesIfNecessary([specifier]);
|
|
106818
|
+
recordTypeReferenceDirectivesIfNecessary([[specifier, /*mode*/ undefined]]);
|
|
106651
106819
|
return;
|
|
106652
106820
|
}
|
|
106653
106821
|
var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName,
|
|
@@ -109760,6 +109928,8 @@ var ts;
|
|
|
109760
109928
|
return emitAsExpression(node);
|
|
109761
109929
|
case 229 /* NonNullExpression */:
|
|
109762
109930
|
return emitNonNullExpression(node);
|
|
109931
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
109932
|
+
return emitExpressionWithTypeArguments(node);
|
|
109763
109933
|
case 230 /* MetaProperty */:
|
|
109764
109934
|
return emitMetaProperty(node);
|
|
109765
109935
|
case 231 /* SyntheticExpression */:
|
|
@@ -110204,6 +110374,7 @@ var ts;
|
|
|
110204
110374
|
writeKeyword("typeof");
|
|
110205
110375
|
writeSpace();
|
|
110206
110376
|
emit(node.exprName);
|
|
110377
|
+
emitTypeArguments(node, node.typeArguments);
|
|
110207
110378
|
}
|
|
110208
110379
|
function emitTypeLiteral(node) {
|
|
110209
110380
|
writePunctuation("{");
|
|
@@ -111759,9 +111930,12 @@ var ts;
|
|
|
111759
111930
|
for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
|
|
111760
111931
|
var directive = types_24[_d];
|
|
111761
111932
|
var pos = writer.getTextPos();
|
|
111762
|
-
|
|
111933
|
+
var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
|
|
111934
|
+
? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
|
|
111935
|
+
: "";
|
|
111936
|
+
writeComment("/// <reference types=\"" + directive.fileName + "\" " + resolutionMode + "/>");
|
|
111763
111937
|
if (bundleFileInfo)
|
|
111764
|
-
bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName });
|
|
111938
|
+
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 });
|
|
111765
111939
|
writeLine();
|
|
111766
111940
|
}
|
|
111767
111941
|
for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
|
|
@@ -114368,7 +114542,7 @@ var ts;
|
|
|
114368
114542
|
}
|
|
114369
114543
|
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
|
|
114370
114544
|
/* @internal */
|
|
114371
|
-
function
|
|
114545
|
+
function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
|
|
114372
114546
|
if (names.length === 0) {
|
|
114373
114547
|
return [];
|
|
114374
114548
|
}
|
|
@@ -114377,19 +114551,28 @@ var ts;
|
|
|
114377
114551
|
for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
|
|
114378
114552
|
var name = names_2[_i];
|
|
114379
114553
|
var result = void 0;
|
|
114380
|
-
|
|
114381
|
-
|
|
114554
|
+
var mode = getModeForFileReference(name, containingFileMode);
|
|
114555
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
114556
|
+
var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
|
|
114557
|
+
var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
|
|
114558
|
+
if (cache.has(cacheKey)) {
|
|
114559
|
+
result = cache.get(cacheKey);
|
|
114382
114560
|
}
|
|
114383
114561
|
else {
|
|
114384
|
-
cache.set(
|
|
114562
|
+
cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
|
|
114385
114563
|
}
|
|
114386
114564
|
resolutions.push(result);
|
|
114387
114565
|
}
|
|
114388
114566
|
return resolutions;
|
|
114389
114567
|
}
|
|
114390
|
-
ts.
|
|
114568
|
+
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
114391
114569
|
;
|
|
114392
114570
|
/* @internal */
|
|
114571
|
+
function getModeForFileReference(ref, containingFileMode) {
|
|
114572
|
+
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
114573
|
+
}
|
|
114574
|
+
ts.getModeForFileReference = getModeForFileReference;
|
|
114575
|
+
/* @internal */
|
|
114393
114576
|
function getModeForResolutionAtIndex(file, index) {
|
|
114394
114577
|
if (file.impliedNodeFormat === undefined)
|
|
114395
114578
|
return undefined;
|
|
@@ -114492,7 +114675,7 @@ var ts;
|
|
|
114492
114675
|
var _d, _e, _f, _g;
|
|
114493
114676
|
var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
|
|
114494
114677
|
var kind = ref.kind, index = ref.index;
|
|
114495
|
-
var pos, end, packageId;
|
|
114678
|
+
var pos, end, packageId, resolutionMode;
|
|
114496
114679
|
switch (kind) {
|
|
114497
114680
|
case ts.FileIncludeKind.Import:
|
|
114498
114681
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
@@ -114506,8 +114689,8 @@ var ts;
|
|
|
114506
114689
|
(_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
|
|
114507
114690
|
break;
|
|
114508
114691
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
114509
|
-
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
114510
|
-
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;
|
|
114692
|
+
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
|
|
114693
|
+
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;
|
|
114511
114694
|
break;
|
|
114512
114695
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
114513
114696
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -114751,7 +114934,7 @@ var ts;
|
|
|
114751
114934
|
var fileReasons = ts.createMultiMap();
|
|
114752
114935
|
var cachedBindAndCheckDiagnosticsForFile = {};
|
|
114753
114936
|
var cachedDeclarationDiagnosticsForFile = {};
|
|
114754
|
-
var resolvedTypeReferenceDirectives =
|
|
114937
|
+
var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
|
|
114755
114938
|
var fileProcessingDiagnostics;
|
|
114756
114939
|
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
|
|
114757
114940
|
// This works as imported modules are discovered recursively in a depth first manner, specifically:
|
|
@@ -114804,12 +114987,12 @@ var ts;
|
|
|
114804
114987
|
}
|
|
114805
114988
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
114806
114989
|
if (host.resolveTypeReferenceDirectives) {
|
|
114807
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
|
|
114990
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
|
|
114808
114991
|
}
|
|
114809
114992
|
else {
|
|
114810
114993
|
typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
114811
|
-
var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114812
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return
|
|
114994
|
+
var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114995
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
|
|
114813
114996
|
}
|
|
114814
114997
|
// Map from a stringified PackageId to the source file with that id.
|
|
114815
114998
|
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
|
|
@@ -114906,7 +115089,8 @@ var ts;
|
|
|
114906
115089
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
114907
115090
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
114908
115091
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
114909
|
-
|
|
115092
|
+
// under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
|
|
115093
|
+
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 });
|
|
114910
115094
|
}
|
|
114911
115095
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
114912
115096
|
}
|
|
@@ -115066,9 +115250,10 @@ var ts;
|
|
|
115066
115250
|
return [];
|
|
115067
115251
|
var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
|
|
115068
115252
|
var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
|
|
115253
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
115069
115254
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
|
|
115070
115255
|
ts.performance.mark("beforeResolveTypeReference");
|
|
115071
|
-
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
|
|
115256
|
+
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
|
|
115072
115257
|
ts.performance.mark("afterResolveTypeReference");
|
|
115073
115258
|
ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
|
|
115074
115259
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -115163,15 +115348,15 @@ var ts;
|
|
|
115163
115348
|
// which per above occurred during the current program creation.
|
|
115164
115349
|
// Since we assume the filesystem does not change during program creation,
|
|
115165
115350
|
// it is safe to reuse resolutions from the earlier call.
|
|
115166
|
-
var
|
|
115351
|
+
var result_14 = [];
|
|
115167
115352
|
var i = 0;
|
|
115168
115353
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
115169
115354
|
var moduleName = moduleNames_1[_i];
|
|
115170
115355
|
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
115171
115356
|
i++;
|
|
115172
|
-
|
|
115357
|
+
result_14.push(resolvedModule);
|
|
115173
115358
|
}
|
|
115174
|
-
return
|
|
115359
|
+
return result_14;
|
|
115175
115360
|
}
|
|
115176
115361
|
// At this point, we know at least one of the following hold:
|
|
115177
115362
|
// - file has local declarations for ambient modules
|
|
@@ -115460,8 +115645,7 @@ var ts;
|
|
|
115460
115645
|
else {
|
|
115461
115646
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
115462
115647
|
}
|
|
115463
|
-
|
|
115464
|
-
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
115648
|
+
var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
|
115465
115649
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
115466
115650
|
// ensure that types resolutions are still correct
|
|
115467
115651
|
var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
@@ -116540,8 +116724,7 @@ var ts;
|
|
|
116540
116724
|
});
|
|
116541
116725
|
}
|
|
116542
116726
|
function processTypeReferenceDirectives(file) {
|
|
116543
|
-
|
|
116544
|
-
var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
116727
|
+
var typeDirectives = file.typeReferenceDirectives;
|
|
116545
116728
|
if (!typeDirectives) {
|
|
116546
116729
|
return;
|
|
116547
116730
|
}
|
|
@@ -116552,17 +116735,21 @@ var ts;
|
|
|
116552
116735
|
// store resolved type directive on the file
|
|
116553
116736
|
var fileName = ts.toFileNameLowerCase(ref.fileName);
|
|
116554
116737
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
116555
|
-
|
|
116738
|
+
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
116739
|
+
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
116740
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext));
|
|
116741
|
+
}
|
|
116742
|
+
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
116556
116743
|
}
|
|
116557
116744
|
}
|
|
116558
|
-
function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116745
|
+
function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116559
116746
|
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 });
|
|
116560
|
-
processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
|
|
116747
|
+
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
|
|
116561
116748
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116562
116749
|
}
|
|
116563
|
-
function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116750
|
+
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116564
116751
|
// If we already found this library as a primary reference - nothing to do
|
|
116565
|
-
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
|
|
116752
|
+
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
|
|
116566
116753
|
if (previousResolution && previousResolution.primary) {
|
|
116567
116754
|
return;
|
|
116568
116755
|
}
|
|
@@ -116601,7 +116788,7 @@ var ts;
|
|
|
116601
116788
|
addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
|
|
116602
116789
|
}
|
|
116603
116790
|
if (saveResolution) {
|
|
116604
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
|
|
116791
|
+
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
|
|
116605
116792
|
}
|
|
116606
116793
|
}
|
|
116607
116794
|
function pathForLibFile(libFileName) {
|
|
@@ -119419,9 +119606,9 @@ var ts;
|
|
|
119419
119606
|
});
|
|
119420
119607
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
119421
119608
|
}
|
|
119422
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
|
|
119609
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
|
|
119423
119610
|
var _a;
|
|
119424
|
-
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
|
|
119611
|
+
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
|
|
119425
119612
|
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
|
|
119426
119613
|
if (!resolutionHost.getGlobalCache) {
|
|
119427
119614
|
return primaryResult;
|
|
@@ -119442,12 +119629,12 @@ var ts;
|
|
|
119442
119629
|
// Default return the result from the first pass
|
|
119443
119630
|
return primaryResult;
|
|
119444
119631
|
}
|
|
119445
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
|
|
119446
|
-
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
|
|
119632
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
|
|
119633
|
+
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
|
|
119447
119634
|
}
|
|
119448
119635
|
function resolveNamesWithLocalCache(_a) {
|
|
119449
119636
|
var _b, _c, _d;
|
|
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;
|
|
119637
|
+
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;
|
|
119451
119638
|
var path = resolutionHost.toPath(containingFile);
|
|
119452
119639
|
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
119453
119640
|
var dirPath = ts.getDirectoryPath(path);
|
|
@@ -119469,8 +119656,15 @@ var ts;
|
|
|
119469
119656
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
119470
119657
|
var i = 0;
|
|
119471
119658
|
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
119472
|
-
var
|
|
119473
|
-
var
|
|
119659
|
+
var entry = names_4[_i];
|
|
119660
|
+
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
119661
|
+
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
119662
|
+
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
119663
|
+
// import's syntax may override the file's default mode.
|
|
119664
|
+
// Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
|
|
119665
|
+
// a default file mode override if applicable.
|
|
119666
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
|
|
119667
|
+
containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
119474
119668
|
i++;
|
|
119475
119669
|
var resolution = resolutionsInFile.get(name, mode);
|
|
119476
119670
|
// Resolution is valid if it is present and not invalidated
|
|
@@ -119499,7 +119693,7 @@ var ts;
|
|
|
119499
119693
|
}
|
|
119500
119694
|
}
|
|
119501
119695
|
else {
|
|
119502
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
119696
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
119503
119697
|
perDirectoryResolution.set(name, mode, resolution);
|
|
119504
119698
|
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
119505
119699
|
resolutionHost.onDiscoveredSymlink();
|
|
@@ -119563,7 +119757,7 @@ var ts;
|
|
|
119563
119757
|
return oldResult.resolvedFileName === newResult.resolvedFileName;
|
|
119564
119758
|
}
|
|
119565
119759
|
}
|
|
119566
|
-
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
|
|
119760
|
+
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
|
|
119567
119761
|
return resolveNamesWithLocalCache({
|
|
119568
119762
|
names: typeDirectiveNames,
|
|
119569
119763
|
containingFile: containingFile,
|
|
@@ -119573,6 +119767,7 @@ var ts;
|
|
|
119573
119767
|
loader: resolveTypeReferenceDirective,
|
|
119574
119768
|
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
|
|
119575
119769
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
119770
|
+
containingSourceFileMode: containingFileMode
|
|
119576
119771
|
});
|
|
119577
119772
|
}
|
|
119578
119773
|
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
@@ -120279,9 +120474,9 @@ var ts;
|
|
|
120279
120474
|
if (!preferSymlinks) {
|
|
120280
120475
|
// Symlinks inside ignored paths are already filtered out of the symlink cache,
|
|
120281
120476
|
// so we only need to remove them from the realpath filenames.
|
|
120282
|
-
var
|
|
120283
|
-
if (
|
|
120284
|
-
return
|
|
120477
|
+
var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
|
|
120478
|
+
if (result_15)
|
|
120479
|
+
return result_15;
|
|
120285
120480
|
}
|
|
120286
120481
|
var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
|
|
120287
120482
|
var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
|
|
@@ -120301,10 +120496,10 @@ var ts;
|
|
|
120301
120496
|
for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
|
|
120302
120497
|
var symlinkDirectory = symlinkDirectories_1[_i];
|
|
120303
120498
|
var option = ts.resolvePath(symlinkDirectory, relative);
|
|
120304
|
-
var
|
|
120499
|
+
var result_16 = cb(option, target === referenceRedirect);
|
|
120305
120500
|
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
|
|
120306
|
-
if (
|
|
120307
|
-
return
|
|
120501
|
+
if (result_16)
|
|
120502
|
+
return result_16;
|
|
120308
120503
|
}
|
|
120309
120504
|
});
|
|
120310
120505
|
});
|
|
@@ -121481,7 +121676,7 @@ var ts;
|
|
|
121481
121676
|
}
|
|
121482
121677
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
121483
121678
|
}) :
|
|
121484
|
-
(function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
|
|
121679
|
+
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
121485
121680
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
121486
121681
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
121487
121682
|
synchronizeProgram();
|
|
@@ -122217,9 +122412,9 @@ var ts;
|
|
|
122217
122412
|
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
122218
122413
|
}
|
|
122219
122414
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
122220
|
-
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|
|
122221
|
-
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
|
|
122222
|
-
return ts.
|
|
122415
|
+
var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
|
|
122416
|
+
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
122417
|
+
return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
|
|
122223
122418
|
};
|
|
122224
122419
|
}
|
|
122225
122420
|
var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
|
|
@@ -124562,7 +124757,7 @@ var ts;
|
|
|
124562
124757
|
case 199 /* ImportType */:
|
|
124563
124758
|
return !node.parent.isTypeOf;
|
|
124564
124759
|
case 227 /* ExpressionWithTypeArguments */:
|
|
124565
|
-
return
|
|
124760
|
+
return ts.isPartOfTypeNode(node.parent);
|
|
124566
124761
|
}
|
|
124567
124762
|
return false;
|
|
124568
124763
|
}
|
|
@@ -127545,6 +127740,10 @@ var ts;
|
|
|
127545
127740
|
return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
|
|
127546
127741
|
}
|
|
127547
127742
|
ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
|
|
127743
|
+
function jsxModeNeedsExplicitImport(jsx) {
|
|
127744
|
+
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
127745
|
+
}
|
|
127746
|
+
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
127548
127747
|
// #endregion
|
|
127549
127748
|
})(ts || (ts = {}));
|
|
127550
127749
|
/*@internal*/
|
|
@@ -129489,9 +129688,18 @@ var ts;
|
|
|
129489
129688
|
return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
|
|
129490
129689
|
}
|
|
129491
129690
|
}
|
|
129691
|
+
function isEmitResolutionKindUsingNodeModules(compilerOptions) {
|
|
129692
|
+
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ||
|
|
129693
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
|
|
129694
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
|
|
129695
|
+
}
|
|
129696
|
+
function isEmitModuleResolutionRespectingExportMaps(compilerOptions) {
|
|
129697
|
+
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
|
|
129698
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
|
|
129699
|
+
}
|
|
129492
129700
|
function getSupportedExtensionsForModuleResolution(compilerOptions) {
|
|
129493
129701
|
var extensions = ts.getSupportedExtensions(compilerOptions);
|
|
129494
|
-
return
|
|
129702
|
+
return isEmitResolutionKindUsingNodeModules(compilerOptions) ?
|
|
129495
129703
|
ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
|
|
129496
129704
|
extensions;
|
|
129497
129705
|
}
|
|
@@ -129654,7 +129862,7 @@ var ts;
|
|
|
129654
129862
|
result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
129655
129863
|
}
|
|
129656
129864
|
getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
|
|
129657
|
-
if (
|
|
129865
|
+
if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
|
|
129658
129866
|
// If looking for a global package name, don't just include everything in `node_modules` because that includes dependencies' own dependencies.
|
|
129659
129867
|
// (But do if we didn't find anything, e.g. 'package.json' missing.)
|
|
129660
129868
|
var foundGlobal = false;
|
|
@@ -129671,12 +129879,68 @@ var ts;
|
|
|
129671
129879
|
}
|
|
129672
129880
|
}
|
|
129673
129881
|
if (!foundGlobal) {
|
|
129674
|
-
|
|
129882
|
+
var ancestorLookup = function (ancestor) {
|
|
129675
129883
|
var nodeModules = ts.combinePaths(ancestor, "node_modules");
|
|
129676
129884
|
if (ts.tryDirectoryExists(host, nodeModules)) {
|
|
129677
129885
|
getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result);
|
|
129678
129886
|
}
|
|
129679
|
-
}
|
|
129887
|
+
};
|
|
129888
|
+
if (fragmentDirectory && isEmitModuleResolutionRespectingExportMaps(compilerOptions)) {
|
|
129889
|
+
var nodeModulesDirectoryLookup_1 = ancestorLookup;
|
|
129890
|
+
ancestorLookup = function (ancestor) {
|
|
129891
|
+
var components = ts.getPathComponents(fragment);
|
|
129892
|
+
components.shift(); // shift off empty root
|
|
129893
|
+
var packagePath = components.shift();
|
|
129894
|
+
if (!packagePath) {
|
|
129895
|
+
return nodeModulesDirectoryLookup_1(ancestor);
|
|
129896
|
+
}
|
|
129897
|
+
if (ts.startsWith(packagePath, "@")) {
|
|
129898
|
+
var subName = components.shift();
|
|
129899
|
+
if (!subName) {
|
|
129900
|
+
return nodeModulesDirectoryLookup_1(ancestor);
|
|
129901
|
+
}
|
|
129902
|
+
packagePath = ts.combinePaths(packagePath, subName);
|
|
129903
|
+
}
|
|
129904
|
+
var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
|
|
129905
|
+
if (ts.tryFileExists(host, packageFile)) {
|
|
129906
|
+
var packageJson = ts.readJson(packageFile, host);
|
|
129907
|
+
var exports = packageJson.exports;
|
|
129908
|
+
if (exports) {
|
|
129909
|
+
if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
|
|
129910
|
+
return; // null exports or entrypoint only, no sub-modules available
|
|
129911
|
+
}
|
|
129912
|
+
var keys = ts.getOwnKeys(exports);
|
|
129913
|
+
var fragmentSubpath_1 = components.join("/");
|
|
129914
|
+
var processedKeys = ts.mapDefined(keys, function (k) {
|
|
129915
|
+
if (k === ".")
|
|
129916
|
+
return undefined;
|
|
129917
|
+
if (!ts.startsWith(k, "./"))
|
|
129918
|
+
return undefined;
|
|
129919
|
+
var subpath = k.substring(2);
|
|
129920
|
+
if (!ts.startsWith(subpath, fragmentSubpath_1))
|
|
129921
|
+
return undefined;
|
|
129922
|
+
// subpath is a valid export (barring conditions, which we don't currently check here)
|
|
129923
|
+
if (!ts.stringContains(subpath, "*")) {
|
|
129924
|
+
return subpath;
|
|
129925
|
+
}
|
|
129926
|
+
// pattern export - only return everything up to the `*`, so the user can autocomplete, then
|
|
129927
|
+
// keep filling in the pattern (we could speculatively return a list of options by hitting disk,
|
|
129928
|
+
// but conditions will make that somewhat awkward, as each condition may have a different set of possible
|
|
129929
|
+
// options for the `*`.
|
|
129930
|
+
return subpath.slice(0, subpath.indexOf("*"));
|
|
129931
|
+
});
|
|
129932
|
+
ts.forEach(processedKeys, function (k) {
|
|
129933
|
+
if (k) {
|
|
129934
|
+
result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
129935
|
+
}
|
|
129936
|
+
});
|
|
129937
|
+
return;
|
|
129938
|
+
}
|
|
129939
|
+
}
|
|
129940
|
+
return nodeModulesDirectoryLookup_1(ancestor);
|
|
129941
|
+
};
|
|
129942
|
+
}
|
|
129943
|
+
ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
|
|
129680
129944
|
}
|
|
129681
129945
|
}
|
|
129682
129946
|
return result;
|
|
@@ -131118,14 +131382,15 @@ var ts;
|
|
|
131118
131382
|
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
|
|
131119
131383
|
return { kind: 1 /* JsDocTagName */ };
|
|
131120
131384
|
}
|
|
131121
|
-
|
|
131385
|
+
var typeExpression = tryGetTypeExpressionFromTag(tag);
|
|
131386
|
+
if (typeExpression) {
|
|
131122
131387
|
currentToken = ts.getTokenAtPosition(sourceFile, position);
|
|
131123
131388
|
if (!currentToken ||
|
|
131124
131389
|
(!ts.isDeclarationName(currentToken) &&
|
|
131125
131390
|
(currentToken.parent.kind !== 345 /* JSDocPropertyTag */ ||
|
|
131126
131391
|
currentToken.parent.name !== currentToken))) {
|
|
131127
131392
|
// Use as type location if inside tag's type expression
|
|
131128
|
-
insideJsDocTagTypeExpression = isCurrentlyEditingNode(
|
|
131393
|
+
insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression);
|
|
131129
131394
|
}
|
|
131130
131395
|
}
|
|
131131
131396
|
if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) {
|
|
@@ -131382,10 +131647,19 @@ var ts;
|
|
|
131382
131647
|
case 341 /* JSDocTypeTag */:
|
|
131383
131648
|
case 343 /* JSDocTypedefTag */:
|
|
131384
131649
|
return true;
|
|
131650
|
+
case 342 /* JSDocTemplateTag */:
|
|
131651
|
+
return !!tag.constraint;
|
|
131385
131652
|
default:
|
|
131386
131653
|
return false;
|
|
131387
131654
|
}
|
|
131388
131655
|
}
|
|
131656
|
+
function tryGetTypeExpressionFromTag(tag) {
|
|
131657
|
+
if (isTagWithTypeExpression(tag)) {
|
|
131658
|
+
var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression;
|
|
131659
|
+
return typeExpression && typeExpression.kind === 307 /* JSDocTypeExpression */ ? typeExpression : undefined;
|
|
131660
|
+
}
|
|
131661
|
+
return undefined;
|
|
131662
|
+
}
|
|
131389
131663
|
function getTypeScriptMemberSymbols() {
|
|
131390
131664
|
// Right of dot member completion list
|
|
131391
131665
|
completionKind = 2 /* PropertyAccess */;
|
|
@@ -134141,7 +134415,7 @@ var ts;
|
|
|
134141
134415
|
}
|
|
134142
134416
|
for (var _c = 0, _d = referencingFile.typeReferenceDirectives; _c < _d.length; _c++) {
|
|
134143
134417
|
var ref = _d[_c];
|
|
134144
|
-
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName);
|
|
134418
|
+
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat);
|
|
134145
134419
|
if (referenced !== undefined && referenced.resolvedFileName === searchSourceFile.fileName) {
|
|
134146
134420
|
refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
|
|
134147
134421
|
}
|
|
@@ -137363,7 +137637,7 @@ var ts;
|
|
|
137363
137637
|
}
|
|
137364
137638
|
var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
|
137365
137639
|
if (typeReferenceDirective) {
|
|
137366
|
-
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
|
|
137640
|
+
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat);
|
|
137367
137641
|
var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217
|
|
137368
137642
|
return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false };
|
|
137369
137643
|
}
|
|
@@ -139169,6 +139443,7 @@ var ts;
|
|
|
139169
139443
|
return oldImports;
|
|
139170
139444
|
}
|
|
139171
139445
|
var typeChecker = program.getTypeChecker();
|
|
139446
|
+
var compilerOptions = program.getCompilerOptions();
|
|
139172
139447
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
139173
139448
|
var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile);
|
|
139174
139449
|
var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */);
|
|
@@ -139225,7 +139500,7 @@ var ts;
|
|
|
139225
139500
|
return usedImports;
|
|
139226
139501
|
function isDeclarationUsed(identifier) {
|
|
139227
139502
|
// The JSX factory symbol is always used if JSX elements are present - even if they are not allowed.
|
|
139228
|
-
return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) ||
|
|
139503
|
+
return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx) ||
|
|
139229
139504
|
ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile);
|
|
139230
139505
|
}
|
|
139231
139506
|
}
|
|
@@ -150916,12 +151191,9 @@ var ts;
|
|
|
150916
151191
|
return undefined;
|
|
150917
151192
|
return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
|
|
150918
151193
|
}
|
|
150919
|
-
function jsxModeNeedsExplicitImport(jsx) {
|
|
150920
|
-
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
150921
|
-
}
|
|
150922
151194
|
function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
|
|
150923
151195
|
var parent = symbolToken.parent;
|
|
150924
|
-
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
151196
|
+
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
150925
151197
|
var jsxNamespace = checker.getJsxNamespace(sourceFile);
|
|
150926
151198
|
if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
|
|
150927
151199
|
return jsxNamespace;
|
|
@@ -157428,7 +157700,7 @@ var ts;
|
|
|
157428
157700
|
// cannot find either start or end node
|
|
157429
157701
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
157430
157702
|
}
|
|
157431
|
-
if (
|
|
157703
|
+
if (start.flags & 4194304 /* JSDoc */) {
|
|
157432
157704
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
|
|
157433
157705
|
}
|
|
157434
157706
|
if (start.parent !== end.parent) {
|
|
@@ -164187,7 +164459,7 @@ var ts;
|
|
|
164187
164459
|
if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
|
|
164188
164460
|
this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) {
|
|
164189
164461
|
var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); // TODO: GH#18217
|
|
164190
|
-
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); });
|
|
164462
|
+
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, ts.isString(name) ? name : name.fileName.toLowerCase()); });
|
|
164191
164463
|
};
|
|
164192
164464
|
}
|
|
164193
164465
|
}
|