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/tsserver.js
CHANGED
|
@@ -96,11 +96,11 @@ var ts;
|
|
|
96
96
|
(function (ts) {
|
|
97
97
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
98
98
|
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
|
99
|
-
ts.versionMajorMinor = "4.
|
|
99
|
+
ts.versionMajorMinor = "4.7";
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220216";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -4840,6 +4840,8 @@ var ts;
|
|
|
4840
4840
|
TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike";
|
|
4841
4841
|
TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike";
|
|
4842
4842
|
/* @internal */
|
|
4843
|
+
TypeFlags[TypeFlags["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
|
|
4844
|
+
/* @internal */
|
|
4843
4845
|
TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains";
|
|
4844
4846
|
TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
4845
4847
|
TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType";
|
|
@@ -5572,6 +5574,8 @@ var ts;
|
|
|
5572
5574
|
BundleFileSectionKind["NoDefaultLib"] = "no-default-lib";
|
|
5573
5575
|
BundleFileSectionKind["Reference"] = "reference";
|
|
5574
5576
|
BundleFileSectionKind["Type"] = "type";
|
|
5577
|
+
BundleFileSectionKind["TypeResolutionModeRequire"] = "type-require";
|
|
5578
|
+
BundleFileSectionKind["TypeResolutionModeImport"] = "type-import";
|
|
5575
5579
|
BundleFileSectionKind["Lib"] = "lib";
|
|
5576
5580
|
BundleFileSectionKind["Prepend"] = "prepend";
|
|
5577
5581
|
BundleFileSectionKind["Text"] = "text";
|
|
@@ -5688,7 +5692,8 @@ var ts;
|
|
|
5688
5692
|
{ name: "types", optional: true, captureSpan: true },
|
|
5689
5693
|
{ name: "lib", optional: true, captureSpan: true },
|
|
5690
5694
|
{ name: "path", optional: true, captureSpan: true },
|
|
5691
|
-
{ name: "no-default-lib", optional: true }
|
|
5695
|
+
{ name: "no-default-lib", optional: true },
|
|
5696
|
+
{ name: "resolution-mode", optional: true }
|
|
5692
5697
|
],
|
|
5693
5698
|
kind: 1 /* TripleSlashXML */
|
|
5694
5699
|
},
|
|
@@ -7636,18 +7641,6 @@ var ts;
|
|
|
7636
7641
|
return getCanonicalFileName(nonCanonicalizedPath);
|
|
7637
7642
|
}
|
|
7638
7643
|
ts.toPath = toPath;
|
|
7639
|
-
function normalizePathAndParts(path) {
|
|
7640
|
-
path = normalizeSlashes(path);
|
|
7641
|
-
var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
|
|
7642
|
-
if (parts.length) {
|
|
7643
|
-
var joinedParts = root + parts.join(ts.directorySeparator);
|
|
7644
|
-
return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
|
|
7645
|
-
}
|
|
7646
|
-
else {
|
|
7647
|
-
return { path: root, parts: parts };
|
|
7648
|
-
}
|
|
7649
|
-
}
|
|
7650
|
-
ts.normalizePathAndParts = normalizePathAndParts;
|
|
7651
7644
|
function removeTrailingDirectorySeparator(path) {
|
|
7652
7645
|
if (hasTrailingDirectorySeparator(path)) {
|
|
7653
7646
|
return path.substr(0, path.length - 1);
|
|
@@ -8080,6 +8073,9 @@ var ts;
|
|
|
8080
8073
|
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."),
|
|
8081
8074
|
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."),
|
|
8082
8075
|
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."),
|
|
8076
|
+
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."),
|
|
8077
|
+
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}'."),
|
|
8078
|
+
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'."),
|
|
8083
8079
|
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."),
|
|
8084
8080
|
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."),
|
|
8085
8081
|
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."),
|
|
@@ -8213,6 +8209,8 @@ var ts;
|
|
|
8213
8209
|
Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
|
|
8214
8210
|
Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
|
|
8215
8211
|
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
|
|
8212
|
+
Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."),
|
|
8213
|
+
resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
|
|
8216
8214
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8217
8215
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8218
8216
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -9638,6 +9636,9 @@ var ts;
|
|
|
9638
9636
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9639
9637
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9640
9638
|
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9639
|
+
Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
|
|
9640
|
+
Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
|
|
9641
|
+
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}'"),
|
|
9641
9642
|
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."),
|
|
9642
9643
|
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'."),
|
|
9643
9644
|
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?"),
|
|
@@ -14093,7 +14094,11 @@ var ts;
|
|
|
14093
14094
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14094
14095
|
for (var i = 0; i < names.length; i++) {
|
|
14095
14096
|
var newResolution = newResolutions[i];
|
|
14096
|
-
var
|
|
14097
|
+
var entry = names[i];
|
|
14098
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
14099
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
14100
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
|
|
14101
|
+
var oldResolution = oldResolutions && oldResolutions.get(name, mode);
|
|
14097
14102
|
var changed = oldResolution
|
|
14098
14103
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14099
14104
|
: newResolution;
|
|
@@ -26688,7 +26693,13 @@ var ts;
|
|
|
26688
26693
|
referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
|
|
26689
26694
|
break;
|
|
26690
26695
|
case "type" /* Type */:
|
|
26691
|
-
typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
|
|
26696
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
26697
|
+
break;
|
|
26698
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26699
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
|
|
26700
|
+
break;
|
|
26701
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26702
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
|
|
26692
26703
|
break;
|
|
26693
26704
|
case "lib" /* Lib */:
|
|
26694
26705
|
libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
@@ -26747,6 +26758,8 @@ var ts;
|
|
|
26747
26758
|
case "no-default-lib" /* NoDefaultLib */:
|
|
26748
26759
|
case "reference" /* Reference */:
|
|
26749
26760
|
case "type" /* Type */:
|
|
26761
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26762
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26750
26763
|
case "lib" /* Lib */:
|
|
26751
26764
|
syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
|
|
26752
26765
|
break;
|
|
@@ -30660,7 +30673,7 @@ var ts;
|
|
|
30660
30673
|
initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
|
|
30661
30674
|
// Prime the scanner.
|
|
30662
30675
|
nextToken();
|
|
30663
|
-
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
30676
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false);
|
|
30664
30677
|
var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
|
|
30665
30678
|
clearState();
|
|
30666
30679
|
return isInvalid ? entityName : undefined;
|
|
@@ -32237,7 +32250,7 @@ var ts;
|
|
|
32237
32250
|
}
|
|
32238
32251
|
return createMissingList();
|
|
32239
32252
|
}
|
|
32240
|
-
function parseEntityName(allowReservedWords, diagnosticMessage) {
|
|
32253
|
+
function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) {
|
|
32241
32254
|
var pos = getNodePos();
|
|
32242
32255
|
var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
|
|
32243
32256
|
var dotPos = getNodePos();
|
|
@@ -32248,7 +32261,7 @@ var ts;
|
|
|
32248
32261
|
break;
|
|
32249
32262
|
}
|
|
32250
32263
|
dotPos = getNodePos();
|
|
32251
|
-
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords,
|
|
32264
|
+
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos);
|
|
32252
32265
|
}
|
|
32253
32266
|
return entity;
|
|
32254
32267
|
}
|
|
@@ -32381,7 +32394,7 @@ var ts;
|
|
|
32381
32394
|
}
|
|
32382
32395
|
// TYPES
|
|
32383
32396
|
function parseEntityNameOfTypeReference() {
|
|
32384
|
-
return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
|
|
32397
|
+
return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected);
|
|
32385
32398
|
}
|
|
32386
32399
|
function parseTypeArgumentsOfTypeReference() {
|
|
32387
32400
|
if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) {
|
|
@@ -32514,7 +32527,7 @@ var ts;
|
|
|
32514
32527
|
function parseTypeQuery() {
|
|
32515
32528
|
var pos = getNodePos();
|
|
32516
32529
|
parseExpected(112 /* TypeOfKeyword */);
|
|
32517
|
-
return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos);
|
|
32530
|
+
return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true)), pos);
|
|
32518
32531
|
}
|
|
32519
32532
|
function parseTypeParameter() {
|
|
32520
32533
|
var pos = getNodePos();
|
|
@@ -35085,11 +35098,12 @@ var ts;
|
|
|
35085
35098
|
}
|
|
35086
35099
|
function parseCaseClause() {
|
|
35087
35100
|
var pos = getNodePos();
|
|
35101
|
+
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35088
35102
|
parseExpected(82 /* CaseKeyword */);
|
|
35089
35103
|
var expression = allowInAnd(parseExpression);
|
|
35090
35104
|
parseExpected(58 /* ColonToken */);
|
|
35091
35105
|
var statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
|
|
35092
|
-
return finishNode(factory.createCaseClause(expression, statements), pos);
|
|
35106
|
+
return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
|
|
35093
35107
|
}
|
|
35094
35108
|
function parseDefaultClause() {
|
|
35095
35109
|
var pos = getNodePos();
|
|
@@ -36252,7 +36266,7 @@ var ts;
|
|
|
36252
36266
|
function parseModuleReference() {
|
|
36253
36267
|
return isExternalModuleReference()
|
|
36254
36268
|
? parseExternalModuleReference()
|
|
36255
|
-
: parseEntityName(/*allowReservedWords*/ false);
|
|
36269
|
+
: parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36256
36270
|
}
|
|
36257
36271
|
function parseExternalModuleReference() {
|
|
36258
36272
|
var pos = getNodePos();
|
|
@@ -36534,7 +36548,7 @@ var ts;
|
|
|
36534
36548
|
var pos = getNodePos();
|
|
36535
36549
|
var hasBrace = parseOptional(18 /* OpenBraceToken */);
|
|
36536
36550
|
var p2 = getNodePos();
|
|
36537
|
-
var entityName = parseEntityName(/* allowReservedWords*/ false);
|
|
36551
|
+
var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36538
36552
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
36539
36553
|
reScanHashToken(); // rescan #id as # id
|
|
36540
36554
|
nextTokenJSDoc(); // then skip the #
|
|
@@ -36977,7 +36991,7 @@ var ts;
|
|
|
36977
36991
|
// parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
|
|
36978
36992
|
var p2 = getNodePos();
|
|
36979
36993
|
var name = ts.tokenIsIdentifierOrKeyword(token())
|
|
36980
|
-
? parseEntityName(/*allowReservedWords*/ true)
|
|
36994
|
+
? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false)
|
|
36981
36995
|
: undefined;
|
|
36982
36996
|
if (name) {
|
|
36983
36997
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
@@ -37002,11 +37016,13 @@ var ts;
|
|
|
37002
37016
|
&& nextTokenJSDoc() === 59 /* AtToken */
|
|
37003
37017
|
&& ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
|
|
37004
37018
|
var kind = scanner.getTokenValue();
|
|
37005
|
-
if (kind
|
|
37019
|
+
if (isJSDocLinkTag(kind))
|
|
37006
37020
|
return kind;
|
|
37007
|
-
}
|
|
37008
37021
|
}
|
|
37009
37022
|
}
|
|
37023
|
+
function isJSDocLinkTag(kind) {
|
|
37024
|
+
return kind === "link" || kind === "linkcode" || kind === "linkplain";
|
|
37025
|
+
}
|
|
37010
37026
|
function parseUnknownTag(start, tagName, indent, indentText) {
|
|
37011
37027
|
return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
|
|
37012
37028
|
}
|
|
@@ -37112,7 +37128,7 @@ var ts;
|
|
|
37112
37128
|
}
|
|
37113
37129
|
function parseSeeTag(start, tagName, indent, indentText) {
|
|
37114
37130
|
var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
|
|
37115
|
-
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue()
|
|
37131
|
+
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); });
|
|
37116
37132
|
var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
|
|
37117
37133
|
var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
|
|
37118
37134
|
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
|
|
@@ -37979,6 +37995,19 @@ var ts;
|
|
|
37979
37995
|
return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
|
|
37980
37996
|
}
|
|
37981
37997
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
37998
|
+
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
37999
|
+
if (!mode) {
|
|
38000
|
+
return undefined;
|
|
38001
|
+
}
|
|
38002
|
+
if (mode === "import") {
|
|
38003
|
+
return ts.ModuleKind.ESNext;
|
|
38004
|
+
}
|
|
38005
|
+
if (mode === "require") {
|
|
38006
|
+
return ts.ModuleKind.CommonJS;
|
|
38007
|
+
}
|
|
38008
|
+
reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
|
|
38009
|
+
return undefined;
|
|
38010
|
+
}
|
|
37982
38011
|
/*@internal*/
|
|
37983
38012
|
function processCommentPragmas(context, sourceText) {
|
|
37984
38013
|
var pragmas = [];
|
|
@@ -38021,12 +38050,13 @@ var ts;
|
|
|
38021
38050
|
var typeReferenceDirectives_1 = context.typeReferenceDirectives;
|
|
38022
38051
|
var libReferenceDirectives_1 = context.libReferenceDirectives;
|
|
38023
38052
|
ts.forEach(ts.toArray(entryOrList), function (arg) {
|
|
38024
|
-
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
|
|
38053
|
+
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
|
|
38025
38054
|
if (arg.arguments["no-default-lib"]) {
|
|
38026
38055
|
context.hasNoDefaultLib = true;
|
|
38027
38056
|
}
|
|
38028
38057
|
else if (types) {
|
|
38029
|
-
|
|
38058
|
+
var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
|
|
38059
|
+
typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
|
|
38030
38060
|
}
|
|
38031
38061
|
else if (lib) {
|
|
38032
38062
|
libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
|
|
@@ -41604,14 +41634,14 @@ var ts;
|
|
|
41604
41634
|
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
|
41605
41635
|
* is assumed to be the same as root directory of the project.
|
|
41606
41636
|
*/
|
|
41607
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
|
|
41637
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
|
|
41608
41638
|
var traceEnabled = isTraceEnabled(options, host);
|
|
41609
41639
|
if (redirectedReference) {
|
|
41610
41640
|
options = redirectedReference.commandLine.options;
|
|
41611
41641
|
}
|
|
41612
41642
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41613
41643
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41614
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/
|
|
41644
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
|
|
41615
41645
|
if (result) {
|
|
41616
41646
|
if (traceEnabled) {
|
|
41617
41647
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41646,7 +41676,18 @@ var ts;
|
|
|
41646
41676
|
}
|
|
41647
41677
|
var failedLookupLocations = [];
|
|
41648
41678
|
var features = getDefaultNodeResolutionFeatures(options);
|
|
41649
|
-
|
|
41679
|
+
// Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
|
|
41680
|
+
// setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
|
|
41681
|
+
// set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports
|
|
41682
|
+
// 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,
|
|
41683
|
+
// 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
|
|
41684
|
+
// resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution
|
|
41685
|
+
// context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do).
|
|
41686
|
+
if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
|
|
41687
|
+
features |= NodeResolutionFeatures.EsmMode;
|
|
41688
|
+
}
|
|
41689
|
+
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
41690
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
|
|
41650
41691
|
var resolved = primaryLookup();
|
|
41651
41692
|
var primary = true;
|
|
41652
41693
|
if (!resolved) {
|
|
@@ -41666,7 +41707,7 @@ var ts;
|
|
|
41666
41707
|
};
|
|
41667
41708
|
}
|
|
41668
41709
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41669
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/
|
|
41710
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
41670
41711
|
if (traceEnabled)
|
|
41671
41712
|
traceResult(result);
|
|
41672
41713
|
return result;
|
|
@@ -41717,7 +41758,7 @@ var ts;
|
|
|
41717
41758
|
result_4 = searchResult && searchResult.value;
|
|
41718
41759
|
}
|
|
41719
41760
|
else {
|
|
41720
|
-
var candidate =
|
|
41761
|
+
var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
|
|
41721
41762
|
result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
|
|
41722
41763
|
}
|
|
41723
41764
|
return resolvedTypeScriptOnly(result_4);
|
|
@@ -41952,7 +41993,11 @@ var ts;
|
|
|
41952
41993
|
ts.Debug.assert(keys.length === values.length);
|
|
41953
41994
|
var map = createModeAwareCache();
|
|
41954
41995
|
for (var i = 0; i < keys.length; ++i) {
|
|
41955
|
-
|
|
41996
|
+
var entry = keys[i];
|
|
41997
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
41998
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
41999
|
+
var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
|
|
42000
|
+
map.set(name, mode, values[i]);
|
|
41956
42001
|
}
|
|
41957
42002
|
return map;
|
|
41958
42003
|
}
|
|
@@ -42420,13 +42465,25 @@ var ts;
|
|
|
42420
42465
|
return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
|
|
42421
42466
|
}
|
|
42422
42467
|
else {
|
|
42423
|
-
var _a =
|
|
42468
|
+
var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
|
|
42424
42469
|
var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
|
|
42425
42470
|
// Treat explicit "node_modules" import as an external library import.
|
|
42426
42471
|
return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
|
|
42427
42472
|
}
|
|
42428
42473
|
}
|
|
42429
42474
|
}
|
|
42475
|
+
// If you import from "." inside a containing directory "/foo", the result of `normalizePath`
|
|
42476
|
+
// would be "/foo", but this loses the information that `foo` is a directory and we intended
|
|
42477
|
+
// to look inside of it. The Node CommonJS resolution algorithm doesn't call this out
|
|
42478
|
+
// (https://nodejs.org/api/modules.html#all-together), but it seems that module paths ending
|
|
42479
|
+
// in `.` are actually normalized to `./` before proceeding with the resolution algorithm.
|
|
42480
|
+
function normalizePathForCJSResolution(containingDirectory, moduleName) {
|
|
42481
|
+
var combined = ts.combinePaths(containingDirectory, moduleName);
|
|
42482
|
+
var parts = ts.getPathComponents(combined);
|
|
42483
|
+
var lastPart = ts.lastOrUndefined(parts);
|
|
42484
|
+
var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
|
|
42485
|
+
return { path: path, parts: parts };
|
|
42486
|
+
}
|
|
42430
42487
|
function realPath(path, host, traceEnabled) {
|
|
42431
42488
|
if (!host.realpath) {
|
|
42432
42489
|
return path;
|
|
@@ -42468,7 +42525,13 @@ var ts;
|
|
|
42468
42525
|
onlyRecordFailures = true;
|
|
42469
42526
|
}
|
|
42470
42527
|
}
|
|
42471
|
-
|
|
42528
|
+
// esm mode relative imports shouldn't do any directory lookups (either inside `package.json`
|
|
42529
|
+
// files or implicit `index.js`es). This is a notable depature from cjs norms, where `./foo/pkg`
|
|
42530
|
+
// could have been redirected by `./foo/pkg/package.json` to an arbitrary location!
|
|
42531
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42532
|
+
return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
|
|
42533
|
+
}
|
|
42534
|
+
return undefined;
|
|
42472
42535
|
}
|
|
42473
42536
|
/*@internal*/
|
|
42474
42537
|
ts.nodeModulesPathPart = "/node_modules/";
|
|
@@ -42835,7 +42898,16 @@ var ts;
|
|
|
42835
42898
|
// Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types"
|
|
42836
42899
|
var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
|
|
42837
42900
|
// Don't do package.json lookup recursively, because Node.js' package lookup doesn't.
|
|
42838
|
-
|
|
42901
|
+
// Disable `EsmMode` for the resolution of the package path for cjs-mode packages (so the `main` field can omit extensions)
|
|
42902
|
+
// (technically it only emits a deprecation warning in esm packages right now, but that's probably
|
|
42903
|
+
// enough to mean we don't need to support it)
|
|
42904
|
+
var features = state.features;
|
|
42905
|
+
if ((jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.type) !== "module") {
|
|
42906
|
+
state.features &= ~NodeResolutionFeatures.EsmMode;
|
|
42907
|
+
}
|
|
42908
|
+
var result = nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ false);
|
|
42909
|
+
state.features = features;
|
|
42910
|
+
return result;
|
|
42839
42911
|
};
|
|
42840
42912
|
var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
|
|
42841
42913
|
var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
|
|
@@ -43180,6 +43252,14 @@ var ts;
|
|
|
43180
43252
|
}
|
|
43181
43253
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
43182
43254
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
43255
|
+
if (!pathAndExtension && packageInfo
|
|
43256
|
+
&& packageInfo.packageJsonContent.exports === undefined
|
|
43257
|
+
&& packageInfo.packageJsonContent.main === undefined
|
|
43258
|
+
&& state.features & NodeResolutionFeatures.EsmMode) {
|
|
43259
|
+
// EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
|
|
43260
|
+
// a default `index.js` entrypoint if no `main` or `exports` are present
|
|
43261
|
+
pathAndExtension = loadModuleFromFile(extensions, ts.combinePaths(candidate, "index.js"), onlyRecordFailures, state);
|
|
43262
|
+
}
|
|
43183
43263
|
return withPackageId(packageInfo, pathAndExtension);
|
|
43184
43264
|
};
|
|
43185
43265
|
if (rest !== "") { // If "rest" is empty, we just did this search above.
|
|
@@ -46937,8 +47017,7 @@ var ts;
|
|
|
46937
47017
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
46938
47018
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
46939
47019
|
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
46940
|
-
IntersectionState[IntersectionState["
|
|
46941
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
|
|
47020
|
+
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
46942
47021
|
})(IntersectionState || (IntersectionState = {}));
|
|
46943
47022
|
var RecursionFlags;
|
|
46944
47023
|
(function (RecursionFlags) {
|
|
@@ -50397,8 +50476,15 @@ var ts;
|
|
|
50397
50476
|
return res;
|
|
50398
50477
|
}
|
|
50399
50478
|
var candidates = ts.mapDefined(symbol.declarations, function (d) {
|
|
50400
|
-
if (!ts.isAmbientModule(d) && d.parent
|
|
50401
|
-
|
|
50479
|
+
if (!ts.isAmbientModule(d) && d.parent) {
|
|
50480
|
+
// direct children of a module
|
|
50481
|
+
if (hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
|
|
50482
|
+
return getSymbolOfNode(d.parent);
|
|
50483
|
+
}
|
|
50484
|
+
// export ='d member of an ambient module
|
|
50485
|
+
if (ts.isModuleBlock(d.parent) && d.parent.parent && resolveExternalModuleSymbol(getSymbolOfNode(d.parent.parent)) === symbol) {
|
|
50486
|
+
return getSymbolOfNode(d.parent.parent);
|
|
50487
|
+
}
|
|
50402
50488
|
}
|
|
50403
50489
|
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)) {
|
|
50404
50490
|
if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
|
|
@@ -54635,12 +54721,9 @@ var ts;
|
|
|
54635
54721
|
}
|
|
54636
54722
|
}
|
|
54637
54723
|
if (ts.isInJSFile(declaration)) {
|
|
54638
|
-
var
|
|
54639
|
-
if (
|
|
54640
|
-
|
|
54641
|
-
var pos = func.parameters.indexOf(declaration);
|
|
54642
|
-
return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
54643
|
-
}
|
|
54724
|
+
var type_1 = getParameterTypeOfTypeTag(func, declaration);
|
|
54725
|
+
if (type_1)
|
|
54726
|
+
return type_1;
|
|
54644
54727
|
}
|
|
54645
54728
|
// Use contextual parameter type if one is available
|
|
54646
54729
|
var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
|
|
@@ -55207,9 +55290,9 @@ var ts;
|
|
|
55207
55290
|
if (typeNode === undefined) {
|
|
55208
55291
|
return useUnknownInCatchVariables ? unknownType : anyType;
|
|
55209
55292
|
}
|
|
55210
|
-
var
|
|
55293
|
+
var type_2 = getTypeOfNode(typeNode);
|
|
55211
55294
|
// an errorType will make `checkTryStatement` issue an error
|
|
55212
|
-
return isTypeAny(
|
|
55295
|
+
return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
|
|
55213
55296
|
}
|
|
55214
55297
|
// Handle export default expressions
|
|
55215
55298
|
if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
|
|
@@ -55438,11 +55521,11 @@ var ts;
|
|
|
55438
55521
|
return errorType;
|
|
55439
55522
|
}
|
|
55440
55523
|
var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
|
|
55441
|
-
var
|
|
55524
|
+
var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
|
|
55442
55525
|
if (!popTypeResolution()) {
|
|
55443
55526
|
return reportCircularityError(symbol);
|
|
55444
55527
|
}
|
|
55445
|
-
return
|
|
55528
|
+
return type_3;
|
|
55446
55529
|
}
|
|
55447
55530
|
}
|
|
55448
55531
|
var type = createObjectType(16 /* Anonymous */, symbol);
|
|
@@ -57674,10 +57757,10 @@ var ts;
|
|
|
57674
57757
|
var baseTypes = [];
|
|
57675
57758
|
var different = false;
|
|
57676
57759
|
for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
|
|
57677
|
-
var
|
|
57678
|
-
var baseType = getBaseConstraint(
|
|
57760
|
+
var type_4 = types_7[_i];
|
|
57761
|
+
var baseType = getBaseConstraint(type_4);
|
|
57679
57762
|
if (baseType) {
|
|
57680
|
-
if (baseType !==
|
|
57763
|
+
if (baseType !== type_4) {
|
|
57681
57764
|
different = true;
|
|
57682
57765
|
}
|
|
57683
57766
|
baseTypes.push(baseType);
|
|
@@ -58390,6 +58473,13 @@ var ts;
|
|
|
58390
58473
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
58391
58474
|
return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
58392
58475
|
}
|
|
58476
|
+
function getParameterTypeOfTypeTag(func, parameter) {
|
|
58477
|
+
var signature = getSignatureOfTypeTag(func);
|
|
58478
|
+
if (!signature)
|
|
58479
|
+
return undefined;
|
|
58480
|
+
var pos = func.parameters.indexOf(parameter);
|
|
58481
|
+
return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
|
|
58482
|
+
}
|
|
58393
58483
|
function getReturnTypeOfTypeTag(node) {
|
|
58394
58484
|
var signature = getSignatureOfTypeTag(node);
|
|
58395
58485
|
return signature && getReturnTypeOfSignature(signature);
|
|
@@ -58648,13 +58738,15 @@ var ts;
|
|
|
58648
58738
|
return signature;
|
|
58649
58739
|
}
|
|
58650
58740
|
function getOrCreateTypeFromSignature(signature) {
|
|
58741
|
+
var _a;
|
|
58651
58742
|
// There are two ways to declare a construct signature, one is by declaring a class constructor
|
|
58652
58743
|
// using the constructor keyword, and the other is declaring a bare construct signature in an
|
|
58653
58744
|
// object type literal or interface (using the new keyword). Each way of declaring a constructor
|
|
58654
58745
|
// will result in a different declaration kind.
|
|
58655
58746
|
if (!signature.isolatedSignatureType) {
|
|
58656
|
-
var kind =
|
|
58657
|
-
|
|
58747
|
+
var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
|
|
58748
|
+
// If declaration is undefined, it is likely to be the signature of the default constructor.
|
|
58749
|
+
var isConstructor = kind === undefined || kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */;
|
|
58658
58750
|
var type = createObjectType(16 /* Anonymous */);
|
|
58659
58751
|
type.members = emptySymbols;
|
|
58660
58752
|
type.properties = ts.emptyArray;
|
|
@@ -59582,7 +59674,7 @@ var ts;
|
|
|
59582
59674
|
}
|
|
59583
59675
|
}
|
|
59584
59676
|
var fixedLength = properties.length;
|
|
59585
|
-
var lengthSymbol = createSymbol(4 /* Property */, "length");
|
|
59677
|
+
var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
|
|
59586
59678
|
if (combinedFlags & 12 /* Variable */) {
|
|
59587
59679
|
lengthSymbol.type = numberType;
|
|
59588
59680
|
}
|
|
@@ -63129,9 +63221,11 @@ var ts;
|
|
|
63129
63221
|
isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
|
|
63130
63222
|
return true;
|
|
63131
63223
|
}
|
|
63132
|
-
|
|
63224
|
+
// In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`.
|
|
63225
|
+
// Since unions and intersections may reduce to `never`, we exclude them here.
|
|
63226
|
+
if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */)))
|
|
63133
63227
|
return true;
|
|
63134
|
-
if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */))
|
|
63228
|
+
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
63135
63229
|
return true;
|
|
63136
63230
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
|
|
63137
63231
|
return true;
|
|
@@ -63220,11 +63314,11 @@ var ts;
|
|
|
63220
63314
|
var overflow = false;
|
|
63221
63315
|
var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
|
|
63222
63316
|
var lastSkippedInfo;
|
|
63223
|
-
var incompatibleStack
|
|
63317
|
+
var incompatibleStack;
|
|
63224
63318
|
var inPropertyCheck = false;
|
|
63225
63319
|
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
63226
63320
|
var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
|
|
63227
|
-
if (incompatibleStack
|
|
63321
|
+
if (incompatibleStack) {
|
|
63228
63322
|
reportIncompatibleStack();
|
|
63229
63323
|
}
|
|
63230
63324
|
if (overflow) {
|
|
@@ -63281,19 +63375,19 @@ var ts;
|
|
|
63281
63375
|
return {
|
|
63282
63376
|
errorInfo: errorInfo,
|
|
63283
63377
|
lastSkippedInfo: lastSkippedInfo,
|
|
63284
|
-
incompatibleStack: incompatibleStack.slice(),
|
|
63378
|
+
incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
|
|
63285
63379
|
overrideNextErrorInfo: overrideNextErrorInfo,
|
|
63286
|
-
relatedInfo:
|
|
63380
|
+
relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
|
|
63287
63381
|
};
|
|
63288
63382
|
}
|
|
63289
63383
|
function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
|
|
63290
63384
|
overrideNextErrorInfo++; // Suppress the next relation error
|
|
63291
63385
|
lastSkippedInfo = undefined; // Reset skipped info cache
|
|
63292
|
-
incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
|
|
63386
|
+
(incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
|
|
63293
63387
|
}
|
|
63294
63388
|
function reportIncompatibleStack() {
|
|
63295
|
-
var stack = incompatibleStack;
|
|
63296
|
-
incompatibleStack =
|
|
63389
|
+
var stack = incompatibleStack || [];
|
|
63390
|
+
incompatibleStack = undefined;
|
|
63297
63391
|
var info = lastSkippedInfo;
|
|
63298
63392
|
lastSkippedInfo = undefined;
|
|
63299
63393
|
if (stack.length === 1) {
|
|
@@ -63399,7 +63493,7 @@ var ts;
|
|
|
63399
63493
|
}
|
|
63400
63494
|
function reportError(message, arg0, arg1, arg2, arg3) {
|
|
63401
63495
|
ts.Debug.assert(!!errorNode);
|
|
63402
|
-
if (incompatibleStack
|
|
63496
|
+
if (incompatibleStack)
|
|
63403
63497
|
reportIncompatibleStack();
|
|
63404
63498
|
if (message.elidedInCompatabilityPyramid)
|
|
63405
63499
|
return;
|
|
@@ -63415,7 +63509,7 @@ var ts;
|
|
|
63415
63509
|
}
|
|
63416
63510
|
}
|
|
63417
63511
|
function reportRelationError(message, source, target) {
|
|
63418
|
-
if (incompatibleStack
|
|
63512
|
+
if (incompatibleStack)
|
|
63419
63513
|
reportIncompatibleStack();
|
|
63420
63514
|
var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
|
|
63421
63515
|
var generalizedSource = source;
|
|
@@ -63527,7 +63621,9 @@ var ts;
|
|
|
63527
63621
|
if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
|
|
63528
63622
|
return -1 /* True */;
|
|
63529
63623
|
}
|
|
63530
|
-
|
|
63624
|
+
if (reportErrors) {
|
|
63625
|
+
reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
|
|
63626
|
+
}
|
|
63531
63627
|
return 0 /* False */;
|
|
63532
63628
|
}
|
|
63533
63629
|
// Normalize the source and target types: Turn fresh literal types into regular literal types,
|
|
@@ -63539,7 +63635,12 @@ var ts;
|
|
|
63539
63635
|
if (source === target)
|
|
63540
63636
|
return -1 /* True */;
|
|
63541
63637
|
if (relation === identityRelation) {
|
|
63542
|
-
|
|
63638
|
+
if (source.flags !== target.flags)
|
|
63639
|
+
return 0 /* False */;
|
|
63640
|
+
if (source.flags & 67358815 /* Singleton */)
|
|
63641
|
+
return -1 /* True */;
|
|
63642
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63643
|
+
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63543
63644
|
}
|
|
63544
63645
|
// We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
|
|
63545
63646
|
// and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
|
|
@@ -63549,163 +63650,130 @@ var ts;
|
|
|
63549
63650
|
if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
|
|
63550
63651
|
return -1 /* True */;
|
|
63551
63652
|
}
|
|
63552
|
-
//
|
|
63553
|
-
// If so,
|
|
63554
|
-
|
|
63555
|
-
|
|
63556
|
-
|
|
63557
|
-
|
|
63558
|
-
|
|
63559
|
-
|
|
63560
|
-
|
|
63561
|
-
|
|
63562
|
-
|
|
63563
|
-
|
|
63564
|
-
if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) {
|
|
63565
|
-
target = getNormalizedType(nullStrippedTarget, /*writing*/ true);
|
|
63566
|
-
}
|
|
63567
|
-
if (source === nullStrippedTarget)
|
|
63568
|
-
return -1 /* True */;
|
|
63653
|
+
// See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
|
|
63654
|
+
// plus a single non-nullable type. If so, remove null and/or undefined from the target type.
|
|
63655
|
+
if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
|
|
63656
|
+
var types = target.types;
|
|
63657
|
+
var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
|
|
63658
|
+
types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
|
|
63659
|
+
undefined;
|
|
63660
|
+
if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
|
|
63661
|
+
target = getNormalizedType(candidate, /*writing*/ true);
|
|
63662
|
+
if (source === target)
|
|
63663
|
+
return -1 /* True */;
|
|
63664
|
+
}
|
|
63569
63665
|
}
|
|
63570
63666
|
if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
|
|
63571
63667
|
isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
|
|
63572
63668
|
return -1 /* True */;
|
|
63573
|
-
|
|
63574
|
-
|
|
63575
|
-
|
|
63576
|
-
|
|
63669
|
+
if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
|
|
63670
|
+
var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
|
|
63671
|
+
if (isPerformingExcessPropertyChecks) {
|
|
63672
|
+
if (hasExcessProperties(source, target, reportErrors)) {
|
|
63673
|
+
if (reportErrors) {
|
|
63674
|
+
reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
|
|
63675
|
+
}
|
|
63676
|
+
return 0 /* False */;
|
|
63677
|
+
}
|
|
63678
|
+
}
|
|
63679
|
+
var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
|
|
63680
|
+
source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
|
|
63681
|
+
target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
|
|
63682
|
+
(getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
|
|
63683
|
+
var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
|
|
63684
|
+
if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
|
|
63577
63685
|
if (reportErrors) {
|
|
63578
|
-
|
|
63686
|
+
var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
|
|
63687
|
+
var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
|
|
63688
|
+
var calls = getSignaturesOfType(source, 0 /* Call */);
|
|
63689
|
+
var constructs = getSignaturesOfType(source, 1 /* Construct */);
|
|
63690
|
+
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
|
|
63691
|
+
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
63692
|
+
reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
|
|
63693
|
+
}
|
|
63694
|
+
else {
|
|
63695
|
+
reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
|
|
63696
|
+
}
|
|
63579
63697
|
}
|
|
63580
63698
|
return 0 /* False */;
|
|
63581
63699
|
}
|
|
63582
|
-
|
|
63583
|
-
|
|
63584
|
-
|
|
63585
|
-
|
|
63586
|
-
|
|
63587
|
-
|
|
63588
|
-
|
|
63589
|
-
|
|
63590
|
-
|
|
63591
|
-
|
|
63592
|
-
|
|
63593
|
-
|
|
63594
|
-
|
|
63595
|
-
|
|
63596
|
-
|
|
63597
|
-
|
|
63598
|
-
|
|
63599
|
-
|
|
63700
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63701
|
+
var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
|
|
63702
|
+
target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
|
|
63703
|
+
var result_7 = skipCaching ?
|
|
63704
|
+
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
63705
|
+
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
63706
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
63707
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
63708
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
63709
|
+
//
|
|
63710
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63711
|
+
//
|
|
63712
|
+
// declare let wrong: { a: { y: string } };
|
|
63713
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63714
|
+
//
|
|
63715
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63716
|
+
// x = y; // Mismatched property in source intersection
|
|
63717
|
+
// }
|
|
63718
|
+
//
|
|
63719
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63720
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63721
|
+
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63722
|
+
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 */); }))) {
|
|
63723
|
+
inPropertyCheck = true;
|
|
63724
|
+
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63725
|
+
inPropertyCheck = false;
|
|
63726
|
+
}
|
|
63727
|
+
if (result_7) {
|
|
63728
|
+
return result_7;
|
|
63600
63729
|
}
|
|
63601
|
-
return 0 /* False */;
|
|
63602
|
-
}
|
|
63603
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63604
|
-
var result = 0 /* False */;
|
|
63605
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
63606
|
-
if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
|
|
63607
|
-
// We skip caching when source or target is a union with no more than three constituents.
|
|
63608
|
-
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63609
63730
|
}
|
|
63610
|
-
|
|
63611
|
-
|
|
63731
|
+
if (reportErrors) {
|
|
63732
|
+
reportErrorResults(originalSource, originalTarget, source, target, headMessage);
|
|
63612
63733
|
}
|
|
63613
|
-
|
|
63614
|
-
|
|
63615
|
-
|
|
63734
|
+
return 0 /* False */;
|
|
63735
|
+
}
|
|
63736
|
+
function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
|
|
63737
|
+
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63738
|
+
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63739
|
+
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63740
|
+
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63741
|
+
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63742
|
+
if (maybeSuppress) {
|
|
63743
|
+
overrideNextErrorInfo--;
|
|
63744
|
+
}
|
|
63745
|
+
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63746
|
+
var currentError = errorInfo;
|
|
63747
|
+
tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
|
|
63748
|
+
if (errorInfo !== currentError) {
|
|
63749
|
+
maybeSuppress = !!errorInfo;
|
|
63750
|
+
}
|
|
63751
|
+
}
|
|
63752
|
+
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63753
|
+
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63754
|
+
}
|
|
63755
|
+
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63756
|
+
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63757
|
+
}
|
|
63758
|
+
else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
|
|
63759
|
+
var targetTypes = target.types;
|
|
63760
|
+
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63761
|
+
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63762
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63763
|
+
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63764
|
+
// do not report top error
|
|
63765
|
+
return;
|
|
63616
63766
|
}
|
|
63617
63767
|
}
|
|
63618
|
-
|
|
63619
|
-
|
|
63620
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
63621
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
63622
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
63623
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
63624
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
63625
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
63626
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
63627
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
63628
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
63629
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
63630
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
63631
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
63632
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
63633
|
-
if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
|
|
63634
|
-
if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
63635
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
63636
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63637
|
-
resetErrorInfo(saveErrorInfo);
|
|
63638
|
-
}
|
|
63639
|
-
}
|
|
63640
|
-
}
|
|
63768
|
+
else {
|
|
63769
|
+
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63641
63770
|
}
|
|
63642
|
-
|
|
63643
|
-
|
|
63644
|
-
|
|
63645
|
-
|
|
63646
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63647
|
-
//
|
|
63648
|
-
// declare let wrong: { a: { y: string } };
|
|
63649
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63650
|
-
//
|
|
63651
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63652
|
-
// x = y; // Mismatched property in source intersection
|
|
63653
|
-
// }
|
|
63654
|
-
//
|
|
63655
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63656
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63657
|
-
if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63658
|
-
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 */); }))) {
|
|
63659
|
-
inPropertyCheck = true;
|
|
63660
|
-
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63661
|
-
inPropertyCheck = false;
|
|
63662
|
-
}
|
|
63663
|
-
reportErrorResults(source, target, result, isComparingJsxAttributes);
|
|
63664
|
-
return result;
|
|
63665
|
-
function reportErrorResults(source, target, result, isComparingJsxAttributes) {
|
|
63666
|
-
if (!result && reportErrors) {
|
|
63667
|
-
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63668
|
-
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63669
|
-
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63670
|
-
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63671
|
-
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63672
|
-
if (maybeSuppress) {
|
|
63673
|
-
overrideNextErrorInfo--;
|
|
63674
|
-
}
|
|
63675
|
-
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63676
|
-
var currentError = errorInfo;
|
|
63677
|
-
tryElaborateArrayLikeErrors(source, target, reportErrors);
|
|
63678
|
-
if (errorInfo !== currentError) {
|
|
63679
|
-
maybeSuppress = !!errorInfo;
|
|
63680
|
-
}
|
|
63681
|
-
}
|
|
63682
|
-
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63683
|
-
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63684
|
-
}
|
|
63685
|
-
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63686
|
-
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63687
|
-
}
|
|
63688
|
-
else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) {
|
|
63689
|
-
var targetTypes = target.types;
|
|
63690
|
-
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63691
|
-
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63692
|
-
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63693
|
-
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63694
|
-
// do not report top error
|
|
63695
|
-
return result;
|
|
63696
|
-
}
|
|
63697
|
-
}
|
|
63698
|
-
else {
|
|
63699
|
-
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63700
|
-
}
|
|
63701
|
-
if (!headMessage && maybeSuppress) {
|
|
63702
|
-
lastSkippedInfo = [source, target];
|
|
63703
|
-
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63704
|
-
return result;
|
|
63705
|
-
}
|
|
63706
|
-
reportRelationError(headMessage, source, target);
|
|
63707
|
-
}
|
|
63771
|
+
if (!headMessage && maybeSuppress) {
|
|
63772
|
+
lastSkippedInfo = [source, target];
|
|
63773
|
+
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63774
|
+
return;
|
|
63708
63775
|
}
|
|
63776
|
+
reportRelationError(headMessage, source, target);
|
|
63709
63777
|
}
|
|
63710
63778
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
63711
63779
|
if (!ts.tracing) {
|
|
@@ -63732,21 +63800,6 @@ var ts;
|
|
|
63732
63800
|
}
|
|
63733
63801
|
}
|
|
63734
63802
|
}
|
|
63735
|
-
function isIdenticalTo(source, target, recursionFlags) {
|
|
63736
|
-
if (source.flags !== target.flags)
|
|
63737
|
-
return 0 /* False */;
|
|
63738
|
-
if (source.flags & 67358815 /* Singleton */)
|
|
63739
|
-
return -1 /* True */;
|
|
63740
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63741
|
-
if (source.flags & 3145728 /* UnionOrIntersection */) {
|
|
63742
|
-
var result_7 = eachTypeRelatedToSomeType(source, target);
|
|
63743
|
-
if (result_7) {
|
|
63744
|
-
result_7 &= eachTypeRelatedToSomeType(target, source);
|
|
63745
|
-
}
|
|
63746
|
-
return result_7;
|
|
63747
|
-
}
|
|
63748
|
-
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63749
|
-
}
|
|
63750
63803
|
function getTypeOfPropertyInTypes(types, name) {
|
|
63751
63804
|
var appendPropType = function (propTypes, type) {
|
|
63752
63805
|
var _a;
|
|
@@ -63845,6 +63898,41 @@ var ts;
|
|
|
63845
63898
|
function shouldCheckAsExcessProperty(prop, container) {
|
|
63846
63899
|
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
|
|
63847
63900
|
}
|
|
63901
|
+
function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
|
|
63902
|
+
// Note that these checks are specifically ordered to produce correct results. In particular,
|
|
63903
|
+
// we need to deconstruct unions before intersections (because unions are always at the top),
|
|
63904
|
+
// and we need to handle "each" relations before "some" relations for the same kind of type.
|
|
63905
|
+
if (source.flags & 1048576 /* Union */) {
|
|
63906
|
+
return relation === comparableRelation ?
|
|
63907
|
+
someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
|
|
63908
|
+
eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
|
|
63909
|
+
}
|
|
63910
|
+
if (target.flags & 1048576 /* Union */) {
|
|
63911
|
+
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
63912
|
+
}
|
|
63913
|
+
if (target.flags & 2097152 /* Intersection */) {
|
|
63914
|
+
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
63915
|
+
}
|
|
63916
|
+
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
63917
|
+
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
63918
|
+
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
63919
|
+
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
63920
|
+
// appear to be comparable to '2'.
|
|
63921
|
+
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
63922
|
+
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
63923
|
+
if (constraints !== source.types) {
|
|
63924
|
+
source = getIntersectionType(constraints);
|
|
63925
|
+
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
63926
|
+
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
63927
|
+
}
|
|
63928
|
+
}
|
|
63929
|
+
}
|
|
63930
|
+
// Check to see if any constituents of the intersection are immediately related to the target.
|
|
63931
|
+
// Don't report errors though. Elaborating on whether a source constituent is related to the target is
|
|
63932
|
+
// not actually useful and leads to some confusing error messages. Instead, we rely on the caller
|
|
63933
|
+
// checking whether the full intersection viewed as an object is related to the target.
|
|
63934
|
+
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
63935
|
+
}
|
|
63848
63936
|
function eachTypeRelatedToSomeType(source, target) {
|
|
63849
63937
|
var result = -1 /* True */;
|
|
63850
63938
|
var sourceTypes = source.types;
|
|
@@ -63880,8 +63968,11 @@ var ts;
|
|
|
63880
63968
|
}
|
|
63881
63969
|
}
|
|
63882
63970
|
if (reportErrors) {
|
|
63971
|
+
// Elaborate only if we can find a best matching type in the target union
|
|
63883
63972
|
var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
|
|
63884
|
-
|
|
63973
|
+
if (bestMatchingType) {
|
|
63974
|
+
isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
|
|
63975
|
+
}
|
|
63885
63976
|
}
|
|
63886
63977
|
return 0 /* False */;
|
|
63887
63978
|
}
|
|
@@ -64017,7 +64108,7 @@ var ts;
|
|
|
64017
64108
|
if (overflow) {
|
|
64018
64109
|
return 0 /* False */;
|
|
64019
64110
|
}
|
|
64020
|
-
var keyIntersectionState = intersectionState | (inPropertyCheck ?
|
|
64111
|
+
var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
|
|
64021
64112
|
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
64022
64113
|
var entry = relation.get(id);
|
|
64023
64114
|
if (entry !== undefined) {
|
|
@@ -64085,6 +64176,7 @@ var ts;
|
|
|
64085
64176
|
return originalHandler(onlyUnreliable);
|
|
64086
64177
|
};
|
|
64087
64178
|
}
|
|
64179
|
+
var result;
|
|
64088
64180
|
if (expandingFlags === 3 /* Both */) {
|
|
64089
64181
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
|
|
64090
64182
|
sourceId: source.id,
|
|
@@ -64094,8 +64186,13 @@ var ts;
|
|
|
64094
64186
|
depth: sourceDepth,
|
|
64095
64187
|
targetDepth: targetDepth
|
|
64096
64188
|
});
|
|
64189
|
+
result = 3 /* Maybe */;
|
|
64190
|
+
}
|
|
64191
|
+
else {
|
|
64192
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64193
|
+
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
|
|
64194
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64097
64195
|
}
|
|
64098
|
-
var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
|
|
64099
64196
|
if (outofbandVarianceMarkerHandler) {
|
|
64100
64197
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
64101
64198
|
}
|
|
@@ -64127,98 +64224,97 @@ var ts;
|
|
|
64127
64224
|
return result;
|
|
64128
64225
|
}
|
|
64129
64226
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
64130
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64131
|
-
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
|
|
64132
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64133
|
-
return result;
|
|
64134
|
-
}
|
|
64135
|
-
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
|
|
64136
64227
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
64137
64228
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
64138
64229
|
}
|
|
64139
|
-
|
|
64140
|
-
|
|
64141
|
-
|
|
64142
|
-
|
|
64143
|
-
|
|
64144
|
-
|
|
64145
|
-
|
|
64146
|
-
|
|
64147
|
-
|
|
64148
|
-
|
|
64149
|
-
|
|
64150
|
-
|
|
64151
|
-
if (target.flags & 2097152 /* Intersection */) {
|
|
64152
|
-
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
64153
|
-
}
|
|
64154
|
-
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
64155
|
-
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
64156
|
-
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
64157
|
-
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
64158
|
-
// appear to be comparable to '2'.
|
|
64159
|
-
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
64160
|
-
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
64161
|
-
if (constraints !== source.types) {
|
|
64162
|
-
source = getIntersectionType(constraints);
|
|
64163
|
-
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
64164
|
-
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
64165
|
-
}
|
|
64230
|
+
var result;
|
|
64231
|
+
var originalErrorInfo;
|
|
64232
|
+
var varianceCheckFailed = false;
|
|
64233
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
64234
|
+
var sourceFlags = source.flags;
|
|
64235
|
+
var targetFlags = target.flags;
|
|
64236
|
+
if (relation === identityRelation) {
|
|
64237
|
+
// We've already checked that source.flags and target.flags are identical
|
|
64238
|
+
if (sourceFlags & 3145728 /* UnionOrIntersection */) {
|
|
64239
|
+
var result_8 = eachTypeRelatedToSomeType(source, target);
|
|
64240
|
+
if (result_8) {
|
|
64241
|
+
result_8 &= eachTypeRelatedToSomeType(target, source);
|
|
64166
64242
|
}
|
|
64243
|
+
return result_8;
|
|
64167
64244
|
}
|
|
64168
|
-
|
|
64169
|
-
//
|
|
64170
|
-
// Don't report errors though. Checking whether a constituent is related to the source is not actually
|
|
64171
|
-
// useful and leads to some confusing error messages. Instead it is better to let the below checks
|
|
64172
|
-
// take care of this, or to not elaborate at all. For instance,
|
|
64173
|
-
//
|
|
64174
|
-
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
|
|
64175
|
-
//
|
|
64176
|
-
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
|
|
64177
|
-
// than to report that 'D' is not assignable to 'A' or 'B'.
|
|
64178
|
-
//
|
|
64179
|
-
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
|
|
64180
|
-
// breaking the intersection apart.
|
|
64181
|
-
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
64182
|
-
}
|
|
64183
|
-
var flags = source.flags & target.flags;
|
|
64184
|
-
if (relation === identityRelation && !(flags & 524288 /* Object */)) {
|
|
64185
|
-
if (flags & 4194304 /* Index */) {
|
|
64245
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64186
64246
|
return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
|
|
64187
64247
|
}
|
|
64188
|
-
|
|
64189
|
-
|
|
64190
|
-
|
|
64191
|
-
|
|
64192
|
-
return result_8;
|
|
64248
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64249
|
+
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64250
|
+
if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64251
|
+
return result;
|
|
64193
64252
|
}
|
|
64194
64253
|
}
|
|
64195
64254
|
}
|
|
64196
|
-
if (
|
|
64255
|
+
if (sourceFlags & 16777216 /* Conditional */) {
|
|
64197
64256
|
if (source.root.isDistributive === target.root.isDistributive) {
|
|
64198
|
-
if (
|
|
64199
|
-
if (
|
|
64200
|
-
if (
|
|
64201
|
-
if (
|
|
64202
|
-
return
|
|
64257
|
+
if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64258
|
+
if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64259
|
+
if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64260
|
+
if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64261
|
+
return result;
|
|
64203
64262
|
}
|
|
64204
64263
|
}
|
|
64205
64264
|
}
|
|
64206
64265
|
}
|
|
64207
64266
|
}
|
|
64208
64267
|
}
|
|
64209
|
-
if (
|
|
64268
|
+
if (sourceFlags & 33554432 /* Substitution */) {
|
|
64210
64269
|
return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
|
|
64211
64270
|
}
|
|
64212
|
-
|
|
64271
|
+
if (!(sourceFlags & 524288 /* Object */)) {
|
|
64272
|
+
return 0 /* False */;
|
|
64273
|
+
}
|
|
64274
|
+
}
|
|
64275
|
+
else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
|
|
64276
|
+
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
64277
|
+
return result;
|
|
64278
|
+
}
|
|
64279
|
+
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
64280
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
64281
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
64282
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
64283
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
64284
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
64285
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
64286
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
64287
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
64288
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
64289
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
64290
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
64291
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
64292
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
64293
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
64294
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
64295
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
64296
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
64297
|
+
resetErrorInfo(saveErrorInfo);
|
|
64298
|
+
return result;
|
|
64299
|
+
}
|
|
64300
|
+
}
|
|
64301
|
+
}
|
|
64302
|
+
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
64303
|
+
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
64304
|
+
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64305
|
+
// Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
|
|
64306
|
+
// Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64307
|
+
// Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
|
|
64308
|
+
if (!(sourceFlags & 465829888 /* Instantiable */ ||
|
|
64309
|
+
sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
|
|
64310
|
+
sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
|
|
64311
|
+
return 0 /* False */;
|
|
64312
|
+
}
|
|
64213
64313
|
}
|
|
64214
|
-
var result;
|
|
64215
|
-
var originalErrorInfo;
|
|
64216
|
-
var varianceCheckFailed = false;
|
|
64217
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
64218
64314
|
// We limit alias variance probing to only object and conditional types since their alias behavior
|
|
64219
64315
|
// is more predictable than other, interned types, which may or may not have an alias depending on
|
|
64220
64316
|
// the order in which things were checked.
|
|
64221
|
-
if (
|
|
64317
|
+
if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
|
|
64222
64318
|
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
|
|
64223
64319
|
!(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
|
|
64224
64320
|
var variances = getAliasVariances(source.aliasSymbol);
|
|
@@ -64236,7 +64332,7 @@ var ts;
|
|
|
64236
64332
|
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
|
|
64237
64333
|
return result;
|
|
64238
64334
|
}
|
|
64239
|
-
if (
|
|
64335
|
+
if (targetFlags & 262144 /* TypeParameter */) {
|
|
64240
64336
|
// 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].
|
|
64241
64337
|
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
|
|
64242
64338
|
if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
|
|
@@ -64248,10 +64344,10 @@ var ts;
|
|
|
64248
64344
|
}
|
|
64249
64345
|
}
|
|
64250
64346
|
}
|
|
64251
|
-
else if (
|
|
64347
|
+
else if (targetFlags & 4194304 /* Index */) {
|
|
64252
64348
|
var targetType_1 = target.type;
|
|
64253
64349
|
// A keyof S is related to a keyof T if T is related to S.
|
|
64254
|
-
if (
|
|
64350
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64255
64351
|
if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64256
64352
|
return result;
|
|
64257
64353
|
}
|
|
@@ -64302,8 +64398,8 @@ var ts;
|
|
|
64302
64398
|
}
|
|
64303
64399
|
}
|
|
64304
64400
|
}
|
|
64305
|
-
else if (
|
|
64306
|
-
if (
|
|
64401
|
+
else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
64402
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64307
64403
|
// Relate components directly before falling back to constraint relationships
|
|
64308
64404
|
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
|
|
64309
64405
|
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
|
|
@@ -64409,7 +64505,7 @@ var ts;
|
|
|
64409
64505
|
}
|
|
64410
64506
|
}
|
|
64411
64507
|
}
|
|
64412
|
-
else if (
|
|
64508
|
+
else if (targetFlags & 16777216 /* Conditional */) {
|
|
64413
64509
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64414
64510
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64415
64511
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
@@ -64434,8 +64530,8 @@ var ts;
|
|
|
64434
64530
|
}
|
|
64435
64531
|
}
|
|
64436
64532
|
}
|
|
64437
|
-
else if (
|
|
64438
|
-
if (
|
|
64533
|
+
else if (targetFlags & 134217728 /* TemplateLiteral */) {
|
|
64534
|
+
if (sourceFlags & 134217728 /* TemplateLiteral */) {
|
|
64439
64535
|
if (relation === comparableRelation) {
|
|
64440
64536
|
return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
|
|
64441
64537
|
}
|
|
@@ -64447,11 +64543,11 @@ var ts;
|
|
|
64447
64543
|
return -1 /* True */;
|
|
64448
64544
|
}
|
|
64449
64545
|
}
|
|
64450
|
-
if (
|
|
64451
|
-
// IndexedAccess comparisons are handled above in the `
|
|
64452
|
-
if (!(
|
|
64546
|
+
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
64547
|
+
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
64548
|
+
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
64453
64549
|
var constraint = getConstraintOfType(source);
|
|
64454
|
-
if (!constraint || (
|
|
64550
|
+
if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
64455
64551
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
64456
64552
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
64457
64553
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64464,7 +64560,7 @@ var ts;
|
|
|
64464
64560
|
return result;
|
|
64465
64561
|
}
|
|
64466
64562
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
64467
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(
|
|
64563
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
64468
64564
|
resetErrorInfo(saveErrorInfo);
|
|
64469
64565
|
return result;
|
|
64470
64566
|
}
|
|
@@ -64481,14 +64577,14 @@ var ts;
|
|
|
64481
64577
|
}
|
|
64482
64578
|
}
|
|
64483
64579
|
}
|
|
64484
|
-
else if (
|
|
64580
|
+
else if (sourceFlags & 4194304 /* Index */) {
|
|
64485
64581
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
64486
64582
|
resetErrorInfo(saveErrorInfo);
|
|
64487
64583
|
return result;
|
|
64488
64584
|
}
|
|
64489
64585
|
}
|
|
64490
|
-
else if (
|
|
64491
|
-
if (!(
|
|
64586
|
+
else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
64587
|
+
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
64492
64588
|
var constraint = getBaseConstraintOfType(source);
|
|
64493
64589
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
64494
64590
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64496,8 +64592,8 @@ var ts;
|
|
|
64496
64592
|
}
|
|
64497
64593
|
}
|
|
64498
64594
|
}
|
|
64499
|
-
else if (
|
|
64500
|
-
if (
|
|
64595
|
+
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
64596
|
+
if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
|
|
64501
64597
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
64502
64598
|
resetErrorInfo(saveErrorInfo);
|
|
64503
64599
|
return result;
|
|
@@ -64511,14 +64607,14 @@ var ts;
|
|
|
64511
64607
|
}
|
|
64512
64608
|
}
|
|
64513
64609
|
}
|
|
64514
|
-
else if (
|
|
64610
|
+
else if (sourceFlags & 16777216 /* Conditional */) {
|
|
64515
64611
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64516
64612
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64517
64613
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
64518
64614
|
resetErrorInfo(saveErrorInfo);
|
|
64519
64615
|
return 3 /* Maybe */;
|
|
64520
64616
|
}
|
|
64521
|
-
if (
|
|
64617
|
+
if (targetFlags & 16777216 /* Conditional */) {
|
|
64522
64618
|
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
|
|
64523
64619
|
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
|
|
64524
64620
|
// and Y1 is related to Y2.
|
|
@@ -64578,15 +64674,21 @@ var ts;
|
|
|
64578
64674
|
}
|
|
64579
64675
|
return 0 /* False */;
|
|
64580
64676
|
}
|
|
64581
|
-
var sourceIsPrimitive = !!(
|
|
64677
|
+
var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
|
|
64582
64678
|
if (relation !== identityRelation) {
|
|
64583
64679
|
source = getApparentType(source);
|
|
64680
|
+
sourceFlags = source.flags;
|
|
64584
64681
|
}
|
|
64585
64682
|
else if (isGenericMappedType(source)) {
|
|
64586
64683
|
return 0 /* False */;
|
|
64587
64684
|
}
|
|
64588
64685
|
if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target &&
|
|
64589
64686
|
!isTupleType(source) && !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) {
|
|
64687
|
+
// When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType,
|
|
64688
|
+
// and an empty array literal wouldn't be assignable to a `never[]` without this check.
|
|
64689
|
+
if (isEmptyArrayLiteralType(source)) {
|
|
64690
|
+
return -1 /* True */;
|
|
64691
|
+
}
|
|
64590
64692
|
// We have type references to the same generic type, and the type references are not marker
|
|
64591
64693
|
// type references (which are intended by be compared structurally). Obtain the variance
|
|
64592
64694
|
// information for the type parameters and relate the type arguments accordingly.
|
|
@@ -64622,7 +64724,7 @@ var ts;
|
|
|
64622
64724
|
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
|
|
64623
64725
|
// to X. Failing both of those we want to check if the aggregation of A and B's members structurally
|
|
64624
64726
|
// relates to X. Thus, we include intersection types on the source side here.
|
|
64625
|
-
if (
|
|
64727
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
|
|
64626
64728
|
// Report structural errors only if we haven't reported any errors yet
|
|
64627
64729
|
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
|
|
64628
64730
|
result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
|
|
@@ -64646,7 +64748,7 @@ var ts;
|
|
|
64646
64748
|
// there exists a constituent of T for every combination of the discriminants of S
|
|
64647
64749
|
// with respect to T. We do not report errors here, as we will use the existing
|
|
64648
64750
|
// error result from checking each constituent of the union.
|
|
64649
|
-
if (
|
|
64751
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
|
|
64650
64752
|
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
|
|
64651
64753
|
if (objectOnlyTarget.flags & 1048576 /* Union */) {
|
|
64652
64754
|
var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
|
|
@@ -64893,6 +64995,15 @@ var ts;
|
|
|
64893
64995
|
}
|
|
64894
64996
|
return 0 /* False */;
|
|
64895
64997
|
}
|
|
64998
|
+
// Ensure {readonly a: whatever} is not a subtype of {a: whatever},
|
|
64999
|
+
// while {a: whatever} is a subtype of {readonly a: whatever}.
|
|
65000
|
+
// This ensures the subtype relationship is ordered, and preventing declaration order
|
|
65001
|
+
// from deciding which type "wins" in union subtype reduction.
|
|
65002
|
+
// They're still assignable to one another, since `readonly` doesn't affect assignability.
|
|
65003
|
+
if ((relation === subtypeRelation || relation === strictSubtypeRelation) &&
|
|
65004
|
+
!!(sourcePropFlags & 64 /* Readonly */) && !(targetPropFlags & 64 /* Readonly */)) {
|
|
65005
|
+
return 0 /* False */;
|
|
65006
|
+
}
|
|
64896
65007
|
// If the target comes from a partial union prop, allow `undefined` in the target type
|
|
64897
65008
|
var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
|
|
64898
65009
|
if (!related) {
|
|
@@ -65161,7 +65272,6 @@ var ts;
|
|
|
65161
65272
|
}
|
|
65162
65273
|
}
|
|
65163
65274
|
var result = -1 /* True */;
|
|
65164
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
65165
65275
|
var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
|
|
65166
65276
|
var sourceObjectFlags = ts.getObjectFlags(source);
|
|
65167
65277
|
var targetObjectFlags = ts.getObjectFlags(target);
|
|
@@ -65202,6 +65312,7 @@ var ts;
|
|
|
65202
65312
|
else {
|
|
65203
65313
|
outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
|
|
65204
65314
|
var t = targetSignatures_1[_i];
|
|
65315
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
65205
65316
|
// Only elaborate errors from the first failure
|
|
65206
65317
|
var shouldElaborateErrors = reportErrors;
|
|
65207
65318
|
for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
|
|
@@ -68372,9 +68483,6 @@ var ts;
|
|
|
68372
68483
|
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
|
|
68373
68484
|
mapType(type, mapper);
|
|
68374
68485
|
}
|
|
68375
|
-
function getConstituentCount(type) {
|
|
68376
|
-
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
68377
|
-
}
|
|
68378
68486
|
function extractTypesOfKind(type, kind) {
|
|
68379
68487
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
68380
68488
|
}
|
|
@@ -73095,6 +73203,9 @@ var ts;
|
|
|
73095
73203
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
73096
73204
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
73097
73205
|
}
|
|
73206
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
|
|
73207
|
+
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
73208
|
+
}
|
|
73098
73209
|
}
|
|
73099
73210
|
else {
|
|
73100
73211
|
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
|
|
@@ -75579,8 +75690,8 @@ var ts;
|
|
|
75579
75690
|
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75580
75691
|
var synthType = type;
|
|
75581
75692
|
if (!synthType.defaultOnlyType) {
|
|
75582
|
-
var
|
|
75583
|
-
synthType.defaultOnlyType =
|
|
75693
|
+
var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75694
|
+
synthType.defaultOnlyType = type_5;
|
|
75584
75695
|
}
|
|
75585
75696
|
return synthType.defaultOnlyType;
|
|
75586
75697
|
}
|
|
@@ -76040,21 +76151,22 @@ var ts;
|
|
|
76040
76151
|
if (links.type === unknownType) {
|
|
76041
76152
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
76042
76153
|
}
|
|
76043
|
-
assignBindingElementTypes(declaration.name);
|
|
76154
|
+
assignBindingElementTypes(declaration.name, links.type);
|
|
76044
76155
|
}
|
|
76045
76156
|
}
|
|
76046
76157
|
}
|
|
76047
76158
|
// When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
|
|
76048
76159
|
// the destructured type into the contained binding elements.
|
|
76049
|
-
function assignBindingElementTypes(pattern) {
|
|
76160
|
+
function assignBindingElementTypes(pattern, parentType) {
|
|
76050
76161
|
for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
|
|
76051
76162
|
var element = _a[_i];
|
|
76052
76163
|
if (!ts.isOmittedExpression(element)) {
|
|
76164
|
+
var type = getBindingElementTypeFromParentType(element, parentType);
|
|
76053
76165
|
if (element.name.kind === 79 /* Identifier */) {
|
|
76054
|
-
getSymbolLinks(getSymbolOfNode(element)).type =
|
|
76166
|
+
getSymbolLinks(getSymbolOfNode(element)).type = type;
|
|
76055
76167
|
}
|
|
76056
76168
|
else {
|
|
76057
|
-
assignBindingElementTypes(element.name);
|
|
76169
|
+
assignBindingElementTypes(element.name, type);
|
|
76058
76170
|
}
|
|
76059
76171
|
}
|
|
76060
76172
|
}
|
|
@@ -76307,12 +76419,12 @@ var ts;
|
|
|
76307
76419
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
76308
76420
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
76309
76421
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
76310
|
-
var
|
|
76422
|
+
var type_6 = getBaseConstraintOfType(operandType) || operandType;
|
|
76311
76423
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
76312
|
-
if (
|
|
76424
|
+
if (type_6.flags & 3 /* AnyOrUnknown */) {
|
|
76313
76425
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
76314
76426
|
}
|
|
76315
|
-
return !!(filterType(
|
|
76427
|
+
return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
76316
76428
|
}
|
|
76317
76429
|
var type = getTypeOfExpression(node.expression);
|
|
76318
76430
|
if (!isLiteralType(type)) {
|
|
@@ -78434,6 +78546,7 @@ var ts;
|
|
|
78434
78546
|
}
|
|
78435
78547
|
}
|
|
78436
78548
|
checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
|
|
78549
|
+
checkUnmatchedJSDocParameters(node);
|
|
78437
78550
|
ts.forEach(node.parameters, checkParameter);
|
|
78438
78551
|
// TODO(rbuckton): Should we start checking JSDoc types?
|
|
78439
78552
|
if (node.type) {
|
|
@@ -79794,28 +79907,24 @@ var ts;
|
|
|
79794
79907
|
if (returnType.flags & 1 /* Any */) {
|
|
79795
79908
|
return;
|
|
79796
79909
|
}
|
|
79910
|
+
var headMessage;
|
|
79797
79911
|
var expectedReturnType;
|
|
79798
|
-
var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
|
79799
|
-
var errorInfo;
|
|
79800
79912
|
switch (node.parent.kind) {
|
|
79801
79913
|
case 256 /* ClassDeclaration */:
|
|
79914
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
79802
79915
|
var classSymbol = getSymbolOfNode(node.parent);
|
|
79803
79916
|
var classConstructorType = getTypeOfSymbol(classSymbol);
|
|
79804
79917
|
expectedReturnType = getUnionType([classConstructorType, voidType]);
|
|
79805
79918
|
break;
|
|
79806
|
-
case 163 /* Parameter */:
|
|
79807
|
-
expectedReturnType = voidType;
|
|
79808
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
79809
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
|
|
79810
|
-
break;
|
|
79811
79919
|
case 166 /* PropertyDeclaration */:
|
|
79920
|
+
case 163 /* Parameter */:
|
|
79921
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
|
|
79812
79922
|
expectedReturnType = voidType;
|
|
79813
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
79814
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
|
|
79815
79923
|
break;
|
|
79816
79924
|
case 168 /* MethodDeclaration */:
|
|
79817
79925
|
case 171 /* GetAccessor */:
|
|
79818
79926
|
case 172 /* SetAccessor */:
|
|
79927
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
79819
79928
|
var methodType = getTypeOfNode(node.parent);
|
|
79820
79929
|
var descriptorType = createTypedPropertyDescriptorType(methodType);
|
|
79821
79930
|
expectedReturnType = getUnionType([descriptorType, voidType]);
|
|
@@ -79823,7 +79932,7 @@ var ts;
|
|
|
79823
79932
|
default:
|
|
79824
79933
|
return ts.Debug.fail();
|
|
79825
79934
|
}
|
|
79826
|
-
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage
|
|
79935
|
+
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
|
|
79827
79936
|
}
|
|
79828
79937
|
/**
|
|
79829
79938
|
* If a TypeNode can be resolved to a value symbol imported from an external module, it is
|
|
@@ -80005,31 +80114,6 @@ var ts;
|
|
|
80005
80114
|
}
|
|
80006
80115
|
function checkJSDocParameterTag(node) {
|
|
80007
80116
|
checkSourceElement(node.typeExpression);
|
|
80008
|
-
if (!ts.getParameterSymbolFromJSDoc(node)) {
|
|
80009
|
-
var decl = ts.getHostSignatureFromJSDoc(node);
|
|
80010
|
-
// don't issue an error for invalid hosts -- just functions --
|
|
80011
|
-
// and give a better error message when the host function mentions `arguments`
|
|
80012
|
-
// but the tag doesn't have an array type
|
|
80013
|
-
if (decl) {
|
|
80014
|
-
var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
|
|
80015
|
-
if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
|
|
80016
|
-
return;
|
|
80017
|
-
}
|
|
80018
|
-
if (!containsArgumentsReference(decl)) {
|
|
80019
|
-
if (ts.isQualifiedName(node.name)) {
|
|
80020
|
-
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));
|
|
80021
|
-
}
|
|
80022
|
-
else {
|
|
80023
|
-
error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
|
|
80024
|
-
}
|
|
80025
|
-
}
|
|
80026
|
-
else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
|
|
80027
|
-
node.typeExpression && node.typeExpression.type &&
|
|
80028
|
-
!isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
|
|
80029
|
-
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));
|
|
80030
|
-
}
|
|
80031
|
-
}
|
|
80032
|
-
}
|
|
80033
80117
|
}
|
|
80034
80118
|
function checkJSDocPropertyTag(node) {
|
|
80035
80119
|
checkSourceElement(node.typeExpression);
|
|
@@ -82102,6 +82186,45 @@ var ts;
|
|
|
82102
82186
|
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
|
|
82103
82187
|
}
|
|
82104
82188
|
}
|
|
82189
|
+
function checkUnmatchedJSDocParameters(node) {
|
|
82190
|
+
var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
|
|
82191
|
+
if (!ts.length(jsdocParameters))
|
|
82192
|
+
return;
|
|
82193
|
+
var isJs = ts.isInJSFile(node);
|
|
82194
|
+
var parameters = new ts.Set();
|
|
82195
|
+
var excludedParameters = new ts.Set();
|
|
82196
|
+
ts.forEach(node.parameters, function (_a, index) {
|
|
82197
|
+
var name = _a.name;
|
|
82198
|
+
if (ts.isIdentifier(name)) {
|
|
82199
|
+
parameters.add(name.escapedText);
|
|
82200
|
+
}
|
|
82201
|
+
if (ts.isBindingPattern(name)) {
|
|
82202
|
+
excludedParameters.add(index);
|
|
82203
|
+
}
|
|
82204
|
+
});
|
|
82205
|
+
var containsArguments = containsArgumentsReference(node);
|
|
82206
|
+
if (containsArguments) {
|
|
82207
|
+
var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
|
|
82208
|
+
if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
|
82209
|
+
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82210
|
+
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));
|
|
82211
|
+
}
|
|
82212
|
+
}
|
|
82213
|
+
else {
|
|
82214
|
+
ts.forEach(jsdocParameters, function (_a, index) {
|
|
82215
|
+
var name = _a.name;
|
|
82216
|
+
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
82217
|
+
return;
|
|
82218
|
+
}
|
|
82219
|
+
if (ts.isQualifiedName(name)) {
|
|
82220
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
|
|
82221
|
+
}
|
|
82222
|
+
else {
|
|
82223
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
82224
|
+
}
|
|
82225
|
+
});
|
|
82226
|
+
}
|
|
82227
|
+
}
|
|
82105
82228
|
/**
|
|
82106
82229
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
82107
82230
|
*/
|
|
@@ -83310,6 +83433,9 @@ var ts;
|
|
|
83310
83433
|
var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
|
|
83311
83434
|
addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
|
|
83312
83435
|
}
|
|
83436
|
+
if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
|
|
83437
|
+
error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
|
|
83438
|
+
}
|
|
83313
83439
|
break;
|
|
83314
83440
|
}
|
|
83315
83441
|
case 274 /* ExportSpecifier */: {
|
|
@@ -85354,7 +85480,7 @@ var ts;
|
|
|
85354
85480
|
if (resolvedTypeReferenceDirectives) {
|
|
85355
85481
|
// populate reverse mapping: file path -> type reference directive that was resolved to this file
|
|
85356
85482
|
fileToDirective = new ts.Map();
|
|
85357
|
-
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
|
|
85483
|
+
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
|
|
85358
85484
|
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
|
|
85359
85485
|
return;
|
|
85360
85486
|
}
|
|
@@ -85362,7 +85488,7 @@ var ts;
|
|
|
85362
85488
|
if (file) {
|
|
85363
85489
|
// Add the transitive closure of path references loaded by this file (as long as they are not)
|
|
85364
85490
|
// part of an existing type reference.
|
|
85365
|
-
addReferencedFilesToTypeDirective(file, key);
|
|
85491
|
+
addReferencedFilesToTypeDirective(file, key, mode);
|
|
85366
85492
|
}
|
|
85367
85493
|
});
|
|
85368
85494
|
}
|
|
@@ -85556,16 +85682,16 @@ var ts;
|
|
|
85556
85682
|
}
|
|
85557
85683
|
return false;
|
|
85558
85684
|
}
|
|
85559
|
-
function addReferencedFilesToTypeDirective(file, key) {
|
|
85685
|
+
function addReferencedFilesToTypeDirective(file, key, mode) {
|
|
85560
85686
|
if (fileToDirective.has(file.path))
|
|
85561
85687
|
return;
|
|
85562
|
-
fileToDirective.set(file.path, key);
|
|
85688
|
+
fileToDirective.set(file.path, [key, mode]);
|
|
85563
85689
|
for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
|
|
85564
|
-
var
|
|
85690
|
+
var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
|
|
85565
85691
|
var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
|
|
85566
85692
|
var referencedFile = host.getSourceFile(resolvedFile);
|
|
85567
85693
|
if (referencedFile) {
|
|
85568
|
-
addReferencedFilesToTypeDirective(referencedFile, key);
|
|
85694
|
+
addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
|
|
85569
85695
|
}
|
|
85570
85696
|
}
|
|
85571
85697
|
}
|
|
@@ -87270,28 +87396,27 @@ var ts;
|
|
|
87270
87396
|
}
|
|
87271
87397
|
function findMostOverlappyType(source, unionTarget) {
|
|
87272
87398
|
var bestMatch;
|
|
87273
|
-
|
|
87274
|
-
|
|
87275
|
-
var
|
|
87276
|
-
|
|
87277
|
-
|
|
87278
|
-
|
|
87279
|
-
|
|
87280
|
-
|
|
87281
|
-
|
|
87282
|
-
|
|
87283
|
-
|
|
87284
|
-
|
|
87285
|
-
|
|
87286
|
-
|
|
87287
|
-
|
|
87288
|
-
|
|
87289
|
-
|
|
87290
|
-
|
|
87291
|
-
|
|
87292
|
-
|
|
87293
|
-
|
|
87294
|
-
matchingCount = 1;
|
|
87399
|
+
if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87400
|
+
var matchingCount = 0;
|
|
87401
|
+
for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
|
|
87402
|
+
var target = _a[_i];
|
|
87403
|
+
if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87404
|
+
var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
|
|
87405
|
+
if (overlap.flags & 4194304 /* Index */) {
|
|
87406
|
+
// perfect overlap of keys
|
|
87407
|
+
return target;
|
|
87408
|
+
}
|
|
87409
|
+
else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
|
|
87410
|
+
// We only want to account for literal types otherwise.
|
|
87411
|
+
// If we have a union of index types, it seems likely that we
|
|
87412
|
+
// needed to elaborate between two generic mapped types anyway.
|
|
87413
|
+
var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
|
|
87414
|
+
if (len >= matchingCount) {
|
|
87415
|
+
bestMatch = target;
|
|
87416
|
+
matchingCount = len;
|
|
87417
|
+
}
|
|
87418
|
+
}
|
|
87419
|
+
}
|
|
87295
87420
|
}
|
|
87296
87421
|
}
|
|
87297
87422
|
return bestMatch;
|
|
@@ -106334,7 +106459,7 @@ var ts;
|
|
|
106334
106459
|
var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
|
|
106335
106460
|
hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
|
|
106336
106461
|
collectReferences(sourceFile, refs);
|
|
106337
|
-
recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
|
|
106462
|
+
recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
|
|
106338
106463
|
collectLibs(sourceFile, libs);
|
|
106339
106464
|
return sourceFile;
|
|
106340
106465
|
}
|
|
@@ -106389,9 +106514,10 @@ var ts;
|
|
|
106389
106514
|
return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
|
|
106390
106515
|
}
|
|
106391
106516
|
function getFileReferencesForUsedTypeReferences() {
|
|
106392
|
-
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()),
|
|
106517
|
+
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
|
|
106393
106518
|
}
|
|
106394
|
-
function
|
|
106519
|
+
function getFileReferenceForSpecifierModeTuple(_a) {
|
|
106520
|
+
var typeName = _a[0], mode = _a[1];
|
|
106395
106521
|
// Elide type references for which we have imports
|
|
106396
106522
|
if (emittedImports) {
|
|
106397
106523
|
for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
|
|
@@ -106407,7 +106533,7 @@ var ts;
|
|
|
106407
106533
|
}
|
|
106408
106534
|
}
|
|
106409
106535
|
}
|
|
106410
|
-
return { fileName: typeName, pos: -1, end: -1 };
|
|
106536
|
+
return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
|
|
106411
106537
|
}
|
|
106412
106538
|
function mapReferencesIntoArray(references, outputFilePath) {
|
|
106413
106539
|
return function (file) {
|
|
@@ -106427,7 +106553,7 @@ var ts;
|
|
|
106427
106553
|
// If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration
|
|
106428
106554
|
// via a non-relative name, emit a type reference directive to that non-relative name, rather than
|
|
106429
106555
|
// a relative path to the declaration file
|
|
106430
|
-
recordTypeReferenceDirectivesIfNecessary([specifier]);
|
|
106556
|
+
recordTypeReferenceDirectivesIfNecessary([[specifier, /*mode*/ undefined]]);
|
|
106431
106557
|
return;
|
|
106432
106558
|
}
|
|
106433
106559
|
var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName,
|
|
@@ -111539,9 +111665,12 @@ var ts;
|
|
|
111539
111665
|
for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
|
|
111540
111666
|
var directive = types_24[_d];
|
|
111541
111667
|
var pos = writer.getTextPos();
|
|
111542
|
-
|
|
111668
|
+
var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
|
|
111669
|
+
? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
|
|
111670
|
+
: "";
|
|
111671
|
+
writeComment("/// <reference types=\"" + directive.fileName + "\" " + resolutionMode + "/>");
|
|
111543
111672
|
if (bundleFileInfo)
|
|
111544
|
-
bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName });
|
|
111673
|
+
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 });
|
|
111545
111674
|
writeLine();
|
|
111546
111675
|
}
|
|
111547
111676
|
for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
|
|
@@ -114148,7 +114277,7 @@ var ts;
|
|
|
114148
114277
|
}
|
|
114149
114278
|
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
|
|
114150
114279
|
/* @internal */
|
|
114151
|
-
function
|
|
114280
|
+
function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
|
|
114152
114281
|
if (names.length === 0) {
|
|
114153
114282
|
return [];
|
|
114154
114283
|
}
|
|
@@ -114157,19 +114286,28 @@ var ts;
|
|
|
114157
114286
|
for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
|
|
114158
114287
|
var name = names_2[_i];
|
|
114159
114288
|
var result = void 0;
|
|
114160
|
-
|
|
114161
|
-
|
|
114289
|
+
var mode = getModeForFileReference(name, containingFileMode);
|
|
114290
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
114291
|
+
var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
|
|
114292
|
+
var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
|
|
114293
|
+
if (cache.has(cacheKey)) {
|
|
114294
|
+
result = cache.get(cacheKey);
|
|
114162
114295
|
}
|
|
114163
114296
|
else {
|
|
114164
|
-
cache.set(
|
|
114297
|
+
cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
|
|
114165
114298
|
}
|
|
114166
114299
|
resolutions.push(result);
|
|
114167
114300
|
}
|
|
114168
114301
|
return resolutions;
|
|
114169
114302
|
}
|
|
114170
|
-
ts.
|
|
114303
|
+
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
114171
114304
|
;
|
|
114172
114305
|
/* @internal */
|
|
114306
|
+
function getModeForFileReference(ref, containingFileMode) {
|
|
114307
|
+
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
114308
|
+
}
|
|
114309
|
+
ts.getModeForFileReference = getModeForFileReference;
|
|
114310
|
+
/* @internal */
|
|
114173
114311
|
function getModeForResolutionAtIndex(file, index) {
|
|
114174
114312
|
if (file.impliedNodeFormat === undefined)
|
|
114175
114313
|
return undefined;
|
|
@@ -114272,7 +114410,7 @@ var ts;
|
|
|
114272
114410
|
var _d, _e, _f, _g;
|
|
114273
114411
|
var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
|
|
114274
114412
|
var kind = ref.kind, index = ref.index;
|
|
114275
|
-
var pos, end, packageId;
|
|
114413
|
+
var pos, end, packageId, resolutionMode;
|
|
114276
114414
|
switch (kind) {
|
|
114277
114415
|
case ts.FileIncludeKind.Import:
|
|
114278
114416
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
@@ -114286,8 +114424,8 @@ var ts;
|
|
|
114286
114424
|
(_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
|
|
114287
114425
|
break;
|
|
114288
114426
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
114289
|
-
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
114290
|
-
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;
|
|
114427
|
+
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
|
|
114428
|
+
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;
|
|
114291
114429
|
break;
|
|
114292
114430
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
114293
114431
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -114531,7 +114669,7 @@ var ts;
|
|
|
114531
114669
|
var fileReasons = ts.createMultiMap();
|
|
114532
114670
|
var cachedBindAndCheckDiagnosticsForFile = {};
|
|
114533
114671
|
var cachedDeclarationDiagnosticsForFile = {};
|
|
114534
|
-
var resolvedTypeReferenceDirectives =
|
|
114672
|
+
var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
|
|
114535
114673
|
var fileProcessingDiagnostics;
|
|
114536
114674
|
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
|
|
114537
114675
|
// This works as imported modules are discovered recursively in a depth first manner, specifically:
|
|
@@ -114584,12 +114722,12 @@ var ts;
|
|
|
114584
114722
|
}
|
|
114585
114723
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
114586
114724
|
if (host.resolveTypeReferenceDirectives) {
|
|
114587
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
|
|
114725
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
|
|
114588
114726
|
}
|
|
114589
114727
|
else {
|
|
114590
114728
|
typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
114591
|
-
var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114592
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return
|
|
114729
|
+
var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114730
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
|
|
114593
114731
|
}
|
|
114594
114732
|
// Map from a stringified PackageId to the source file with that id.
|
|
114595
114733
|
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
|
|
@@ -114686,7 +114824,8 @@ var ts;
|
|
|
114686
114824
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
114687
114825
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
114688
114826
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
114689
|
-
|
|
114827
|
+
// under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
|
|
114828
|
+
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 });
|
|
114690
114829
|
}
|
|
114691
114830
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
114692
114831
|
}
|
|
@@ -114846,9 +114985,10 @@ var ts;
|
|
|
114846
114985
|
return [];
|
|
114847
114986
|
var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
|
|
114848
114987
|
var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
|
|
114988
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
114849
114989
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
|
|
114850
114990
|
ts.performance.mark("beforeResolveTypeReference");
|
|
114851
|
-
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
|
|
114991
|
+
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
|
|
114852
114992
|
ts.performance.mark("afterResolveTypeReference");
|
|
114853
114993
|
ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
|
|
114854
114994
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -115240,8 +115380,7 @@ var ts;
|
|
|
115240
115380
|
else {
|
|
115241
115381
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
115242
115382
|
}
|
|
115243
|
-
|
|
115244
|
-
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
115383
|
+
var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
|
115245
115384
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
115246
115385
|
// ensure that types resolutions are still correct
|
|
115247
115386
|
var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
@@ -116320,8 +116459,7 @@ var ts;
|
|
|
116320
116459
|
});
|
|
116321
116460
|
}
|
|
116322
116461
|
function processTypeReferenceDirectives(file) {
|
|
116323
|
-
|
|
116324
|
-
var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
116462
|
+
var typeDirectives = file.typeReferenceDirectives;
|
|
116325
116463
|
if (!typeDirectives) {
|
|
116326
116464
|
return;
|
|
116327
116465
|
}
|
|
@@ -116332,17 +116470,21 @@ var ts;
|
|
|
116332
116470
|
// store resolved type directive on the file
|
|
116333
116471
|
var fileName = ts.toFileNameLowerCase(ref.fileName);
|
|
116334
116472
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
116335
|
-
|
|
116473
|
+
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
116474
|
+
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
116475
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext));
|
|
116476
|
+
}
|
|
116477
|
+
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
116336
116478
|
}
|
|
116337
116479
|
}
|
|
116338
|
-
function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116480
|
+
function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116339
116481
|
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 });
|
|
116340
|
-
processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
|
|
116482
|
+
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
|
|
116341
116483
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116342
116484
|
}
|
|
116343
|
-
function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116485
|
+
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116344
116486
|
// If we already found this library as a primary reference - nothing to do
|
|
116345
|
-
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
|
|
116487
|
+
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
|
|
116346
116488
|
if (previousResolution && previousResolution.primary) {
|
|
116347
116489
|
return;
|
|
116348
116490
|
}
|
|
@@ -116381,7 +116523,7 @@ var ts;
|
|
|
116381
116523
|
addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
|
|
116382
116524
|
}
|
|
116383
116525
|
if (saveResolution) {
|
|
116384
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
|
|
116526
|
+
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
|
|
116385
116527
|
}
|
|
116386
116528
|
}
|
|
116387
116529
|
function pathForLibFile(libFileName) {
|
|
@@ -119199,9 +119341,9 @@ var ts;
|
|
|
119199
119341
|
});
|
|
119200
119342
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
119201
119343
|
}
|
|
119202
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
|
|
119344
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
|
|
119203
119345
|
var _a;
|
|
119204
|
-
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
|
|
119346
|
+
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
|
|
119205
119347
|
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
|
|
119206
119348
|
if (!resolutionHost.getGlobalCache) {
|
|
119207
119349
|
return primaryResult;
|
|
@@ -119222,12 +119364,12 @@ var ts;
|
|
|
119222
119364
|
// Default return the result from the first pass
|
|
119223
119365
|
return primaryResult;
|
|
119224
119366
|
}
|
|
119225
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
|
|
119226
|
-
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
|
|
119367
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
|
|
119368
|
+
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
|
|
119227
119369
|
}
|
|
119228
119370
|
function resolveNamesWithLocalCache(_a) {
|
|
119229
119371
|
var _b, _c, _d;
|
|
119230
|
-
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;
|
|
119372
|
+
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;
|
|
119231
119373
|
var path = resolutionHost.toPath(containingFile);
|
|
119232
119374
|
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
119233
119375
|
var dirPath = ts.getDirectoryPath(path);
|
|
@@ -119249,8 +119391,15 @@ var ts;
|
|
|
119249
119391
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
119250
119392
|
var i = 0;
|
|
119251
119393
|
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
119252
|
-
var
|
|
119253
|
-
var
|
|
119394
|
+
var entry = names_4[_i];
|
|
119395
|
+
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
119396
|
+
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
119397
|
+
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
119398
|
+
// import's syntax may override the file's default mode.
|
|
119399
|
+
// Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
|
|
119400
|
+
// a default file mode override if applicable.
|
|
119401
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
|
|
119402
|
+
containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
119254
119403
|
i++;
|
|
119255
119404
|
var resolution = resolutionsInFile.get(name, mode);
|
|
119256
119405
|
// Resolution is valid if it is present and not invalidated
|
|
@@ -119279,7 +119428,7 @@ var ts;
|
|
|
119279
119428
|
}
|
|
119280
119429
|
}
|
|
119281
119430
|
else {
|
|
119282
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
119431
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
119283
119432
|
perDirectoryResolution.set(name, mode, resolution);
|
|
119284
119433
|
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
119285
119434
|
resolutionHost.onDiscoveredSymlink();
|
|
@@ -119343,7 +119492,7 @@ var ts;
|
|
|
119343
119492
|
return oldResult.resolvedFileName === newResult.resolvedFileName;
|
|
119344
119493
|
}
|
|
119345
119494
|
}
|
|
119346
|
-
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
|
|
119495
|
+
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
|
|
119347
119496
|
return resolveNamesWithLocalCache({
|
|
119348
119497
|
names: typeDirectiveNames,
|
|
119349
119498
|
containingFile: containingFile,
|
|
@@ -119353,6 +119502,7 @@ var ts;
|
|
|
119353
119502
|
loader: resolveTypeReferenceDirective,
|
|
119354
119503
|
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
|
|
119355
119504
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
119505
|
+
containingSourceFileMode: containingFileMode
|
|
119356
119506
|
});
|
|
119357
119507
|
}
|
|
119358
119508
|
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
@@ -121261,7 +121411,7 @@ var ts;
|
|
|
121261
121411
|
}
|
|
121262
121412
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
121263
121413
|
}) :
|
|
121264
|
-
(function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
|
|
121414
|
+
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
121265
121415
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
121266
121416
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
121267
121417
|
synchronizeProgram();
|
|
@@ -121997,9 +122147,9 @@ var ts;
|
|
|
121997
122147
|
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
121998
122148
|
}
|
|
121999
122149
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
122000
|
-
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|
|
122001
|
-
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
|
|
122002
|
-
return ts.
|
|
122150
|
+
var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
|
|
122151
|
+
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
122152
|
+
return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
|
|
122003
122153
|
};
|
|
122004
122154
|
}
|
|
122005
122155
|
var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
|
|
@@ -126908,6 +127058,10 @@ var ts;
|
|
|
126908
127058
|
return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
|
|
126909
127059
|
}
|
|
126910
127060
|
ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
|
|
127061
|
+
function jsxModeNeedsExplicitImport(jsx) {
|
|
127062
|
+
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
127063
|
+
}
|
|
127064
|
+
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
126911
127065
|
// #endregion
|
|
126912
127066
|
})(ts || (ts = {}));
|
|
126913
127067
|
/*@internal*/
|
|
@@ -128852,9 +129006,18 @@ var ts;
|
|
|
128852
129006
|
return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
|
|
128853
129007
|
}
|
|
128854
129008
|
}
|
|
129009
|
+
function isEmitResolutionKindUsingNodeModules(compilerOptions) {
|
|
129010
|
+
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ||
|
|
129011
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
|
|
129012
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
|
|
129013
|
+
}
|
|
129014
|
+
function isEmitModuleResolutionRespectingExportMaps(compilerOptions) {
|
|
129015
|
+
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
|
|
129016
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
|
|
129017
|
+
}
|
|
128855
129018
|
function getSupportedExtensionsForModuleResolution(compilerOptions) {
|
|
128856
129019
|
var extensions = ts.getSupportedExtensions(compilerOptions);
|
|
128857
|
-
return
|
|
129020
|
+
return isEmitResolutionKindUsingNodeModules(compilerOptions) ?
|
|
128858
129021
|
ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
|
|
128859
129022
|
extensions;
|
|
128860
129023
|
}
|
|
@@ -129017,7 +129180,7 @@ var ts;
|
|
|
129017
129180
|
result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
129018
129181
|
}
|
|
129019
129182
|
getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
|
|
129020
|
-
if (
|
|
129183
|
+
if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
|
|
129021
129184
|
// If looking for a global package name, don't just include everything in `node_modules` because that includes dependencies' own dependencies.
|
|
129022
129185
|
// (But do if we didn't find anything, e.g. 'package.json' missing.)
|
|
129023
129186
|
var foundGlobal = false;
|
|
@@ -129034,12 +129197,68 @@ var ts;
|
|
|
129034
129197
|
}
|
|
129035
129198
|
}
|
|
129036
129199
|
if (!foundGlobal) {
|
|
129037
|
-
|
|
129200
|
+
var ancestorLookup = function (ancestor) {
|
|
129038
129201
|
var nodeModules = ts.combinePaths(ancestor, "node_modules");
|
|
129039
129202
|
if (ts.tryDirectoryExists(host, nodeModules)) {
|
|
129040
129203
|
getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result);
|
|
129041
129204
|
}
|
|
129042
|
-
}
|
|
129205
|
+
};
|
|
129206
|
+
if (fragmentDirectory && isEmitModuleResolutionRespectingExportMaps(compilerOptions)) {
|
|
129207
|
+
var nodeModulesDirectoryLookup_1 = ancestorLookup;
|
|
129208
|
+
ancestorLookup = function (ancestor) {
|
|
129209
|
+
var components = ts.getPathComponents(fragment);
|
|
129210
|
+
components.shift(); // shift off empty root
|
|
129211
|
+
var packagePath = components.shift();
|
|
129212
|
+
if (!packagePath) {
|
|
129213
|
+
return nodeModulesDirectoryLookup_1(ancestor);
|
|
129214
|
+
}
|
|
129215
|
+
if (ts.startsWith(packagePath, "@")) {
|
|
129216
|
+
var subName = components.shift();
|
|
129217
|
+
if (!subName) {
|
|
129218
|
+
return nodeModulesDirectoryLookup_1(ancestor);
|
|
129219
|
+
}
|
|
129220
|
+
packagePath = ts.combinePaths(packagePath, subName);
|
|
129221
|
+
}
|
|
129222
|
+
var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
|
|
129223
|
+
if (ts.tryFileExists(host, packageFile)) {
|
|
129224
|
+
var packageJson = ts.readJson(packageFile, host);
|
|
129225
|
+
var exports = packageJson.exports;
|
|
129226
|
+
if (exports) {
|
|
129227
|
+
if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
|
|
129228
|
+
return; // null exports or entrypoint only, no sub-modules available
|
|
129229
|
+
}
|
|
129230
|
+
var keys = ts.getOwnKeys(exports);
|
|
129231
|
+
var fragmentSubpath_1 = components.join("/");
|
|
129232
|
+
var processedKeys = ts.mapDefined(keys, function (k) {
|
|
129233
|
+
if (k === ".")
|
|
129234
|
+
return undefined;
|
|
129235
|
+
if (!ts.startsWith(k, "./"))
|
|
129236
|
+
return undefined;
|
|
129237
|
+
var subpath = k.substring(2);
|
|
129238
|
+
if (!ts.startsWith(subpath, fragmentSubpath_1))
|
|
129239
|
+
return undefined;
|
|
129240
|
+
// subpath is a valid export (barring conditions, which we don't currently check here)
|
|
129241
|
+
if (!ts.stringContains(subpath, "*")) {
|
|
129242
|
+
return subpath;
|
|
129243
|
+
}
|
|
129244
|
+
// pattern export - only return everything up to the `*`, so the user can autocomplete, then
|
|
129245
|
+
// keep filling in the pattern (we could speculatively return a list of options by hitting disk,
|
|
129246
|
+
// but conditions will make that somewhat awkward, as each condition may have a different set of possible
|
|
129247
|
+
// options for the `*`.
|
|
129248
|
+
return subpath.slice(0, subpath.indexOf("*"));
|
|
129249
|
+
});
|
|
129250
|
+
ts.forEach(processedKeys, function (k) {
|
|
129251
|
+
if (k) {
|
|
129252
|
+
result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
|
|
129253
|
+
}
|
|
129254
|
+
});
|
|
129255
|
+
return;
|
|
129256
|
+
}
|
|
129257
|
+
}
|
|
129258
|
+
return nodeModulesDirectoryLookup_1(ancestor);
|
|
129259
|
+
};
|
|
129260
|
+
}
|
|
129261
|
+
ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
|
|
129043
129262
|
}
|
|
129044
129263
|
}
|
|
129045
129264
|
return result;
|
|
@@ -130481,14 +130700,15 @@ var ts;
|
|
|
130481
130700
|
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
|
|
130482
130701
|
return { kind: 1 /* JsDocTagName */ };
|
|
130483
130702
|
}
|
|
130484
|
-
|
|
130703
|
+
var typeExpression = tryGetTypeExpressionFromTag(tag);
|
|
130704
|
+
if (typeExpression) {
|
|
130485
130705
|
currentToken = ts.getTokenAtPosition(sourceFile, position);
|
|
130486
130706
|
if (!currentToken ||
|
|
130487
130707
|
(!ts.isDeclarationName(currentToken) &&
|
|
130488
130708
|
(currentToken.parent.kind !== 345 /* JSDocPropertyTag */ ||
|
|
130489
130709
|
currentToken.parent.name !== currentToken))) {
|
|
130490
130710
|
// Use as type location if inside tag's type expression
|
|
130491
|
-
insideJsDocTagTypeExpression = isCurrentlyEditingNode(
|
|
130711
|
+
insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression);
|
|
130492
130712
|
}
|
|
130493
130713
|
}
|
|
130494
130714
|
if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) {
|
|
@@ -130745,10 +130965,19 @@ var ts;
|
|
|
130745
130965
|
case 341 /* JSDocTypeTag */:
|
|
130746
130966
|
case 343 /* JSDocTypedefTag */:
|
|
130747
130967
|
return true;
|
|
130968
|
+
case 342 /* JSDocTemplateTag */:
|
|
130969
|
+
return !!tag.constraint;
|
|
130748
130970
|
default:
|
|
130749
130971
|
return false;
|
|
130750
130972
|
}
|
|
130751
130973
|
}
|
|
130974
|
+
function tryGetTypeExpressionFromTag(tag) {
|
|
130975
|
+
if (isTagWithTypeExpression(tag)) {
|
|
130976
|
+
var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression;
|
|
130977
|
+
return typeExpression && typeExpression.kind === 307 /* JSDocTypeExpression */ ? typeExpression : undefined;
|
|
130978
|
+
}
|
|
130979
|
+
return undefined;
|
|
130980
|
+
}
|
|
130752
130981
|
function getTypeScriptMemberSymbols() {
|
|
130753
130982
|
// Right of dot member completion list
|
|
130754
130983
|
completionKind = 2 /* PropertyAccess */;
|
|
@@ -133504,7 +133733,7 @@ var ts;
|
|
|
133504
133733
|
}
|
|
133505
133734
|
for (var _c = 0, _d = referencingFile.typeReferenceDirectives; _c < _d.length; _c++) {
|
|
133506
133735
|
var ref = _d[_c];
|
|
133507
|
-
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName);
|
|
133736
|
+
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat);
|
|
133508
133737
|
if (referenced !== undefined && referenced.resolvedFileName === searchSourceFile.fileName) {
|
|
133509
133738
|
refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
|
|
133510
133739
|
}
|
|
@@ -136726,7 +136955,7 @@ var ts;
|
|
|
136726
136955
|
}
|
|
136727
136956
|
var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
|
136728
136957
|
if (typeReferenceDirective) {
|
|
136729
|
-
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
|
|
136958
|
+
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat);
|
|
136730
136959
|
var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217
|
|
136731
136960
|
return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false };
|
|
136732
136961
|
}
|
|
@@ -138532,6 +138761,7 @@ var ts;
|
|
|
138532
138761
|
return oldImports;
|
|
138533
138762
|
}
|
|
138534
138763
|
var typeChecker = program.getTypeChecker();
|
|
138764
|
+
var compilerOptions = program.getCompilerOptions();
|
|
138535
138765
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
138536
138766
|
var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile);
|
|
138537
138767
|
var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */);
|
|
@@ -138588,7 +138818,7 @@ var ts;
|
|
|
138588
138818
|
return usedImports;
|
|
138589
138819
|
function isDeclarationUsed(identifier) {
|
|
138590
138820
|
// The JSX factory symbol is always used if JSX elements are present - even if they are not allowed.
|
|
138591
|
-
return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) ||
|
|
138821
|
+
return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx) ||
|
|
138592
138822
|
ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile);
|
|
138593
138823
|
}
|
|
138594
138824
|
}
|
|
@@ -145828,8 +146058,18 @@ var ts;
|
|
|
145828
146058
|
var indent = sourceFile.text.slice(startPosition, fnStart);
|
|
145829
146059
|
this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
|
|
145830
146060
|
};
|
|
146061
|
+
ChangeTracker.prototype.createJSDocText = function (sourceFile, node) {
|
|
146062
|
+
var comments = ts.flatMap(node.jsDoc, function (jsDoc) {
|
|
146063
|
+
return ts.isString(jsDoc.comment) ? ts.factory.createJSDocText(jsDoc.comment) : jsDoc.comment;
|
|
146064
|
+
});
|
|
146065
|
+
var jsDoc = ts.singleOrUndefined(node.jsDoc);
|
|
146066
|
+
return jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && ts.length(comments) === 0 ? undefined :
|
|
146067
|
+
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
146068
|
+
};
|
|
146069
|
+
ChangeTracker.prototype.replaceJSDocComment = function (sourceFile, node, tags) {
|
|
146070
|
+
this.insertJsdocCommentBefore(sourceFile, updateJSDocHost(node), ts.factory.createJSDocComment(this.createJSDocText(sourceFile, node), ts.factory.createNodeArray(tags)));
|
|
146071
|
+
};
|
|
145831
146072
|
ChangeTracker.prototype.addJSDocTags = function (sourceFile, parent, newTags) {
|
|
145832
|
-
var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
|
|
145833
146073
|
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
145834
146074
|
var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags.some(function (tag, i) {
|
|
145835
146075
|
var merged = tryMergeJsdocTags(tag, newTag);
|
|
@@ -145837,20 +146077,10 @@ var ts;
|
|
|
145837
146077
|
oldTags[i] = merged;
|
|
145838
146078
|
return !!merged;
|
|
145839
146079
|
}); });
|
|
145840
|
-
|
|
145841
|
-
var jsDoc = ts.singleOrUndefined(parent.jsDoc);
|
|
145842
|
-
var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
|
|
145843
|
-
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
145844
|
-
var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
|
|
145845
|
-
var host = updateJSDocHost(parent);
|
|
145846
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
146080
|
+
this.replaceJSDocComment(sourceFile, parent, __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true));
|
|
145847
146081
|
};
|
|
145848
146082
|
ChangeTracker.prototype.filterJSDocTags = function (sourceFile, parent, predicate) {
|
|
145849
|
-
|
|
145850
|
-
var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
|
|
145851
|
-
var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray([], (ts.filter(oldTags, predicate) || ts.emptyArray), true)));
|
|
145852
|
-
var host = updateJSDocHost(parent);
|
|
145853
|
-
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
146083
|
+
this.replaceJSDocComment(sourceFile, parent, ts.filter(ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }), predicate));
|
|
145854
146084
|
};
|
|
145855
146085
|
ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) {
|
|
145856
146086
|
this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text });
|
|
@@ -149645,9 +149875,9 @@ var ts;
|
|
|
149645
149875
|
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
|
|
149646
149876
|
var checker = program.getTypeChecker();
|
|
149647
149877
|
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
|
|
149648
|
-
var
|
|
149878
|
+
var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
|
|
149649
149879
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149650
|
-
var fix = getImportFixForSymbol(sourceFile,
|
|
149880
|
+
var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
149651
149881
|
if (fix) {
|
|
149652
149882
|
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
149653
149883
|
}
|
|
@@ -149836,7 +150066,7 @@ var ts;
|
|
|
149836
150066
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
149837
150067
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
149838
150068
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
149839
|
-
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
|
|
150069
|
+
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
|
|
149840
150070
|
}
|
|
149841
150071
|
function codeFixActionToCodeAction(_a) {
|
|
149842
150072
|
var description = _a.description, changes = _a.changes, commands = _a.commands;
|
|
@@ -149896,7 +150126,7 @@ var ts;
|
|
|
149896
150126
|
/*position*/ undefined,
|
|
149897
150127
|
/*isValidTypeOnlyUseSite*/ false,
|
|
149898
150128
|
/*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
149899
|
-
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
|
|
150129
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
|
|
149900
150130
|
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
149901
150131
|
}
|
|
149902
150132
|
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
@@ -150066,7 +150296,7 @@ var ts;
|
|
|
150066
150296
|
// 5. Literally nothing to go on
|
|
150067
150297
|
return true;
|
|
150068
150298
|
}
|
|
150069
|
-
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire,
|
|
150299
|
+
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
|
|
150070
150300
|
var isJs = ts.isSourceFileJS(sourceFile);
|
|
150071
150301
|
var compilerOptions = program.getCompilerOptions();
|
|
150072
150302
|
var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
|
|
@@ -150075,7 +150305,7 @@ var ts;
|
|
|
150075
150305
|
? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
|
|
150076
150306
|
: function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
|
|
150077
150307
|
var computedWithoutCacheCount = 0;
|
|
150078
|
-
var fixes = ts.flatMap(
|
|
150308
|
+
var fixes = ts.flatMap(exportInfo, function (exportInfo, i) {
|
|
150079
150309
|
var checker = getChecker(exportInfo.isFromPackageJson);
|
|
150080
150310
|
var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
|
|
150081
150311
|
var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
|
|
@@ -150084,7 +150314,7 @@ var ts;
|
|
|
150084
150314
|
return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
|
|
150085
150315
|
// `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
|
|
150086
150316
|
return !importedSymbolHasValueMeaning && isJs && position !== undefined
|
|
150087
|
-
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo }
|
|
150317
|
+
? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
|
|
150088
150318
|
: {
|
|
150089
150319
|
kind: 3 /* AddNew */,
|
|
150090
150320
|
moduleSpecifier: moduleSpecifier,
|
|
@@ -150092,6 +150322,7 @@ var ts;
|
|
|
150092
150322
|
useRequire: useRequire,
|
|
150093
150323
|
addAsTypeOnly: addAsTypeOnly,
|
|
150094
150324
|
exportInfo: exportInfo,
|
|
150325
|
+
isReExport: i > 0,
|
|
150095
150326
|
};
|
|
150096
150327
|
});
|
|
150097
150328
|
});
|
|
@@ -150129,12 +150360,13 @@ var ts;
|
|
|
150129
150360
|
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
150130
150361
|
}
|
|
150131
150362
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
150132
|
-
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
150363
|
+
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
|
|
150133
150364
|
}
|
|
150134
|
-
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150135
|
-
|
|
150365
|
+
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150366
|
+
var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
|
|
150367
|
+
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
|
|
150136
150368
|
}
|
|
150137
|
-
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150369
|
+
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
|
|
150138
150370
|
if (!ts.some(fixes))
|
|
150139
150371
|
return;
|
|
150140
150372
|
// These will always be placed first if available, and are better than other kinds
|
|
@@ -150143,22 +150375,37 @@ var ts;
|
|
|
150143
150375
|
}
|
|
150144
150376
|
return fixes.reduce(function (best, fix) {
|
|
150145
150377
|
// Takes true branch of conditional if `fix` is better than `best`
|
|
150146
|
-
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
150378
|
+
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best;
|
|
150147
150379
|
});
|
|
150148
150380
|
}
|
|
150149
150381
|
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
150150
|
-
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
|
|
150382
|
+
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) {
|
|
150151
150383
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
150152
150384
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
150153
150385
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
150154
|
-
|| ts.compareBooleans(
|
|
150386
|
+
|| ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath))
|
|
150155
150387
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
150156
150388
|
}
|
|
150157
150389
|
return 0 /* EqualTo */;
|
|
150158
150390
|
}
|
|
150159
|
-
|
|
150160
|
-
|
|
150161
|
-
|
|
150391
|
+
// This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export.
|
|
150392
|
+
// E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`.
|
|
150393
|
+
// This can produce false positives or negatives if re-exports cross into sibling directories
|
|
150394
|
+
// (e.g. `export * from "../whatever"`) or are not named "index" (we don't even try to consider
|
|
150395
|
+
// this if we're in a resolution mode where you can't drop trailing "/index" from paths).
|
|
150396
|
+
function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath) {
|
|
150397
|
+
var _a;
|
|
150398
|
+
if (fix.isReExport &&
|
|
150399
|
+
((_a = fix.exportInfo) === null || _a === void 0 ? void 0 : _a.moduleFileName) &&
|
|
150400
|
+
ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
|
|
150401
|
+
isIndexFileName(fix.exportInfo.moduleFileName)) {
|
|
150402
|
+
var reExportDir = toPath(ts.getDirectoryPath(fix.exportInfo.moduleFileName));
|
|
150403
|
+
return ts.startsWith((importingFile.path), reExportDir);
|
|
150404
|
+
}
|
|
150405
|
+
return false;
|
|
150406
|
+
}
|
|
150407
|
+
function isIndexFileName(fileName) {
|
|
150408
|
+
return ts.getBaseFileName(fileName, [".js", ".jsx", ".d.ts", ".ts", ".tsx"], /*ignoreCase*/ true) === "index";
|
|
150162
150409
|
}
|
|
150163
150410
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
150164
150411
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
@@ -150176,9 +150423,9 @@ var ts;
|
|
|
150176
150423
|
return undefined;
|
|
150177
150424
|
var symbol = checker.getAliasedSymbol(umdSymbol);
|
|
150178
150425
|
var symbolName = umdSymbol.name;
|
|
150179
|
-
var
|
|
150426
|
+
var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
150180
150427
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150181
|
-
var fixes = getImportFixes(
|
|
150428
|
+
var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
150182
150429
|
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
150183
150430
|
}
|
|
150184
150431
|
function getUmdSymbol(token, checker) {
|
|
@@ -150245,8 +150492,8 @@ var ts;
|
|
|
150245
150492
|
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
|
|
150246
150493
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
|
|
150247
150494
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
150248
|
-
var
|
|
150249
|
-
var fixes = ts.arrayFrom(ts.flatMapIterator(
|
|
150495
|
+
var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
150496
|
+
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
|
|
150250
150497
|
var _ = _a[0], exportInfos = _a[1];
|
|
150251
150498
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
150252
150499
|
}));
|
|
@@ -150262,12 +150509,9 @@ var ts;
|
|
|
150262
150509
|
return undefined;
|
|
150263
150510
|
return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
|
|
150264
150511
|
}
|
|
150265
|
-
function jsxModeNeedsExplicitImport(jsx) {
|
|
150266
|
-
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
150267
|
-
}
|
|
150268
150512
|
function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
|
|
150269
150513
|
var parent = symbolToken.parent;
|
|
150270
|
-
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
150514
|
+
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
150271
150515
|
var jsxNamespace = checker.getJsxNamespace(sourceFile);
|
|
150272
150516
|
if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
|
|
150273
150517
|
return jsxNamespace;
|
|
@@ -152347,6 +152591,95 @@ var ts;
|
|
|
152347
152591
|
})(ts || (ts = {}));
|
|
152348
152592
|
/* @internal */
|
|
152349
152593
|
var ts;
|
|
152594
|
+
(function (ts) {
|
|
152595
|
+
var codefix;
|
|
152596
|
+
(function (codefix) {
|
|
152597
|
+
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
152598
|
+
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
152599
|
+
var errorCodes = [
|
|
152600
|
+
ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code,
|
|
152601
|
+
];
|
|
152602
|
+
codefix.registerCodeFix({
|
|
152603
|
+
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
152604
|
+
errorCodes: errorCodes,
|
|
152605
|
+
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
152606
|
+
var sourceFile = context.sourceFile, span = context.span;
|
|
152607
|
+
var actions = [];
|
|
152608
|
+
var info = getInfo(sourceFile, span.start);
|
|
152609
|
+
if (info) {
|
|
152610
|
+
ts.append(actions, getDeleteAction(context, info));
|
|
152611
|
+
ts.append(actions, getRenameAction(context, info));
|
|
152612
|
+
return actions;
|
|
152613
|
+
}
|
|
152614
|
+
return undefined;
|
|
152615
|
+
},
|
|
152616
|
+
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
152617
|
+
var tagsToSignature = new ts.Map();
|
|
152618
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
152619
|
+
codefix.eachDiagnostic(context, errorCodes, function (_a) {
|
|
152620
|
+
var file = _a.file, start = _a.start;
|
|
152621
|
+
var info = getInfo(file, start);
|
|
152622
|
+
if (info) {
|
|
152623
|
+
tagsToSignature.set(info.signature, ts.append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
152624
|
+
}
|
|
152625
|
+
});
|
|
152626
|
+
tagsToSignature.forEach(function (tags, signature) {
|
|
152627
|
+
if (context.fixId === deleteUnmatchedParameter) {
|
|
152628
|
+
var tagsSet_1 = new ts.Set(tags);
|
|
152629
|
+
changes.filterJSDocTags(signature.getSourceFile(), signature, function (t) { return !tagsSet_1.has(t); });
|
|
152630
|
+
}
|
|
152631
|
+
});
|
|
152632
|
+
}));
|
|
152633
|
+
}
|
|
152634
|
+
});
|
|
152635
|
+
function getDeleteAction(context, _a) {
|
|
152636
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
152637
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
152638
|
+
return changeTracker.filterJSDocTags(context.sourceFile, signature, function (t) { return t !== jsDocParameterTag; });
|
|
152639
|
+
});
|
|
152640
|
+
return codefix.createCodeFixAction(deleteUnmatchedParameter, changes, [ts.Diagnostics.Delete_unused_param_tag_0, name.getText(context.sourceFile)], deleteUnmatchedParameter, ts.Diagnostics.Delete_all_unused_param_tags);
|
|
152641
|
+
}
|
|
152642
|
+
function getRenameAction(context, _a) {
|
|
152643
|
+
var name = _a.name, signature = _a.signature, jsDocParameterTag = _a.jsDocParameterTag;
|
|
152644
|
+
if (!ts.length(signature.parameters))
|
|
152645
|
+
return undefined;
|
|
152646
|
+
var sourceFile = context.sourceFile;
|
|
152647
|
+
var tags = ts.getJSDocTags(signature);
|
|
152648
|
+
var names = new ts.Set();
|
|
152649
|
+
for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
|
|
152650
|
+
var tag = tags_2[_i];
|
|
152651
|
+
if (ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name)) {
|
|
152652
|
+
names.add(tag.name.escapedText);
|
|
152653
|
+
}
|
|
152654
|
+
}
|
|
152655
|
+
// @todo - match to all available names instead to the first parameter name
|
|
152656
|
+
// @see /codeFixRenameUnmatchedParameter3.ts
|
|
152657
|
+
var parameterName = ts.firstDefined(signature.parameters, function (p) {
|
|
152658
|
+
return ts.isIdentifier(p.name) && !names.has(p.name.escapedText) ? p.name.getText(sourceFile) : undefined;
|
|
152659
|
+
});
|
|
152660
|
+
if (parameterName === undefined)
|
|
152661
|
+
return undefined;
|
|
152662
|
+
var newJSDocParameterTag = ts.factory.updateJSDocParameterTag(jsDocParameterTag, jsDocParameterTag.tagName, ts.factory.createIdentifier(parameterName), jsDocParameterTag.isBracketed, jsDocParameterTag.typeExpression, jsDocParameterTag.isNameFirst, jsDocParameterTag.comment);
|
|
152663
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) {
|
|
152664
|
+
return changeTracker.replaceJSDocComment(sourceFile, signature, ts.map(tags, function (t) { return t === jsDocParameterTag ? newJSDocParameterTag : t; }));
|
|
152665
|
+
});
|
|
152666
|
+
return codefix.createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [ts.Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
|
|
152667
|
+
}
|
|
152668
|
+
function getInfo(sourceFile, pos) {
|
|
152669
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
152670
|
+
if (token.parent && ts.isJSDocParameterTag(token.parent) && ts.isIdentifier(token.parent.name)) {
|
|
152671
|
+
var jsDocParameterTag = token.parent;
|
|
152672
|
+
var signature = ts.getHostSignatureFromJSDoc(jsDocParameterTag);
|
|
152673
|
+
if (signature) {
|
|
152674
|
+
return { signature: signature, name: token.parent.name, jsDocParameterTag: jsDocParameterTag };
|
|
152675
|
+
}
|
|
152676
|
+
}
|
|
152677
|
+
return undefined;
|
|
152678
|
+
}
|
|
152679
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
152680
|
+
})(ts || (ts = {}));
|
|
152681
|
+
/* @internal */
|
|
152682
|
+
var ts;
|
|
152350
152683
|
(function (ts) {
|
|
152351
152684
|
var codefix;
|
|
152352
152685
|
(function (codefix) {
|
|
@@ -163444,7 +163777,7 @@ var ts;
|
|
|
163444
163777
|
if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
|
|
163445
163778
|
this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) {
|
|
163446
163779
|
var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); // TODO: GH#18217
|
|
163447
|
-
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); });
|
|
163780
|
+
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, ts.isString(name) ? name : name.fileName.toLowerCase()); });
|
|
163448
163781
|
};
|
|
163449
163782
|
}
|
|
163450
163783
|
}
|
|
@@ -166143,8 +166476,8 @@ var ts;
|
|
|
166143
166476
|
Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile, resolutionMode) {
|
|
166144
166477
|
return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
|
|
166145
166478
|
};
|
|
166146
|
-
Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference) {
|
|
166147
|
-
return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference);
|
|
166479
|
+
Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
166480
|
+
return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode);
|
|
166148
166481
|
};
|
|
166149
166482
|
Project.prototype.directoryExists = function (path) {
|
|
166150
166483
|
return this.directoryStructureHost.directoryExists(path); // TODO: GH#18217
|