typescript 4.8.0-dev.20220803 → 4.8.0-dev.20220806
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 +4 -0
- package/lib/de/diagnosticMessages.generated.json +4 -0
- package/lib/es/diagnosticMessages.generated.json +4 -0
- package/lib/fr/diagnosticMessages.generated.json +4 -0
- package/lib/it/diagnosticMessages.generated.json +4 -0
- package/lib/ja/diagnosticMessages.generated.json +4 -0
- package/lib/ko/diagnosticMessages.generated.json +4 -0
- package/lib/pl/diagnosticMessages.generated.json +4 -0
- package/lib/pt-br/diagnosticMessages.generated.json +4 -0
- package/lib/ru/diagnosticMessages.generated.json +4 -0
- package/lib/tr/diagnosticMessages.generated.json +4 -0
- package/lib/tsc.js +237 -108
- package/lib/tsserver.js +312 -115
- package/lib/tsserverlibrary.js +312 -115
- package/lib/typescript.js +312 -115
- package/lib/typescriptServices.js +312 -115
- package/lib/typingsInstaller.js +308 -114
- package/lib/zh-cn/diagnosticMessages.generated.json +4 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +4 -0
- package/package.json +4 -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.20220806";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -8556,7 +8556,7 @@ var ts;
|
|
|
8556
8556
|
File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""),
|
|
8557
8557
|
File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"),
|
|
8558
8558
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8559
|
-
|
|
8559
|
+
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."),
|
|
8560
8560
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8561
8561
|
An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."),
|
|
8562
8562
|
An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."),
|
|
@@ -8564,6 +8564,11 @@ var ts;
|
|
|
8564
8564
|
auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."),
|
|
8565
8565
|
An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."),
|
|
8566
8566
|
Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
|
|
8567
|
+
The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."),
|
|
8568
|
+
To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."),
|
|
8569
|
+
To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."),
|
|
8570
|
+
To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."),
|
|
8571
|
+
To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."),
|
|
8567
8572
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
8568
8573
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
8569
8574
|
Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
@@ -21858,7 +21863,7 @@ var ts;
|
|
|
21858
21863
|
* Wraps an expression in parentheses if it is needed in order to use the expression for
|
|
21859
21864
|
* property or element access.
|
|
21860
21865
|
*/
|
|
21861
|
-
function parenthesizeLeftSideOfAccess(expression) {
|
|
21866
|
+
function parenthesizeLeftSideOfAccess(expression, optionalChain) {
|
|
21862
21867
|
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
|
21863
21868
|
// to parenthesize the expression before a dot. The known exception is:
|
|
21864
21869
|
//
|
|
@@ -21867,7 +21872,8 @@ var ts;
|
|
|
21867
21872
|
//
|
|
21868
21873
|
var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
|
|
21869
21874
|
if (ts.isLeftHandSideExpression(emittedExpression)
|
|
21870
|
-
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
21875
|
+
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
21876
|
+
&& (optionalChain || !ts.isOptionalChain(emittedExpression))) {
|
|
21871
21877
|
// TODO(rbuckton): Verify whether this assertion holds.
|
|
21872
21878
|
return expression;
|
|
21873
21879
|
}
|
|
@@ -23274,7 +23280,7 @@ var ts;
|
|
|
23274
23280
|
// @api
|
|
23275
23281
|
function createDecorator(expression) {
|
|
23276
23282
|
var node = createBaseNode(165 /* Decorator */);
|
|
23277
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
23283
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
23278
23284
|
node.transformFlags |=
|
|
23279
23285
|
propagateChildFlags(node.expression) |
|
|
23280
23286
|
1 /* ContainsTypeScript */ |
|
|
@@ -24075,7 +24081,7 @@ var ts;
|
|
|
24075
24081
|
// @api
|
|
24076
24082
|
function createPropertyAccessExpression(expression, name) {
|
|
24077
24083
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24078
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24084
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24079
24085
|
node.name = asName(name);
|
|
24080
24086
|
node.transformFlags =
|
|
24081
24087
|
propagateChildFlags(node.expression) |
|
|
@@ -24105,7 +24111,7 @@ var ts;
|
|
|
24105
24111
|
function createPropertyAccessChain(expression, questionDotToken, name) {
|
|
24106
24112
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24107
24113
|
node.flags |= 32 /* OptionalChain */;
|
|
24108
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24114
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24109
24115
|
node.questionDotToken = questionDotToken;
|
|
24110
24116
|
node.name = asName(name);
|
|
24111
24117
|
node.transformFlags |=
|
|
@@ -24131,7 +24137,7 @@ var ts;
|
|
|
24131
24137
|
// @api
|
|
24132
24138
|
function createElementAccessExpression(expression, index) {
|
|
24133
24139
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24134
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24140
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24135
24141
|
node.argumentExpression = asExpression(index);
|
|
24136
24142
|
node.transformFlags |=
|
|
24137
24143
|
propagateChildFlags(node.expression) |
|
|
@@ -24159,7 +24165,7 @@ var ts;
|
|
|
24159
24165
|
function createElementAccessChain(expression, questionDotToken, index) {
|
|
24160
24166
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24161
24167
|
node.flags |= 32 /* OptionalChain */;
|
|
24162
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24168
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24163
24169
|
node.questionDotToken = questionDotToken;
|
|
24164
24170
|
node.argumentExpression = asExpression(index);
|
|
24165
24171
|
node.transformFlags |=
|
|
@@ -24183,7 +24189,7 @@ var ts;
|
|
|
24183
24189
|
// @api
|
|
24184
24190
|
function createCallExpression(expression, typeArguments, argumentsArray) {
|
|
24185
24191
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24186
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24192
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24187
24193
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24188
24194
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
24189
24195
|
node.transformFlags |=
|
|
@@ -24216,7 +24222,7 @@ var ts;
|
|
|
24216
24222
|
function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
|
|
24217
24223
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24218
24224
|
node.flags |= 32 /* OptionalChain */;
|
|
24219
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24225
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24220
24226
|
node.questionDotToken = questionDotToken;
|
|
24221
24227
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24222
24228
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
@@ -24271,7 +24277,7 @@ var ts;
|
|
|
24271
24277
|
// @api
|
|
24272
24278
|
function createTaggedTemplateExpression(tag, typeArguments, template) {
|
|
24273
24279
|
var node = createBaseExpression(210 /* TaggedTemplateExpression */);
|
|
24274
|
-
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
|
|
24280
|
+
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
|
|
24275
24281
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24276
24282
|
node.template = template;
|
|
24277
24283
|
node.transformFlags |=
|
|
@@ -24709,7 +24715,7 @@ var ts;
|
|
|
24709
24715
|
// @api
|
|
24710
24716
|
function createExpressionWithTypeArguments(expression, typeArguments) {
|
|
24711
24717
|
var node = createBaseNode(228 /* ExpressionWithTypeArguments */);
|
|
24712
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24718
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24713
24719
|
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
24714
24720
|
node.transformFlags |=
|
|
24715
24721
|
propagateChildFlags(node.expression) |
|
|
@@ -24745,7 +24751,7 @@ var ts;
|
|
|
24745
24751
|
// @api
|
|
24746
24752
|
function createNonNullExpression(expression) {
|
|
24747
24753
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24748
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24754
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24749
24755
|
node.transformFlags |=
|
|
24750
24756
|
propagateChildFlags(node.expression) |
|
|
24751
24757
|
1 /* ContainsTypeScript */;
|
|
@@ -24764,7 +24770,7 @@ var ts;
|
|
|
24764
24770
|
function createNonNullChain(expression) {
|
|
24765
24771
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24766
24772
|
node.flags |= 32 /* OptionalChain */;
|
|
24767
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24773
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24768
24774
|
node.transformFlags |=
|
|
24769
24775
|
propagateChildFlags(node.expression) |
|
|
24770
24776
|
1 /* ContainsTypeScript */;
|
|
@@ -26968,7 +26974,7 @@ var ts;
|
|
|
26968
26974
|
}
|
|
26969
26975
|
else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
|
|
26970
26976
|
thisArg = createVoidZero();
|
|
26971
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
|
|
26977
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
|
|
26972
26978
|
}
|
|
26973
26979
|
else if (ts.isPropertyAccessExpression(callee)) {
|
|
26974
26980
|
if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
|
|
@@ -26997,7 +27003,7 @@ var ts;
|
|
|
26997
27003
|
else {
|
|
26998
27004
|
// for `a()` target is `a` and thisArg is `void 0`
|
|
26999
27005
|
thisArg = createVoidZero();
|
|
27000
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
27006
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
27001
27007
|
}
|
|
27002
27008
|
return { target: target, thisArg: thisArg };
|
|
27003
27009
|
}
|
|
@@ -51672,7 +51678,40 @@ var ts;
|
|
|
51672
51678
|
// An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of
|
|
51673
51679
|
// normal mode restrictions
|
|
51674
51680
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) {
|
|
51675
|
-
|
|
51681
|
+
if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) {
|
|
51682
|
+
// ImportEquals in a ESM file resolving to another ESM file
|
|
51683
|
+
error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference);
|
|
51684
|
+
}
|
|
51685
|
+
else {
|
|
51686
|
+
// CJS file resolving to an ESM file
|
|
51687
|
+
var diagnosticDetails = void 0;
|
|
51688
|
+
var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
|
|
51689
|
+
if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
|
|
51690
|
+
var scope = currentSourceFile.packageJsonScope;
|
|
51691
|
+
var targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : undefined;
|
|
51692
|
+
if (scope && !scope.packageJsonContent.type) {
|
|
51693
|
+
if (targetExt) {
|
|
51694
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51695
|
+
/*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, ts.combinePaths(scope.packageDirectory, "package.json"));
|
|
51696
|
+
}
|
|
51697
|
+
else {
|
|
51698
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51699
|
+
/*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, ts.combinePaths(scope.packageDirectory, "package.json"));
|
|
51700
|
+
}
|
|
51701
|
+
}
|
|
51702
|
+
else {
|
|
51703
|
+
if (targetExt) {
|
|
51704
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51705
|
+
/*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt);
|
|
51706
|
+
}
|
|
51707
|
+
else {
|
|
51708
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51709
|
+
/*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module);
|
|
51710
|
+
}
|
|
51711
|
+
}
|
|
51712
|
+
}
|
|
51713
|
+
diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, ts.chainDiagnosticMessages(diagnosticDetails, ts.Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference)));
|
|
51714
|
+
}
|
|
51676
51715
|
}
|
|
51677
51716
|
}
|
|
51678
51717
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
@@ -73180,12 +73219,15 @@ var ts;
|
|
|
73180
73219
|
if (contextualReturnType) {
|
|
73181
73220
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73182
73221
|
if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
|
|
73183
|
-
var
|
|
73184
|
-
|
|
73185
|
-
|
|
73222
|
+
var isAsyncGenerator_1 = (functionFlags & 2 /* Async */) !== 0;
|
|
73223
|
+
if (contextualReturnType.flags & 1048576 /* Union */) {
|
|
73224
|
+
contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, type, isAsyncGenerator_1); });
|
|
73225
|
+
}
|
|
73226
|
+
var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0);
|
|
73227
|
+
if (!iterationReturnType) {
|
|
73186
73228
|
return undefined;
|
|
73187
73229
|
}
|
|
73188
|
-
contextualReturnType =
|
|
73230
|
+
contextualReturnType = iterationReturnType;
|
|
73189
73231
|
// falls through to unwrap Promise for AsyncGenerators
|
|
73190
73232
|
}
|
|
73191
73233
|
if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function
|
|
@@ -73212,9 +73254,13 @@ var ts;
|
|
|
73212
73254
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73213
73255
|
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73214
73256
|
if (contextualReturnType) {
|
|
73257
|
+
var isAsyncGenerator_2 = (functionFlags & 2 /* Async */) !== 0;
|
|
73258
|
+
if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* Union */) {
|
|
73259
|
+
contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, type, isAsyncGenerator_2); });
|
|
73260
|
+
}
|
|
73215
73261
|
return node.asteriskToken
|
|
73216
73262
|
? contextualReturnType
|
|
73217
|
-
: getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType,
|
|
73263
|
+
: getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, isAsyncGenerator_2);
|
|
73218
73264
|
}
|
|
73219
73265
|
}
|
|
73220
73266
|
return undefined;
|
|
@@ -83989,17 +84035,28 @@ var ts;
|
|
|
83989
84035
|
* the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
|
|
83990
84036
|
*/
|
|
83991
84037
|
function getIterationTypesOfIterable(type, use, errorNode) {
|
|
84038
|
+
var _a, _b;
|
|
83992
84039
|
if (isTypeAny(type)) {
|
|
83993
84040
|
return anyIterationTypes;
|
|
83994
84041
|
}
|
|
83995
84042
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
83996
|
-
var
|
|
84043
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84044
|
+
var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
83997
84045
|
if (iterationTypes_1 === noIterationTypes) {
|
|
83998
84046
|
if (errorNode) {
|
|
83999
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84047
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84048
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84049
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84050
|
+
}
|
|
84000
84051
|
}
|
|
84001
84052
|
return undefined;
|
|
84002
84053
|
}
|
|
84054
|
+
else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
84055
|
+
for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) {
|
|
84056
|
+
var diag = _c[_i];
|
|
84057
|
+
diagnostics.add(diag);
|
|
84058
|
+
}
|
|
84059
|
+
}
|
|
84003
84060
|
return iterationTypes_1;
|
|
84004
84061
|
}
|
|
84005
84062
|
var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
|
|
@@ -84007,19 +84064,27 @@ var ts;
|
|
|
84007
84064
|
if (cachedTypes)
|
|
84008
84065
|
return cachedTypes === noIterationTypes ? undefined : cachedTypes;
|
|
84009
84066
|
var allIterationTypes;
|
|
84010
|
-
for (var
|
|
84011
|
-
var constituent =
|
|
84012
|
-
var
|
|
84067
|
+
for (var _d = 0, _e = type.types; _d < _e.length; _d++) {
|
|
84068
|
+
var constituent = _e[_d];
|
|
84069
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84070
|
+
var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer);
|
|
84013
84071
|
if (iterationTypes_2 === noIterationTypes) {
|
|
84014
84072
|
if (errorNode) {
|
|
84015
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84073
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84074
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84075
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84076
|
+
}
|
|
84016
84077
|
}
|
|
84017
84078
|
setCachedIterationTypes(type, cacheKey, noIterationTypes);
|
|
84018
84079
|
return undefined;
|
|
84019
84080
|
}
|
|
84020
|
-
else {
|
|
84021
|
-
|
|
84081
|
+
else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
84082
|
+
for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) {
|
|
84083
|
+
var diag = _g[_f];
|
|
84084
|
+
diagnostics.add(diag);
|
|
84085
|
+
}
|
|
84022
84086
|
}
|
|
84087
|
+
allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
|
|
84023
84088
|
}
|
|
84024
84089
|
var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
|
|
84025
84090
|
setCachedIterationTypes(type, cacheKey, iterationTypes);
|
|
@@ -84047,47 +84112,62 @@ var ts;
|
|
|
84047
84112
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84048
84113
|
* `getIterationTypesOfIterable` instead.
|
|
84049
84114
|
*/
|
|
84050
|
-
function getIterationTypesOfIterableWorker(type, use, errorNode) {
|
|
84115
|
+
function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) {
|
|
84051
84116
|
if (isTypeAny(type)) {
|
|
84052
84117
|
return anyIterationTypes;
|
|
84053
84118
|
}
|
|
84119
|
+
// If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached.
|
|
84120
|
+
// In addition, we should not cache any new results for this call.
|
|
84121
|
+
var noCache = false;
|
|
84054
84122
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84055
84123
|
var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
|
|
84056
84124
|
getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
|
|
84057
84125
|
if (iterationTypes) {
|
|
84058
|
-
|
|
84059
|
-
|
|
84060
|
-
|
|
84126
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84127
|
+
// ignore the cached value
|
|
84128
|
+
noCache = true;
|
|
84129
|
+
}
|
|
84130
|
+
else {
|
|
84131
|
+
return use & 8 /* ForOfFlag */ ?
|
|
84132
|
+
getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
|
|
84133
|
+
iterationTypes;
|
|
84134
|
+
}
|
|
84061
84135
|
}
|
|
84062
84136
|
}
|
|
84063
84137
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84064
84138
|
var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
|
|
84065
84139
|
getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
|
|
84066
84140
|
if (iterationTypes) {
|
|
84067
|
-
if (
|
|
84068
|
-
//
|
|
84069
|
-
|
|
84070
|
-
return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
|
|
84071
|
-
}
|
|
84141
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84142
|
+
// ignore the cached value
|
|
84143
|
+
noCache = true;
|
|
84072
84144
|
}
|
|
84073
84145
|
else {
|
|
84074
|
-
|
|
84146
|
+
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84147
|
+
// for a sync iterable in an async context, only use the cached types if they are valid.
|
|
84148
|
+
if (iterationTypes !== noIterationTypes) {
|
|
84149
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84150
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84151
|
+
}
|
|
84152
|
+
}
|
|
84153
|
+
else {
|
|
84154
|
+
return iterationTypes;
|
|
84155
|
+
}
|
|
84075
84156
|
}
|
|
84076
84157
|
}
|
|
84077
84158
|
}
|
|
84078
84159
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84079
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
|
|
84160
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84080
84161
|
if (iterationTypes !== noIterationTypes) {
|
|
84081
84162
|
return iterationTypes;
|
|
84082
84163
|
}
|
|
84083
84164
|
}
|
|
84084
84165
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84085
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
|
|
84166
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84086
84167
|
if (iterationTypes !== noIterationTypes) {
|
|
84087
84168
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84088
|
-
|
|
84089
|
-
|
|
84090
|
-
: noIterationTypes);
|
|
84169
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84170
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84091
84171
|
}
|
|
84092
84172
|
else {
|
|
84093
84173
|
return iterationTypes;
|
|
@@ -84108,7 +84188,7 @@ var ts;
|
|
|
84108
84188
|
}
|
|
84109
84189
|
function getIterationTypesOfGlobalIterableType(globalType, resolver) {
|
|
84110
84190
|
var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
|
|
84111
|
-
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84191
|
+
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84112
84192
|
return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
|
|
84113
84193
|
}
|
|
84114
84194
|
/**
|
|
@@ -84162,26 +84242,26 @@ var ts;
|
|
|
84162
84242
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84163
84243
|
* `getIterationTypesOfIterable` instead.
|
|
84164
84244
|
*/
|
|
84165
|
-
function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
|
|
84245
|
+
function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84166
84246
|
var _a;
|
|
84167
84247
|
var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
|
|
84168
84248
|
var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
|
|
84169
84249
|
if (isTypeAny(methodType)) {
|
|
84170
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84250
|
+
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84171
84251
|
}
|
|
84172
84252
|
var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
|
|
84173
84253
|
if (!ts.some(signatures)) {
|
|
84174
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84254
|
+
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84175
84255
|
}
|
|
84176
84256
|
var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
|
|
84177
|
-
var iterationTypes = (_a =
|
|
84178
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84257
|
+
var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes;
|
|
84258
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84179
84259
|
}
|
|
84180
84260
|
function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
|
|
84181
84261
|
var message = allowAsyncIterables
|
|
84182
84262
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
84183
84263
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
84184
|
-
errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84264
|
+
return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84185
84265
|
}
|
|
84186
84266
|
/**
|
|
84187
84267
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -84189,13 +84269,29 @@ var ts;
|
|
|
84189
84269
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84190
84270
|
* record is returned. Otherwise, `undefined` is returned.
|
|
84191
84271
|
*/
|
|
84192
|
-
function getIterationTypesOfIterator(type, resolver, errorNode) {
|
|
84272
|
+
function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) {
|
|
84273
|
+
return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false);
|
|
84274
|
+
}
|
|
84275
|
+
/**
|
|
84276
|
+
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84277
|
+
*
|
|
84278
|
+
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84279
|
+
* record is returned. Otherwise, `undefined` is returned.
|
|
84280
|
+
*
|
|
84281
|
+
* NOTE: You probably don't want to call this directly and should be calling
|
|
84282
|
+
* `getIterationTypesOfIterator` instead.
|
|
84283
|
+
*/
|
|
84284
|
+
function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84193
84285
|
if (isTypeAny(type)) {
|
|
84194
84286
|
return anyIterationTypes;
|
|
84195
84287
|
}
|
|
84196
84288
|
var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
|
|
84197
|
-
getIterationTypesOfIteratorFast(type, resolver)
|
|
84198
|
-
|
|
84289
|
+
getIterationTypesOfIteratorFast(type, resolver);
|
|
84290
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84291
|
+
iterationTypes = undefined;
|
|
84292
|
+
noCache = true;
|
|
84293
|
+
}
|
|
84294
|
+
iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache));
|
|
84199
84295
|
return iterationTypes === noIterationTypes ? undefined : iterationTypes;
|
|
84200
84296
|
}
|
|
84201
84297
|
/**
|
|
@@ -84233,7 +84329,7 @@ var ts;
|
|
|
84233
84329
|
// iteration types of their `next`, `return`, and `throw` methods. While we define these as `any`
|
|
84234
84330
|
// and `undefined` in our libs by default, a custom lib *could* use different definitions.
|
|
84235
84331
|
var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
|
|
84236
|
-
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84332
|
+
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84237
84333
|
var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
|
|
84238
84334
|
return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
|
|
84239
84335
|
}
|
|
@@ -84303,8 +84399,8 @@ var ts;
|
|
|
84303
84399
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84304
84400
|
* record is returned. Otherwise, we return `undefined`.
|
|
84305
84401
|
*/
|
|
84306
|
-
function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
|
|
84307
|
-
var _a, _b, _c, _d;
|
|
84402
|
+
function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) {
|
|
84403
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84308
84404
|
var method = getPropertyOfType(type, methodName);
|
|
84309
84405
|
// Ignore 'return' or 'throw' if they are missing.
|
|
84310
84406
|
if (!method && methodName !== "next") {
|
|
@@ -84324,9 +84420,15 @@ var ts;
|
|
|
84324
84420
|
var diagnostic = methodName === "next"
|
|
84325
84421
|
? resolver.mustHaveANextMethodDiagnostic
|
|
84326
84422
|
: resolver.mustBeAMethodDiagnostic;
|
|
84327
|
-
|
|
84423
|
+
if (errorOutputContainer) {
|
|
84424
|
+
(_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []);
|
|
84425
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName));
|
|
84426
|
+
}
|
|
84427
|
+
else {
|
|
84428
|
+
error(errorNode, diagnostic, methodName);
|
|
84429
|
+
}
|
|
84328
84430
|
}
|
|
84329
|
-
return methodName === "next" ?
|
|
84431
|
+
return methodName === "next" ? noIterationTypes : undefined;
|
|
84330
84432
|
}
|
|
84331
84433
|
// If the method signature comes exclusively from the global iterator or generator type,
|
|
84332
84434
|
// create iteration types from its type arguments like `getIterationTypesOfIteratorFast`
|
|
@@ -84338,8 +84440,8 @@ var ts;
|
|
|
84338
84440
|
if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
|
|
84339
84441
|
var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false);
|
|
84340
84442
|
var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false);
|
|
84341
|
-
var isGeneratorMethod = ((
|
|
84342
|
-
var isIteratorMethod = !isGeneratorMethod && ((
|
|
84443
|
+
var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol;
|
|
84444
|
+
var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol;
|
|
84343
84445
|
if (isGeneratorMethod || isIteratorMethod) {
|
|
84344
84446
|
var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
|
|
84345
84447
|
var mapper = methodType.mapper;
|
|
@@ -84379,7 +84481,13 @@ var ts;
|
|
|
84379
84481
|
var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
|
|
84380
84482
|
if (iterationTypes === noIterationTypes) {
|
|
84381
84483
|
if (errorNode) {
|
|
84382
|
-
|
|
84484
|
+
if (errorOutputContainer) {
|
|
84485
|
+
(_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []);
|
|
84486
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
|
|
84487
|
+
}
|
|
84488
|
+
else {
|
|
84489
|
+
error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
|
|
84490
|
+
}
|
|
84383
84491
|
}
|
|
84384
84492
|
yieldType = anyType;
|
|
84385
84493
|
returnTypes = ts.append(returnTypes, anyType);
|
|
@@ -84400,13 +84508,13 @@ var ts;
|
|
|
84400
84508
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84401
84509
|
* `getIterationTypesOfIterator` instead.
|
|
84402
84510
|
*/
|
|
84403
|
-
function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
|
|
84511
|
+
function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84404
84512
|
var iterationTypes = combineIterationTypes([
|
|
84405
|
-
getIterationTypesOfMethod(type, resolver, "next", errorNode),
|
|
84406
|
-
getIterationTypesOfMethod(type, resolver, "return", errorNode),
|
|
84407
|
-
getIterationTypesOfMethod(type, resolver, "throw", errorNode),
|
|
84513
|
+
getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer),
|
|
84514
|
+
getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer),
|
|
84515
|
+
getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer),
|
|
84408
84516
|
]);
|
|
84409
|
-
return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84517
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84410
84518
|
}
|
|
84411
84519
|
/**
|
|
84412
84520
|
* Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like,
|
|
@@ -84427,7 +84535,7 @@ var ts;
|
|
|
84427
84535
|
var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
|
|
84428
84536
|
var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
|
|
84429
84537
|
return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
|
|
84430
|
-
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
|
|
84538
|
+
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined);
|
|
84431
84539
|
}
|
|
84432
84540
|
function checkBreakOrContinueStatement(node) {
|
|
84433
84541
|
// Grammar checking
|
|
@@ -122724,8 +122832,6 @@ var ts;
|
|
|
122724
122832
|
if (watcher.files === 0 && watcher.resolutions === 0) {
|
|
122725
122833
|
fileWatchesOfAffectingLocations.delete(path);
|
|
122726
122834
|
watcher.watcher.close();
|
|
122727
|
-
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
122728
|
-
watcher.watcher = ts.noopFileWatcher;
|
|
122729
122835
|
}
|
|
122730
122836
|
});
|
|
122731
122837
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
@@ -123071,20 +123177,27 @@ var ts;
|
|
|
123071
123177
|
}
|
|
123072
123178
|
var paths = new ts.Set();
|
|
123073
123179
|
paths.add(locationToWatch);
|
|
123180
|
+
var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
|
|
123181
|
+
resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
|
|
123182
|
+
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
|
123183
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123184
|
+
paths.forEach(function (path) {
|
|
123185
|
+
if (watcher.resolutions)
|
|
123186
|
+
(affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
|
|
123187
|
+
if (watcher.files)
|
|
123188
|
+
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123189
|
+
packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
|
|
123190
|
+
});
|
|
123191
|
+
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123192
|
+
}) : ts.noopFileWatcher;
|
|
123074
123193
|
var watcher = {
|
|
123075
|
-
watcher:
|
|
123076
|
-
|
|
123077
|
-
|
|
123078
|
-
|
|
123079
|
-
|
|
123080
|
-
|
|
123081
|
-
|
|
123082
|
-
if (watcher.files)
|
|
123083
|
-
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123084
|
-
(_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
|
|
123085
|
-
});
|
|
123086
|
-
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123087
|
-
}) : ts.noopFileWatcher,
|
|
123194
|
+
watcher: actualWatcher !== ts.noopFileWatcher ? {
|
|
123195
|
+
close: function () {
|
|
123196
|
+
actualWatcher.close();
|
|
123197
|
+
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
123198
|
+
actualWatcher = ts.noopFileWatcher;
|
|
123199
|
+
}
|
|
123200
|
+
} : actualWatcher,
|
|
123088
123201
|
resolutions: forResolution ? 1 : 0,
|
|
123089
123202
|
files: forResolution ? 0 : 1,
|
|
123090
123203
|
paths: paths,
|
|
@@ -123498,7 +123611,7 @@ var ts;
|
|
|
123498
123611
|
var info = getInfo(importingSourceFileName, host);
|
|
123499
123612
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
123500
123613
|
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
123501
|
-
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
123614
|
+
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123502
123615
|
}
|
|
123503
123616
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
123504
123617
|
if (options === void 0) { options = {}; }
|
|
@@ -123581,7 +123694,7 @@ var ts;
|
|
|
123581
123694
|
return nodeModulesSpecifiers;
|
|
123582
123695
|
}
|
|
123583
123696
|
if (!specifier && !modulePath.isRedirect) {
|
|
123584
|
-
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
|
|
123697
|
+
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123585
123698
|
if (ts.pathIsBareSpecifier(local)) {
|
|
123586
123699
|
pathsSpecifiers = ts.append(pathsSpecifiers, local);
|
|
123587
123700
|
}
|
|
@@ -123609,7 +123722,7 @@ var ts;
|
|
|
123609
123722
|
var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
|
|
123610
123723
|
return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
|
|
123611
123724
|
}
|
|
123612
|
-
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
|
|
123725
|
+
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) {
|
|
123613
123726
|
var ending = _a.ending, relativePreference = _a.relativePreference;
|
|
123614
123727
|
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
|
|
123615
123728
|
var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
|
|
@@ -123623,9 +123736,8 @@ var ts;
|
|
|
123623
123736
|
if (!relativeToBaseUrl) {
|
|
123624
123737
|
return relativePath;
|
|
123625
123738
|
}
|
|
123626
|
-
var
|
|
123627
|
-
var
|
|
123628
|
-
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
|
|
123739
|
+
var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
|
|
123740
|
+
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
|
|
123629
123741
|
if (!nonRelative) {
|
|
123630
123742
|
return relativePath;
|
|
123631
123743
|
}
|
|
@@ -123860,28 +123972,102 @@ var ts;
|
|
|
123860
123972
|
return ambientModuleDeclare.name.text;
|
|
123861
123973
|
}
|
|
123862
123974
|
}
|
|
123863
|
-
function
|
|
123975
|
+
function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
|
|
123976
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) {
|
|
123977
|
+
return [2 /* JsExtension */];
|
|
123978
|
+
}
|
|
123979
|
+
switch (preferredEnding) {
|
|
123980
|
+
case 2 /* JsExtension */: return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
|
|
123981
|
+
case 1 /* Index */: return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
|
|
123982
|
+
case 0 /* Minimal */: return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
|
|
123983
|
+
default: ts.Debug.assertNever(preferredEnding);
|
|
123984
|
+
}
|
|
123985
|
+
}
|
|
123986
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
123864
123987
|
for (var key in paths) {
|
|
123865
|
-
|
|
123866
|
-
var
|
|
123867
|
-
var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
|
|
123988
|
+
var _loop_36 = function (patternText_1) {
|
|
123989
|
+
var pattern = ts.normalizePath(patternText_1);
|
|
123868
123990
|
var indexOfStar = pattern.indexOf("*");
|
|
123991
|
+
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
123992
|
+
// meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
|
|
123993
|
+
// causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
|
|
123994
|
+
// and matches the '*'. For example:
|
|
123995
|
+
//
|
|
123996
|
+
// Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
|
|
123997
|
+
// ---------------------->------------------------------->--------------------->---------------------------------------------------------------
|
|
123998
|
+
// import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
|
|
123999
|
+
// import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
|
|
124000
|
+
//
|
|
124001
|
+
// (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
|
|
124002
|
+
//
|
|
124003
|
+
// The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
|
|
124004
|
+
// the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
|
|
124005
|
+
// (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
|
|
124006
|
+
// extension for a module specifier.)
|
|
124007
|
+
//
|
|
124008
|
+
// Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
|
|
124009
|
+
// .ts extension) or the possible relative module specifiers representing that file:
|
|
124010
|
+
//
|
|
124011
|
+
// Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
|
|
124012
|
+
// --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
|
|
124013
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
|
|
124014
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
|
|
124015
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
|
|
124016
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js
|
|
124017
|
+
// dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
|
|
124018
|
+
//
|
|
124019
|
+
// The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
|
|
124020
|
+
// relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
|
|
124021
|
+
// into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
|
|
124022
|
+
// exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
|
|
124023
|
+
// specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
|
|
124024
|
+
// resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
|
|
124025
|
+
// in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
|
|
124026
|
+
// sorted among the others for a particular value of `importModuleSpecifierEnding`.
|
|
124027
|
+
var candidates = allowedEndings.map(function (ending) { return ({
|
|
124028
|
+
ending: ending,
|
|
124029
|
+
value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
|
|
124030
|
+
}); });
|
|
124031
|
+
if (ts.tryGetExtensionFromPath(pattern)) {
|
|
124032
|
+
candidates.push({ ending: undefined, value: relativeToBaseUrl });
|
|
124033
|
+
}
|
|
123869
124034
|
if (indexOfStar !== -1) {
|
|
123870
|
-
var prefix = pattern.
|
|
123871
|
-
var suffix = pattern.
|
|
123872
|
-
|
|
123873
|
-
|
|
123874
|
-
|
|
123875
|
-
|
|
123876
|
-
|
|
123877
|
-
|
|
124035
|
+
var prefix = pattern.substring(0, indexOfStar);
|
|
124036
|
+
var suffix = pattern.substring(indexOfStar + 1);
|
|
124037
|
+
for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) {
|
|
124038
|
+
var _c = candidates_3[_b], ending = _c.ending, value = _c.value;
|
|
124039
|
+
if (value.length >= prefix.length + suffix.length &&
|
|
124040
|
+
ts.startsWith(value, prefix) &&
|
|
124041
|
+
ts.endsWith(value, suffix) &&
|
|
124042
|
+
validateEnding({ ending: ending, value: value })) {
|
|
124043
|
+
var matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
|
124044
|
+
return { value: key.replace("*", matchedStar) };
|
|
124045
|
+
}
|
|
123878
124046
|
}
|
|
123879
124047
|
}
|
|
123880
|
-
else if (
|
|
123881
|
-
return
|
|
124048
|
+
else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Minimal */ && pattern === c.value; }) ||
|
|
124049
|
+
ts.some(candidates, function (c) { return c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c); })) {
|
|
124050
|
+
return { value: key };
|
|
123882
124051
|
}
|
|
124052
|
+
};
|
|
124053
|
+
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
124054
|
+
var patternText_1 = _a[_i];
|
|
124055
|
+
var state_12 = _loop_36(patternText_1);
|
|
124056
|
+
if (typeof state_12 === "object")
|
|
124057
|
+
return state_12.value;
|
|
123883
124058
|
}
|
|
123884
124059
|
}
|
|
124060
|
+
function validateEnding(_a) {
|
|
124061
|
+
var ending = _a.ending, value = _a.value;
|
|
124062
|
+
// Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
|
|
124063
|
+
// is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
|
|
124064
|
+
// here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
|
|
124065
|
+
// do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the
|
|
124066
|
+
// `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
|
|
124067
|
+
// that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
|
|
124068
|
+
// everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
|
|
124069
|
+
return ending !== 0 /* Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
|
|
124070
|
+
}
|
|
123885
124071
|
}
|
|
123886
124072
|
var MatchingMode;
|
|
123887
124073
|
(function (MatchingMode) {
|
|
@@ -123977,10 +124163,10 @@ var ts;
|
|
|
123977
124163
|
return undefined;
|
|
123978
124164
|
}
|
|
123979
124165
|
// Simplify the full file path to something that can be resolved by Node.
|
|
124166
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
123980
124167
|
var moduleSpecifier = path;
|
|
123981
124168
|
var isPackageRootPath = false;
|
|
123982
124169
|
if (!packageNameOnly) {
|
|
123983
|
-
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
123984
124170
|
var packageRootIndex = parts.packageRootIndex;
|
|
123985
124171
|
var moduleFileName = void 0;
|
|
123986
124172
|
while (true) {
|
|
@@ -124029,15 +124215,13 @@ var ts;
|
|
|
124029
124215
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
124030
124216
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
124031
124217
|
var moduleFileToTry = path;
|
|
124218
|
+
var maybeBlockedByTypesVersions = false;
|
|
124032
124219
|
var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
124033
124220
|
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
|
124034
124221
|
var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
|
|
124222
|
+
var importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
124035
124223
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
124036
|
-
|
|
124037
|
-
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
124038
|
-
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
|
124039
|
-
// with, so for now we just stick with the mode of the file.
|
|
124040
|
-
var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124224
|
+
var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124041
124225
|
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
|
124042
124226
|
? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
|
124043
124227
|
: undefined;
|
|
@@ -124056,16 +124240,26 @@ var ts;
|
|
|
124056
124240
|
: undefined;
|
|
124057
124241
|
if (versionPaths) {
|
|
124058
124242
|
var subModuleName = path.slice(packageRootPath.length + 1);
|
|
124059
|
-
var fromPaths = tryGetModuleNameFromPaths(
|
|
124060
|
-
if (fromPaths
|
|
124243
|
+
var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options);
|
|
124244
|
+
if (fromPaths === undefined) {
|
|
124245
|
+
maybeBlockedByTypesVersions = true;
|
|
124246
|
+
}
|
|
124247
|
+
else {
|
|
124061
124248
|
moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
|
|
124062
124249
|
}
|
|
124063
124250
|
}
|
|
124064
124251
|
// If the file is the main module, it can be imported by the package name
|
|
124065
124252
|
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
124066
|
-
if (ts.isString(mainFileRelative)) {
|
|
124253
|
+
if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) {
|
|
124254
|
+
// The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
|
|
124255
|
+
// explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
|
|
124256
|
+
// (The only way this can happen is if some file in a package that's not resolvable from outside the
|
|
124257
|
+
// package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
|
|
124258
|
+
// happens very easily in fourslash tests though, since every test file listed gets included. See
|
|
124259
|
+
// importNameCodeFix_typesVersions.ts for an example.)
|
|
124067
124260
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
124068
124261
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
124262
|
+
// ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
|
|
124069
124263
|
return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
|
|
124070
124264
|
}
|
|
124071
124265
|
}
|