typescript 4.6.0-dev.20220210 → 4.7.0-dev.20220216
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 +488 -367
- package/lib/tsserver.js +828 -495
- package/lib/tsserverlibrary.d.ts +25 -19
- package/lib/tsserverlibrary.js +828 -495
- package/lib/typescript.d.ts +17 -18
- package/lib/typescript.js +826 -493
- package/lib/typescriptServices.d.ts +17 -18
- package/lib/typescriptServices.js +826 -493
- package/lib/typingsInstaller.js +595 -445
- 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/typingsInstaller.js
CHANGED
|
@@ -85,11 +85,11 @@ var ts;
|
|
|
85
85
|
(function (ts) {
|
|
86
86
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
87
87
|
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
|
88
|
-
ts.versionMajorMinor = "4.
|
|
88
|
+
ts.versionMajorMinor = "4.7";
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220216";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -4829,6 +4829,8 @@ var ts;
|
|
|
4829
4829
|
TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike";
|
|
4830
4830
|
TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike";
|
|
4831
4831
|
/* @internal */
|
|
4832
|
+
TypeFlags[TypeFlags["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
|
|
4833
|
+
/* @internal */
|
|
4832
4834
|
TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains";
|
|
4833
4835
|
TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
4834
4836
|
TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType";
|
|
@@ -5561,6 +5563,8 @@ var ts;
|
|
|
5561
5563
|
BundleFileSectionKind["NoDefaultLib"] = "no-default-lib";
|
|
5562
5564
|
BundleFileSectionKind["Reference"] = "reference";
|
|
5563
5565
|
BundleFileSectionKind["Type"] = "type";
|
|
5566
|
+
BundleFileSectionKind["TypeResolutionModeRequire"] = "type-require";
|
|
5567
|
+
BundleFileSectionKind["TypeResolutionModeImport"] = "type-import";
|
|
5564
5568
|
BundleFileSectionKind["Lib"] = "lib";
|
|
5565
5569
|
BundleFileSectionKind["Prepend"] = "prepend";
|
|
5566
5570
|
BundleFileSectionKind["Text"] = "text";
|
|
@@ -5677,7 +5681,8 @@ var ts;
|
|
|
5677
5681
|
{ name: "types", optional: true, captureSpan: true },
|
|
5678
5682
|
{ name: "lib", optional: true, captureSpan: true },
|
|
5679
5683
|
{ name: "path", optional: true, captureSpan: true },
|
|
5680
|
-
{ name: "no-default-lib", optional: true }
|
|
5684
|
+
{ name: "no-default-lib", optional: true },
|
|
5685
|
+
{ name: "resolution-mode", optional: true }
|
|
5681
5686
|
],
|
|
5682
5687
|
kind: 1 /* TripleSlashXML */
|
|
5683
5688
|
},
|
|
@@ -7625,18 +7630,6 @@ var ts;
|
|
|
7625
7630
|
return getCanonicalFileName(nonCanonicalizedPath);
|
|
7626
7631
|
}
|
|
7627
7632
|
ts.toPath = toPath;
|
|
7628
|
-
function normalizePathAndParts(path) {
|
|
7629
|
-
path = normalizeSlashes(path);
|
|
7630
|
-
var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
|
|
7631
|
-
if (parts.length) {
|
|
7632
|
-
var joinedParts = root + parts.join(ts.directorySeparator);
|
|
7633
|
-
return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
|
|
7634
|
-
}
|
|
7635
|
-
else {
|
|
7636
|
-
return { path: root, parts: parts };
|
|
7637
|
-
}
|
|
7638
|
-
}
|
|
7639
|
-
ts.normalizePathAndParts = normalizePathAndParts;
|
|
7640
7633
|
function removeTrailingDirectorySeparator(path) {
|
|
7641
7634
|
if (hasTrailingDirectorySeparator(path)) {
|
|
7642
7635
|
return path.substr(0, path.length - 1);
|
|
@@ -8069,6 +8062,9 @@ var ts;
|
|
|
8069
8062
|
An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."),
|
|
8070
8063
|
Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
|
|
8071
8064
|
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."),
|
|
8065
|
+
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."),
|
|
8066
|
+
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}'."),
|
|
8067
|
+
Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
|
|
8072
8068
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
8073
8069
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
8074
8070
|
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."),
|
|
@@ -8202,6 +8198,8 @@ var ts;
|
|
|
8202
8198
|
Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
|
|
8203
8199
|
Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
|
|
8204
8200
|
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"),
|
|
8201
|
+
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`."),
|
|
8202
|
+
resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
|
|
8205
8203
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8206
8204
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8207
8205
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -9627,6 +9625,9 @@ var ts;
|
|
|
9627
9625
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9628
9626
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9629
9627
|
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9628
|
+
Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
|
|
9629
|
+
Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
|
|
9630
|
+
Rename_param_tag_name_0_to_1: diag(95173, ts.DiagnosticCategory.Message, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
|
|
9630
9631
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
9631
9632
|
Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
9632
9633
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -14082,7 +14083,11 @@ var ts;
|
|
|
14082
14083
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14083
14084
|
for (var i = 0; i < names.length; i++) {
|
|
14084
14085
|
var newResolution = newResolutions[i];
|
|
14085
|
-
var
|
|
14086
|
+
var entry = names[i];
|
|
14087
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
14088
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
14089
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
|
|
14090
|
+
var oldResolution = oldResolutions && oldResolutions.get(name, mode);
|
|
14086
14091
|
var changed = oldResolution
|
|
14087
14092
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14088
14093
|
: newResolution;
|
|
@@ -26677,7 +26682,13 @@ var ts;
|
|
|
26677
26682
|
referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
|
|
26678
26683
|
break;
|
|
26679
26684
|
case "type" /* Type */:
|
|
26680
|
-
typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
|
|
26685
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
26686
|
+
break;
|
|
26687
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26688
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
|
|
26689
|
+
break;
|
|
26690
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26691
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
|
|
26681
26692
|
break;
|
|
26682
26693
|
case "lib" /* Lib */:
|
|
26683
26694
|
libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
@@ -26736,6 +26747,8 @@ var ts;
|
|
|
26736
26747
|
case "no-default-lib" /* NoDefaultLib */:
|
|
26737
26748
|
case "reference" /* Reference */:
|
|
26738
26749
|
case "type" /* Type */:
|
|
26750
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26751
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26739
26752
|
case "lib" /* Lib */:
|
|
26740
26753
|
syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
|
|
26741
26754
|
break;
|
|
@@ -30649,7 +30662,7 @@ var ts;
|
|
|
30649
30662
|
initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
|
|
30650
30663
|
// Prime the scanner.
|
|
30651
30664
|
nextToken();
|
|
30652
|
-
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
30665
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false);
|
|
30653
30666
|
var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
|
|
30654
30667
|
clearState();
|
|
30655
30668
|
return isInvalid ? entityName : undefined;
|
|
@@ -32226,7 +32239,7 @@ var ts;
|
|
|
32226
32239
|
}
|
|
32227
32240
|
return createMissingList();
|
|
32228
32241
|
}
|
|
32229
|
-
function parseEntityName(allowReservedWords, diagnosticMessage) {
|
|
32242
|
+
function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) {
|
|
32230
32243
|
var pos = getNodePos();
|
|
32231
32244
|
var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
|
|
32232
32245
|
var dotPos = getNodePos();
|
|
@@ -32237,7 +32250,7 @@ var ts;
|
|
|
32237
32250
|
break;
|
|
32238
32251
|
}
|
|
32239
32252
|
dotPos = getNodePos();
|
|
32240
|
-
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords,
|
|
32253
|
+
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos);
|
|
32241
32254
|
}
|
|
32242
32255
|
return entity;
|
|
32243
32256
|
}
|
|
@@ -32370,7 +32383,7 @@ var ts;
|
|
|
32370
32383
|
}
|
|
32371
32384
|
// TYPES
|
|
32372
32385
|
function parseEntityNameOfTypeReference() {
|
|
32373
|
-
return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
|
|
32386
|
+
return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected);
|
|
32374
32387
|
}
|
|
32375
32388
|
function parseTypeArgumentsOfTypeReference() {
|
|
32376
32389
|
if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) {
|
|
@@ -32503,7 +32516,7 @@ var ts;
|
|
|
32503
32516
|
function parseTypeQuery() {
|
|
32504
32517
|
var pos = getNodePos();
|
|
32505
32518
|
parseExpected(112 /* TypeOfKeyword */);
|
|
32506
|
-
return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos);
|
|
32519
|
+
return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true)), pos);
|
|
32507
32520
|
}
|
|
32508
32521
|
function parseTypeParameter() {
|
|
32509
32522
|
var pos = getNodePos();
|
|
@@ -35074,11 +35087,12 @@ var ts;
|
|
|
35074
35087
|
}
|
|
35075
35088
|
function parseCaseClause() {
|
|
35076
35089
|
var pos = getNodePos();
|
|
35090
|
+
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35077
35091
|
parseExpected(82 /* CaseKeyword */);
|
|
35078
35092
|
var expression = allowInAnd(parseExpression);
|
|
35079
35093
|
parseExpected(58 /* ColonToken */);
|
|
35080
35094
|
var statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
|
|
35081
|
-
return finishNode(factory.createCaseClause(expression, statements), pos);
|
|
35095
|
+
return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
|
|
35082
35096
|
}
|
|
35083
35097
|
function parseDefaultClause() {
|
|
35084
35098
|
var pos = getNodePos();
|
|
@@ -36241,7 +36255,7 @@ var ts;
|
|
|
36241
36255
|
function parseModuleReference() {
|
|
36242
36256
|
return isExternalModuleReference()
|
|
36243
36257
|
? parseExternalModuleReference()
|
|
36244
|
-
: parseEntityName(/*allowReservedWords*/ false);
|
|
36258
|
+
: parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36245
36259
|
}
|
|
36246
36260
|
function parseExternalModuleReference() {
|
|
36247
36261
|
var pos = getNodePos();
|
|
@@ -36523,7 +36537,7 @@ var ts;
|
|
|
36523
36537
|
var pos = getNodePos();
|
|
36524
36538
|
var hasBrace = parseOptional(18 /* OpenBraceToken */);
|
|
36525
36539
|
var p2 = getNodePos();
|
|
36526
|
-
var entityName = parseEntityName(/* allowReservedWords*/ false);
|
|
36540
|
+
var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36527
36541
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
36528
36542
|
reScanHashToken(); // rescan #id as # id
|
|
36529
36543
|
nextTokenJSDoc(); // then skip the #
|
|
@@ -36966,7 +36980,7 @@ var ts;
|
|
|
36966
36980
|
// parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
|
|
36967
36981
|
var p2 = getNodePos();
|
|
36968
36982
|
var name = ts.tokenIsIdentifierOrKeyword(token())
|
|
36969
|
-
? parseEntityName(/*allowReservedWords*/ true)
|
|
36983
|
+
? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false)
|
|
36970
36984
|
: undefined;
|
|
36971
36985
|
if (name) {
|
|
36972
36986
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
@@ -36991,11 +37005,13 @@ var ts;
|
|
|
36991
37005
|
&& nextTokenJSDoc() === 59 /* AtToken */
|
|
36992
37006
|
&& ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
|
|
36993
37007
|
var kind = scanner.getTokenValue();
|
|
36994
|
-
if (kind
|
|
37008
|
+
if (isJSDocLinkTag(kind))
|
|
36995
37009
|
return kind;
|
|
36996
|
-
}
|
|
36997
37010
|
}
|
|
36998
37011
|
}
|
|
37012
|
+
function isJSDocLinkTag(kind) {
|
|
37013
|
+
return kind === "link" || kind === "linkcode" || kind === "linkplain";
|
|
37014
|
+
}
|
|
36999
37015
|
function parseUnknownTag(start, tagName, indent, indentText) {
|
|
37000
37016
|
return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
|
|
37001
37017
|
}
|
|
@@ -37101,7 +37117,7 @@ var ts;
|
|
|
37101
37117
|
}
|
|
37102
37118
|
function parseSeeTag(start, tagName, indent, indentText) {
|
|
37103
37119
|
var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
|
|
37104
|
-
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue()
|
|
37120
|
+
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); });
|
|
37105
37121
|
var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
|
|
37106
37122
|
var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
|
|
37107
37123
|
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
|
|
@@ -37968,6 +37984,19 @@ var ts;
|
|
|
37968
37984
|
return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
|
|
37969
37985
|
}
|
|
37970
37986
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
37987
|
+
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
37988
|
+
if (!mode) {
|
|
37989
|
+
return undefined;
|
|
37990
|
+
}
|
|
37991
|
+
if (mode === "import") {
|
|
37992
|
+
return ts.ModuleKind.ESNext;
|
|
37993
|
+
}
|
|
37994
|
+
if (mode === "require") {
|
|
37995
|
+
return ts.ModuleKind.CommonJS;
|
|
37996
|
+
}
|
|
37997
|
+
reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
|
|
37998
|
+
return undefined;
|
|
37999
|
+
}
|
|
37971
38000
|
/*@internal*/
|
|
37972
38001
|
function processCommentPragmas(context, sourceText) {
|
|
37973
38002
|
var pragmas = [];
|
|
@@ -38010,12 +38039,13 @@ var ts;
|
|
|
38010
38039
|
var typeReferenceDirectives_1 = context.typeReferenceDirectives;
|
|
38011
38040
|
var libReferenceDirectives_1 = context.libReferenceDirectives;
|
|
38012
38041
|
ts.forEach(ts.toArray(entryOrList), function (arg) {
|
|
38013
|
-
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
|
|
38042
|
+
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
|
|
38014
38043
|
if (arg.arguments["no-default-lib"]) {
|
|
38015
38044
|
context.hasNoDefaultLib = true;
|
|
38016
38045
|
}
|
|
38017
38046
|
else if (types) {
|
|
38018
|
-
|
|
38047
|
+
var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
|
|
38048
|
+
typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
|
|
38019
38049
|
}
|
|
38020
38050
|
else if (lib) {
|
|
38021
38051
|
libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
|
|
@@ -41593,14 +41623,14 @@ var ts;
|
|
|
41593
41623
|
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
|
41594
41624
|
* is assumed to be the same as root directory of the project.
|
|
41595
41625
|
*/
|
|
41596
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
|
|
41626
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
|
|
41597
41627
|
var traceEnabled = isTraceEnabled(options, host);
|
|
41598
41628
|
if (redirectedReference) {
|
|
41599
41629
|
options = redirectedReference.commandLine.options;
|
|
41600
41630
|
}
|
|
41601
41631
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41602
41632
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41603
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/
|
|
41633
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
|
|
41604
41634
|
if (result) {
|
|
41605
41635
|
if (traceEnabled) {
|
|
41606
41636
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41635,7 +41665,18 @@ var ts;
|
|
|
41635
41665
|
}
|
|
41636
41666
|
var failedLookupLocations = [];
|
|
41637
41667
|
var features = getDefaultNodeResolutionFeatures(options);
|
|
41638
|
-
|
|
41668
|
+
// Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
|
|
41669
|
+
// setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
|
|
41670
|
+
// set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports
|
|
41671
|
+
// 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,
|
|
41672
|
+
// 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
|
|
41673
|
+
// resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution
|
|
41674
|
+
// context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do).
|
|
41675
|
+
if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
|
|
41676
|
+
features |= NodeResolutionFeatures.EsmMode;
|
|
41677
|
+
}
|
|
41678
|
+
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
41679
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
|
|
41639
41680
|
var resolved = primaryLookup();
|
|
41640
41681
|
var primary = true;
|
|
41641
41682
|
if (!resolved) {
|
|
@@ -41655,7 +41696,7 @@ var ts;
|
|
|
41655
41696
|
};
|
|
41656
41697
|
}
|
|
41657
41698
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41658
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/
|
|
41699
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
41659
41700
|
if (traceEnabled)
|
|
41660
41701
|
traceResult(result);
|
|
41661
41702
|
return result;
|
|
@@ -41706,7 +41747,7 @@ var ts;
|
|
|
41706
41747
|
result_4 = searchResult && searchResult.value;
|
|
41707
41748
|
}
|
|
41708
41749
|
else {
|
|
41709
|
-
var candidate =
|
|
41750
|
+
var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
|
|
41710
41751
|
result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
|
|
41711
41752
|
}
|
|
41712
41753
|
return resolvedTypeScriptOnly(result_4);
|
|
@@ -41941,7 +41982,11 @@ var ts;
|
|
|
41941
41982
|
ts.Debug.assert(keys.length === values.length);
|
|
41942
41983
|
var map = createModeAwareCache();
|
|
41943
41984
|
for (var i = 0; i < keys.length; ++i) {
|
|
41944
|
-
|
|
41985
|
+
var entry = keys[i];
|
|
41986
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
41987
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
41988
|
+
var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
|
|
41989
|
+
map.set(name, mode, values[i]);
|
|
41945
41990
|
}
|
|
41946
41991
|
return map;
|
|
41947
41992
|
}
|
|
@@ -42409,13 +42454,25 @@ var ts;
|
|
|
42409
42454
|
return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
|
|
42410
42455
|
}
|
|
42411
42456
|
else {
|
|
42412
|
-
var _a =
|
|
42457
|
+
var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
|
|
42413
42458
|
var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
|
|
42414
42459
|
// Treat explicit "node_modules" import as an external library import.
|
|
42415
42460
|
return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
|
|
42416
42461
|
}
|
|
42417
42462
|
}
|
|
42418
42463
|
}
|
|
42464
|
+
// If you import from "." inside a containing directory "/foo", the result of `normalizePath`
|
|
42465
|
+
// would be "/foo", but this loses the information that `foo` is a directory and we intended
|
|
42466
|
+
// to look inside of it. The Node CommonJS resolution algorithm doesn't call this out
|
|
42467
|
+
// (https://nodejs.org/api/modules.html#all-together), but it seems that module paths ending
|
|
42468
|
+
// in `.` are actually normalized to `./` before proceeding with the resolution algorithm.
|
|
42469
|
+
function normalizePathForCJSResolution(containingDirectory, moduleName) {
|
|
42470
|
+
var combined = ts.combinePaths(containingDirectory, moduleName);
|
|
42471
|
+
var parts = ts.getPathComponents(combined);
|
|
42472
|
+
var lastPart = ts.lastOrUndefined(parts);
|
|
42473
|
+
var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
|
|
42474
|
+
return { path: path, parts: parts };
|
|
42475
|
+
}
|
|
42419
42476
|
function realPath(path, host, traceEnabled) {
|
|
42420
42477
|
if (!host.realpath) {
|
|
42421
42478
|
return path;
|
|
@@ -42457,7 +42514,13 @@ var ts;
|
|
|
42457
42514
|
onlyRecordFailures = true;
|
|
42458
42515
|
}
|
|
42459
42516
|
}
|
|
42460
|
-
|
|
42517
|
+
// esm mode relative imports shouldn't do any directory lookups (either inside `package.json`
|
|
42518
|
+
// files or implicit `index.js`es). This is a notable depature from cjs norms, where `./foo/pkg`
|
|
42519
|
+
// could have been redirected by `./foo/pkg/package.json` to an arbitrary location!
|
|
42520
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42521
|
+
return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
|
|
42522
|
+
}
|
|
42523
|
+
return undefined;
|
|
42461
42524
|
}
|
|
42462
42525
|
/*@internal*/
|
|
42463
42526
|
ts.nodeModulesPathPart = "/node_modules/";
|
|
@@ -42824,7 +42887,16 @@ var ts;
|
|
|
42824
42887
|
// Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types"
|
|
42825
42888
|
var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
|
|
42826
42889
|
// Don't do package.json lookup recursively, because Node.js' package lookup doesn't.
|
|
42827
|
-
|
|
42890
|
+
// Disable `EsmMode` for the resolution of the package path for cjs-mode packages (so the `main` field can omit extensions)
|
|
42891
|
+
// (technically it only emits a deprecation warning in esm packages right now, but that's probably
|
|
42892
|
+
// enough to mean we don't need to support it)
|
|
42893
|
+
var features = state.features;
|
|
42894
|
+
if ((jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.type) !== "module") {
|
|
42895
|
+
state.features &= ~NodeResolutionFeatures.EsmMode;
|
|
42896
|
+
}
|
|
42897
|
+
var result = nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ false);
|
|
42898
|
+
state.features = features;
|
|
42899
|
+
return result;
|
|
42828
42900
|
};
|
|
42829
42901
|
var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
|
|
42830
42902
|
var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
|
|
@@ -43169,6 +43241,14 @@ var ts;
|
|
|
43169
43241
|
}
|
|
43170
43242
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
43171
43243
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
43244
|
+
if (!pathAndExtension && packageInfo
|
|
43245
|
+
&& packageInfo.packageJsonContent.exports === undefined
|
|
43246
|
+
&& packageInfo.packageJsonContent.main === undefined
|
|
43247
|
+
&& state.features & NodeResolutionFeatures.EsmMode) {
|
|
43248
|
+
// EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
|
|
43249
|
+
// a default `index.js` entrypoint if no `main` or `exports` are present
|
|
43250
|
+
pathAndExtension = loadModuleFromFile(extensions, ts.combinePaths(candidate, "index.js"), onlyRecordFailures, state);
|
|
43251
|
+
}
|
|
43172
43252
|
return withPackageId(packageInfo, pathAndExtension);
|
|
43173
43253
|
};
|
|
43174
43254
|
if (rest !== "") { // If "rest" is empty, we just did this search above.
|
|
@@ -46926,8 +47006,7 @@ var ts;
|
|
|
46926
47006
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
46927
47007
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
46928
47008
|
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
46929
|
-
IntersectionState[IntersectionState["
|
|
46930
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
|
|
47009
|
+
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
46931
47010
|
})(IntersectionState || (IntersectionState = {}));
|
|
46932
47011
|
var RecursionFlags;
|
|
46933
47012
|
(function (RecursionFlags) {
|
|
@@ -50386,8 +50465,15 @@ var ts;
|
|
|
50386
50465
|
return res;
|
|
50387
50466
|
}
|
|
50388
50467
|
var candidates = ts.mapDefined(symbol.declarations, function (d) {
|
|
50389
|
-
if (!ts.isAmbientModule(d) && d.parent
|
|
50390
|
-
|
|
50468
|
+
if (!ts.isAmbientModule(d) && d.parent) {
|
|
50469
|
+
// direct children of a module
|
|
50470
|
+
if (hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
|
|
50471
|
+
return getSymbolOfNode(d.parent);
|
|
50472
|
+
}
|
|
50473
|
+
// export ='d member of an ambient module
|
|
50474
|
+
if (ts.isModuleBlock(d.parent) && d.parent.parent && resolveExternalModuleSymbol(getSymbolOfNode(d.parent.parent)) === symbol) {
|
|
50475
|
+
return getSymbolOfNode(d.parent.parent);
|
|
50476
|
+
}
|
|
50391
50477
|
}
|
|
50392
50478
|
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)) {
|
|
50393
50479
|
if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
|
|
@@ -54624,12 +54710,9 @@ var ts;
|
|
|
54624
54710
|
}
|
|
54625
54711
|
}
|
|
54626
54712
|
if (ts.isInJSFile(declaration)) {
|
|
54627
|
-
var
|
|
54628
|
-
if (
|
|
54629
|
-
|
|
54630
|
-
var pos = func.parameters.indexOf(declaration);
|
|
54631
|
-
return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
54632
|
-
}
|
|
54713
|
+
var type_1 = getParameterTypeOfTypeTag(func, declaration);
|
|
54714
|
+
if (type_1)
|
|
54715
|
+
return type_1;
|
|
54633
54716
|
}
|
|
54634
54717
|
// Use contextual parameter type if one is available
|
|
54635
54718
|
var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
|
|
@@ -55196,9 +55279,9 @@ var ts;
|
|
|
55196
55279
|
if (typeNode === undefined) {
|
|
55197
55280
|
return useUnknownInCatchVariables ? unknownType : anyType;
|
|
55198
55281
|
}
|
|
55199
|
-
var
|
|
55282
|
+
var type_2 = getTypeOfNode(typeNode);
|
|
55200
55283
|
// an errorType will make `checkTryStatement` issue an error
|
|
55201
|
-
return isTypeAny(
|
|
55284
|
+
return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
|
|
55202
55285
|
}
|
|
55203
55286
|
// Handle export default expressions
|
|
55204
55287
|
if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
|
|
@@ -55427,11 +55510,11 @@ var ts;
|
|
|
55427
55510
|
return errorType;
|
|
55428
55511
|
}
|
|
55429
55512
|
var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
|
|
55430
|
-
var
|
|
55513
|
+
var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
|
55431
55514
|
if (!popTypeResolution()) {
|
|
55432
55515
|
return reportCircularityError(symbol);
|
|
55433
55516
|
}
|
|
55434
|
-
return
|
|
55517
|
+
return type_3;
|
|
55435
55518
|
}
|
|
55436
55519
|
}
|
|
55437
55520
|
var type = createObjectType(16 /* Anonymous */, symbol);
|
|
@@ -57663,10 +57746,10 @@ var ts;
|
|
|
57663
57746
|
var baseTypes = [];
|
|
57664
57747
|
var different = false;
|
|
57665
57748
|
for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
|
|
57666
|
-
var
|
|
57667
|
-
var baseType = getBaseConstraint(
|
|
57749
|
+
var type_4 = types_7[_i];
|
|
57750
|
+
var baseType = getBaseConstraint(type_4);
|
|
57668
57751
|
if (baseType) {
|
|
57669
|
-
if (baseType !==
|
|
57752
|
+
if (baseType !== type_4) {
|
|
57670
57753
|
different = true;
|
|
57671
57754
|
}
|
|
57672
57755
|
baseTypes.push(baseType);
|
|
@@ -58379,6 +58462,13 @@ var ts;
|
|
|
58379
58462
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
58380
58463
|
return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
58381
58464
|
}
|
|
58465
|
+
function getParameterTypeOfTypeTag(func, parameter) {
|
|
58466
|
+
var signature = getSignatureOfTypeTag(func);
|
|
58467
|
+
if (!signature)
|
|
58468
|
+
return undefined;
|
|
58469
|
+
var pos = func.parameters.indexOf(parameter);
|
|
58470
|
+
return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
58471
|
+
}
|
|
58382
58472
|
function getReturnTypeOfTypeTag(node) {
|
|
58383
58473
|
var signature = getSignatureOfTypeTag(node);
|
|
58384
58474
|
return signature && getReturnTypeOfSignature(signature);
|
|
@@ -58637,13 +58727,15 @@ var ts;
|
|
|
58637
58727
|
return signature;
|
|
58638
58728
|
}
|
|
58639
58729
|
function getOrCreateTypeFromSignature(signature) {
|
|
58730
|
+
var _a;
|
|
58640
58731
|
// There are two ways to declare a construct signature, one is by declaring a class constructor
|
|
58641
58732
|
// using the constructor keyword, and the other is declaring a bare construct signature in an
|
|
58642
58733
|
// object type literal or interface (using the new keyword). Each way of declaring a constructor
|
|
58643
58734
|
// will result in a different declaration kind.
|
|
58644
58735
|
if (!signature.isolatedSignatureType) {
|
|
58645
|
-
var kind =
|
|
58646
|
-
|
|
58736
|
+
var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
|
|
58737
|
+
// If declaration is undefined, it is likely to be the signature of the default constructor.
|
|
58738
|
+
var isConstructor = kind === undefined || kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */;
|
|
58647
58739
|
var type = createObjectType(16 /* Anonymous */);
|
|
58648
58740
|
type.members = emptySymbols;
|
|
58649
58741
|
type.properties = ts.emptyArray;
|
|
@@ -59571,7 +59663,7 @@ var ts;
|
|
|
59571
59663
|
}
|
|
59572
59664
|
}
|
|
59573
59665
|
var fixedLength = properties.length;
|
|
59574
|
-
var lengthSymbol = createSymbol(4 /* Property */, "length");
|
|
59666
|
+
var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
|
|
59575
59667
|
if (combinedFlags & 12 /* Variable */) {
|
|
59576
59668
|
lengthSymbol.type = numberType;
|
|
59577
59669
|
}
|
|
@@ -63118,9 +63210,11 @@ var ts;
|
|
|
63118
63210
|
isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
|
|
63119
63211
|
return true;
|
|
63120
63212
|
}
|
|
63121
|
-
|
|
63213
|
+
// In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`.
|
|
63214
|
+
// Since unions and intersections may reduce to `never`, we exclude them here.
|
|
63215
|
+
if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */)))
|
|
63122
63216
|
return true;
|
|
63123
|
-
if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */))
|
|
63217
|
+
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
63124
63218
|
return true;
|
|
63125
63219
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
|
|
63126
63220
|
return true;
|
|
@@ -63209,11 +63303,11 @@ var ts;
|
|
|
63209
63303
|
var overflow = false;
|
|
63210
63304
|
var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
|
|
63211
63305
|
var lastSkippedInfo;
|
|
63212
|
-
var incompatibleStack
|
|
63306
|
+
var incompatibleStack;
|
|
63213
63307
|
var inPropertyCheck = false;
|
|
63214
63308
|
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
63215
63309
|
var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
|
|
63216
|
-
if (incompatibleStack
|
|
63310
|
+
if (incompatibleStack) {
|
|
63217
63311
|
reportIncompatibleStack();
|
|
63218
63312
|
}
|
|
63219
63313
|
if (overflow) {
|
|
@@ -63270,19 +63364,19 @@ var ts;
|
|
|
63270
63364
|
return {
|
|
63271
63365
|
errorInfo: errorInfo,
|
|
63272
63366
|
lastSkippedInfo: lastSkippedInfo,
|
|
63273
|
-
incompatibleStack: incompatibleStack.slice(),
|
|
63367
|
+
incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
|
|
63274
63368
|
overrideNextErrorInfo: overrideNextErrorInfo,
|
|
63275
|
-
relatedInfo:
|
|
63369
|
+
relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
|
|
63276
63370
|
};
|
|
63277
63371
|
}
|
|
63278
63372
|
function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
|
|
63279
63373
|
overrideNextErrorInfo++; // Suppress the next relation error
|
|
63280
63374
|
lastSkippedInfo = undefined; // Reset skipped info cache
|
|
63281
|
-
incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
|
|
63375
|
+
(incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
|
|
63282
63376
|
}
|
|
63283
63377
|
function reportIncompatibleStack() {
|
|
63284
|
-
var stack = incompatibleStack;
|
|
63285
|
-
incompatibleStack =
|
|
63378
|
+
var stack = incompatibleStack || [];
|
|
63379
|
+
incompatibleStack = undefined;
|
|
63286
63380
|
var info = lastSkippedInfo;
|
|
63287
63381
|
lastSkippedInfo = undefined;
|
|
63288
63382
|
if (stack.length === 1) {
|
|
@@ -63388,7 +63482,7 @@ var ts;
|
|
|
63388
63482
|
}
|
|
63389
63483
|
function reportError(message, arg0, arg1, arg2, arg3) {
|
|
63390
63484
|
ts.Debug.assert(!!errorNode);
|
|
63391
|
-
if (incompatibleStack
|
|
63485
|
+
if (incompatibleStack)
|
|
63392
63486
|
reportIncompatibleStack();
|
|
63393
63487
|
if (message.elidedInCompatabilityPyramid)
|
|
63394
63488
|
return;
|
|
@@ -63404,7 +63498,7 @@ var ts;
|
|
|
63404
63498
|
}
|
|
63405
63499
|
}
|
|
63406
63500
|
function reportRelationError(message, source, target) {
|
|
63407
|
-
if (incompatibleStack
|
|
63501
|
+
if (incompatibleStack)
|
|
63408
63502
|
reportIncompatibleStack();
|
|
63409
63503
|
var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
|
|
63410
63504
|
var generalizedSource = source;
|
|
@@ -63516,7 +63610,9 @@ var ts;
|
|
|
63516
63610
|
if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
|
|
63517
63611
|
return -1 /* True */;
|
|
63518
63612
|
}
|
|
63519
|
-
|
|
63613
|
+
if (reportErrors) {
|
|
63614
|
+
reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
|
|
63615
|
+
}
|
|
63520
63616
|
return 0 /* False */;
|
|
63521
63617
|
}
|
|
63522
63618
|
// Normalize the source and target types: Turn fresh literal types into regular literal types,
|
|
@@ -63528,7 +63624,12 @@ var ts;
|
|
|
63528
63624
|
if (source === target)
|
|
63529
63625
|
return -1 /* True */;
|
|
63530
63626
|
if (relation === identityRelation) {
|
|
63531
|
-
|
|
63627
|
+
if (source.flags !== target.flags)
|
|
63628
|
+
return 0 /* False */;
|
|
63629
|
+
if (source.flags & 67358815 /* Singleton */)
|
|
63630
|
+
return -1 /* True */;
|
|
63631
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63632
|
+
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63532
63633
|
}
|
|
63533
63634
|
// We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
|
|
63534
63635
|
// and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
|
|
@@ -63538,163 +63639,130 @@ var ts;
|
|
|
63538
63639
|
if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
|
|
63539
63640
|
return -1 /* True */;
|
|
63540
63641
|
}
|
|
63541
|
-
//
|
|
63542
|
-
// If so,
|
|
63543
|
-
|
|
63544
|
-
|
|
63545
|
-
|
|
63546
|
-
|
|
63547
|
-
|
|
63548
|
-
|
|
63549
|
-
|
|
63550
|
-
|
|
63551
|
-
|
|
63552
|
-
|
|
63553
|
-
if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) {
|
|
63554
|
-
target = getNormalizedType(nullStrippedTarget, /*writing*/ true);
|
|
63555
|
-
}
|
|
63556
|
-
if (source === nullStrippedTarget)
|
|
63557
|
-
return -1 /* True */;
|
|
63642
|
+
// See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
|
|
63643
|
+
// plus a single non-nullable type. If so, remove null and/or undefined from the target type.
|
|
63644
|
+
if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
|
|
63645
|
+
var types = target.types;
|
|
63646
|
+
var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
|
|
63647
|
+
types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
|
|
63648
|
+
undefined;
|
|
63649
|
+
if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
|
|
63650
|
+
target = getNormalizedType(candidate, /*writing*/ true);
|
|
63651
|
+
if (source === target)
|
|
63652
|
+
return -1 /* True */;
|
|
63653
|
+
}
|
|
63558
63654
|
}
|
|
63559
63655
|
if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
|
|
63560
63656
|
isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
|
|
63561
63657
|
return -1 /* True */;
|
|
63562
|
-
|
|
63563
|
-
|
|
63564
|
-
|
|
63565
|
-
|
|
63658
|
+
if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
|
|
63659
|
+
var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
|
|
63660
|
+
if (isPerformingExcessPropertyChecks) {
|
|
63661
|
+
if (hasExcessProperties(source, target, reportErrors)) {
|
|
63662
|
+
if (reportErrors) {
|
|
63663
|
+
reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
|
|
63664
|
+
}
|
|
63665
|
+
return 0 /* False */;
|
|
63666
|
+
}
|
|
63667
|
+
}
|
|
63668
|
+
var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
|
|
63669
|
+
source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
|
|
63670
|
+
target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
|
|
63671
|
+
(getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
|
|
63672
|
+
var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
|
|
63673
|
+
if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
|
|
63566
63674
|
if (reportErrors) {
|
|
63567
|
-
|
|
63675
|
+
var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
|
|
63676
|
+
var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
|
|
63677
|
+
var calls = getSignaturesOfType(source, 0 /* Call */);
|
|
63678
|
+
var constructs = getSignaturesOfType(source, 1 /* Construct */);
|
|
63679
|
+
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
|
|
63680
|
+
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
63681
|
+
reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
|
|
63682
|
+
}
|
|
63683
|
+
else {
|
|
63684
|
+
reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
|
|
63685
|
+
}
|
|
63568
63686
|
}
|
|
63569
63687
|
return 0 /* False */;
|
|
63570
63688
|
}
|
|
63571
|
-
|
|
63572
|
-
|
|
63573
|
-
|
|
63574
|
-
|
|
63575
|
-
|
|
63576
|
-
|
|
63577
|
-
|
|
63578
|
-
|
|
63579
|
-
|
|
63580
|
-
|
|
63581
|
-
|
|
63582
|
-
|
|
63583
|
-
|
|
63584
|
-
|
|
63585
|
-
|
|
63586
|
-
|
|
63587
|
-
|
|
63588
|
-
|
|
63689
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63690
|
+
var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
|
|
63691
|
+
target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
|
|
63692
|
+
var result_7 = skipCaching ?
|
|
63693
|
+
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
63694
|
+
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
63695
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
63696
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
63697
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
63698
|
+
//
|
|
63699
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63700
|
+
//
|
|
63701
|
+
// declare let wrong: { a: { y: string } };
|
|
63702
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63703
|
+
//
|
|
63704
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63705
|
+
// x = y; // Mismatched property in source intersection
|
|
63706
|
+
// }
|
|
63707
|
+
//
|
|
63708
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63709
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63710
|
+
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63711
|
+
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 */); }))) {
|
|
63712
|
+
inPropertyCheck = true;
|
|
63713
|
+
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63714
|
+
inPropertyCheck = false;
|
|
63715
|
+
}
|
|
63716
|
+
if (result_7) {
|
|
63717
|
+
return result_7;
|
|
63589
63718
|
}
|
|
63590
|
-
return 0 /* False */;
|
|
63591
|
-
}
|
|
63592
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63593
|
-
var result = 0 /* False */;
|
|
63594
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
63595
|
-
if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
|
|
63596
|
-
// We skip caching when source or target is a union with no more than three constituents.
|
|
63597
|
-
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63598
63719
|
}
|
|
63599
|
-
|
|
63600
|
-
|
|
63720
|
+
if (reportErrors) {
|
|
63721
|
+
reportErrorResults(originalSource, originalTarget, source, target, headMessage);
|
|
63601
63722
|
}
|
|
63602
|
-
|
|
63603
|
-
|
|
63604
|
-
|
|
63723
|
+
return 0 /* False */;
|
|
63724
|
+
}
|
|
63725
|
+
function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
|
|
63726
|
+
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63727
|
+
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63728
|
+
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63729
|
+
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63730
|
+
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63731
|
+
if (maybeSuppress) {
|
|
63732
|
+
overrideNextErrorInfo--;
|
|
63733
|
+
}
|
|
63734
|
+
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63735
|
+
var currentError = errorInfo;
|
|
63736
|
+
tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
|
|
63737
|
+
if (errorInfo !== currentError) {
|
|
63738
|
+
maybeSuppress = !!errorInfo;
|
|
63739
|
+
}
|
|
63740
|
+
}
|
|
63741
|
+
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63742
|
+
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63743
|
+
}
|
|
63744
|
+
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63745
|
+
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63746
|
+
}
|
|
63747
|
+
else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
|
|
63748
|
+
var targetTypes = target.types;
|
|
63749
|
+
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63750
|
+
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63751
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63752
|
+
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63753
|
+
// do not report top error
|
|
63754
|
+
return;
|
|
63605
63755
|
}
|
|
63606
63756
|
}
|
|
63607
|
-
|
|
63608
|
-
|
|
63609
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
63610
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
63611
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
63612
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
63613
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
63614
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
63615
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
63616
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
63617
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
63618
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
63619
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
63620
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
63621
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
63622
|
-
if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
|
|
63623
|
-
if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
63624
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
63625
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63626
|
-
resetErrorInfo(saveErrorInfo);
|
|
63627
|
-
}
|
|
63628
|
-
}
|
|
63629
|
-
}
|
|
63757
|
+
else {
|
|
63758
|
+
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63630
63759
|
}
|
|
63631
|
-
|
|
63632
|
-
|
|
63633
|
-
|
|
63634
|
-
|
|
63635
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63636
|
-
//
|
|
63637
|
-
// declare let wrong: { a: { y: string } };
|
|
63638
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63639
|
-
//
|
|
63640
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63641
|
-
// x = y; // Mismatched property in source intersection
|
|
63642
|
-
// }
|
|
63643
|
-
//
|
|
63644
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63645
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63646
|
-
if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63647
|
-
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 */); }))) {
|
|
63648
|
-
inPropertyCheck = true;
|
|
63649
|
-
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63650
|
-
inPropertyCheck = false;
|
|
63651
|
-
}
|
|
63652
|
-
reportErrorResults(source, target, result, isComparingJsxAttributes);
|
|
63653
|
-
return result;
|
|
63654
|
-
function reportErrorResults(source, target, result, isComparingJsxAttributes) {
|
|
63655
|
-
if (!result && reportErrors) {
|
|
63656
|
-
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63657
|
-
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63658
|
-
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63659
|
-
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63660
|
-
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63661
|
-
if (maybeSuppress) {
|
|
63662
|
-
overrideNextErrorInfo--;
|
|
63663
|
-
}
|
|
63664
|
-
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63665
|
-
var currentError = errorInfo;
|
|
63666
|
-
tryElaborateArrayLikeErrors(source, target, reportErrors);
|
|
63667
|
-
if (errorInfo !== currentError) {
|
|
63668
|
-
maybeSuppress = !!errorInfo;
|
|
63669
|
-
}
|
|
63670
|
-
}
|
|
63671
|
-
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63672
|
-
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63673
|
-
}
|
|
63674
|
-
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63675
|
-
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63676
|
-
}
|
|
63677
|
-
else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) {
|
|
63678
|
-
var targetTypes = target.types;
|
|
63679
|
-
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63680
|
-
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63681
|
-
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63682
|
-
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63683
|
-
// do not report top error
|
|
63684
|
-
return result;
|
|
63685
|
-
}
|
|
63686
|
-
}
|
|
63687
|
-
else {
|
|
63688
|
-
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63689
|
-
}
|
|
63690
|
-
if (!headMessage && maybeSuppress) {
|
|
63691
|
-
lastSkippedInfo = [source, target];
|
|
63692
|
-
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63693
|
-
return result;
|
|
63694
|
-
}
|
|
63695
|
-
reportRelationError(headMessage, source, target);
|
|
63696
|
-
}
|
|
63760
|
+
if (!headMessage && maybeSuppress) {
|
|
63761
|
+
lastSkippedInfo = [source, target];
|
|
63762
|
+
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63763
|
+
return;
|
|
63697
63764
|
}
|
|
63765
|
+
reportRelationError(headMessage, source, target);
|
|
63698
63766
|
}
|
|
63699
63767
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
63700
63768
|
if (!ts.tracing) {
|
|
@@ -63721,21 +63789,6 @@ var ts;
|
|
|
63721
63789
|
}
|
|
63722
63790
|
}
|
|
63723
63791
|
}
|
|
63724
|
-
function isIdenticalTo(source, target, recursionFlags) {
|
|
63725
|
-
if (source.flags !== target.flags)
|
|
63726
|
-
return 0 /* False */;
|
|
63727
|
-
if (source.flags & 67358815 /* Singleton */)
|
|
63728
|
-
return -1 /* True */;
|
|
63729
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63730
|
-
if (source.flags & 3145728 /* UnionOrIntersection */) {
|
|
63731
|
-
var result_7 = eachTypeRelatedToSomeType(source, target);
|
|
63732
|
-
if (result_7) {
|
|
63733
|
-
result_7 &= eachTypeRelatedToSomeType(target, source);
|
|
63734
|
-
}
|
|
63735
|
-
return result_7;
|
|
63736
|
-
}
|
|
63737
|
-
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63738
|
-
}
|
|
63739
63792
|
function getTypeOfPropertyInTypes(types, name) {
|
|
63740
63793
|
var appendPropType = function (propTypes, type) {
|
|
63741
63794
|
var _a;
|
|
@@ -63834,6 +63887,41 @@ var ts;
|
|
|
63834
63887
|
function shouldCheckAsExcessProperty(prop, container) {
|
|
63835
63888
|
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
|
|
63836
63889
|
}
|
|
63890
|
+
function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
|
|
63891
|
+
// Note that these checks are specifically ordered to produce correct results. In particular,
|
|
63892
|
+
// we need to deconstruct unions before intersections (because unions are always at the top),
|
|
63893
|
+
// and we need to handle "each" relations before "some" relations for the same kind of type.
|
|
63894
|
+
if (source.flags & 1048576 /* Union */) {
|
|
63895
|
+
return relation === comparableRelation ?
|
|
63896
|
+
someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
|
|
63897
|
+
eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
|
|
63898
|
+
}
|
|
63899
|
+
if (target.flags & 1048576 /* Union */) {
|
|
63900
|
+
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
63901
|
+
}
|
|
63902
|
+
if (target.flags & 2097152 /* Intersection */) {
|
|
63903
|
+
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
63904
|
+
}
|
|
63905
|
+
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
63906
|
+
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
63907
|
+
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
63908
|
+
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
63909
|
+
// appear to be comparable to '2'.
|
|
63910
|
+
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
63911
|
+
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
63912
|
+
if (constraints !== source.types) {
|
|
63913
|
+
source = getIntersectionType(constraints);
|
|
63914
|
+
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
63915
|
+
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
63916
|
+
}
|
|
63917
|
+
}
|
|
63918
|
+
}
|
|
63919
|
+
// Check to see if any constituents of the intersection are immediately related to the target.
|
|
63920
|
+
// Don't report errors though. Elaborating on whether a source constituent is related to the target is
|
|
63921
|
+
// not actually useful and leads to some confusing error messages. Instead, we rely on the caller
|
|
63922
|
+
// checking whether the full intersection viewed as an object is related to the target.
|
|
63923
|
+
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
63924
|
+
}
|
|
63837
63925
|
function eachTypeRelatedToSomeType(source, target) {
|
|
63838
63926
|
var result = -1 /* True */;
|
|
63839
63927
|
var sourceTypes = source.types;
|
|
@@ -63869,8 +63957,11 @@ var ts;
|
|
|
63869
63957
|
}
|
|
63870
63958
|
}
|
|
63871
63959
|
if (reportErrors) {
|
|
63960
|
+
// Elaborate only if we can find a best matching type in the target union
|
|
63872
63961
|
var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
|
|
63873
|
-
|
|
63962
|
+
if (bestMatchingType) {
|
|
63963
|
+
isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
|
|
63964
|
+
}
|
|
63874
63965
|
}
|
|
63875
63966
|
return 0 /* False */;
|
|
63876
63967
|
}
|
|
@@ -64006,7 +64097,7 @@ var ts;
|
|
|
64006
64097
|
if (overflow) {
|
|
64007
64098
|
return 0 /* False */;
|
|
64008
64099
|
}
|
|
64009
|
-
var keyIntersectionState = intersectionState | (inPropertyCheck ?
|
|
64100
|
+
var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
|
|
64010
64101
|
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
64011
64102
|
var entry = relation.get(id);
|
|
64012
64103
|
if (entry !== undefined) {
|
|
@@ -64074,6 +64165,7 @@ var ts;
|
|
|
64074
64165
|
return originalHandler(onlyUnreliable);
|
|
64075
64166
|
};
|
|
64076
64167
|
}
|
|
64168
|
+
var result;
|
|
64077
64169
|
if (expandingFlags === 3 /* Both */) {
|
|
64078
64170
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
|
|
64079
64171
|
sourceId: source.id,
|
|
@@ -64083,8 +64175,13 @@ var ts;
|
|
|
64083
64175
|
depth: sourceDepth,
|
|
64084
64176
|
targetDepth: targetDepth
|
|
64085
64177
|
});
|
|
64178
|
+
result = 3 /* Maybe */;
|
|
64179
|
+
}
|
|
64180
|
+
else {
|
|
64181
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64182
|
+
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
|
|
64183
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64086
64184
|
}
|
|
64087
|
-
var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
|
|
64088
64185
|
if (outofbandVarianceMarkerHandler) {
|
|
64089
64186
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
64090
64187
|
}
|
|
@@ -64116,98 +64213,97 @@ var ts;
|
|
|
64116
64213
|
return result;
|
|
64117
64214
|
}
|
|
64118
64215
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
64119
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64120
|
-
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
|
|
64121
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64122
|
-
return result;
|
|
64123
|
-
}
|
|
64124
|
-
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
|
|
64125
64216
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
64126
64217
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
64127
64218
|
}
|
|
64128
|
-
|
|
64129
|
-
|
|
64130
|
-
|
|
64131
|
-
|
|
64132
|
-
|
|
64133
|
-
|
|
64134
|
-
|
|
64135
|
-
|
|
64136
|
-
|
|
64137
|
-
|
|
64138
|
-
|
|
64139
|
-
|
|
64140
|
-
if (target.flags & 2097152 /* Intersection */) {
|
|
64141
|
-
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
64142
|
-
}
|
|
64143
|
-
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
64144
|
-
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
64145
|
-
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
64146
|
-
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
64147
|
-
// appear to be comparable to '2'.
|
|
64148
|
-
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
64149
|
-
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
64150
|
-
if (constraints !== source.types) {
|
|
64151
|
-
source = getIntersectionType(constraints);
|
|
64152
|
-
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
64153
|
-
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
64154
|
-
}
|
|
64219
|
+
var result;
|
|
64220
|
+
var originalErrorInfo;
|
|
64221
|
+
var varianceCheckFailed = false;
|
|
64222
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
64223
|
+
var sourceFlags = source.flags;
|
|
64224
|
+
var targetFlags = target.flags;
|
|
64225
|
+
if (relation === identityRelation) {
|
|
64226
|
+
// We've already checked that source.flags and target.flags are identical
|
|
64227
|
+
if (sourceFlags & 3145728 /* UnionOrIntersection */) {
|
|
64228
|
+
var result_8 = eachTypeRelatedToSomeType(source, target);
|
|
64229
|
+
if (result_8) {
|
|
64230
|
+
result_8 &= eachTypeRelatedToSomeType(target, source);
|
|
64155
64231
|
}
|
|
64232
|
+
return result_8;
|
|
64156
64233
|
}
|
|
64157
|
-
|
|
64158
|
-
//
|
|
64159
|
-
// Don't report errors though. Checking whether a constituent is related to the source is not actually
|
|
64160
|
-
// useful and leads to some confusing error messages. Instead it is better to let the below checks
|
|
64161
|
-
// take care of this, or to not elaborate at all. For instance,
|
|
64162
|
-
//
|
|
64163
|
-
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
|
|
64164
|
-
//
|
|
64165
|
-
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
|
|
64166
|
-
// than to report that 'D' is not assignable to 'A' or 'B'.
|
|
64167
|
-
//
|
|
64168
|
-
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
|
|
64169
|
-
// breaking the intersection apart.
|
|
64170
|
-
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
64171
|
-
}
|
|
64172
|
-
var flags = source.flags & target.flags;
|
|
64173
|
-
if (relation === identityRelation && !(flags & 524288 /* Object */)) {
|
|
64174
|
-
if (flags & 4194304 /* Index */) {
|
|
64234
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64175
64235
|
return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
|
|
64176
64236
|
}
|
|
64177
|
-
|
|
64178
|
-
|
|
64179
|
-
|
|
64180
|
-
|
|
64181
|
-
return result_8;
|
|
64237
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64238
|
+
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64239
|
+
if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64240
|
+
return result;
|
|
64182
64241
|
}
|
|
64183
64242
|
}
|
|
64184
64243
|
}
|
|
64185
|
-
if (
|
|
64244
|
+
if (sourceFlags & 16777216 /* Conditional */) {
|
|
64186
64245
|
if (source.root.isDistributive === target.root.isDistributive) {
|
|
64187
|
-
if (
|
|
64188
|
-
if (
|
|
64189
|
-
if (
|
|
64190
|
-
if (
|
|
64191
|
-
return
|
|
64246
|
+
if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64247
|
+
if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64248
|
+
if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64249
|
+
if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64250
|
+
return result;
|
|
64192
64251
|
}
|
|
64193
64252
|
}
|
|
64194
64253
|
}
|
|
64195
64254
|
}
|
|
64196
64255
|
}
|
|
64197
64256
|
}
|
|
64198
|
-
if (
|
|
64257
|
+
if (sourceFlags & 33554432 /* Substitution */) {
|
|
64199
64258
|
return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
|
|
64200
64259
|
}
|
|
64201
|
-
|
|
64260
|
+
if (!(sourceFlags & 524288 /* Object */)) {
|
|
64261
|
+
return 0 /* False */;
|
|
64262
|
+
}
|
|
64263
|
+
}
|
|
64264
|
+
else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
|
|
64265
|
+
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
64266
|
+
return result;
|
|
64267
|
+
}
|
|
64268
|
+
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
64269
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
64270
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
64271
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
64272
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
64273
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
64274
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
64275
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
64276
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
64277
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
64278
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
64279
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
64280
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
64281
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
64282
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
64283
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
64284
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
64285
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
64286
|
+
resetErrorInfo(saveErrorInfo);
|
|
64287
|
+
return result;
|
|
64288
|
+
}
|
|
64289
|
+
}
|
|
64290
|
+
}
|
|
64291
|
+
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
64292
|
+
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
64293
|
+
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64294
|
+
// Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
|
|
64295
|
+
// Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64296
|
+
// Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
|
|
64297
|
+
if (!(sourceFlags & 465829888 /* Instantiable */ ||
|
|
64298
|
+
sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
|
|
64299
|
+
sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
|
|
64300
|
+
return 0 /* False */;
|
|
64301
|
+
}
|
|
64202
64302
|
}
|
|
64203
|
-
var result;
|
|
64204
|
-
var originalErrorInfo;
|
|
64205
|
-
var varianceCheckFailed = false;
|
|
64206
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
64207
64303
|
// We limit alias variance probing to only object and conditional types since their alias behavior
|
|
64208
64304
|
// is more predictable than other, interned types, which may or may not have an alias depending on
|
|
64209
64305
|
// the order in which things were checked.
|
|
64210
|
-
if (
|
|
64306
|
+
if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
|
|
64211
64307
|
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
|
|
64212
64308
|
!(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
|
|
64213
64309
|
var variances = getAliasVariances(source.aliasSymbol);
|
|
@@ -64225,7 +64321,7 @@ var ts;
|
|
|
64225
64321
|
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
|
|
64226
64322
|
return result;
|
|
64227
64323
|
}
|
|
64228
|
-
if (
|
|
64324
|
+
if (targetFlags & 262144 /* TypeParameter */) {
|
|
64229
64325
|
// 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].
|
|
64230
64326
|
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
|
|
64231
64327
|
if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
|
|
@@ -64237,10 +64333,10 @@ var ts;
|
|
|
64237
64333
|
}
|
|
64238
64334
|
}
|
|
64239
64335
|
}
|
|
64240
|
-
else if (
|
|
64336
|
+
else if (targetFlags & 4194304 /* Index */) {
|
|
64241
64337
|
var targetType_1 = target.type;
|
|
64242
64338
|
// A keyof S is related to a keyof T if T is related to S.
|
|
64243
|
-
if (
|
|
64339
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64244
64340
|
if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64245
64341
|
return result;
|
|
64246
64342
|
}
|
|
@@ -64291,8 +64387,8 @@ var ts;
|
|
|
64291
64387
|
}
|
|
64292
64388
|
}
|
|
64293
64389
|
}
|
|
64294
|
-
else if (
|
|
64295
|
-
if (
|
|
64390
|
+
else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
64391
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64296
64392
|
// Relate components directly before falling back to constraint relationships
|
|
64297
64393
|
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
|
|
64298
64394
|
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
|
|
@@ -64398,7 +64494,7 @@ var ts;
|
|
|
64398
64494
|
}
|
|
64399
64495
|
}
|
|
64400
64496
|
}
|
|
64401
|
-
else if (
|
|
64497
|
+
else if (targetFlags & 16777216 /* Conditional */) {
|
|
64402
64498
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64403
64499
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64404
64500
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
@@ -64423,8 +64519,8 @@ var ts;
|
|
|
64423
64519
|
}
|
|
64424
64520
|
}
|
|
64425
64521
|
}
|
|
64426
|
-
else if (
|
|
64427
|
-
if (
|
|
64522
|
+
else if (targetFlags & 134217728 /* TemplateLiteral */) {
|
|
64523
|
+
if (sourceFlags & 134217728 /* TemplateLiteral */) {
|
|
64428
64524
|
if (relation === comparableRelation) {
|
|
64429
64525
|
return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
|
|
64430
64526
|
}
|
|
@@ -64436,11 +64532,11 @@ var ts;
|
|
|
64436
64532
|
return -1 /* True */;
|
|
64437
64533
|
}
|
|
64438
64534
|
}
|
|
64439
|
-
if (
|
|
64440
|
-
// IndexedAccess comparisons are handled above in the `
|
|
64441
|
-
if (!(
|
|
64535
|
+
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
64536
|
+
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
64537
|
+
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
64442
64538
|
var constraint = getConstraintOfType(source);
|
|
64443
|
-
if (!constraint || (
|
|
64539
|
+
if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
64444
64540
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
64445
64541
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
64446
64542
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64453,7 +64549,7 @@ var ts;
|
|
|
64453
64549
|
return result;
|
|
64454
64550
|
}
|
|
64455
64551
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
64456
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(
|
|
64552
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
64457
64553
|
resetErrorInfo(saveErrorInfo);
|
|
64458
64554
|
return result;
|
|
64459
64555
|
}
|
|
@@ -64470,14 +64566,14 @@ var ts;
|
|
|
64470
64566
|
}
|
|
64471
64567
|
}
|
|
64472
64568
|
}
|
|
64473
|
-
else if (
|
|
64569
|
+
else if (sourceFlags & 4194304 /* Index */) {
|
|
64474
64570
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
64475
64571
|
resetErrorInfo(saveErrorInfo);
|
|
64476
64572
|
return result;
|
|
64477
64573
|
}
|
|
64478
64574
|
}
|
|
64479
|
-
else if (
|
|
64480
|
-
if (!(
|
|
64575
|
+
else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
64576
|
+
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
64481
64577
|
var constraint = getBaseConstraintOfType(source);
|
|
64482
64578
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
64483
64579
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64485,8 +64581,8 @@ var ts;
|
|
|
64485
64581
|
}
|
|
64486
64582
|
}
|
|
64487
64583
|
}
|
|
64488
|
-
else if (
|
|
64489
|
-
if (
|
|
64584
|
+
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
64585
|
+
if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
|
|
64490
64586
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
64491
64587
|
resetErrorInfo(saveErrorInfo);
|
|
64492
64588
|
return result;
|
|
@@ -64500,14 +64596,14 @@ var ts;
|
|
|
64500
64596
|
}
|
|
64501
64597
|
}
|
|
64502
64598
|
}
|
|
64503
|
-
else if (
|
|
64599
|
+
else if (sourceFlags & 16777216 /* Conditional */) {
|
|
64504
64600
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64505
64601
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64506
64602
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
64507
64603
|
resetErrorInfo(saveErrorInfo);
|
|
64508
64604
|
return 3 /* Maybe */;
|
|
64509
64605
|
}
|
|
64510
|
-
if (
|
|
64606
|
+
if (targetFlags & 16777216 /* Conditional */) {
|
|
64511
64607
|
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
|
|
64512
64608
|
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
|
|
64513
64609
|
// and Y1 is related to Y2.
|
|
@@ -64567,15 +64663,21 @@ var ts;
|
|
|
64567
64663
|
}
|
|
64568
64664
|
return 0 /* False */;
|
|
64569
64665
|
}
|
|
64570
|
-
var sourceIsPrimitive = !!(
|
|
64666
|
+
var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
|
|
64571
64667
|
if (relation !== identityRelation) {
|
|
64572
64668
|
source = getApparentType(source);
|
|
64669
|
+
sourceFlags = source.flags;
|
|
64573
64670
|
}
|
|
64574
64671
|
else if (isGenericMappedType(source)) {
|
|
64575
64672
|
return 0 /* False */;
|
|
64576
64673
|
}
|
|
64577
64674
|
if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target &&
|
|
64578
64675
|
!isTupleType(source) && !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) {
|
|
64676
|
+
// When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType,
|
|
64677
|
+
// and an empty array literal wouldn't be assignable to a `never[]` without this check.
|
|
64678
|
+
if (isEmptyArrayLiteralType(source)) {
|
|
64679
|
+
return -1 /* True */;
|
|
64680
|
+
}
|
|
64579
64681
|
// We have type references to the same generic type, and the type references are not marker
|
|
64580
64682
|
// type references (which are intended by be compared structurally). Obtain the variance
|
|
64581
64683
|
// information for the type parameters and relate the type arguments accordingly.
|
|
@@ -64611,7 +64713,7 @@ var ts;
|
|
|
64611
64713
|
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
|
|
64612
64714
|
// to X. Failing both of those we want to check if the aggregation of A and B's members structurally
|
|
64613
64715
|
// relates to X. Thus, we include intersection types on the source side here.
|
|
64614
|
-
if (
|
|
64716
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
|
|
64615
64717
|
// Report structural errors only if we haven't reported any errors yet
|
|
64616
64718
|
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
|
|
64617
64719
|
result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
|
|
@@ -64635,7 +64737,7 @@ var ts;
|
|
|
64635
64737
|
// there exists a constituent of T for every combination of the discriminants of S
|
|
64636
64738
|
// with respect to T. We do not report errors here, as we will use the existing
|
|
64637
64739
|
// error result from checking each constituent of the union.
|
|
64638
|
-
if (
|
|
64740
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
|
|
64639
64741
|
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
|
|
64640
64742
|
if (objectOnlyTarget.flags & 1048576 /* Union */) {
|
|
64641
64743
|
var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
|
|
@@ -64882,6 +64984,15 @@ var ts;
|
|
|
64882
64984
|
}
|
|
64883
64985
|
return 0 /* False */;
|
|
64884
64986
|
}
|
|
64987
|
+
// Ensure {readonly a: whatever} is not a subtype of {a: whatever},
|
|
64988
|
+
// while {a: whatever} is a subtype of {readonly a: whatever}.
|
|
64989
|
+
// This ensures the subtype relationship is ordered, and preventing declaration order
|
|
64990
|
+
// from deciding which type "wins" in union subtype reduction.
|
|
64991
|
+
// They're still assignable to one another, since `readonly` doesn't affect assignability.
|
|
64992
|
+
if ((relation === subtypeRelation || relation === strictSubtypeRelation) &&
|
|
64993
|
+
!!(sourcePropFlags & 64 /* Readonly */) && !(targetPropFlags & 64 /* Readonly */)) {
|
|
64994
|
+
return 0 /* False */;
|
|
64995
|
+
}
|
|
64885
64996
|
// If the target comes from a partial union prop, allow `undefined` in the target type
|
|
64886
64997
|
var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
|
|
64887
64998
|
if (!related) {
|
|
@@ -65150,7 +65261,6 @@ var ts;
|
|
|
65150
65261
|
}
|
|
65151
65262
|
}
|
|
65152
65263
|
var result = -1 /* True */;
|
|
65153
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
65154
65264
|
var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
|
|
65155
65265
|
var sourceObjectFlags = ts.getObjectFlags(source);
|
|
65156
65266
|
var targetObjectFlags = ts.getObjectFlags(target);
|
|
@@ -65191,6 +65301,7 @@ var ts;
|
|
|
65191
65301
|
else {
|
|
65192
65302
|
outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
|
|
65193
65303
|
var t = targetSignatures_1[_i];
|
|
65304
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
65194
65305
|
// Only elaborate errors from the first failure
|
|
65195
65306
|
var shouldElaborateErrors = reportErrors;
|
|
65196
65307
|
for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
|
|
@@ -68361,9 +68472,6 @@ var ts;
|
|
|
68361
68472
|
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
|
|
68362
68473
|
mapType(type, mapper);
|
|
68363
68474
|
}
|
|
68364
|
-
function getConstituentCount(type) {
|
|
68365
|
-
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
68366
|
-
}
|
|
68367
68475
|
function extractTypesOfKind(type, kind) {
|
|
68368
68476
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
68369
68477
|
}
|
|
@@ -73084,6 +73192,9 @@ var ts;
|
|
|
73084
73192
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
73085
73193
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
73086
73194
|
}
|
|
73195
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
|
|
73196
|
+
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
73197
|
+
}
|
|
73087
73198
|
}
|
|
73088
73199
|
else {
|
|
73089
73200
|
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
|
|
@@ -75568,8 +75679,8 @@ var ts;
|
|
|
75568
75679
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75569
75680
|
var synthType = type;
|
|
75570
75681
|
if (!synthType.defaultOnlyType) {
|
|
75571
|
-
var
|
|
75572
|
-
synthType.defaultOnlyType =
|
|
75682
|
+
var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75683
|
+
synthType.defaultOnlyType = type_5;
|
|
75573
75684
|
}
|
|
75574
75685
|
return synthType.defaultOnlyType;
|
|
75575
75686
|
}
|
|
@@ -76029,21 +76140,22 @@ var ts;
|
|
|
76029
76140
|
if (links.type === unknownType) {
|
|
76030
76141
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
76031
76142
|
}
|
|
76032
|
-
assignBindingElementTypes(declaration.name);
|
|
76143
|
+
assignBindingElementTypes(declaration.name, links.type);
|
|
76033
76144
|
}
|
|
76034
76145
|
}
|
|
76035
76146
|
}
|
|
76036
76147
|
// When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
|
|
76037
76148
|
// the destructured type into the contained binding elements.
|
|
76038
|
-
function assignBindingElementTypes(pattern) {
|
|
76149
|
+
function assignBindingElementTypes(pattern, parentType) {
|
|
76039
76150
|
for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
|
|
76040
76151
|
var element = _a[_i];
|
|
76041
76152
|
if (!ts.isOmittedExpression(element)) {
|
|
76153
|
+
var type = getBindingElementTypeFromParentType(element, parentType);
|
|
76042
76154
|
if (element.name.kind === 79 /* Identifier */) {
|
|
76043
|
-
getSymbolLinks(getSymbolOfNode(element)).type =
|
|
76155
|
+
getSymbolLinks(getSymbolOfNode(element)).type = type;
|
|
76044
76156
|
}
|
|
76045
76157
|
else {
|
|
76046
|
-
assignBindingElementTypes(element.name);
|
|
76158
|
+
assignBindingElementTypes(element.name, type);
|
|
76047
76159
|
}
|
|
76048
76160
|
}
|
|
76049
76161
|
}
|
|
@@ -76296,12 +76408,12 @@ var ts;
|
|
|
76296
76408
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
76297
76409
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
76298
76410
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
76299
|
-
var
|
|
76411
|
+
var type_6 = getBaseConstraintOfType(operandType) || operandType;
|
|
76300
76412
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
76301
|
-
if (
|
|
76413
|
+
if (type_6.flags & 3 /* AnyOrUnknown */) {
|
|
76302
76414
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
76303
76415
|
}
|
|
76304
|
-
return !!(filterType(
|
|
76416
|
+
return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
76305
76417
|
}
|
|
76306
76418
|
var type = getTypeOfExpression(node.expression);
|
|
76307
76419
|
if (!isLiteralType(type)) {
|
|
@@ -78423,6 +78535,7 @@ var ts;
|
|
|
78423
78535
|
}
|
|
78424
78536
|
}
|
|
78425
78537
|
checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
|
|
78538
|
+
checkUnmatchedJSDocParameters(node);
|
|
78426
78539
|
ts.forEach(node.parameters, checkParameter);
|
|
78427
78540
|
// TODO(rbuckton): Should we start checking JSDoc types?
|
|
78428
78541
|
if (node.type) {
|
|
@@ -79783,28 +79896,24 @@ var ts;
|
|
|
79783
79896
|
if (returnType.flags & 1 /* Any */) {
|
|
79784
79897
|
return;
|
|
79785
79898
|
}
|
|
79899
|
+
var headMessage;
|
|
79786
79900
|
var expectedReturnType;
|
|
79787
|
-
var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
|
79788
|
-
var errorInfo;
|
|
79789
79901
|
switch (node.parent.kind) {
|
|
79790
79902
|
case 256 /* ClassDeclaration */:
|
|
79903
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
79791
79904
|
var classSymbol = getSymbolOfNode(node.parent);
|
|
79792
79905
|
var classConstructorType = getTypeOfSymbol(classSymbol);
|
|
79793
79906
|
expectedReturnType = getUnionType([classConstructorType, voidType]);
|
|
79794
79907
|
break;
|
|
79795
|
-
case 163 /* Parameter */:
|
|
79796
|
-
expectedReturnType = voidType;
|
|
79797
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
79798
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
|
|
79799
|
-
break;
|
|
79800
79908
|
case 166 /* PropertyDeclaration */:
|
|
79909
|
+
case 163 /* Parameter */:
|
|
79910
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
|
|
79801
79911
|
expectedReturnType = voidType;
|
|
79802
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
79803
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
|
|
79804
79912
|
break;
|
|
79805
79913
|
case 168 /* MethodDeclaration */:
|
|
79806
79914
|
case 171 /* GetAccessor */:
|
|
79807
79915
|
case 172 /* SetAccessor */:
|
|
79916
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
79808
79917
|
var methodType = getTypeOfNode(node.parent);
|
|
79809
79918
|
var descriptorType = createTypedPropertyDescriptorType(methodType);
|
|
79810
79919
|
expectedReturnType = getUnionType([descriptorType, voidType]);
|
|
@@ -79812,7 +79921,7 @@ var ts;
|
|
|
79812
79921
|
default:
|
|
79813
79922
|
return ts.Debug.fail();
|
|
79814
79923
|
}
|
|
79815
|
-
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage
|
|
79924
|
+
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
|
|
79816
79925
|
}
|
|
79817
79926
|
/**
|
|
79818
79927
|
* If a TypeNode can be resolved to a value symbol imported from an external module, it is
|
|
@@ -79994,31 +80103,6 @@ var ts;
|
|
|
79994
80103
|
}
|
|
79995
80104
|
function checkJSDocParameterTag(node) {
|
|
79996
80105
|
checkSourceElement(node.typeExpression);
|
|
79997
|
-
if (!ts.getParameterSymbolFromJSDoc(node)) {
|
|
79998
|
-
var decl = ts.getHostSignatureFromJSDoc(node);
|
|
79999
|
-
// don't issue an error for invalid hosts -- just functions --
|
|
80000
|
-
// and give a better error message when the host function mentions `arguments`
|
|
80001
|
-
// but the tag doesn't have an array type
|
|
80002
|
-
if (decl) {
|
|
80003
|
-
var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
|
|
80004
|
-
if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
|
|
80005
|
-
return;
|
|
80006
|
-
}
|
|
80007
|
-
if (!containsArgumentsReference(decl)) {
|
|
80008
|
-
if (ts.isQualifiedName(node.name)) {
|
|
80009
|
-
error(node.name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(node.name), ts.entityNameToString(node.name.left));
|
|
80010
|
-
}
|
|
80011
|
-
else {
|
|
80012
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
|
|
80013
|
-
}
|
|
80014
|
-
}
|
|
80015
|
-
else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
|
|
80016
|
-
node.typeExpression && node.typeExpression.type &&
|
|
80017
|
-
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
|
|
80018
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 160 /* QualifiedName */ ? node.name.right : node.name));
|
|
80019
|
-
}
|
|
80020
|
-
}
|
|
80021
|
-
}
|
|
80022
80106
|
}
|
|
80023
80107
|
function checkJSDocPropertyTag(node) {
|
|
80024
80108
|
checkSourceElement(node.typeExpression);
|
|
@@ -82091,6 +82175,45 @@ var ts;
|
|
|
82091
82175
|
error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
|
|
82092
82176
|
}
|
|
82093
82177
|
}
|
|
82178
|
+
function checkUnmatchedJSDocParameters(node) {
|
|
82179
|
+
var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
|
|
82180
|
+
if (!ts.length(jsdocParameters))
|
|
82181
|
+
return;
|
|
82182
|
+
var isJs = ts.isInJSFile(node);
|
|
82183
|
+
var parameters = new ts.Set();
|
|
82184
|
+
var excludedParameters = new ts.Set();
|
|
82185
|
+
ts.forEach(node.parameters, function (_a, index) {
|
|
82186
|
+
var name = _a.name;
|
|
82187
|
+
if (ts.isIdentifier(name)) {
|
|
82188
|
+
parameters.add(name.escapedText);
|
|
82189
|
+
}
|
|
82190
|
+
if (ts.isBindingPattern(name)) {
|
|
82191
|
+
excludedParameters.add(index);
|
|
82192
|
+
}
|
|
82193
|
+
});
|
|
82194
|
+
var containsArguments = containsArgumentsReference(node);
|
|
82195
|
+
if (containsArguments) {
|
|
82196
|
+
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82197
|
+
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82198
|
+
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82199
|
+
errorOrSuggestion(isJs, lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
|
|
82200
|
+
}
|
|
82201
|
+
}
|
|
82202
|
+
else {
|
|
82203
|
+
ts.forEach(jsdocParameters, function (_a, index) {
|
|
82204
|
+
var name = _a.name;
|
|
82205
|
+
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
82206
|
+
return;
|
|
82207
|
+
}
|
|
82208
|
+
if (ts.isQualifiedName(name)) {
|
|
82209
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82210
|
+
}
|
|
82211
|
+
else {
|
|
82212
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
82213
|
+
}
|
|
82214
|
+
});
|
|
82215
|
+
}
|
|
82216
|
+
}
|
|
82094
82217
|
/**
|
|
82095
82218
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
82096
82219
|
*/
|
|
@@ -83299,6 +83422,9 @@ var ts;
|
|
|
83299
83422
|
var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
|
|
83300
83423
|
addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
|
|
83301
83424
|
}
|
|
83425
|
+
if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
|
|
83426
|
+
error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
|
|
83427
|
+
}
|
|
83302
83428
|
break;
|
|
83303
83429
|
}
|
|
83304
83430
|
case 274 /* ExportSpecifier */: {
|
|
@@ -85343,7 +85469,7 @@ var ts;
|
|
|
85343
85469
|
if (resolvedTypeReferenceDirectives) {
|
|
85344
85470
|
// populate reverse mapping: file path -> type reference directive that was resolved to this file
|
|
85345
85471
|
fileToDirective = new ts.Map();
|
|
85346
|
-
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
|
|
85472
|
+
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
|
|
85347
85473
|
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
|
|
85348
85474
|
return;
|
|
85349
85475
|
}
|
|
@@ -85351,7 +85477,7 @@ var ts;
|
|
|
85351
85477
|
if (file) {
|
|
85352
85478
|
// Add the transitive closure of path references loaded by this file (as long as they are not)
|
|
85353
85479
|
// part of an existing type reference.
|
|
85354
|
-
addReferencedFilesToTypeDirective(file, key);
|
|
85480
|
+
addReferencedFilesToTypeDirective(file, key, mode);
|
|
85355
85481
|
}
|
|
85356
85482
|
});
|
|
85357
85483
|
}
|
|
@@ -85545,16 +85671,16 @@ var ts;
|
|
|
85545
85671
|
}
|
|
85546
85672
|
return false;
|
|
85547
85673
|
}
|
|
85548
|
-
function addReferencedFilesToTypeDirective(file, key) {
|
|
85674
|
+
function addReferencedFilesToTypeDirective(file, key, mode) {
|
|
85549
85675
|
if (fileToDirective.has(file.path))
|
|
85550
85676
|
return;
|
|
85551
|
-
fileToDirective.set(file.path, key);
|
|
85677
|
+
fileToDirective.set(file.path, [key, mode]);
|
|
85552
85678
|
for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
|
|
85553
|
-
var
|
|
85679
|
+
var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
|
|
85554
85680
|
var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
|
|
85555
85681
|
var referencedFile = host.getSourceFile(resolvedFile);
|
|
85556
85682
|
if (referencedFile) {
|
|
85557
|
-
addReferencedFilesToTypeDirective(referencedFile, key);
|
|
85683
|
+
addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
|
|
85558
85684
|
}
|
|
85559
85685
|
}
|
|
85560
85686
|
}
|
|
@@ -87259,28 +87385,27 @@ var ts;
|
|
|
87259
87385
|
}
|
|
87260
87386
|
function findMostOverlappyType(source, unionTarget) {
|
|
87261
87387
|
var bestMatch;
|
|
87262
|
-
|
|
87263
|
-
|
|
87264
|
-
var
|
|
87265
|
-
|
|
87266
|
-
|
|
87267
|
-
|
|
87268
|
-
|
|
87269
|
-
|
|
87270
|
-
|
|
87271
|
-
|
|
87272
|
-
|
|
87273
|
-
|
|
87274
|
-
|
|
87275
|
-
|
|
87276
|
-
|
|
87277
|
-
|
|
87278
|
-
|
|
87279
|
-
|
|
87280
|
-
|
|
87281
|
-
|
|
87282
|
-
|
|
87283
|
-
matchingCount = 1;
|
|
87388
|
+
if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87389
|
+
var matchingCount = 0;
|
|
87390
|
+
for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
|
|
87391
|
+
var target = _a[_i];
|
|
87392
|
+
if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87393
|
+
var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
|
|
87394
|
+
if (overlap.flags & 4194304 /* Index */) {
|
|
87395
|
+
// perfect overlap of keys
|
|
87396
|
+
return target;
|
|
87397
|
+
}
|
|
87398
|
+
else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
|
|
87399
|
+
// We only want to account for literal types otherwise.
|
|
87400
|
+
// If we have a union of index types, it seems likely that we
|
|
87401
|
+
// needed to elaborate between two generic mapped types anyway.
|
|
87402
|
+
var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
|
|
87403
|
+
if (len >= matchingCount) {
|
|
87404
|
+
bestMatch = target;
|
|
87405
|
+
matchingCount = len;
|
|
87406
|
+
}
|
|
87407
|
+
}
|
|
87408
|
+
}
|
|
87284
87409
|
}
|
|
87285
87410
|
}
|
|
87286
87411
|
return bestMatch;
|
|
@@ -106323,7 +106448,7 @@ var ts;
|
|
|
106323
106448
|
var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
|
|
106324
106449
|
hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
|
|
106325
106450
|
collectReferences(sourceFile, refs);
|
|
106326
|
-
recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
|
|
106451
|
+
recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
|
|
106327
106452
|
collectLibs(sourceFile, libs);
|
|
106328
106453
|
return sourceFile;
|
|
106329
106454
|
}
|
|
@@ -106378,9 +106503,10 @@ var ts;
|
|
|
106378
106503
|
return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
|
|
106379
106504
|
}
|
|
106380
106505
|
function getFileReferencesForUsedTypeReferences() {
|
|
106381
|
-
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()),
|
|
106506
|
+
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
|
|
106382
106507
|
}
|
|
106383
|
-
function
|
|
106508
|
+
function getFileReferenceForSpecifierModeTuple(_a) {
|
|
106509
|
+
var typeName = _a[0], mode = _a[1];
|
|
106384
106510
|
// Elide type references for which we have imports
|
|
106385
106511
|
if (emittedImports) {
|
|
106386
106512
|
for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
|
|
@@ -106396,7 +106522,7 @@ var ts;
|
|
|
106396
106522
|
}
|
|
106397
106523
|
}
|
|
106398
106524
|
}
|
|
106399
|
-
return { fileName: typeName, pos: -1, end: -1 };
|
|
106525
|
+
return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
|
|
106400
106526
|
}
|
|
106401
106527
|
function mapReferencesIntoArray(references, outputFilePath) {
|
|
106402
106528
|
return function (file) {
|
|
@@ -106416,7 +106542,7 @@ var ts;
|
|
|
106416
106542
|
// If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration
|
|
106417
106543
|
// via a non-relative name, emit a type reference directive to that non-relative name, rather than
|
|
106418
106544
|
// a relative path to the declaration file
|
|
106419
|
-
recordTypeReferenceDirectivesIfNecessary([specifier]);
|
|
106545
|
+
recordTypeReferenceDirectivesIfNecessary([[specifier, /*mode*/ undefined]]);
|
|
106420
106546
|
return;
|
|
106421
106547
|
}
|
|
106422
106548
|
var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName,
|
|
@@ -111528,9 +111654,12 @@ var ts;
|
|
|
111528
111654
|
for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
|
|
111529
111655
|
var directive = types_24[_d];
|
|
111530
111656
|
var pos = writer.getTextPos();
|
|
111531
|
-
|
|
111657
|
+
var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
|
|
111658
|
+
? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
|
|
111659
|
+
: "";
|
|
111660
|
+
writeComment("/// <reference types=\"" + directive.fileName + "\" " + resolutionMode + "/>");
|
|
111532
111661
|
if (bundleFileInfo)
|
|
111533
|
-
bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName });
|
|
111662
|
+
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 });
|
|
111534
111663
|
writeLine();
|
|
111535
111664
|
}
|
|
111536
111665
|
for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
|
|
@@ -114137,7 +114266,7 @@ var ts;
|
|
|
114137
114266
|
}
|
|
114138
114267
|
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
|
|
114139
114268
|
/* @internal */
|
|
114140
|
-
function
|
|
114269
|
+
function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
|
|
114141
114270
|
if (names.length === 0) {
|
|
114142
114271
|
return [];
|
|
114143
114272
|
}
|
|
@@ -114146,19 +114275,28 @@ var ts;
|
|
|
114146
114275
|
for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
|
|
114147
114276
|
var name = names_2[_i];
|
|
114148
114277
|
var result = void 0;
|
|
114149
|
-
|
|
114150
|
-
|
|
114278
|
+
var mode = getModeForFileReference(name, containingFileMode);
|
|
114279
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
114280
|
+
var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
|
|
114281
|
+
var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
|
|
114282
|
+
if (cache.has(cacheKey)) {
|
|
114283
|
+
result = cache.get(cacheKey);
|
|
114151
114284
|
}
|
|
114152
114285
|
else {
|
|
114153
|
-
cache.set(
|
|
114286
|
+
cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
|
|
114154
114287
|
}
|
|
114155
114288
|
resolutions.push(result);
|
|
114156
114289
|
}
|
|
114157
114290
|
return resolutions;
|
|
114158
114291
|
}
|
|
114159
|
-
ts.
|
|
114292
|
+
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
114160
114293
|
;
|
|
114161
114294
|
/* @internal */
|
|
114295
|
+
function getModeForFileReference(ref, containingFileMode) {
|
|
114296
|
+
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
114297
|
+
}
|
|
114298
|
+
ts.getModeForFileReference = getModeForFileReference;
|
|
114299
|
+
/* @internal */
|
|
114162
114300
|
function getModeForResolutionAtIndex(file, index) {
|
|
114163
114301
|
if (file.impliedNodeFormat === undefined)
|
|
114164
114302
|
return undefined;
|
|
@@ -114261,7 +114399,7 @@ var ts;
|
|
|
114261
114399
|
var _d, _e, _f, _g;
|
|
114262
114400
|
var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
|
|
114263
114401
|
var kind = ref.kind, index = ref.index;
|
|
114264
|
-
var pos, end, packageId;
|
|
114402
|
+
var pos, end, packageId, resolutionMode;
|
|
114265
114403
|
switch (kind) {
|
|
114266
114404
|
case ts.FileIncludeKind.Import:
|
|
114267
114405
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
@@ -114275,8 +114413,8 @@ var ts;
|
|
|
114275
114413
|
(_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
|
|
114276
114414
|
break;
|
|
114277
114415
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
114278
|
-
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
114279
|
-
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;
|
|
114416
|
+
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
|
|
114417
|
+
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;
|
|
114280
114418
|
break;
|
|
114281
114419
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
114282
114420
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -114520,7 +114658,7 @@ var ts;
|
|
|
114520
114658
|
var fileReasons = ts.createMultiMap();
|
|
114521
114659
|
var cachedBindAndCheckDiagnosticsForFile = {};
|
|
114522
114660
|
var cachedDeclarationDiagnosticsForFile = {};
|
|
114523
|
-
var resolvedTypeReferenceDirectives =
|
|
114661
|
+
var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
|
|
114524
114662
|
var fileProcessingDiagnostics;
|
|
114525
114663
|
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
|
|
114526
114664
|
// This works as imported modules are discovered recursively in a depth first manner, specifically:
|
|
@@ -114573,12 +114711,12 @@ var ts;
|
|
|
114573
114711
|
}
|
|
114574
114712
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
114575
114713
|
if (host.resolveTypeReferenceDirectives) {
|
|
114576
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
|
|
114714
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
|
|
114577
114715
|
}
|
|
114578
114716
|
else {
|
|
114579
114717
|
typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
114580
|
-
var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114581
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return
|
|
114718
|
+
var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114719
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
|
|
114582
114720
|
}
|
|
114583
114721
|
// Map from a stringified PackageId to the source file with that id.
|
|
114584
114722
|
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
|
|
@@ -114675,7 +114813,8 @@ var ts;
|
|
|
114675
114813
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
114676
114814
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
114677
114815
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
114678
|
-
|
|
114816
|
+
// under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
|
|
114817
|
+
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 });
|
|
114679
114818
|
}
|
|
114680
114819
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
114681
114820
|
}
|
|
@@ -114835,9 +114974,10 @@ var ts;
|
|
|
114835
114974
|
return [];
|
|
114836
114975
|
var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
|
|
114837
114976
|
var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
|
|
114977
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
114838
114978
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
|
|
114839
114979
|
ts.performance.mark("beforeResolveTypeReference");
|
|
114840
|
-
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
|
|
114980
|
+
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
|
|
114841
114981
|
ts.performance.mark("afterResolveTypeReference");
|
|
114842
114982
|
ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
|
|
114843
114983
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -115229,8 +115369,7 @@ var ts;
|
|
|
115229
115369
|
else {
|
|
115230
115370
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
115231
115371
|
}
|
|
115232
|
-
|
|
115233
|
-
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
115372
|
+
var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
|
115234
115373
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
115235
115374
|
// ensure that types resolutions are still correct
|
|
115236
115375
|
var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
@@ -116309,8 +116448,7 @@ var ts;
|
|
|
116309
116448
|
});
|
|
116310
116449
|
}
|
|
116311
116450
|
function processTypeReferenceDirectives(file) {
|
|
116312
|
-
|
|
116313
|
-
var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
116451
|
+
var typeDirectives = file.typeReferenceDirectives;
|
|
116314
116452
|
if (!typeDirectives) {
|
|
116315
116453
|
return;
|
|
116316
116454
|
}
|
|
@@ -116321,17 +116459,21 @@ var ts;
|
|
|
116321
116459
|
// store resolved type directive on the file
|
|
116322
116460
|
var fileName = ts.toFileNameLowerCase(ref.fileName);
|
|
116323
116461
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
116324
|
-
|
|
116462
|
+
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
116463
|
+
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
116464
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext));
|
|
116465
|
+
}
|
|
116466
|
+
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
116325
116467
|
}
|
|
116326
116468
|
}
|
|
116327
|
-
function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116469
|
+
function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116328
116470
|
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 });
|
|
116329
|
-
processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
|
|
116471
|
+
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
|
|
116330
116472
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116331
116473
|
}
|
|
116332
|
-
function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116474
|
+
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116333
116475
|
// If we already found this library as a primary reference - nothing to do
|
|
116334
|
-
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
|
|
116476
|
+
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
|
|
116335
116477
|
if (previousResolution && previousResolution.primary) {
|
|
116336
116478
|
return;
|
|
116337
116479
|
}
|
|
@@ -116370,7 +116512,7 @@ var ts;
|
|
|
116370
116512
|
addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
|
|
116371
116513
|
}
|
|
116372
116514
|
if (saveResolution) {
|
|
116373
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
|
|
116515
|
+
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
|
|
116374
116516
|
}
|
|
116375
116517
|
}
|
|
116376
116518
|
function pathForLibFile(libFileName) {
|
|
@@ -119188,9 +119330,9 @@ var ts;
|
|
|
119188
119330
|
});
|
|
119189
119331
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
119190
119332
|
}
|
|
119191
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
|
|
119333
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
|
|
119192
119334
|
var _a;
|
|
119193
|
-
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
|
|
119335
|
+
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
|
|
119194
119336
|
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
|
|
119195
119337
|
if (!resolutionHost.getGlobalCache) {
|
|
119196
119338
|
return primaryResult;
|
|
@@ -119211,12 +119353,12 @@ var ts;
|
|
|
119211
119353
|
// Default return the result from the first pass
|
|
119212
119354
|
return primaryResult;
|
|
119213
119355
|
}
|
|
119214
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
|
|
119215
|
-
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
|
|
119356
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
|
|
119357
|
+
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
|
|
119216
119358
|
}
|
|
119217
119359
|
function resolveNamesWithLocalCache(_a) {
|
|
119218
119360
|
var _b, _c, _d;
|
|
119219
|
-
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;
|
|
119361
|
+
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;
|
|
119220
119362
|
var path = resolutionHost.toPath(containingFile);
|
|
119221
119363
|
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
119222
119364
|
var dirPath = ts.getDirectoryPath(path);
|
|
@@ -119238,8 +119380,15 @@ var ts;
|
|
|
119238
119380
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
119239
119381
|
var i = 0;
|
|
119240
119382
|
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
119241
|
-
var
|
|
119242
|
-
var
|
|
119383
|
+
var entry = names_4[_i];
|
|
119384
|
+
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
119385
|
+
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
119386
|
+
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
119387
|
+
// import's syntax may override the file's default mode.
|
|
119388
|
+
// Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
|
|
119389
|
+
// a default file mode override if applicable.
|
|
119390
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
|
|
119391
|
+
containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
119243
119392
|
i++;
|
|
119244
119393
|
var resolution = resolutionsInFile.get(name, mode);
|
|
119245
119394
|
// Resolution is valid if it is present and not invalidated
|
|
@@ -119268,7 +119417,7 @@ var ts;
|
|
|
119268
119417
|
}
|
|
119269
119418
|
}
|
|
119270
119419
|
else {
|
|
119271
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
119420
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
119272
119421
|
perDirectoryResolution.set(name, mode, resolution);
|
|
119273
119422
|
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
119274
119423
|
resolutionHost.onDiscoveredSymlink();
|
|
@@ -119332,7 +119481,7 @@ var ts;
|
|
|
119332
119481
|
return oldResult.resolvedFileName === newResult.resolvedFileName;
|
|
119333
119482
|
}
|
|
119334
119483
|
}
|
|
119335
|
-
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
|
|
119484
|
+
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
|
|
119336
119485
|
return resolveNamesWithLocalCache({
|
|
119337
119486
|
names: typeDirectiveNames,
|
|
119338
119487
|
containingFile: containingFile,
|
|
@@ -119342,6 +119491,7 @@ var ts;
|
|
|
119342
119491
|
loader: resolveTypeReferenceDirective,
|
|
119343
119492
|
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
|
|
119344
119493
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
119494
|
+
containingSourceFileMode: containingFileMode
|
|
119345
119495
|
});
|
|
119346
119496
|
}
|
|
119347
119497
|
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
@@ -121250,7 +121400,7 @@ var ts;
|
|
|
121250
121400
|
}
|
|
121251
121401
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
121252
121402
|
}) :
|
|
121253
|
-
(function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
|
|
121403
|
+
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
121254
121404
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
121255
121405
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
121256
121406
|
synchronizeProgram();
|
|
@@ -121986,9 +122136,9 @@ var ts;
|
|
|
121986
122136
|
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
121987
122137
|
}
|
|
121988
122138
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
121989
|
-
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|
|
121990
|
-
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
|
|
121991
|
-
return ts.
|
|
122139
|
+
var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
|
|
122140
|
+
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
122141
|
+
return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
|
|
121992
122142
|
};
|
|
121993
122143
|
}
|
|
121994
122144
|
var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
|