typescript 4.8.0-dev.20220802 → 4.8.0-dev.20220805
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/lib.es2015.promise.d.ts +9 -4
- package/lib/lib.es5.d.ts +2 -2
- 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 +231 -111
- package/lib/tsserver.js +320 -132
- package/lib/tsserverlibrary.js +320 -132
- package/lib/typescript.js +320 -132
- package/lib/typescriptServices.js +320 -132
- package/lib/typingsInstaller.js +316 -131
- 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/tsserver.js
CHANGED
|
@@ -109,7 +109,7 @@ var ts;
|
|
|
109
109
|
// The following is baselined as a literal template type without intervention
|
|
110
110
|
/** The version of the TypeScript compiler release */
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
112
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
112
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220805";
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -8576,7 +8576,7 @@ var ts;
|
|
|
8576
8576
|
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\""),
|
|
8577
8577
|
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"),
|
|
8578
8578
|
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."),
|
|
8579
|
-
|
|
8579
|
+
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."),
|
|
8580
8580
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8581
8581
|
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."),
|
|
8582
8582
|
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."),
|
|
@@ -8584,6 +8584,11 @@ var ts;
|
|
|
8584
8584
|
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."),
|
|
8585
8585
|
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."),
|
|
8586
8586
|
Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
|
|
8587
|
+
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."),
|
|
8588
|
+
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\" }`."),
|
|
8589
|
+
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}'."),
|
|
8590
|
+
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}'."),
|
|
8591
|
+
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\" }`."),
|
|
8587
8592
|
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."),
|
|
8588
8593
|
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."),
|
|
8589
8594
|
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),
|
|
@@ -21878,7 +21883,7 @@ var ts;
|
|
|
21878
21883
|
* Wraps an expression in parentheses if it is needed in order to use the expression for
|
|
21879
21884
|
* property or element access.
|
|
21880
21885
|
*/
|
|
21881
|
-
function parenthesizeLeftSideOfAccess(expression) {
|
|
21886
|
+
function parenthesizeLeftSideOfAccess(expression, optionalChain) {
|
|
21882
21887
|
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
|
21883
21888
|
// to parenthesize the expression before a dot. The known exception is:
|
|
21884
21889
|
//
|
|
@@ -21887,7 +21892,8 @@ var ts;
|
|
|
21887
21892
|
//
|
|
21888
21893
|
var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
|
|
21889
21894
|
if (ts.isLeftHandSideExpression(emittedExpression)
|
|
21890
|
-
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
21895
|
+
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
21896
|
+
&& (optionalChain || !ts.isOptionalChain(emittedExpression))) {
|
|
21891
21897
|
// TODO(rbuckton): Verify whether this assertion holds.
|
|
21892
21898
|
return expression;
|
|
21893
21899
|
}
|
|
@@ -23294,7 +23300,7 @@ var ts;
|
|
|
23294
23300
|
// @api
|
|
23295
23301
|
function createDecorator(expression) {
|
|
23296
23302
|
var node = createBaseNode(165 /* Decorator */);
|
|
23297
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
23303
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
23298
23304
|
node.transformFlags |=
|
|
23299
23305
|
propagateChildFlags(node.expression) |
|
|
23300
23306
|
1 /* ContainsTypeScript */ |
|
|
@@ -24095,7 +24101,7 @@ var ts;
|
|
|
24095
24101
|
// @api
|
|
24096
24102
|
function createPropertyAccessExpression(expression, name) {
|
|
24097
24103
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24098
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24104
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24099
24105
|
node.name = asName(name);
|
|
24100
24106
|
node.transformFlags =
|
|
24101
24107
|
propagateChildFlags(node.expression) |
|
|
@@ -24125,7 +24131,7 @@ var ts;
|
|
|
24125
24131
|
function createPropertyAccessChain(expression, questionDotToken, name) {
|
|
24126
24132
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24127
24133
|
node.flags |= 32 /* OptionalChain */;
|
|
24128
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24134
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24129
24135
|
node.questionDotToken = questionDotToken;
|
|
24130
24136
|
node.name = asName(name);
|
|
24131
24137
|
node.transformFlags |=
|
|
@@ -24151,7 +24157,7 @@ var ts;
|
|
|
24151
24157
|
// @api
|
|
24152
24158
|
function createElementAccessExpression(expression, index) {
|
|
24153
24159
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24154
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24160
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24155
24161
|
node.argumentExpression = asExpression(index);
|
|
24156
24162
|
node.transformFlags |=
|
|
24157
24163
|
propagateChildFlags(node.expression) |
|
|
@@ -24179,7 +24185,7 @@ var ts;
|
|
|
24179
24185
|
function createElementAccessChain(expression, questionDotToken, index) {
|
|
24180
24186
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24181
24187
|
node.flags |= 32 /* OptionalChain */;
|
|
24182
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24188
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24183
24189
|
node.questionDotToken = questionDotToken;
|
|
24184
24190
|
node.argumentExpression = asExpression(index);
|
|
24185
24191
|
node.transformFlags |=
|
|
@@ -24203,7 +24209,7 @@ var ts;
|
|
|
24203
24209
|
// @api
|
|
24204
24210
|
function createCallExpression(expression, typeArguments, argumentsArray) {
|
|
24205
24211
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24206
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24212
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24207
24213
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24208
24214
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
24209
24215
|
node.transformFlags |=
|
|
@@ -24236,7 +24242,7 @@ var ts;
|
|
|
24236
24242
|
function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
|
|
24237
24243
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24238
24244
|
node.flags |= 32 /* OptionalChain */;
|
|
24239
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24245
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24240
24246
|
node.questionDotToken = questionDotToken;
|
|
24241
24247
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24242
24248
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
@@ -24291,7 +24297,7 @@ var ts;
|
|
|
24291
24297
|
// @api
|
|
24292
24298
|
function createTaggedTemplateExpression(tag, typeArguments, template) {
|
|
24293
24299
|
var node = createBaseExpression(210 /* TaggedTemplateExpression */);
|
|
24294
|
-
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
|
|
24300
|
+
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
|
|
24295
24301
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24296
24302
|
node.template = template;
|
|
24297
24303
|
node.transformFlags |=
|
|
@@ -24729,7 +24735,7 @@ var ts;
|
|
|
24729
24735
|
// @api
|
|
24730
24736
|
function createExpressionWithTypeArguments(expression, typeArguments) {
|
|
24731
24737
|
var node = createBaseNode(228 /* ExpressionWithTypeArguments */);
|
|
24732
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24738
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24733
24739
|
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
24734
24740
|
node.transformFlags |=
|
|
24735
24741
|
propagateChildFlags(node.expression) |
|
|
@@ -24765,7 +24771,7 @@ var ts;
|
|
|
24765
24771
|
// @api
|
|
24766
24772
|
function createNonNullExpression(expression) {
|
|
24767
24773
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24768
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24774
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24769
24775
|
node.transformFlags |=
|
|
24770
24776
|
propagateChildFlags(node.expression) |
|
|
24771
24777
|
1 /* ContainsTypeScript */;
|
|
@@ -24784,7 +24790,7 @@ var ts;
|
|
|
24784
24790
|
function createNonNullChain(expression) {
|
|
24785
24791
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24786
24792
|
node.flags |= 32 /* OptionalChain */;
|
|
24787
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24793
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24788
24794
|
node.transformFlags |=
|
|
24789
24795
|
propagateChildFlags(node.expression) |
|
|
24790
24796
|
1 /* ContainsTypeScript */;
|
|
@@ -26988,7 +26994,7 @@ var ts;
|
|
|
26988
26994
|
}
|
|
26989
26995
|
else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
|
|
26990
26996
|
thisArg = createVoidZero();
|
|
26991
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
|
|
26997
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
|
|
26992
26998
|
}
|
|
26993
26999
|
else if (ts.isPropertyAccessExpression(callee)) {
|
|
26994
27000
|
if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
|
|
@@ -27017,7 +27023,7 @@ var ts;
|
|
|
27017
27023
|
else {
|
|
27018
27024
|
// for `a()` target is `a` and thisArg is `void 0`
|
|
27019
27025
|
thisArg = createVoidZero();
|
|
27020
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
27026
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
27021
27027
|
}
|
|
27022
27028
|
return { target: target, thisArg: thisArg };
|
|
27023
27029
|
}
|
|
@@ -51692,7 +51698,40 @@ var ts;
|
|
|
51692
51698
|
// An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of
|
|
51693
51699
|
// normal mode restrictions
|
|
51694
51700
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) {
|
|
51695
|
-
|
|
51701
|
+
if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) {
|
|
51702
|
+
// ImportEquals in a ESM file resolving to another ESM file
|
|
51703
|
+
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);
|
|
51704
|
+
}
|
|
51705
|
+
else {
|
|
51706
|
+
// CJS file resolving to an ESM file
|
|
51707
|
+
var diagnosticDetails = void 0;
|
|
51708
|
+
var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
|
|
51709
|
+
if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
|
|
51710
|
+
var scope = currentSourceFile.packageJsonScope;
|
|
51711
|
+
var targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : undefined;
|
|
51712
|
+
if (scope && !scope.packageJsonContent.type) {
|
|
51713
|
+
if (targetExt) {
|
|
51714
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51715
|
+
/*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"));
|
|
51716
|
+
}
|
|
51717
|
+
else {
|
|
51718
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51719
|
+
/*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"));
|
|
51720
|
+
}
|
|
51721
|
+
}
|
|
51722
|
+
else {
|
|
51723
|
+
if (targetExt) {
|
|
51724
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51725
|
+
/*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);
|
|
51726
|
+
}
|
|
51727
|
+
else {
|
|
51728
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51729
|
+
/*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module);
|
|
51730
|
+
}
|
|
51731
|
+
}
|
|
51732
|
+
}
|
|
51733
|
+
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)));
|
|
51734
|
+
}
|
|
51696
51735
|
}
|
|
51697
51736
|
}
|
|
51698
51737
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
@@ -66198,6 +66237,26 @@ var ts;
|
|
|
66198
66237
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66199
66238
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66200
66239
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66240
|
+
if (!result && (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */)) {
|
|
66241
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66242
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
66243
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66244
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66245
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66246
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66247
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66248
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66249
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
66250
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66251
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66252
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66253
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66254
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66255
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66256
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66257
|
+
result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
66258
|
+
}
|
|
66259
|
+
}
|
|
66201
66260
|
if (result) {
|
|
66202
66261
|
resetErrorInfo(saveErrorInfo);
|
|
66203
66262
|
}
|
|
@@ -66255,28 +66314,6 @@ var ts;
|
|
|
66255
66314
|
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
66256
66315
|
return result;
|
|
66257
66316
|
}
|
|
66258
|
-
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
66259
|
-
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66260
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
66261
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66262
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66263
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66264
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66265
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66266
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66267
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
66268
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66269
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66270
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66271
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66272
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66273
|
-
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66274
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66275
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66276
|
-
return result;
|
|
66277
|
-
}
|
|
66278
|
-
}
|
|
66279
|
-
}
|
|
66280
66317
|
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
66281
66318
|
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
66282
66319
|
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
@@ -84011,17 +84048,28 @@ var ts;
|
|
|
84011
84048
|
* the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
|
|
84012
84049
|
*/
|
|
84013
84050
|
function getIterationTypesOfIterable(type, use, errorNode) {
|
|
84051
|
+
var _a, _b;
|
|
84014
84052
|
if (isTypeAny(type)) {
|
|
84015
84053
|
return anyIterationTypes;
|
|
84016
84054
|
}
|
|
84017
84055
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
84018
|
-
var
|
|
84056
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84057
|
+
var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
84019
84058
|
if (iterationTypes_1 === noIterationTypes) {
|
|
84020
84059
|
if (errorNode) {
|
|
84021
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84060
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84061
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84062
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84063
|
+
}
|
|
84022
84064
|
}
|
|
84023
84065
|
return undefined;
|
|
84024
84066
|
}
|
|
84067
|
+
else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
84068
|
+
for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) {
|
|
84069
|
+
var diag = _c[_i];
|
|
84070
|
+
diagnostics.add(diag);
|
|
84071
|
+
}
|
|
84072
|
+
}
|
|
84025
84073
|
return iterationTypes_1;
|
|
84026
84074
|
}
|
|
84027
84075
|
var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
|
|
@@ -84029,19 +84077,27 @@ var ts;
|
|
|
84029
84077
|
if (cachedTypes)
|
|
84030
84078
|
return cachedTypes === noIterationTypes ? undefined : cachedTypes;
|
|
84031
84079
|
var allIterationTypes;
|
|
84032
|
-
for (var
|
|
84033
|
-
var constituent =
|
|
84034
|
-
var
|
|
84080
|
+
for (var _d = 0, _e = type.types; _d < _e.length; _d++) {
|
|
84081
|
+
var constituent = _e[_d];
|
|
84082
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84083
|
+
var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer);
|
|
84035
84084
|
if (iterationTypes_2 === noIterationTypes) {
|
|
84036
84085
|
if (errorNode) {
|
|
84037
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84086
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84087
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84088
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84089
|
+
}
|
|
84038
84090
|
}
|
|
84039
84091
|
setCachedIterationTypes(type, cacheKey, noIterationTypes);
|
|
84040
84092
|
return undefined;
|
|
84041
84093
|
}
|
|
84042
|
-
else {
|
|
84043
|
-
|
|
84094
|
+
else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
84095
|
+
for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) {
|
|
84096
|
+
var diag = _g[_f];
|
|
84097
|
+
diagnostics.add(diag);
|
|
84098
|
+
}
|
|
84044
84099
|
}
|
|
84100
|
+
allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
|
|
84045
84101
|
}
|
|
84046
84102
|
var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
|
|
84047
84103
|
setCachedIterationTypes(type, cacheKey, iterationTypes);
|
|
@@ -84069,47 +84125,62 @@ var ts;
|
|
|
84069
84125
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84070
84126
|
* `getIterationTypesOfIterable` instead.
|
|
84071
84127
|
*/
|
|
84072
|
-
function getIterationTypesOfIterableWorker(type, use, errorNode) {
|
|
84128
|
+
function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) {
|
|
84073
84129
|
if (isTypeAny(type)) {
|
|
84074
84130
|
return anyIterationTypes;
|
|
84075
84131
|
}
|
|
84132
|
+
// If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached.
|
|
84133
|
+
// In addition, we should not cache any new results for this call.
|
|
84134
|
+
var noCache = false;
|
|
84076
84135
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84077
84136
|
var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
|
|
84078
84137
|
getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
|
|
84079
84138
|
if (iterationTypes) {
|
|
84080
|
-
|
|
84081
|
-
|
|
84082
|
-
|
|
84139
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84140
|
+
// ignore the cached value
|
|
84141
|
+
noCache = true;
|
|
84142
|
+
}
|
|
84143
|
+
else {
|
|
84144
|
+
return use & 8 /* ForOfFlag */ ?
|
|
84145
|
+
getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
|
|
84146
|
+
iterationTypes;
|
|
84147
|
+
}
|
|
84083
84148
|
}
|
|
84084
84149
|
}
|
|
84085
84150
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84086
84151
|
var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
|
|
84087
84152
|
getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
|
|
84088
84153
|
if (iterationTypes) {
|
|
84089
|
-
if (
|
|
84090
|
-
//
|
|
84091
|
-
|
|
84092
|
-
return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
|
|
84093
|
-
}
|
|
84154
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84155
|
+
// ignore the cached value
|
|
84156
|
+
noCache = true;
|
|
84094
84157
|
}
|
|
84095
84158
|
else {
|
|
84096
|
-
|
|
84159
|
+
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84160
|
+
// for a sync iterable in an async context, only use the cached types if they are valid.
|
|
84161
|
+
if (iterationTypes !== noIterationTypes) {
|
|
84162
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84163
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84164
|
+
}
|
|
84165
|
+
}
|
|
84166
|
+
else {
|
|
84167
|
+
return iterationTypes;
|
|
84168
|
+
}
|
|
84097
84169
|
}
|
|
84098
84170
|
}
|
|
84099
84171
|
}
|
|
84100
84172
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84101
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
|
|
84173
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84102
84174
|
if (iterationTypes !== noIterationTypes) {
|
|
84103
84175
|
return iterationTypes;
|
|
84104
84176
|
}
|
|
84105
84177
|
}
|
|
84106
84178
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84107
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
|
|
84179
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84108
84180
|
if (iterationTypes !== noIterationTypes) {
|
|
84109
84181
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84110
|
-
|
|
84111
|
-
|
|
84112
|
-
: noIterationTypes);
|
|
84182
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84183
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84113
84184
|
}
|
|
84114
84185
|
else {
|
|
84115
84186
|
return iterationTypes;
|
|
@@ -84130,7 +84201,7 @@ var ts;
|
|
|
84130
84201
|
}
|
|
84131
84202
|
function getIterationTypesOfGlobalIterableType(globalType, resolver) {
|
|
84132
84203
|
var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
|
|
84133
|
-
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84204
|
+
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84134
84205
|
return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
|
|
84135
84206
|
}
|
|
84136
84207
|
/**
|
|
@@ -84184,40 +84255,56 @@ var ts;
|
|
|
84184
84255
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84185
84256
|
* `getIterationTypesOfIterable` instead.
|
|
84186
84257
|
*/
|
|
84187
|
-
function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
|
|
84258
|
+
function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84188
84259
|
var _a;
|
|
84189
84260
|
var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
|
|
84190
84261
|
var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
|
|
84191
84262
|
if (isTypeAny(methodType)) {
|
|
84192
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84263
|
+
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84193
84264
|
}
|
|
84194
84265
|
var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
|
|
84195
84266
|
if (!ts.some(signatures)) {
|
|
84196
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84267
|
+
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84197
84268
|
}
|
|
84198
84269
|
var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
|
|
84199
|
-
var iterationTypes = (_a =
|
|
84200
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84270
|
+
var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes;
|
|
84271
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84201
84272
|
}
|
|
84202
84273
|
function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
|
|
84203
84274
|
var message = allowAsyncIterables
|
|
84204
84275
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
84205
84276
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
84206
|
-
errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84277
|
+
return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84278
|
+
}
|
|
84279
|
+
/**
|
|
84280
|
+
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84281
|
+
*
|
|
84282
|
+
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84283
|
+
* record is returned. Otherwise, `undefined` is returned.
|
|
84284
|
+
*/
|
|
84285
|
+
function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) {
|
|
84286
|
+
return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false);
|
|
84207
84287
|
}
|
|
84208
84288
|
/**
|
|
84209
84289
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84210
84290
|
*
|
|
84211
84291
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84212
84292
|
* record is returned. Otherwise, `undefined` is returned.
|
|
84293
|
+
*
|
|
84294
|
+
* NOTE: You probably don't want to call this directly and should be calling
|
|
84295
|
+
* `getIterationTypesOfIterator` instead.
|
|
84213
84296
|
*/
|
|
84214
|
-
function
|
|
84297
|
+
function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84215
84298
|
if (isTypeAny(type)) {
|
|
84216
84299
|
return anyIterationTypes;
|
|
84217
84300
|
}
|
|
84218
84301
|
var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
|
|
84219
|
-
getIterationTypesOfIteratorFast(type, resolver)
|
|
84220
|
-
|
|
84302
|
+
getIterationTypesOfIteratorFast(type, resolver);
|
|
84303
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84304
|
+
iterationTypes = undefined;
|
|
84305
|
+
noCache = true;
|
|
84306
|
+
}
|
|
84307
|
+
iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache));
|
|
84221
84308
|
return iterationTypes === noIterationTypes ? undefined : iterationTypes;
|
|
84222
84309
|
}
|
|
84223
84310
|
/**
|
|
@@ -84255,7 +84342,7 @@ var ts;
|
|
|
84255
84342
|
// iteration types of their `next`, `return`, and `throw` methods. While we define these as `any`
|
|
84256
84343
|
// and `undefined` in our libs by default, a custom lib *could* use different definitions.
|
|
84257
84344
|
var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
|
|
84258
|
-
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84345
|
+
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84259
84346
|
var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
|
|
84260
84347
|
return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
|
|
84261
84348
|
}
|
|
@@ -84325,8 +84412,8 @@ var ts;
|
|
|
84325
84412
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84326
84413
|
* record is returned. Otherwise, we return `undefined`.
|
|
84327
84414
|
*/
|
|
84328
|
-
function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
|
|
84329
|
-
var _a, _b, _c, _d;
|
|
84415
|
+
function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) {
|
|
84416
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84330
84417
|
var method = getPropertyOfType(type, methodName);
|
|
84331
84418
|
// Ignore 'return' or 'throw' if they are missing.
|
|
84332
84419
|
if (!method && methodName !== "next") {
|
|
@@ -84346,9 +84433,15 @@ var ts;
|
|
|
84346
84433
|
var diagnostic = methodName === "next"
|
|
84347
84434
|
? resolver.mustHaveANextMethodDiagnostic
|
|
84348
84435
|
: resolver.mustBeAMethodDiagnostic;
|
|
84349
|
-
|
|
84436
|
+
if (errorOutputContainer) {
|
|
84437
|
+
(_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []);
|
|
84438
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName));
|
|
84439
|
+
}
|
|
84440
|
+
else {
|
|
84441
|
+
error(errorNode, diagnostic, methodName);
|
|
84442
|
+
}
|
|
84350
84443
|
}
|
|
84351
|
-
return methodName === "next" ?
|
|
84444
|
+
return methodName === "next" ? noIterationTypes : undefined;
|
|
84352
84445
|
}
|
|
84353
84446
|
// If the method signature comes exclusively from the global iterator or generator type,
|
|
84354
84447
|
// create iteration types from its type arguments like `getIterationTypesOfIteratorFast`
|
|
@@ -84360,8 +84453,8 @@ var ts;
|
|
|
84360
84453
|
if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
|
|
84361
84454
|
var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false);
|
|
84362
84455
|
var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false);
|
|
84363
|
-
var isGeneratorMethod = ((
|
|
84364
|
-
var isIteratorMethod = !isGeneratorMethod && ((
|
|
84456
|
+
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;
|
|
84457
|
+
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;
|
|
84365
84458
|
if (isGeneratorMethod || isIteratorMethod) {
|
|
84366
84459
|
var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
|
|
84367
84460
|
var mapper = methodType.mapper;
|
|
@@ -84401,7 +84494,13 @@ var ts;
|
|
|
84401
84494
|
var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
|
|
84402
84495
|
if (iterationTypes === noIterationTypes) {
|
|
84403
84496
|
if (errorNode) {
|
|
84404
|
-
|
|
84497
|
+
if (errorOutputContainer) {
|
|
84498
|
+
(_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []);
|
|
84499
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
|
|
84500
|
+
}
|
|
84501
|
+
else {
|
|
84502
|
+
error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
|
|
84503
|
+
}
|
|
84405
84504
|
}
|
|
84406
84505
|
yieldType = anyType;
|
|
84407
84506
|
returnTypes = ts.append(returnTypes, anyType);
|
|
@@ -84422,13 +84521,13 @@ var ts;
|
|
|
84422
84521
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84423
84522
|
* `getIterationTypesOfIterator` instead.
|
|
84424
84523
|
*/
|
|
84425
|
-
function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
|
|
84524
|
+
function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84426
84525
|
var iterationTypes = combineIterationTypes([
|
|
84427
|
-
getIterationTypesOfMethod(type, resolver, "next", errorNode),
|
|
84428
|
-
getIterationTypesOfMethod(type, resolver, "return", errorNode),
|
|
84429
|
-
getIterationTypesOfMethod(type, resolver, "throw", errorNode),
|
|
84526
|
+
getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer),
|
|
84527
|
+
getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer),
|
|
84528
|
+
getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer),
|
|
84430
84529
|
]);
|
|
84431
|
-
return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84530
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84432
84531
|
}
|
|
84433
84532
|
/**
|
|
84434
84533
|
* Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like,
|
|
@@ -84449,7 +84548,7 @@ var ts;
|
|
|
84449
84548
|
var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
|
|
84450
84549
|
var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
|
|
84451
84550
|
return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
|
|
84452
|
-
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
|
|
84551
|
+
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined);
|
|
84453
84552
|
}
|
|
84454
84553
|
function checkBreakOrContinueStatement(node) {
|
|
84455
84554
|
// Grammar checking
|
|
@@ -122746,8 +122845,6 @@ var ts;
|
|
|
122746
122845
|
if (watcher.files === 0 && watcher.resolutions === 0) {
|
|
122747
122846
|
fileWatchesOfAffectingLocations.delete(path);
|
|
122748
122847
|
watcher.watcher.close();
|
|
122749
|
-
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
122750
|
-
watcher.watcher = ts.noopFileWatcher;
|
|
122751
122848
|
}
|
|
122752
122849
|
});
|
|
122753
122850
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
@@ -123093,20 +123190,27 @@ var ts;
|
|
|
123093
123190
|
}
|
|
123094
123191
|
var paths = new ts.Set();
|
|
123095
123192
|
paths.add(locationToWatch);
|
|
123193
|
+
var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
|
|
123194
|
+
resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
|
|
123195
|
+
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
|
123196
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123197
|
+
paths.forEach(function (path) {
|
|
123198
|
+
if (watcher.resolutions)
|
|
123199
|
+
(affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
|
|
123200
|
+
if (watcher.files)
|
|
123201
|
+
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123202
|
+
packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
|
|
123203
|
+
});
|
|
123204
|
+
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123205
|
+
}) : ts.noopFileWatcher;
|
|
123096
123206
|
var watcher = {
|
|
123097
|
-
watcher:
|
|
123098
|
-
|
|
123099
|
-
|
|
123100
|
-
|
|
123101
|
-
|
|
123102
|
-
|
|
123103
|
-
|
|
123104
|
-
if (watcher.files)
|
|
123105
|
-
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123106
|
-
(_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
|
|
123107
|
-
});
|
|
123108
|
-
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123109
|
-
}) : ts.noopFileWatcher,
|
|
123207
|
+
watcher: actualWatcher !== ts.noopFileWatcher ? {
|
|
123208
|
+
close: function () {
|
|
123209
|
+
actualWatcher.close();
|
|
123210
|
+
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
123211
|
+
actualWatcher = ts.noopFileWatcher;
|
|
123212
|
+
}
|
|
123213
|
+
} : actualWatcher,
|
|
123110
123214
|
resolutions: forResolution ? 1 : 0,
|
|
123111
123215
|
files: forResolution ? 0 : 1,
|
|
123112
123216
|
paths: paths,
|
|
@@ -123520,7 +123624,7 @@ var ts;
|
|
|
123520
123624
|
var info = getInfo(importingSourceFileName, host);
|
|
123521
123625
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
123522
123626
|
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
123523
|
-
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
123627
|
+
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123524
123628
|
}
|
|
123525
123629
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
123526
123630
|
if (options === void 0) { options = {}; }
|
|
@@ -123603,7 +123707,7 @@ var ts;
|
|
|
123603
123707
|
return nodeModulesSpecifiers;
|
|
123604
123708
|
}
|
|
123605
123709
|
if (!specifier && !modulePath.isRedirect) {
|
|
123606
|
-
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
|
|
123710
|
+
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123607
123711
|
if (ts.pathIsBareSpecifier(local)) {
|
|
123608
123712
|
pathsSpecifiers = ts.append(pathsSpecifiers, local);
|
|
123609
123713
|
}
|
|
@@ -123631,7 +123735,7 @@ var ts;
|
|
|
123631
123735
|
var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
|
|
123632
123736
|
return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
|
|
123633
123737
|
}
|
|
123634
|
-
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
|
|
123738
|
+
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) {
|
|
123635
123739
|
var ending = _a.ending, relativePreference = _a.relativePreference;
|
|
123636
123740
|
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
|
|
123637
123741
|
var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
|
|
@@ -123645,9 +123749,8 @@ var ts;
|
|
|
123645
123749
|
if (!relativeToBaseUrl) {
|
|
123646
123750
|
return relativePath;
|
|
123647
123751
|
}
|
|
123648
|
-
var
|
|
123649
|
-
var
|
|
123650
|
-
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
|
|
123752
|
+
var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
|
|
123753
|
+
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
|
|
123651
123754
|
if (!nonRelative) {
|
|
123652
123755
|
return relativePath;
|
|
123653
123756
|
}
|
|
@@ -123882,28 +123985,102 @@ var ts;
|
|
|
123882
123985
|
return ambientModuleDeclare.name.text;
|
|
123883
123986
|
}
|
|
123884
123987
|
}
|
|
123885
|
-
function
|
|
123988
|
+
function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
|
|
123989
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) {
|
|
123990
|
+
return [2 /* JsExtension */];
|
|
123991
|
+
}
|
|
123992
|
+
switch (preferredEnding) {
|
|
123993
|
+
case 2 /* JsExtension */: return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
|
|
123994
|
+
case 1 /* Index */: return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
|
|
123995
|
+
case 0 /* Minimal */: return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
|
|
123996
|
+
default: ts.Debug.assertNever(preferredEnding);
|
|
123997
|
+
}
|
|
123998
|
+
}
|
|
123999
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
123886
124000
|
for (var key in paths) {
|
|
123887
|
-
|
|
123888
|
-
var
|
|
123889
|
-
var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
|
|
124001
|
+
var _loop_36 = function (patternText_1) {
|
|
124002
|
+
var pattern = ts.normalizePath(patternText_1);
|
|
123890
124003
|
var indexOfStar = pattern.indexOf("*");
|
|
124004
|
+
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
124005
|
+
// meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
|
|
124006
|
+
// causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
|
|
124007
|
+
// and matches the '*'. For example:
|
|
124008
|
+
//
|
|
124009
|
+
// Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
|
|
124010
|
+
// ---------------------->------------------------------->--------------------->---------------------------------------------------------------
|
|
124011
|
+
// import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
|
|
124012
|
+
// import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
|
|
124013
|
+
//
|
|
124014
|
+
// (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
|
|
124015
|
+
//
|
|
124016
|
+
// The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
|
|
124017
|
+
// the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
|
|
124018
|
+
// (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
|
|
124019
|
+
// extension for a module specifier.)
|
|
124020
|
+
//
|
|
124021
|
+
// Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
|
|
124022
|
+
// .ts extension) or the possible relative module specifiers representing that file:
|
|
124023
|
+
//
|
|
124024
|
+
// Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
|
|
124025
|
+
// --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
|
|
124026
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
|
|
124027
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
|
|
124028
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
|
|
124029
|
+
// 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
|
|
124030
|
+
// dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
|
|
124031
|
+
//
|
|
124032
|
+
// The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
|
|
124033
|
+
// relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
|
|
124034
|
+
// into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
|
|
124035
|
+
// exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
|
|
124036
|
+
// specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
|
|
124037
|
+
// resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
|
|
124038
|
+
// in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
|
|
124039
|
+
// sorted among the others for a particular value of `importModuleSpecifierEnding`.
|
|
124040
|
+
var candidates = allowedEndings.map(function (ending) { return ({
|
|
124041
|
+
ending: ending,
|
|
124042
|
+
value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
|
|
124043
|
+
}); });
|
|
124044
|
+
if (ts.tryGetExtensionFromPath(pattern)) {
|
|
124045
|
+
candidates.push({ ending: undefined, value: relativeToBaseUrl });
|
|
124046
|
+
}
|
|
123891
124047
|
if (indexOfStar !== -1) {
|
|
123892
|
-
var prefix = pattern.
|
|
123893
|
-
var suffix = pattern.
|
|
123894
|
-
|
|
123895
|
-
|
|
123896
|
-
|
|
123897
|
-
|
|
123898
|
-
|
|
123899
|
-
|
|
124048
|
+
var prefix = pattern.substring(0, indexOfStar);
|
|
124049
|
+
var suffix = pattern.substring(indexOfStar + 1);
|
|
124050
|
+
for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) {
|
|
124051
|
+
var _c = candidates_3[_b], ending = _c.ending, value = _c.value;
|
|
124052
|
+
if (value.length >= prefix.length + suffix.length &&
|
|
124053
|
+
ts.startsWith(value, prefix) &&
|
|
124054
|
+
ts.endsWith(value, suffix) &&
|
|
124055
|
+
validateEnding({ ending: ending, value: value })) {
|
|
124056
|
+
var matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
|
124057
|
+
return { value: key.replace("*", matchedStar) };
|
|
124058
|
+
}
|
|
123900
124059
|
}
|
|
123901
124060
|
}
|
|
123902
|
-
else if (
|
|
123903
|
-
return
|
|
124061
|
+
else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Minimal */ && pattern === c.value; }) ||
|
|
124062
|
+
ts.some(candidates, function (c) { return c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c); })) {
|
|
124063
|
+
return { value: key };
|
|
123904
124064
|
}
|
|
124065
|
+
};
|
|
124066
|
+
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
124067
|
+
var patternText_1 = _a[_i];
|
|
124068
|
+
var state_12 = _loop_36(patternText_1);
|
|
124069
|
+
if (typeof state_12 === "object")
|
|
124070
|
+
return state_12.value;
|
|
123905
124071
|
}
|
|
123906
124072
|
}
|
|
124073
|
+
function validateEnding(_a) {
|
|
124074
|
+
var ending = _a.ending, value = _a.value;
|
|
124075
|
+
// Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
|
|
124076
|
+
// is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
|
|
124077
|
+
// here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
|
|
124078
|
+
// 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
|
|
124079
|
+
// `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
|
|
124080
|
+
// that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
|
|
124081
|
+
// everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
|
|
124082
|
+
return ending !== 0 /* Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
|
|
124083
|
+
}
|
|
123907
124084
|
}
|
|
123908
124085
|
var MatchingMode;
|
|
123909
124086
|
(function (MatchingMode) {
|
|
@@ -123999,10 +124176,10 @@ var ts;
|
|
|
123999
124176
|
return undefined;
|
|
124000
124177
|
}
|
|
124001
124178
|
// Simplify the full file path to something that can be resolved by Node.
|
|
124179
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
124002
124180
|
var moduleSpecifier = path;
|
|
124003
124181
|
var isPackageRootPath = false;
|
|
124004
124182
|
if (!packageNameOnly) {
|
|
124005
|
-
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
124006
124183
|
var packageRootIndex = parts.packageRootIndex;
|
|
124007
124184
|
var moduleFileName = void 0;
|
|
124008
124185
|
while (true) {
|
|
@@ -124051,15 +124228,13 @@ var ts;
|
|
|
124051
124228
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
124052
124229
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
124053
124230
|
var moduleFileToTry = path;
|
|
124231
|
+
var maybeBlockedByTypesVersions = false;
|
|
124054
124232
|
var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
124055
124233
|
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
|
124056
124234
|
var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
|
|
124235
|
+
var importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
124057
124236
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
124058
|
-
|
|
124059
|
-
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
124060
|
-
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
|
124061
|
-
// with, so for now we just stick with the mode of the file.
|
|
124062
|
-
var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124237
|
+
var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124063
124238
|
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
|
124064
124239
|
? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
|
124065
124240
|
: undefined;
|
|
@@ -124078,16 +124253,26 @@ var ts;
|
|
|
124078
124253
|
: undefined;
|
|
124079
124254
|
if (versionPaths) {
|
|
124080
124255
|
var subModuleName = path.slice(packageRootPath.length + 1);
|
|
124081
|
-
var fromPaths = tryGetModuleNameFromPaths(
|
|
124082
|
-
if (fromPaths
|
|
124256
|
+
var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options);
|
|
124257
|
+
if (fromPaths === undefined) {
|
|
124258
|
+
maybeBlockedByTypesVersions = true;
|
|
124259
|
+
}
|
|
124260
|
+
else {
|
|
124083
124261
|
moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
|
|
124084
124262
|
}
|
|
124085
124263
|
}
|
|
124086
124264
|
// If the file is the main module, it can be imported by the package name
|
|
124087
124265
|
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
124088
|
-
if (ts.isString(mainFileRelative)) {
|
|
124266
|
+
if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) {
|
|
124267
|
+
// The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
|
|
124268
|
+
// explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
|
|
124269
|
+
// (The only way this can happen is if some file in a package that's not resolvable from outside the
|
|
124270
|
+
// package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
|
|
124271
|
+
// happens very easily in fourslash tests though, since every test file listed gets included. See
|
|
124272
|
+
// importNameCodeFix_typesVersions.ts for an example.)
|
|
124089
124273
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
124090
124274
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
124275
|
+
// ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
|
|
124091
124276
|
return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
|
|
124092
124277
|
}
|
|
124093
124278
|
}
|
|
@@ -156488,7 +156673,7 @@ var ts;
|
|
|
156488
156673
|
return undefined;
|
|
156489
156674
|
return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
|
|
156490
156675
|
}
|
|
156491
|
-
if (ts.isIdentifier(token) && ts.isCallExpression(parent)) {
|
|
156676
|
+
if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) {
|
|
156492
156677
|
return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile };
|
|
156493
156678
|
}
|
|
156494
156679
|
if (!ts.isPropertyAccessExpression(parent))
|
|
@@ -161733,6 +161918,9 @@ var ts;
|
|
|
161733
161918
|
if (!containingDecl) {
|
|
161734
161919
|
return;
|
|
161735
161920
|
}
|
|
161921
|
+
if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) {
|
|
161922
|
+
return;
|
|
161923
|
+
}
|
|
161736
161924
|
var checker = program.getTypeChecker();
|
|
161737
161925
|
var signatureSymbol = containingDecl.symbol;
|
|
161738
161926
|
if (!signatureSymbol) {
|