typescript 4.5.0-dev.20210928 → 4.5.0-dev.20211002
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 +17 -4
- package/lib/de/diagnosticMessages.generated.json +6 -4
- package/lib/es/diagnosticMessages.generated.json +17 -4
- package/lib/fr/diagnosticMessages.generated.json +17 -4
- package/lib/it/diagnosticMessages.generated.json +6 -4
- package/lib/ja/diagnosticMessages.generated.json +17 -4
- package/lib/ko/diagnosticMessages.generated.json +6 -4
- package/lib/lib.es5.d.ts +10 -10
- package/lib/pl/diagnosticMessages.generated.json +17 -4
- package/lib/pt-br/diagnosticMessages.generated.json +17 -4
- package/lib/ru/diagnosticMessages.generated.json +2 -0
- package/lib/tr/diagnosticMessages.generated.json +17 -4
- package/lib/tsc.js +405 -224
- package/lib/tsserver.js +453 -231
- package/lib/tsserverlibrary.d.ts +1 -0
- package/lib/tsserverlibrary.js +453 -231
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +448 -228
- package/lib/typescriptServices.d.ts +1 -0
- package/lib/typescriptServices.js +448 -228
- package/lib/typingsInstaller.js +440 -224
- package/lib/zh-cn/diagnosticMessages.generated.json +17 -4
- package/lib/zh-tw/diagnosticMessages.generated.json +6 -4
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211002";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -5143,6 +5143,7 @@ var ts;
|
|
|
5143
5143
|
// module kind).
|
|
5144
5144
|
ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
|
|
5145
5145
|
ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
|
|
5146
|
+
ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022";
|
|
5146
5147
|
ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
|
|
5147
5148
|
// Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext
|
|
5148
5149
|
ModuleKind[ModuleKind["Node12"] = 100] = "Node12";
|
|
@@ -8060,7 +8061,7 @@ var ts;
|
|
|
8060
8061
|
Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."),
|
|
8061
8062
|
Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."),
|
|
8062
8063
|
Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."),
|
|
8063
|
-
|
|
8064
|
+
Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."),
|
|
8064
8065
|
Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext'."),
|
|
8065
8066
|
Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."),
|
|
8066
8067
|
Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
|
|
@@ -8078,7 +8079,7 @@ var ts;
|
|
|
8078
8079
|
Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."),
|
|
8079
8080
|
Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"),
|
|
8080
8081
|
Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
|
|
8081
|
-
|
|
8082
|
+
The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."),
|
|
8082
8083
|
A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
|
|
8083
8084
|
An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."),
|
|
8084
8085
|
This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."),
|
|
@@ -8109,7 +8110,7 @@ var ts;
|
|
|
8109
8110
|
await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
8110
8111
|
_0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
|
|
8111
8112
|
_0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
|
|
8112
|
-
|
|
8113
|
+
Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
8113
8114
|
An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."),
|
|
8114
8115
|
An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."),
|
|
8115
8116
|
Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"),
|
|
@@ -8161,7 +8162,7 @@ var ts;
|
|
|
8161
8162
|
File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
|
|
8162
8163
|
The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"),
|
|
8163
8164
|
for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
8164
|
-
|
|
8165
|
+
Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
8165
8166
|
Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."),
|
|
8166
8167
|
Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
|
|
8167
8168
|
Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"),
|
|
@@ -19614,6 +19615,7 @@ var ts;
|
|
|
19614
19615
|
case ts.ModuleKind.AMD:
|
|
19615
19616
|
case ts.ModuleKind.ES2015:
|
|
19616
19617
|
case ts.ModuleKind.ES2020:
|
|
19618
|
+
case ts.ModuleKind.ES2022:
|
|
19617
19619
|
case ts.ModuleKind.ESNext:
|
|
19618
19620
|
return true;
|
|
19619
19621
|
default:
|
|
@@ -20718,6 +20720,10 @@ var ts;
|
|
|
20718
20720
|
return !!declaration && (ts.isParameter(declaration) || isCatchClauseVariableDeclaration(declaration));
|
|
20719
20721
|
}
|
|
20720
20722
|
ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable;
|
|
20723
|
+
function isFunctionExpressionOrArrowFunction(node) {
|
|
20724
|
+
return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
|
|
20725
|
+
}
|
|
20726
|
+
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20721
20727
|
})(ts || (ts = {}));
|
|
20722
20728
|
/* @internal */
|
|
20723
20729
|
var ts;
|
|
@@ -31342,7 +31348,6 @@ var ts;
|
|
|
31342
31348
|
case 88 /* DefaultKeyword */:
|
|
31343
31349
|
return nextTokenCanFollowDefaultKeyword();
|
|
31344
31350
|
case 124 /* StaticKeyword */:
|
|
31345
|
-
return nextTokenIsOnSameLineAndCanFollowModifier();
|
|
31346
31351
|
case 136 /* GetKeyword */:
|
|
31347
31352
|
case 148 /* SetKeyword */:
|
|
31348
31353
|
nextToken();
|
|
@@ -35585,7 +35590,7 @@ var ts;
|
|
|
35585
35590
|
}
|
|
35586
35591
|
return list && createNodeArray(list, pos);
|
|
35587
35592
|
}
|
|
35588
|
-
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35593
|
+
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
|
|
35589
35594
|
var pos = getNodePos();
|
|
35590
35595
|
var kind = token();
|
|
35591
35596
|
if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) {
|
|
@@ -35598,6 +35603,9 @@ var ts;
|
|
|
35598
35603
|
else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
|
|
35599
35604
|
return undefined;
|
|
35600
35605
|
}
|
|
35606
|
+
else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) {
|
|
35607
|
+
return undefined;
|
|
35608
|
+
}
|
|
35601
35609
|
else {
|
|
35602
35610
|
if (!parseAnyContextualModifier()) {
|
|
35603
35611
|
return undefined;
|
|
@@ -35614,8 +35622,10 @@ var ts;
|
|
|
35614
35622
|
*/
|
|
35615
35623
|
function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35616
35624
|
var pos = getNodePos();
|
|
35617
|
-
var list, modifier;
|
|
35618
|
-
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) {
|
|
35625
|
+
var list, modifier, hasSeenStatic = false;
|
|
35626
|
+
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) {
|
|
35627
|
+
if (modifier.kind === 124 /* StaticKeyword */)
|
|
35628
|
+
hasSeenStatic = true;
|
|
35619
35629
|
list = ts.append(list, modifier);
|
|
35620
35630
|
}
|
|
35621
35631
|
return list && createNodeArray(list, pos);
|
|
@@ -38320,6 +38330,7 @@ var ts;
|
|
|
38320
38330
|
es6: ts.ModuleKind.ES2015,
|
|
38321
38331
|
es2015: ts.ModuleKind.ES2015,
|
|
38322
38332
|
es2020: ts.ModuleKind.ES2020,
|
|
38333
|
+
es2022: ts.ModuleKind.ES2022,
|
|
38323
38334
|
esnext: ts.ModuleKind.ESNext,
|
|
38324
38335
|
node12: ts.ModuleKind.Node12,
|
|
38325
38336
|
nodenext: ts.ModuleKind.NodeNext,
|
|
@@ -40027,6 +40038,44 @@ var ts;
|
|
|
40027
40038
|
}
|
|
40028
40039
|
return result;
|
|
40029
40040
|
}
|
|
40041
|
+
/**
|
|
40042
|
+
* Generate a list of the compiler options whose value is not the default.
|
|
40043
|
+
* @param options compilerOptions to be evaluated.
|
|
40044
|
+
/** @internal */
|
|
40045
|
+
function getCompilerOptionsDiffValue(options, newLine) {
|
|
40046
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
40047
|
+
return getOverwrittenDefaultOptions();
|
|
40048
|
+
function makePadding(paddingLength) {
|
|
40049
|
+
return Array(paddingLength + 1).join(" ");
|
|
40050
|
+
}
|
|
40051
|
+
function getOverwrittenDefaultOptions() {
|
|
40052
|
+
var result = [];
|
|
40053
|
+
var tab = makePadding(2);
|
|
40054
|
+
commandOptionsWithoutBuild.forEach(function (cmd) {
|
|
40055
|
+
if (!compilerOptionsMap.has(cmd.name)) {
|
|
40056
|
+
return;
|
|
40057
|
+
}
|
|
40058
|
+
var newValue = compilerOptionsMap.get(cmd.name);
|
|
40059
|
+
var defaultValue = getDefaultValueForOption(cmd);
|
|
40060
|
+
if (newValue !== defaultValue) {
|
|
40061
|
+
result.push("" + tab + cmd.name + ": " + newValue);
|
|
40062
|
+
}
|
|
40063
|
+
else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) {
|
|
40064
|
+
result.push("" + tab + cmd.name + ": " + defaultValue);
|
|
40065
|
+
}
|
|
40066
|
+
});
|
|
40067
|
+
return result.join(newLine) + newLine;
|
|
40068
|
+
}
|
|
40069
|
+
}
|
|
40070
|
+
ts.getCompilerOptionsDiffValue = getCompilerOptionsDiffValue;
|
|
40071
|
+
/**
|
|
40072
|
+
* Get the compiler options to be written into the tsconfig.json.
|
|
40073
|
+
* @param options commandlineOptions to be included in the compileOptions.
|
|
40074
|
+
*/
|
|
40075
|
+
function getSerializedCompilerOption(options) {
|
|
40076
|
+
var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
|
|
40077
|
+
return serializeCompilerOptions(compilerOptions);
|
|
40078
|
+
}
|
|
40030
40079
|
/**
|
|
40031
40080
|
* Generate tsconfig configuration when running command line "--init"
|
|
40032
40081
|
* @param options commandlineOptions to be generated into tsconfig.json
|
|
@@ -40034,28 +40083,8 @@ var ts;
|
|
|
40034
40083
|
*/
|
|
40035
40084
|
/* @internal */
|
|
40036
40085
|
function generateTSConfig(options, fileNames, newLine) {
|
|
40037
|
-
var
|
|
40038
|
-
var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
|
|
40086
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
40039
40087
|
return writeConfigurations();
|
|
40040
|
-
function getDefaultValueForOption(option) {
|
|
40041
|
-
switch (option.type) {
|
|
40042
|
-
case "number":
|
|
40043
|
-
return 1;
|
|
40044
|
-
case "boolean":
|
|
40045
|
-
return true;
|
|
40046
|
-
case "string":
|
|
40047
|
-
return option.isFilePath ? "./" : "";
|
|
40048
|
-
case "list":
|
|
40049
|
-
return [];
|
|
40050
|
-
case "object":
|
|
40051
|
-
return {};
|
|
40052
|
-
default:
|
|
40053
|
-
var iterResult = option.type.keys().next();
|
|
40054
|
-
if (!iterResult.done)
|
|
40055
|
-
return iterResult.value;
|
|
40056
|
-
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
40057
|
-
}
|
|
40058
|
-
}
|
|
40059
40088
|
function makePadding(paddingLength) {
|
|
40060
40089
|
return Array(paddingLength + 1).join(" ");
|
|
40061
40090
|
}
|
|
@@ -41042,6 +41071,25 @@ var ts;
|
|
|
41042
41071
|
}); // TODO: GH#18217
|
|
41043
41072
|
}
|
|
41044
41073
|
}
|
|
41074
|
+
function getDefaultValueForOption(option) {
|
|
41075
|
+
switch (option.type) {
|
|
41076
|
+
case "number":
|
|
41077
|
+
return 1;
|
|
41078
|
+
case "boolean":
|
|
41079
|
+
return true;
|
|
41080
|
+
case "string":
|
|
41081
|
+
return option.isFilePath ? "./" : "";
|
|
41082
|
+
case "list":
|
|
41083
|
+
return [];
|
|
41084
|
+
case "object":
|
|
41085
|
+
return {};
|
|
41086
|
+
default:
|
|
41087
|
+
var iterResult = option.type.keys().next();
|
|
41088
|
+
if (!iterResult.done)
|
|
41089
|
+
return iterResult.value;
|
|
41090
|
+
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
41091
|
+
}
|
|
41092
|
+
}
|
|
41045
41093
|
})(ts || (ts = {}));
|
|
41046
41094
|
var ts;
|
|
41047
41095
|
(function (ts) {
|
|
@@ -42418,9 +42466,11 @@ var ts;
|
|
|
42418
42466
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42419
42467
|
}
|
|
42420
42468
|
ts.parsePackageName = parsePackageName;
|
|
42469
|
+
/* @internal */
|
|
42421
42470
|
function allKeysStartWithDot(obj) {
|
|
42422
42471
|
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42423
42472
|
}
|
|
42473
|
+
ts.allKeysStartWithDot = allKeysStartWithDot;
|
|
42424
42474
|
function noKeyStartsWithDot(obj) {
|
|
42425
42475
|
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42426
42476
|
}
|
|
@@ -42627,17 +42677,19 @@ var ts;
|
|
|
42627
42677
|
}
|
|
42628
42678
|
return toSearchResult(/*value*/ undefined);
|
|
42629
42679
|
}
|
|
42630
|
-
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42631
|
-
if (conditions.indexOf("types") === -1)
|
|
42632
|
-
return false; // only apply versioned types conditions if the types condition is applied
|
|
42633
|
-
if (!ts.startsWith(key, "types@"))
|
|
42634
|
-
return false;
|
|
42635
|
-
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42636
|
-
if (!range)
|
|
42637
|
-
return false;
|
|
42638
|
-
return range.test(ts.version);
|
|
42639
|
-
}
|
|
42640
42680
|
}
|
|
42681
|
+
/* @internal */
|
|
42682
|
+
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42683
|
+
if (conditions.indexOf("types") === -1)
|
|
42684
|
+
return false; // only apply versioned types conditions if the types condition is applied
|
|
42685
|
+
if (!ts.startsWith(key, "types@"))
|
|
42686
|
+
return false;
|
|
42687
|
+
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42688
|
+
if (!range)
|
|
42689
|
+
return false;
|
|
42690
|
+
return range.test(ts.version);
|
|
42691
|
+
}
|
|
42692
|
+
ts.isApplicableVersionedTypesKey = isApplicableVersionedTypesKey;
|
|
42641
42693
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42642
42694
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42643
42695
|
}
|
|
@@ -46453,6 +46505,13 @@ var ts;
|
|
|
46453
46505
|
IntersectionState[IntersectionState["UnionIntersectionCheck"] = 8] = "UnionIntersectionCheck";
|
|
46454
46506
|
IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
|
|
46455
46507
|
})(IntersectionState || (IntersectionState = {}));
|
|
46508
|
+
var RecursionFlags;
|
|
46509
|
+
(function (RecursionFlags) {
|
|
46510
|
+
RecursionFlags[RecursionFlags["None"] = 0] = "None";
|
|
46511
|
+
RecursionFlags[RecursionFlags["Source"] = 1] = "Source";
|
|
46512
|
+
RecursionFlags[RecursionFlags["Target"] = 2] = "Target";
|
|
46513
|
+
RecursionFlags[RecursionFlags["Both"] = 3] = "Both";
|
|
46514
|
+
})(RecursionFlags || (RecursionFlags = {}));
|
|
46456
46515
|
var MappedTypeModifiers;
|
|
46457
46516
|
(function (MappedTypeModifiers) {
|
|
46458
46517
|
MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly";
|
|
@@ -47215,17 +47274,9 @@ var ts;
|
|
|
47215
47274
|
}
|
|
47216
47275
|
}
|
|
47217
47276
|
else {
|
|
47218
|
-
|
|
47219
|
-
|
|
47220
|
-
|
|
47221
|
-
var jsxPragma = file.pragmas.get("jsx");
|
|
47222
|
-
if (jsxPragma) {
|
|
47223
|
-
var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
|
|
47224
|
-
file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
|
|
47225
|
-
ts.visitNode(file.localJsxFactory, markAsSynthetic);
|
|
47226
|
-
if (file.localJsxFactory) {
|
|
47227
|
-
return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
|
|
47228
|
-
}
|
|
47277
|
+
var localJsxNamespace = getLocalJsxNamespace(file);
|
|
47278
|
+
if (localJsxNamespace) {
|
|
47279
|
+
return file.localJsxNamespace = localJsxNamespace;
|
|
47229
47280
|
}
|
|
47230
47281
|
}
|
|
47231
47282
|
}
|
|
@@ -47247,11 +47298,25 @@ var ts;
|
|
|
47247
47298
|
_jsxFactoryEntity = ts.factory.createQualifiedName(ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
|
|
47248
47299
|
}
|
|
47249
47300
|
return _jsxNamespace;
|
|
47250
|
-
|
|
47251
|
-
|
|
47252
|
-
|
|
47301
|
+
}
|
|
47302
|
+
function getLocalJsxNamespace(file) {
|
|
47303
|
+
if (file.localJsxNamespace) {
|
|
47304
|
+
return file.localJsxNamespace;
|
|
47305
|
+
}
|
|
47306
|
+
var jsxPragma = file.pragmas.get("jsx");
|
|
47307
|
+
if (jsxPragma) {
|
|
47308
|
+
var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
|
|
47309
|
+
file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
|
|
47310
|
+
ts.visitNode(file.localJsxFactory, markAsSynthetic);
|
|
47311
|
+
if (file.localJsxFactory) {
|
|
47312
|
+
return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
|
|
47313
|
+
}
|
|
47253
47314
|
}
|
|
47254
47315
|
}
|
|
47316
|
+
function markAsSynthetic(node) {
|
|
47317
|
+
ts.setTextRangePosEnd(node, -1, -1);
|
|
47318
|
+
return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
|
|
47319
|
+
}
|
|
47255
47320
|
function getEmitResolver(sourceFile, cancellationToken) {
|
|
47256
47321
|
// Ensure we have all the type information in place for this file so that all the
|
|
47257
47322
|
// emitter questions of this resolver will return the right information.
|
|
@@ -48678,7 +48743,21 @@ var ts;
|
|
|
48678
48743
|
function isSyntacticDefault(node) {
|
|
48679
48744
|
return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node));
|
|
48680
48745
|
}
|
|
48681
|
-
function
|
|
48746
|
+
function getUsageModeForExpression(usage) {
|
|
48747
|
+
return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined;
|
|
48748
|
+
}
|
|
48749
|
+
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
48750
|
+
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
48751
|
+
}
|
|
48752
|
+
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
48753
|
+
var usageMode = file && getUsageModeForExpression(usage);
|
|
48754
|
+
if (file && usageMode !== undefined) {
|
|
48755
|
+
var result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
|
48756
|
+
if (usageMode === ts.ModuleKind.ESNext || result) {
|
|
48757
|
+
return result;
|
|
48758
|
+
}
|
|
48759
|
+
// fallthrough on cjs usages so we imply defaults for interop'd imports, too
|
|
48760
|
+
}
|
|
48682
48761
|
if (!allowSyntheticDefaultImports) {
|
|
48683
48762
|
return false;
|
|
48684
48763
|
}
|
|
@@ -48720,7 +48799,7 @@ var ts;
|
|
|
48720
48799
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
48721
48800
|
}
|
|
48722
48801
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48723
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
|
|
48802
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
48724
48803
|
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
48725
48804
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
48726
48805
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
@@ -48860,7 +48939,7 @@ var ts;
|
|
|
48860
48939
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
48861
48940
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
48862
48941
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48863
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
|
|
48942
|
+
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
48864
48943
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
48865
48944
|
}
|
|
48866
48945
|
}
|
|
@@ -49551,7 +49630,7 @@ var ts;
|
|
|
49551
49630
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49552
49631
|
}
|
|
49553
49632
|
if (sigs && sigs.length) {
|
|
49554
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
|
|
49633
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier);
|
|
49555
49634
|
// Create a new symbol which has the module's type less the call and construct signatures
|
|
49556
49635
|
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49557
49636
|
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
@@ -57247,7 +57326,7 @@ var ts;
|
|
|
57247
57326
|
else if (type !== firstType) {
|
|
57248
57327
|
checkFlags |= 64 /* HasNonUniformType */;
|
|
57249
57328
|
}
|
|
57250
|
-
if (isLiteralType(type)) {
|
|
57329
|
+
if (isLiteralType(type) || isPatternLiteralType(type)) {
|
|
57251
57330
|
checkFlags |= 128 /* HasLiteralType */;
|
|
57252
57331
|
}
|
|
57253
57332
|
if (type.flags & 131072 /* Never */) {
|
|
@@ -61641,7 +61720,7 @@ var ts;
|
|
|
61641
61720
|
return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 234 /* Block */ && isContextSensitive(node.body);
|
|
61642
61721
|
}
|
|
61643
61722
|
function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
|
|
61644
|
-
return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
|
|
61723
|
+
return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
|
|
61645
61724
|
isContextSensitiveFunctionLikeDeclaration(func);
|
|
61646
61725
|
}
|
|
61647
61726
|
function getTypeWithoutSignatures(type) {
|
|
@@ -62513,7 +62592,8 @@ var ts;
|
|
|
62513
62592
|
var sourceStack;
|
|
62514
62593
|
var targetStack;
|
|
62515
62594
|
var maybeCount = 0;
|
|
62516
|
-
var
|
|
62595
|
+
var sourceDepth = 0;
|
|
62596
|
+
var targetDepth = 0;
|
|
62517
62597
|
var expandingFlags = 0 /* None */;
|
|
62518
62598
|
var overflow = false;
|
|
62519
62599
|
var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
|
|
@@ -62521,12 +62601,12 @@ var ts;
|
|
|
62521
62601
|
var incompatibleStack = [];
|
|
62522
62602
|
var inPropertyCheck = false;
|
|
62523
62603
|
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
62524
|
-
var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage);
|
|
62604
|
+
var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
|
|
62525
62605
|
if (incompatibleStack.length) {
|
|
62526
62606
|
reportIncompatibleStack();
|
|
62527
62607
|
}
|
|
62528
62608
|
if (overflow) {
|
|
62529
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth:
|
|
62609
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth });
|
|
62530
62610
|
var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
|
|
62531
62611
|
if (errorOutputContainer) {
|
|
62532
62612
|
(errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
|
|
@@ -62806,13 +62886,17 @@ var ts;
|
|
|
62806
62886
|
}
|
|
62807
62887
|
return true;
|
|
62808
62888
|
}
|
|
62889
|
+
function isRelatedToWorker(source, target, reportErrors) {
|
|
62890
|
+
return isRelatedTo(source, target, 3 /* Both */, reportErrors);
|
|
62891
|
+
}
|
|
62809
62892
|
/**
|
|
62810
62893
|
* Compare two types and return
|
|
62811
62894
|
* * Ternary.True if they are related with no assumptions,
|
|
62812
62895
|
* * Ternary.Maybe if they are related with assumptions of other relationships, or
|
|
62813
62896
|
* * Ternary.False if they are not related.
|
|
62814
62897
|
*/
|
|
62815
|
-
function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
|
|
62898
|
+
function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) {
|
|
62899
|
+
if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; }
|
|
62816
62900
|
if (reportErrors === void 0) { reportErrors = false; }
|
|
62817
62901
|
if (intersectionState === void 0) { intersectionState = 0 /* None */; }
|
|
62818
62902
|
// Before normalization: if `source` is type an object type, and `target` is primitive,
|
|
@@ -62833,7 +62917,7 @@ var ts;
|
|
|
62833
62917
|
if (source === target)
|
|
62834
62918
|
return -1 /* True */;
|
|
62835
62919
|
if (relation === identityRelation) {
|
|
62836
|
-
return isIdenticalTo(source, target);
|
|
62920
|
+
return isIdenticalTo(source, target, recursionFlags);
|
|
62837
62921
|
}
|
|
62838
62922
|
// We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
|
|
62839
62923
|
// and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
|
|
@@ -62884,8 +62968,8 @@ var ts;
|
|
|
62884
62968
|
var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
|
|
62885
62969
|
var calls = getSignaturesOfType(source, 0 /* Call */);
|
|
62886
62970
|
var constructs = getSignaturesOfType(source, 1 /* Construct */);
|
|
62887
|
-
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, /*reportErrors*/ false) ||
|
|
62888
|
-
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, /*reportErrors*/ false)) {
|
|
62971
|
+
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
|
|
62972
|
+
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
62889
62973
|
reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
|
|
62890
62974
|
}
|
|
62891
62975
|
else {
|
|
@@ -62902,11 +62986,11 @@ var ts;
|
|
|
62902
62986
|
// and we need to handle "each" relations before "some" relations for the same kind of type.
|
|
62903
62987
|
if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
|
|
62904
62988
|
result = getConstituentCount(source) * getConstituentCount(target) >= 4 ?
|
|
62905
|
-
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck
|
|
62989
|
+
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags) :
|
|
62906
62990
|
structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
62907
62991
|
}
|
|
62908
62992
|
if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
|
|
62909
|
-
if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
62993
|
+
if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
|
|
62910
62994
|
resetErrorInfo(saveErrorInfo);
|
|
62911
62995
|
}
|
|
62912
62996
|
}
|
|
@@ -62928,7 +63012,7 @@ var ts;
|
|
|
62928
63012
|
if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
|
|
62929
63013
|
if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
62930
63014
|
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
62931
|
-
if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63015
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
62932
63016
|
resetErrorInfo(saveErrorInfo);
|
|
62933
63017
|
}
|
|
62934
63018
|
}
|
|
@@ -62952,7 +63036,7 @@ var ts;
|
|
|
62952
63036
|
if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
62953
63037
|
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 */); }))) {
|
|
62954
63038
|
inPropertyCheck = true;
|
|
62955
|
-
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck
|
|
63039
|
+
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
62956
63040
|
inPropertyCheck = false;
|
|
62957
63041
|
}
|
|
62958
63042
|
reportErrorResults(source, target, result, isComparingJsxAttributes);
|
|
@@ -63027,7 +63111,7 @@ var ts;
|
|
|
63027
63111
|
}
|
|
63028
63112
|
}
|
|
63029
63113
|
}
|
|
63030
|
-
function isIdenticalTo(source, target) {
|
|
63114
|
+
function isIdenticalTo(source, target, recursionFlags) {
|
|
63031
63115
|
if (source.flags !== target.flags)
|
|
63032
63116
|
return 0 /* False */;
|
|
63033
63117
|
if (source.flags & 67358815 /* Singleton */)
|
|
@@ -63040,7 +63124,7 @@ var ts;
|
|
|
63040
63124
|
}
|
|
63041
63125
|
return result_7;
|
|
63042
63126
|
}
|
|
63043
|
-
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None
|
|
63127
|
+
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63044
63128
|
}
|
|
63045
63129
|
function getTypeOfPropertyInTypes(types, name) {
|
|
63046
63130
|
var appendPropType = function (propTypes, type) {
|
|
@@ -63121,7 +63205,7 @@ var ts;
|
|
|
63121
63205
|
}
|
|
63122
63206
|
return { value: true };
|
|
63123
63207
|
}
|
|
63124
|
-
if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
|
|
63208
|
+
if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) {
|
|
63125
63209
|
if (reportErrors) {
|
|
63126
63210
|
reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
|
|
63127
63211
|
}
|
|
@@ -63161,7 +63245,7 @@ var ts;
|
|
|
63161
63245
|
}
|
|
63162
63246
|
var match = getMatchingUnionConstituentForType(target, source);
|
|
63163
63247
|
if (match) {
|
|
63164
|
-
var related = isRelatedTo(source, match, /*reportErrors*/ false);
|
|
63248
|
+
var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false);
|
|
63165
63249
|
if (related) {
|
|
63166
63250
|
return related;
|
|
63167
63251
|
}
|
|
@@ -63169,14 +63253,14 @@ var ts;
|
|
|
63169
63253
|
}
|
|
63170
63254
|
for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
|
|
63171
63255
|
var type = targetTypes_1[_i];
|
|
63172
|
-
var related = isRelatedTo(source, type, /*reportErrors*/ false);
|
|
63256
|
+
var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false);
|
|
63173
63257
|
if (related) {
|
|
63174
63258
|
return related;
|
|
63175
63259
|
}
|
|
63176
63260
|
}
|
|
63177
63261
|
if (reportErrors) {
|
|
63178
63262
|
var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
|
|
63179
|
-
isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true);
|
|
63263
|
+
isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2 /* Target */, /*reportErrors*/ true);
|
|
63180
63264
|
}
|
|
63181
63265
|
return 0 /* False */;
|
|
63182
63266
|
}
|
|
@@ -63185,7 +63269,7 @@ var ts;
|
|
|
63185
63269
|
var targetTypes = target.types;
|
|
63186
63270
|
for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
|
|
63187
63271
|
var targetType = targetTypes_2[_i];
|
|
63188
|
-
var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63272
|
+
var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63189
63273
|
if (!related) {
|
|
63190
63274
|
return 0 /* False */;
|
|
63191
63275
|
}
|
|
@@ -63200,7 +63284,7 @@ var ts;
|
|
|
63200
63284
|
}
|
|
63201
63285
|
var len = sourceTypes.length;
|
|
63202
63286
|
for (var i = 0; i < len; i++) {
|
|
63203
|
-
var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
|
|
63287
|
+
var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
|
|
63204
63288
|
if (related) {
|
|
63205
63289
|
return related;
|
|
63206
63290
|
}
|
|
@@ -63230,13 +63314,13 @@ var ts;
|
|
|
63230
63314
|
// union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`,
|
|
63231
63315
|
// the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}`
|
|
63232
63316
|
// - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union
|
|
63233
|
-
var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
63317
|
+
var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
63234
63318
|
if (related_1) {
|
|
63235
63319
|
result &= related_1;
|
|
63236
63320
|
continue;
|
|
63237
63321
|
}
|
|
63238
63322
|
}
|
|
63239
|
-
var related = isRelatedTo(sourceType, target, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63323
|
+
var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63240
63324
|
if (!related) {
|
|
63241
63325
|
return 0 /* False */;
|
|
63242
63326
|
}
|
|
@@ -63268,31 +63352,31 @@ var ts;
|
|
|
63268
63352
|
// Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_.
|
|
63269
63353
|
// We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by
|
|
63270
63354
|
// the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be)
|
|
63271
|
-
related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t);
|
|
63355
|
+
related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t);
|
|
63272
63356
|
}
|
|
63273
63357
|
else if (variance === 1 /* Covariant */) {
|
|
63274
|
-
related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63358
|
+
related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63275
63359
|
}
|
|
63276
63360
|
else if (variance === 2 /* Contravariant */) {
|
|
63277
|
-
related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63361
|
+
related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63278
63362
|
}
|
|
63279
63363
|
else if (variance === 3 /* Bivariant */) {
|
|
63280
63364
|
// In the bivariant case we first compare contravariantly without reporting
|
|
63281
63365
|
// errors. Then, if that doesn't succeed, we compare covariantly with error
|
|
63282
63366
|
// reporting. Thus, error elaboration will be based on the the covariant check,
|
|
63283
63367
|
// which is generally easier to reason about.
|
|
63284
|
-
related = isRelatedTo(t, s, /*reportErrors*/ false);
|
|
63368
|
+
related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false);
|
|
63285
63369
|
if (!related) {
|
|
63286
|
-
related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63370
|
+
related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63287
63371
|
}
|
|
63288
63372
|
}
|
|
63289
63373
|
else {
|
|
63290
63374
|
// In the invariant case we first compare covariantly, and only when that
|
|
63291
63375
|
// succeeds do we proceed to compare contravariantly. Thus, error elaboration
|
|
63292
63376
|
// will typically be based on the covariant check.
|
|
63293
|
-
related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63377
|
+
related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63294
63378
|
if (related) {
|
|
63295
|
-
related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63379
|
+
related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63296
63380
|
}
|
|
63297
63381
|
}
|
|
63298
63382
|
if (!related) {
|
|
@@ -63308,7 +63392,7 @@ var ts;
|
|
|
63308
63392
|
// Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are
|
|
63309
63393
|
// equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion
|
|
63310
63394
|
// and issue an error. Otherwise, actually compare the structure of the two types.
|
|
63311
|
-
function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
63395
|
+
function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) {
|
|
63312
63396
|
if (overflow) {
|
|
63313
63397
|
return 0 /* False */;
|
|
63314
63398
|
}
|
|
@@ -63352,7 +63436,7 @@ var ts;
|
|
|
63352
63436
|
return 3 /* Maybe */;
|
|
63353
63437
|
}
|
|
63354
63438
|
}
|
|
63355
|
-
if (
|
|
63439
|
+
if (sourceDepth === 100 || targetDepth === 100) {
|
|
63356
63440
|
overflow = true;
|
|
63357
63441
|
return 0 /* False */;
|
|
63358
63442
|
}
|
|
@@ -63360,13 +63444,18 @@ var ts;
|
|
|
63360
63444
|
var maybeStart = maybeCount;
|
|
63361
63445
|
maybeKeys[maybeCount] = id;
|
|
63362
63446
|
maybeCount++;
|
|
63363
|
-
|
|
63364
|
-
|
|
63365
|
-
|
|
63447
|
+
if (recursionFlags & 1 /* Source */) {
|
|
63448
|
+
sourceStack[sourceDepth] = source;
|
|
63449
|
+
sourceDepth++;
|
|
63450
|
+
}
|
|
63451
|
+
if (recursionFlags & 2 /* Target */) {
|
|
63452
|
+
targetStack[targetDepth] = target;
|
|
63453
|
+
targetDepth++;
|
|
63454
|
+
}
|
|
63366
63455
|
var saveExpandingFlags = expandingFlags;
|
|
63367
|
-
if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack,
|
|
63456
|
+
if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
|
|
63368
63457
|
expandingFlags |= 1 /* Source */;
|
|
63369
|
-
if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack,
|
|
63458
|
+
if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
|
|
63370
63459
|
expandingFlags |= 2 /* Target */;
|
|
63371
63460
|
var originalHandler;
|
|
63372
63461
|
var propagatingVarianceFlags = 0;
|
|
@@ -63383,7 +63472,8 @@ var ts;
|
|
|
63383
63472
|
sourceIdStack: sourceStack.map(function (t) { return t.id; }),
|
|
63384
63473
|
targetId: target.id,
|
|
63385
63474
|
targetIdStack: targetStack.map(function (t) { return t.id; }),
|
|
63386
|
-
depth:
|
|
63475
|
+
depth: sourceDepth,
|
|
63476
|
+
targetDepth: targetDepth
|
|
63387
63477
|
});
|
|
63388
63478
|
}
|
|
63389
63479
|
var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
|
|
@@ -63391,9 +63481,14 @@ var ts;
|
|
|
63391
63481
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
63392
63482
|
}
|
|
63393
63483
|
expandingFlags = saveExpandingFlags;
|
|
63394
|
-
|
|
63484
|
+
if (recursionFlags & 1 /* Source */) {
|
|
63485
|
+
sourceDepth--;
|
|
63486
|
+
}
|
|
63487
|
+
if (recursionFlags & 2 /* Target */) {
|
|
63488
|
+
targetDepth--;
|
|
63489
|
+
}
|
|
63395
63490
|
if (result) {
|
|
63396
|
-
if (result === -1 /* True */ ||
|
|
63491
|
+
if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) {
|
|
63397
63492
|
if (result === -1 /* True */ || result === 3 /* Maybe */) {
|
|
63398
63493
|
// If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe
|
|
63399
63494
|
// results as having succeeded once we reach depth 0, but never record Ternary.Unknown results.
|
|
@@ -63447,7 +63542,7 @@ var ts;
|
|
|
63447
63542
|
if (constraints !== source.types) {
|
|
63448
63543
|
source = getIntersectionType(constraints);
|
|
63449
63544
|
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
63450
|
-
return isRelatedTo(source, target, /*reportErrors*/ false);
|
|
63545
|
+
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
63451
63546
|
}
|
|
63452
63547
|
}
|
|
63453
63548
|
}
|
|
@@ -63469,22 +63564,22 @@ var ts;
|
|
|
63469
63564
|
var flags = source.flags & target.flags;
|
|
63470
63565
|
if (relation === identityRelation && !(flags & 524288 /* Object */)) {
|
|
63471
63566
|
if (flags & 4194304 /* Index */) {
|
|
63472
|
-
return isRelatedTo(source.type, target.type, /*reportErrors*/ false);
|
|
63567
|
+
return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
|
|
63473
63568
|
}
|
|
63474
63569
|
var result_8 = 0 /* False */;
|
|
63475
63570
|
if (flags & 8388608 /* IndexedAccess */) {
|
|
63476
|
-
if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) {
|
|
63477
|
-
if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) {
|
|
63571
|
+
if (result_8 = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63572
|
+
if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63478
63573
|
return result_8;
|
|
63479
63574
|
}
|
|
63480
63575
|
}
|
|
63481
63576
|
}
|
|
63482
63577
|
if (flags & 16777216 /* Conditional */) {
|
|
63483
63578
|
if (source.root.isDistributive === target.root.isDistributive) {
|
|
63484
|
-
if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) {
|
|
63485
|
-
if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) {
|
|
63486
|
-
if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) {
|
|
63487
|
-
if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) {
|
|
63579
|
+
if (result_8 = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63580
|
+
if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63581
|
+
if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
63582
|
+
if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
63488
63583
|
return result_8;
|
|
63489
63584
|
}
|
|
63490
63585
|
}
|
|
@@ -63493,7 +63588,7 @@ var ts;
|
|
|
63493
63588
|
}
|
|
63494
63589
|
}
|
|
63495
63590
|
if (flags & 33554432 /* Substitution */) {
|
|
63496
|
-
return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false);
|
|
63591
|
+
return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
|
|
63497
63592
|
}
|
|
63498
63593
|
return 0 /* False */;
|
|
63499
63594
|
}
|
|
@@ -63518,17 +63613,17 @@ var ts;
|
|
|
63518
63613
|
}
|
|
63519
63614
|
// For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T],
|
|
63520
63615
|
// and U is assignable to [...T] when U is constrained to a mutable array or tuple type.
|
|
63521
|
-
if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target)) ||
|
|
63522
|
-
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0]))) {
|
|
63616
|
+
if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) ||
|
|
63617
|
+
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
|
|
63523
63618
|
return result;
|
|
63524
63619
|
}
|
|
63525
63620
|
if (target.flags & 262144 /* TypeParameter */) {
|
|
63526
63621
|
// 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].
|
|
63527
|
-
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
|
|
63622
|
+
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
|
|
63528
63623
|
if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
|
|
63529
63624
|
var templateType = getTemplateTypeFromMappedType(source);
|
|
63530
63625
|
var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
|
|
63531
|
-
if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
|
|
63626
|
+
if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) {
|
|
63532
63627
|
return result;
|
|
63533
63628
|
}
|
|
63534
63629
|
}
|
|
@@ -63538,14 +63633,14 @@ var ts;
|
|
|
63538
63633
|
var targetType_1 = target.type;
|
|
63539
63634
|
// A keyof S is related to a keyof T if T is related to S.
|
|
63540
63635
|
if (source.flags & 4194304 /* Index */) {
|
|
63541
|
-
if (result = isRelatedTo(targetType_1, source.type, /*reportErrors*/ false)) {
|
|
63636
|
+
if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63542
63637
|
return result;
|
|
63543
63638
|
}
|
|
63544
63639
|
}
|
|
63545
63640
|
if (isTupleType(targetType_1)) {
|
|
63546
63641
|
// An index type can have a tuple type target when the tuple type contains variadic elements.
|
|
63547
63642
|
// Check if the source is related to the known keys of the tuple type.
|
|
63548
|
-
if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), reportErrors)) {
|
|
63643
|
+
if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) {
|
|
63549
63644
|
return result;
|
|
63550
63645
|
}
|
|
63551
63646
|
}
|
|
@@ -63558,7 +63653,7 @@ var ts;
|
|
|
63558
63653
|
// false positives. For example, given 'T extends { [K in keyof T]: string }',
|
|
63559
63654
|
// 'keyof T' has itself as its constraint and produces a Ternary.Maybe when
|
|
63560
63655
|
// related to other types.
|
|
63561
|
-
if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1 /* True */) {
|
|
63656
|
+
if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) {
|
|
63562
63657
|
return -1 /* True */;
|
|
63563
63658
|
}
|
|
63564
63659
|
}
|
|
@@ -63582,7 +63677,7 @@ var ts;
|
|
|
63582
63677
|
else {
|
|
63583
63678
|
targetKeys = nameType_1 || constraintType;
|
|
63584
63679
|
}
|
|
63585
|
-
if (isRelatedTo(source, targetKeys, reportErrors) === -1 /* True */) {
|
|
63680
|
+
if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) {
|
|
63586
63681
|
return -1 /* True */;
|
|
63587
63682
|
}
|
|
63588
63683
|
}
|
|
@@ -63592,8 +63687,8 @@ var ts;
|
|
|
63592
63687
|
if (source.flags & 8388608 /* IndexedAccess */) {
|
|
63593
63688
|
// Relate components directly before falling back to constraint relationships
|
|
63594
63689
|
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
|
|
63595
|
-
if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
|
|
63596
|
-
result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
|
|
63690
|
+
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
|
|
63691
|
+
result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
|
|
63597
63692
|
}
|
|
63598
63693
|
if (result) {
|
|
63599
63694
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -63618,7 +63713,7 @@ var ts;
|
|
|
63618
63713
|
// create a new chain for the constraint error
|
|
63619
63714
|
resetErrorInfo(saveErrorInfo);
|
|
63620
63715
|
}
|
|
63621
|
-
if (result = isRelatedTo(source, constraint, reportErrors)) {
|
|
63716
|
+
if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) {
|
|
63622
63717
|
return result;
|
|
63623
63718
|
}
|
|
63624
63719
|
// prefer the shorter chain of the constraint comparison chain, and the direct comparison chain
|
|
@@ -63658,13 +63753,14 @@ var ts;
|
|
|
63658
63753
|
// A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`.
|
|
63659
63754
|
if (includeOptional
|
|
63660
63755
|
? !(filteredByApplicability.flags & 131072 /* Never */)
|
|
63661
|
-
: isRelatedTo(targetKeys, sourceKeys)) {
|
|
63756
|
+
: isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
|
|
63757
|
+
var templateType_1 = getTemplateTypeFromMappedType(target);
|
|
63662
63758
|
var typeParameter = getTypeParameterFromMappedType(target);
|
|
63663
63759
|
// Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj`
|
|
63664
63760
|
// to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`.
|
|
63665
|
-
var nonNullComponent = extractTypesOfKind(
|
|
63761
|
+
var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */);
|
|
63666
63762
|
if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
|
|
63667
|
-
if (result = isRelatedTo(source, nonNullComponent.objectType, reportErrors)) {
|
|
63763
|
+
if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) {
|
|
63668
63764
|
return result;
|
|
63669
63765
|
}
|
|
63670
63766
|
}
|
|
@@ -63684,7 +63780,7 @@ var ts;
|
|
|
63684
63780
|
: typeParameter;
|
|
63685
63781
|
var indexedAccessType = getIndexedAccessType(source, indexingType);
|
|
63686
63782
|
// Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type.
|
|
63687
|
-
if (result = isRelatedTo(indexedAccessType,
|
|
63783
|
+
if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) {
|
|
63688
63784
|
return result;
|
|
63689
63785
|
}
|
|
63690
63786
|
}
|
|
@@ -63711,10 +63807,11 @@ var ts;
|
|
|
63711
63807
|
newParam.mapper = distributionMapper;
|
|
63712
63808
|
}
|
|
63713
63809
|
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
|
|
63714
|
-
var
|
|
63715
|
-
|
|
63716
|
-
|
|
63717
|
-
|
|
63810
|
+
var expanding = isDeeplyNestedType(target, targetStack, targetDepth);
|
|
63811
|
+
var localResult = expanding ? 3 /* Maybe */ : undefined;
|
|
63812
|
+
if (skipTrue || expanding || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false))) {
|
|
63813
|
+
if (!skipFalse && !expanding) {
|
|
63814
|
+
localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
63718
63815
|
}
|
|
63719
63816
|
}
|
|
63720
63817
|
if (localResult) {
|
|
@@ -63724,6 +63821,9 @@ var ts;
|
|
|
63724
63821
|
}
|
|
63725
63822
|
else if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
63726
63823
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
63824
|
+
if (relation === comparableRelation) {
|
|
63825
|
+
return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
|
|
63826
|
+
}
|
|
63727
63827
|
// Report unreliable variance for type variables referenced in template literal type placeholders.
|
|
63728
63828
|
// For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
|
|
63729
63829
|
instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
|
|
@@ -63739,34 +63839,33 @@ var ts;
|
|
|
63739
63839
|
var constraint = getConstraintOfType(source);
|
|
63740
63840
|
if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
63741
63841
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
63742
|
-
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
|
|
63842
|
+
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
63743
63843
|
resetErrorInfo(saveErrorInfo);
|
|
63744
63844
|
return result;
|
|
63745
63845
|
}
|
|
63746
63846
|
}
|
|
63747
63847
|
// hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
|
|
63748
|
-
else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63848
|
+
else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63749
63849
|
resetErrorInfo(saveErrorInfo);
|
|
63750
63850
|
return result;
|
|
63751
63851
|
}
|
|
63752
63852
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
63753
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
63853
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
63754
63854
|
resetErrorInfo(saveErrorInfo);
|
|
63755
63855
|
return result;
|
|
63756
63856
|
}
|
|
63757
63857
|
}
|
|
63758
63858
|
}
|
|
63759
63859
|
else if (source.flags & 4194304 /* Index */) {
|
|
63760
|
-
if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
|
|
63860
|
+
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
63761
63861
|
resetErrorInfo(saveErrorInfo);
|
|
63762
63862
|
return result;
|
|
63763
63863
|
}
|
|
63764
63864
|
}
|
|
63765
|
-
else if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
63865
|
+
else if (source.flags & 134217728 /* TemplateLiteral */ && !(target.flags & 524288 /* Object */)) {
|
|
63766
63866
|
if (!(target.flags & 134217728 /* TemplateLiteral */)) {
|
|
63767
|
-
var
|
|
63768
|
-
|
|
63769
|
-
if (result = isRelatedTo(constraint, target, reportErrors)) {
|
|
63867
|
+
var constraint = getBaseConstraintOfType(source);
|
|
63868
|
+
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
63770
63869
|
resetErrorInfo(saveErrorInfo);
|
|
63771
63870
|
return result;
|
|
63772
63871
|
}
|
|
@@ -63774,14 +63873,14 @@ var ts;
|
|
|
63774
63873
|
}
|
|
63775
63874
|
else if (source.flags & 268435456 /* StringMapping */) {
|
|
63776
63875
|
if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
|
|
63777
|
-
if (result = isRelatedTo(source.type, target.type, reportErrors)) {
|
|
63876
|
+
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
63778
63877
|
resetErrorInfo(saveErrorInfo);
|
|
63779
63878
|
return result;
|
|
63780
63879
|
}
|
|
63781
63880
|
}
|
|
63782
63881
|
else {
|
|
63783
63882
|
var constraint = getBaseConstraintOfType(source);
|
|
63784
|
-
if (constraint && (result = isRelatedTo(constraint, target, reportErrors))) {
|
|
63883
|
+
if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
63785
63884
|
resetErrorInfo(saveErrorInfo);
|
|
63786
63885
|
return result;
|
|
63787
63886
|
}
|
|
@@ -63789,27 +63888,32 @@ var ts;
|
|
|
63789
63888
|
}
|
|
63790
63889
|
else if (source.flags & 16777216 /* Conditional */) {
|
|
63791
63890
|
if (target.flags & 16777216 /* Conditional */) {
|
|
63792
|
-
//
|
|
63793
|
-
//
|
|
63794
|
-
//
|
|
63795
|
-
|
|
63796
|
-
|
|
63797
|
-
|
|
63798
|
-
|
|
63799
|
-
|
|
63800
|
-
var
|
|
63801
|
-
|
|
63802
|
-
|
|
63803
|
-
|
|
63804
|
-
|
|
63805
|
-
|
|
63806
|
-
|
|
63807
|
-
|
|
63808
|
-
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
|
|
63891
|
+
// If one of the conditionals under comparison seems to be infinitely expanding, stop comparing it - back out, try
|
|
63892
|
+
// the constraint, and failing that, give up trying to relate the two. This is the only way we can handle recursive conditional
|
|
63893
|
+
// types, which might expand forever.
|
|
63894
|
+
if (!isDeeplyNestedType(source, sourceStack, sourceDepth) && !isDeeplyNestedType(target, targetStack, targetDepth)) {
|
|
63895
|
+
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
|
|
63896
|
+
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
|
|
63897
|
+
// and Y1 is related to Y2.
|
|
63898
|
+
var sourceParams = source.root.inferTypeParameters;
|
|
63899
|
+
var sourceExtends = source.extendsType;
|
|
63900
|
+
var mapper = void 0;
|
|
63901
|
+
if (sourceParams) {
|
|
63902
|
+
// If the source has infer type parameters, we instantiate them in the context of the target
|
|
63903
|
+
var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker);
|
|
63904
|
+
inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
63905
|
+
sourceExtends = instantiateType(sourceExtends, ctx.mapper);
|
|
63906
|
+
mapper = ctx.mapper;
|
|
63809
63907
|
}
|
|
63810
|
-
if (
|
|
63811
|
-
|
|
63812
|
-
|
|
63908
|
+
if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
|
|
63909
|
+
(isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) {
|
|
63910
|
+
if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) {
|
|
63911
|
+
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
|
|
63912
|
+
}
|
|
63913
|
+
if (result) {
|
|
63914
|
+
resetErrorInfo(saveErrorInfo);
|
|
63915
|
+
return result;
|
|
63916
|
+
}
|
|
63813
63917
|
}
|
|
63814
63918
|
}
|
|
63815
63919
|
}
|
|
@@ -63818,19 +63922,23 @@ var ts;
|
|
|
63818
63922
|
// more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
|
|
63819
63923
|
var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
|
|
63820
63924
|
if (distributiveConstraint) {
|
|
63821
|
-
if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
|
|
63925
|
+
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
63822
63926
|
resetErrorInfo(saveErrorInfo);
|
|
63823
63927
|
return result;
|
|
63824
63928
|
}
|
|
63825
63929
|
}
|
|
63826
63930
|
}
|
|
63827
|
-
//
|
|
63828
|
-
//
|
|
63829
|
-
|
|
63830
|
-
|
|
63831
|
-
|
|
63832
|
-
|
|
63833
|
-
|
|
63931
|
+
// We'll repeatedly decompose source side conditionals if they're recursive - check if we've already recured on the constraint a lot and, if so, bail
|
|
63932
|
+
// on the comparison.
|
|
63933
|
+
if (!isDeeplyNestedType(source, sourceStack, sourceDepth)) {
|
|
63934
|
+
// conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
|
|
63935
|
+
// when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
|
|
63936
|
+
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
|
|
63937
|
+
if (defaultConstraint) {
|
|
63938
|
+
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
63939
|
+
resetErrorInfo(saveErrorInfo);
|
|
63940
|
+
return result;
|
|
63941
|
+
}
|
|
63834
63942
|
}
|
|
63835
63943
|
}
|
|
63836
63944
|
}
|
|
@@ -63874,7 +63982,7 @@ var ts;
|
|
|
63874
63982
|
}
|
|
63875
63983
|
else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
|
|
63876
63984
|
if (relation !== identityRelation) {
|
|
63877
|
-
return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, reportErrors);
|
|
63985
|
+
return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
|
|
63878
63986
|
}
|
|
63879
63987
|
else {
|
|
63880
63988
|
// By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple
|
|
@@ -63996,10 +64104,10 @@ var ts;
|
|
|
63996
64104
|
var result_11;
|
|
63997
64105
|
var targetConstraint = getConstraintTypeFromMappedType(target);
|
|
63998
64106
|
var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
|
|
63999
|
-
if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
|
|
64107
|
+
if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
|
|
64000
64108
|
var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
|
|
64001
64109
|
if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
|
|
64002
|
-
return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
|
|
64110
|
+
return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
|
|
64003
64111
|
}
|
|
64004
64112
|
}
|
|
64005
64113
|
}
|
|
@@ -64131,7 +64239,7 @@ var ts;
|
|
|
64131
64239
|
var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */);
|
|
64132
64240
|
var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional);
|
|
64133
64241
|
var effectiveSource = getTypeOfSourceProperty(sourceProp);
|
|
64134
|
-
return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
64242
|
+
return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
64135
64243
|
}
|
|
64136
64244
|
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
|
|
64137
64245
|
var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
|
|
@@ -64313,7 +64421,7 @@ var ts;
|
|
|
64313
64421
|
var targetType = targetTypeArguments[i];
|
|
64314
64422
|
var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) :
|
|
64315
64423
|
removeMissingType(targetType, !!(targetFlags & 2 /* Optional */));
|
|
64316
|
-
var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
64424
|
+
var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
64317
64425
|
if (!related) {
|
|
64318
64426
|
if (reportErrors && (targetArity > 1 || sourceArity > 1)) {
|
|
64319
64427
|
if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) {
|
|
@@ -64507,7 +64615,7 @@ var ts;
|
|
|
64507
64615
|
* See signatureAssignableTo, compareSignaturesIdentical
|
|
64508
64616
|
*/
|
|
64509
64617
|
function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
|
|
64510
|
-
return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter,
|
|
64618
|
+
return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers));
|
|
64511
64619
|
}
|
|
64512
64620
|
function signaturesIdenticalTo(source, target, kind) {
|
|
64513
64621
|
var sourceSignatures = getSignaturesOfType(source, kind);
|
|
@@ -64540,7 +64648,7 @@ var ts;
|
|
|
64540
64648
|
var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */)
|
|
64541
64649
|
? propType
|
|
64542
64650
|
: getTypeWithFacts(propType, 524288 /* NEUndefined */);
|
|
64543
|
-
var related = isRelatedTo(type, targetInfo.type, reportErrors);
|
|
64651
|
+
var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors);
|
|
64544
64652
|
if (!related) {
|
|
64545
64653
|
if (reportErrors) {
|
|
64546
64654
|
reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
|
|
@@ -64563,7 +64671,7 @@ var ts;
|
|
|
64563
64671
|
return result;
|
|
64564
64672
|
}
|
|
64565
64673
|
function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) {
|
|
64566
|
-
var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors);
|
|
64674
|
+
var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors);
|
|
64567
64675
|
if (!related && reportErrors) {
|
|
64568
64676
|
if (sourceInfo.keyType === targetInfo.keyType) {
|
|
64569
64677
|
reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType));
|
|
@@ -64584,7 +64692,7 @@ var ts;
|
|
|
64584
64692
|
for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
|
|
64585
64693
|
var targetInfo = indexInfos_3[_i];
|
|
64586
64694
|
var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
|
|
64587
|
-
isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) :
|
|
64695
|
+
isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
|
|
64588
64696
|
typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
|
|
64589
64697
|
if (!related) {
|
|
64590
64698
|
return 0 /* False */;
|
|
@@ -64616,7 +64724,7 @@ var ts;
|
|
|
64616
64724
|
for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) {
|
|
64617
64725
|
var targetInfo = targetInfos_1[_i];
|
|
64618
64726
|
var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType);
|
|
64619
|
-
if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
|
|
64727
|
+
if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
|
|
64620
64728
|
return 0 /* False */;
|
|
64621
64729
|
}
|
|
64622
64730
|
}
|
|
@@ -66030,6 +66138,17 @@ var ts;
|
|
|
66030
66138
|
function isFromInferenceBlockedSource(type) {
|
|
66031
66139
|
return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
|
|
66032
66140
|
}
|
|
66141
|
+
function templateLiteralTypesDefinitelyUnrelated(source, target) {
|
|
66142
|
+
// Two template literal types with diffences in their starting or ending text spans are definitely unrelated.
|
|
66143
|
+
var sourceStart = source.texts[0];
|
|
66144
|
+
var targetStart = target.texts[0];
|
|
66145
|
+
var sourceEnd = source.texts[source.texts.length - 1];
|
|
66146
|
+
var targetEnd = target.texts[target.texts.length - 1];
|
|
66147
|
+
var startLen = Math.min(sourceStart.length, targetStart.length);
|
|
66148
|
+
var endLen = Math.min(sourceEnd.length, targetEnd.length);
|
|
66149
|
+
return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
|
|
66150
|
+
sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
|
|
66151
|
+
}
|
|
66033
66152
|
function isValidBigIntString(s) {
|
|
66034
66153
|
var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
|
|
66035
66154
|
var success = true;
|
|
@@ -67092,7 +67211,7 @@ var ts;
|
|
|
67092
67211
|
if (prop.isDiscriminantProperty === undefined) {
|
|
67093
67212
|
prop.isDiscriminantProperty =
|
|
67094
67213
|
(prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ &&
|
|
67095
|
-
!
|
|
67214
|
+
!isGenericType(getTypeOfSymbol(prop));
|
|
67096
67215
|
}
|
|
67097
67216
|
return !!prop.isDiscriminantProperty;
|
|
67098
67217
|
}
|
|
@@ -67611,17 +67730,19 @@ var ts;
|
|
|
67611
67730
|
function extractTypesOfKind(type, kind) {
|
|
67612
67731
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
67613
67732
|
}
|
|
67614
|
-
// Return a new type in which occurrences of the string and
|
|
67615
|
-
// typeWithPrimitives have been replaced with occurrences of
|
|
67616
|
-
//
|
|
67733
|
+
// Return a new type in which occurrences of the string, number and bigint primitives and placeholder template
|
|
67734
|
+
// literal types in typeWithPrimitives have been replaced with occurrences of compatible and more specific types
|
|
67735
|
+
// from typeWithLiterals. This is essentially a limited form of intersection between the two types. We avoid a
|
|
67736
|
+
// true intersection because it is more costly and, when applied to union types, generates a large number of
|
|
67737
|
+
// types we don't actually care about.
|
|
67617
67738
|
function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
|
|
67618
|
-
if (
|
|
67619
|
-
|
|
67620
|
-
isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) {
|
|
67739
|
+
if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) &&
|
|
67740
|
+
maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) {
|
|
67621
67741
|
return mapType(typeWithPrimitives, function (t) {
|
|
67622
|
-
return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) :
|
|
67623
|
-
t
|
|
67624
|
-
t.flags &
|
|
67742
|
+
return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) :
|
|
67743
|
+
isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) :
|
|
67744
|
+
t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) :
|
|
67745
|
+
t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t;
|
|
67625
67746
|
});
|
|
67626
67747
|
}
|
|
67627
67748
|
return typeWithPrimitives;
|
|
@@ -67702,10 +67823,10 @@ var ts;
|
|
|
67702
67823
|
isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */);
|
|
67703
67824
|
return isLengthPushOrUnshift || isElementAssignment;
|
|
67704
67825
|
}
|
|
67705
|
-
function isDeclarationWithExplicitTypeAnnotation(
|
|
67706
|
-
return (
|
|
67707
|
-
|
|
67708
|
-
|
|
67826
|
+
function isDeclarationWithExplicitTypeAnnotation(node) {
|
|
67827
|
+
return (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isParameter(node)) &&
|
|
67828
|
+
!!(ts.getEffectiveTypeAnnotationNode(node) ||
|
|
67829
|
+
ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
|
|
67709
67830
|
}
|
|
67710
67831
|
function getExplicitTypeOfSymbol(symbol, diagnostic) {
|
|
67711
67832
|
if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) {
|
|
@@ -68422,7 +68543,7 @@ var ts;
|
|
|
68422
68543
|
var narrowedPropType = narrowType(propType);
|
|
68423
68544
|
return filterType(type, function (t) {
|
|
68424
68545
|
var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
|
|
68425
|
-
return !(
|
|
68546
|
+
return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType);
|
|
68426
68547
|
});
|
|
68427
68548
|
}
|
|
68428
68549
|
function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) {
|
|
@@ -68891,16 +69012,7 @@ var ts;
|
|
|
68891
69012
|
}
|
|
68892
69013
|
function getNarrowedType(type, candidate, assumeTrue, isRelated) {
|
|
68893
69014
|
if (!assumeTrue) {
|
|
68894
|
-
return filterType(type, function (t) {
|
|
68895
|
-
if (!isRelated(t, candidate)) {
|
|
68896
|
-
return true;
|
|
68897
|
-
}
|
|
68898
|
-
var constraint = getBaseConstraintOfType(t);
|
|
68899
|
-
if (constraint && constraint !== t) {
|
|
68900
|
-
return !isRelated(constraint, candidate);
|
|
68901
|
-
}
|
|
68902
|
-
return false;
|
|
68903
|
-
});
|
|
69015
|
+
return filterType(type, function (t) { return !isRelated(t, candidate); });
|
|
68904
69016
|
}
|
|
68905
69017
|
// If the current type is a union type, remove all constituents that couldn't be instances of
|
|
68906
69018
|
// the candidate type. If one or more constituents remain, return a union of those.
|
|
@@ -70802,12 +70914,9 @@ var ts;
|
|
|
70802
70914
|
}
|
|
70803
70915
|
return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
|
|
70804
70916
|
}
|
|
70805
|
-
function isFunctionExpressionOrArrowFunction(node) {
|
|
70806
|
-
return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
|
|
70807
|
-
}
|
|
70808
70917
|
function getContextualSignatureForFunctionLikeDeclaration(node) {
|
|
70809
70918
|
// Only function expressions, arrow functions, and object literal methods are contextually typed.
|
|
70810
|
-
return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
|
|
70919
|
+
return ts.isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
|
|
70811
70920
|
? getContextualSignature(node)
|
|
70812
70921
|
: undefined;
|
|
70813
70922
|
}
|
|
@@ -71774,6 +71883,14 @@ var ts;
|
|
|
71774
71883
|
markAliasSymbolAsReferenced(jsxFactorySym);
|
|
71775
71884
|
}
|
|
71776
71885
|
}
|
|
71886
|
+
// For JsxFragment, mark jsx pragma as referenced via resolveName
|
|
71887
|
+
if (ts.isJsxOpeningFragment(node)) {
|
|
71888
|
+
var file = ts.getSourceFileOfNode(node);
|
|
71889
|
+
var localJsxNamespace = getLocalJsxNamespace(file);
|
|
71890
|
+
if (localJsxNamespace) {
|
|
71891
|
+
resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true);
|
|
71892
|
+
}
|
|
71893
|
+
}
|
|
71777
71894
|
}
|
|
71778
71895
|
if (isNodeOpeningLikeElement) {
|
|
71779
71896
|
var jsxOpeningLikeNode = node;
|
|
@@ -73446,7 +73563,7 @@ var ts;
|
|
|
73446
73563
|
return false;
|
|
73447
73564
|
var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false);
|
|
73448
73565
|
var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration;
|
|
73449
|
-
if (!decl || !ts.isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
|
|
73566
|
+
if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
|
|
73450
73567
|
return false;
|
|
73451
73568
|
}
|
|
73452
73569
|
var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false);
|
|
@@ -74690,18 +74807,18 @@ var ts;
|
|
|
74690
74807
|
if (moduleSymbol) {
|
|
74691
74808
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
74692
74809
|
if (esModuleSymbol) {
|
|
74693
|
-
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
|
|
74810
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
74694
74811
|
}
|
|
74695
74812
|
}
|
|
74696
74813
|
return createPromiseReturnType(node, anyType);
|
|
74697
74814
|
}
|
|
74698
|
-
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
|
|
74815
|
+
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74699
74816
|
var _a;
|
|
74700
74817
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
74701
74818
|
var synthType = type;
|
|
74702
74819
|
if (!synthType.syntheticType) {
|
|
74703
74820
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
74704
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false);
|
|
74821
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
74705
74822
|
if (hasSyntheticDefault) {
|
|
74706
74823
|
var memberTable = ts.createSymbolTable();
|
|
74707
74824
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
@@ -74863,16 +74980,14 @@ var ts;
|
|
|
74863
74980
|
}
|
|
74864
74981
|
}
|
|
74865
74982
|
function checkImportMetaProperty(node) {
|
|
74866
|
-
if (moduleKind
|
|
74867
|
-
if (
|
|
74868
|
-
|
|
74869
|
-
error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
|
|
74870
|
-
}
|
|
74871
|
-
}
|
|
74872
|
-
else {
|
|
74873
|
-
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext);
|
|
74983
|
+
if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
74984
|
+
if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
74985
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
|
|
74874
74986
|
}
|
|
74875
74987
|
}
|
|
74988
|
+
else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) {
|
|
74989
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
|
|
74990
|
+
}
|
|
74876
74991
|
var file = ts.getSourceFileOfNode(node);
|
|
74877
74992
|
ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
74878
74993
|
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
|
|
@@ -75815,9 +75930,9 @@ var ts;
|
|
|
75815
75930
|
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
|
|
75816
75931
|
diagnostics.add(diagnostic);
|
|
75817
75932
|
}
|
|
75818
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
75933
|
+
if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
75819
75934
|
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
75820
|
-
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.
|
|
75935
|
+
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
|
|
75821
75936
|
diagnostics.add(diagnostic);
|
|
75822
75937
|
}
|
|
75823
75938
|
}
|
|
@@ -77255,7 +77370,7 @@ var ts;
|
|
|
77255
77370
|
}
|
|
77256
77371
|
}
|
|
77257
77372
|
function checkParenthesizedExpression(node, checkMode) {
|
|
77258
|
-
if (ts.isJSDocTypeAssertion(node)) {
|
|
77373
|
+
if (ts.hasJSDocNodes(node) && ts.isJSDocTypeAssertion(node)) {
|
|
77259
77374
|
var type = ts.getJSDocTypeAssertionType(node);
|
|
77260
77375
|
return checkAssertionWorker(type, type, node.expression, checkMode);
|
|
77261
77376
|
}
|
|
@@ -79152,6 +79267,12 @@ var ts;
|
|
|
79152
79267
|
}
|
|
79153
79268
|
}
|
|
79154
79269
|
}
|
|
79270
|
+
function checkJSDocAccessibilityModifiers(node) {
|
|
79271
|
+
var host = ts.getJSDocHost(node);
|
|
79272
|
+
if (host && ts.isPrivateIdentifierClassElementDeclaration(host)) {
|
|
79273
|
+
error(node, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
|
|
79274
|
+
}
|
|
79275
|
+
}
|
|
79155
79276
|
function getIdentifierFromEntityNameExpression(node) {
|
|
79156
79277
|
switch (node.kind) {
|
|
79157
79278
|
case 79 /* Identifier */:
|
|
@@ -82805,6 +82926,10 @@ var ts;
|
|
|
82805
82926
|
return;
|
|
82806
82927
|
case 307 /* JSDocTypeExpression */:
|
|
82807
82928
|
return checkSourceElement(node.type);
|
|
82929
|
+
case 331 /* JSDocPublicTag */:
|
|
82930
|
+
case 333 /* JSDocProtectedTag */:
|
|
82931
|
+
case 332 /* JSDocPrivateTag */:
|
|
82932
|
+
return checkJSDocAccessibilityModifiers(node);
|
|
82808
82933
|
case 193 /* IndexedAccessType */:
|
|
82809
82934
|
return checkIndexedAccessType(node);
|
|
82810
82935
|
case 194 /* MappedType */:
|
|
@@ -85500,8 +85625,8 @@ var ts;
|
|
|
85500
85625
|
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
85501
85626
|
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module));
|
|
85502
85627
|
}
|
|
85503
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
85504
|
-
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.
|
|
85628
|
+
if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
85629
|
+
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher));
|
|
85505
85630
|
}
|
|
85506
85631
|
}
|
|
85507
85632
|
}
|
|
@@ -86190,7 +86315,7 @@ var ts;
|
|
|
86190
86315
|
}
|
|
86191
86316
|
function checkGrammarImportCallExpression(node) {
|
|
86192
86317
|
if (moduleKind === ts.ModuleKind.ES2015) {
|
|
86193
|
-
return grammarErrorOnNode(node, ts.Diagnostics.
|
|
86318
|
+
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext);
|
|
86194
86319
|
}
|
|
86195
86320
|
if (node.typeArguments) {
|
|
86196
86321
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
@@ -87304,7 +87429,7 @@ var ts;
|
|
|
87304
87429
|
}
|
|
87305
87430
|
ts.createSourceMapGenerator = createSourceMapGenerator;
|
|
87306
87431
|
// Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M])
|
|
87307
|
-
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)
|
|
87432
|
+
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/;
|
|
87308
87433
|
var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
|
|
87309
87434
|
function getLineInfo(text, lineStarts) {
|
|
87310
87435
|
return {
|
|
@@ -90596,6 +90721,7 @@ var ts;
|
|
|
90596
90721
|
|| (isExternalModuleExport(node)
|
|
90597
90722
|
&& moduleKind !== ts.ModuleKind.ES2015
|
|
90598
90723
|
&& moduleKind !== ts.ModuleKind.ES2020
|
|
90724
|
+
&& moduleKind !== ts.ModuleKind.ES2022
|
|
90599
90725
|
&& moduleKind !== ts.ModuleKind.ESNext
|
|
90600
90726
|
&& moduleKind !== ts.ModuleKind.System);
|
|
90601
90727
|
}
|
|
@@ -106274,6 +106400,7 @@ var ts;
|
|
|
106274
106400
|
function getModuleTransformer(moduleKind) {
|
|
106275
106401
|
switch (moduleKind) {
|
|
106276
106402
|
case ts.ModuleKind.ESNext:
|
|
106403
|
+
case ts.ModuleKind.ES2022:
|
|
106277
106404
|
case ts.ModuleKind.ES2020:
|
|
106278
106405
|
case ts.ModuleKind.ES2015:
|
|
106279
106406
|
return ts.transformECMAScriptModule;
|
|
@@ -118805,6 +118932,78 @@ var ts;
|
|
|
118805
118932
|
}
|
|
118806
118933
|
}
|
|
118807
118934
|
}
|
|
118935
|
+
var MatchingMode;
|
|
118936
|
+
(function (MatchingMode) {
|
|
118937
|
+
MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
|
|
118938
|
+
MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
|
|
118939
|
+
MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
|
|
118940
|
+
})(MatchingMode || (MatchingMode = {}));
|
|
118941
|
+
function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
|
|
118942
|
+
if (mode === void 0) { mode = 0 /* Exact */; }
|
|
118943
|
+
if (typeof exports === "string") {
|
|
118944
|
+
var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
|
|
118945
|
+
var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
|
|
118946
|
+
switch (mode) {
|
|
118947
|
+
case 0 /* Exact */:
|
|
118948
|
+
if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
|
|
118949
|
+
return { moduleFileToTry: packageName };
|
|
118950
|
+
}
|
|
118951
|
+
break;
|
|
118952
|
+
case 1 /* Directory */:
|
|
118953
|
+
if (ts.containsPath(pathOrPattern, targetFilePath)) {
|
|
118954
|
+
var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
|
|
118955
|
+
return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
|
118956
|
+
}
|
|
118957
|
+
break;
|
|
118958
|
+
case 2 /* Pattern */:
|
|
118959
|
+
var starPos = pathOrPattern.indexOf("*");
|
|
118960
|
+
var leadingSlice = pathOrPattern.slice(0, starPos);
|
|
118961
|
+
var trailingSlice = pathOrPattern.slice(starPos + 1);
|
|
118962
|
+
if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
|
|
118963
|
+
var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
|
118964
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
118965
|
+
}
|
|
118966
|
+
if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
|
|
118967
|
+
var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
|
|
118968
|
+
return { moduleFileToTry: packageName.replace("*", starReplacement) };
|
|
118969
|
+
}
|
|
118970
|
+
break;
|
|
118971
|
+
}
|
|
118972
|
+
}
|
|
118973
|
+
else if (Array.isArray(exports)) {
|
|
118974
|
+
return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
|
|
118975
|
+
}
|
|
118976
|
+
else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
|
|
118977
|
+
if (ts.allKeysStartWithDot(exports)) {
|
|
118978
|
+
// sub-mappings
|
|
118979
|
+
// 3 cases:
|
|
118980
|
+
// * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
|
|
118981
|
+
// * pattern mappings (contains a *)
|
|
118982
|
+
// * exact mappings (no *, does not end with /)
|
|
118983
|
+
return ts.forEach(ts.getOwnKeys(exports), function (k) {
|
|
118984
|
+
var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
|
|
118985
|
+
var mode = ts.endsWith(k, "/") ? 1 /* Directory */
|
|
118986
|
+
: ts.stringContains(k, "*") ? 2 /* Pattern */
|
|
118987
|
+
: 0 /* Exact */;
|
|
118988
|
+
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
|
|
118989
|
+
});
|
|
118990
|
+
}
|
|
118991
|
+
else {
|
|
118992
|
+
// conditional mapping
|
|
118993
|
+
for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
|
|
118994
|
+
var key = _a[_i];
|
|
118995
|
+
if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
|
|
118996
|
+
var subTarget = exports[key];
|
|
118997
|
+
var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
|
|
118998
|
+
if (result) {
|
|
118999
|
+
return result;
|
|
119000
|
+
}
|
|
119001
|
+
}
|
|
119002
|
+
}
|
|
119003
|
+
}
|
|
119004
|
+
}
|
|
119005
|
+
return undefined;
|
|
119006
|
+
}
|
|
118808
119007
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
|
|
118809
119008
|
var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
118810
119009
|
if (normalizedTargetPath === undefined) {
|
|
@@ -118834,7 +119033,15 @@ var ts;
|
|
|
118834
119033
|
var moduleFileNameForExtensionless = void 0;
|
|
118835
119034
|
while (true) {
|
|
118836
119035
|
// If the module could be imported by a directory name, use that directory's name
|
|
118837
|
-
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
|
|
119036
|
+
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
119037
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
|
|
119038
|
+
if (blockedByExports) {
|
|
119039
|
+
return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
|
|
119040
|
+
}
|
|
119041
|
+
if (verbatimFromExports) {
|
|
119042
|
+
return moduleFileToTry;
|
|
119043
|
+
}
|
|
119044
|
+
}
|
|
118838
119045
|
if (packageRootPath) {
|
|
118839
119046
|
moduleSpecifier = packageRootPath;
|
|
118840
119047
|
isPackageRootPath = true;
|
|
@@ -118864,13 +119071,22 @@ var ts;
|
|
|
118864
119071
|
var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
|
|
118865
119072
|
var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
|
|
118866
119073
|
// For classic resolution, only allow importing from node_modules/@types, not other node_modules
|
|
118867
|
-
return ts.getEmitModuleResolutionKind(options)
|
|
119074
|
+
return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
|
|
118868
119075
|
function tryDirectoryWithPackageJson(packageRootIndex) {
|
|
118869
119076
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
118870
119077
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
118871
119078
|
var moduleFileToTry = path;
|
|
118872
119079
|
if (host.fileExists(packageJsonPath)) {
|
|
118873
119080
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119081
|
+
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119082
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
|
|
119083
|
+
if (fromExports) {
|
|
119084
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119085
|
+
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119086
|
+
}
|
|
119087
|
+
if (packageJsonContent.exports) {
|
|
119088
|
+
return { moduleFileToTry: path, blockedByExports: true };
|
|
119089
|
+
}
|
|
118874
119090
|
var versionPaths = packageJsonContent.typesVersions
|
|
118875
119091
|
? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
|
|
118876
119092
|
: undefined;
|