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
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220805";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8761,7 +8761,7 @@ var ts;
|
|
|
8761
8761
|
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\""),
|
|
8762
8762
|
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"),
|
|
8763
8763
|
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."),
|
|
8764
|
-
|
|
8764
|
+
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."),
|
|
8765
8765
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8766
8766
|
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."),
|
|
8767
8767
|
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."),
|
|
@@ -8769,6 +8769,11 @@ var ts;
|
|
|
8769
8769
|
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."),
|
|
8770
8770
|
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."),
|
|
8771
8771
|
Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
|
|
8772
|
+
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."),
|
|
8773
|
+
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\" }`."),
|
|
8774
|
+
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}'."),
|
|
8775
|
+
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}'."),
|
|
8776
|
+
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\" }`."),
|
|
8772
8777
|
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."),
|
|
8773
8778
|
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."),
|
|
8774
8779
|
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),
|
|
@@ -22063,7 +22068,7 @@ var ts;
|
|
|
22063
22068
|
* Wraps an expression in parentheses if it is needed in order to use the expression for
|
|
22064
22069
|
* property or element access.
|
|
22065
22070
|
*/
|
|
22066
|
-
function parenthesizeLeftSideOfAccess(expression) {
|
|
22071
|
+
function parenthesizeLeftSideOfAccess(expression, optionalChain) {
|
|
22067
22072
|
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
|
22068
22073
|
// to parenthesize the expression before a dot. The known exception is:
|
|
22069
22074
|
//
|
|
@@ -22072,7 +22077,8 @@ var ts;
|
|
|
22072
22077
|
//
|
|
22073
22078
|
var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
|
|
22074
22079
|
if (ts.isLeftHandSideExpression(emittedExpression)
|
|
22075
|
-
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
22080
|
+
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
22081
|
+
&& (optionalChain || !ts.isOptionalChain(emittedExpression))) {
|
|
22076
22082
|
// TODO(rbuckton): Verify whether this assertion holds.
|
|
22077
22083
|
return expression;
|
|
22078
22084
|
}
|
|
@@ -23479,7 +23485,7 @@ var ts;
|
|
|
23479
23485
|
// @api
|
|
23480
23486
|
function createDecorator(expression) {
|
|
23481
23487
|
var node = createBaseNode(165 /* Decorator */);
|
|
23482
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
23488
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
23483
23489
|
node.transformFlags |=
|
|
23484
23490
|
propagateChildFlags(node.expression) |
|
|
23485
23491
|
1 /* ContainsTypeScript */ |
|
|
@@ -24280,7 +24286,7 @@ var ts;
|
|
|
24280
24286
|
// @api
|
|
24281
24287
|
function createPropertyAccessExpression(expression, name) {
|
|
24282
24288
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24283
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24289
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24284
24290
|
node.name = asName(name);
|
|
24285
24291
|
node.transformFlags =
|
|
24286
24292
|
propagateChildFlags(node.expression) |
|
|
@@ -24310,7 +24316,7 @@ var ts;
|
|
|
24310
24316
|
function createPropertyAccessChain(expression, questionDotToken, name) {
|
|
24311
24317
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24312
24318
|
node.flags |= 32 /* OptionalChain */;
|
|
24313
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24319
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24314
24320
|
node.questionDotToken = questionDotToken;
|
|
24315
24321
|
node.name = asName(name);
|
|
24316
24322
|
node.transformFlags |=
|
|
@@ -24336,7 +24342,7 @@ var ts;
|
|
|
24336
24342
|
// @api
|
|
24337
24343
|
function createElementAccessExpression(expression, index) {
|
|
24338
24344
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24339
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24345
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24340
24346
|
node.argumentExpression = asExpression(index);
|
|
24341
24347
|
node.transformFlags |=
|
|
24342
24348
|
propagateChildFlags(node.expression) |
|
|
@@ -24364,7 +24370,7 @@ var ts;
|
|
|
24364
24370
|
function createElementAccessChain(expression, questionDotToken, index) {
|
|
24365
24371
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24366
24372
|
node.flags |= 32 /* OptionalChain */;
|
|
24367
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24373
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24368
24374
|
node.questionDotToken = questionDotToken;
|
|
24369
24375
|
node.argumentExpression = asExpression(index);
|
|
24370
24376
|
node.transformFlags |=
|
|
@@ -24388,7 +24394,7 @@ var ts;
|
|
|
24388
24394
|
// @api
|
|
24389
24395
|
function createCallExpression(expression, typeArguments, argumentsArray) {
|
|
24390
24396
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24391
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24397
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24392
24398
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24393
24399
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
24394
24400
|
node.transformFlags |=
|
|
@@ -24421,7 +24427,7 @@ var ts;
|
|
|
24421
24427
|
function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
|
|
24422
24428
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24423
24429
|
node.flags |= 32 /* OptionalChain */;
|
|
24424
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24430
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24425
24431
|
node.questionDotToken = questionDotToken;
|
|
24426
24432
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24427
24433
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
@@ -24476,7 +24482,7 @@ var ts;
|
|
|
24476
24482
|
// @api
|
|
24477
24483
|
function createTaggedTemplateExpression(tag, typeArguments, template) {
|
|
24478
24484
|
var node = createBaseExpression(210 /* TaggedTemplateExpression */);
|
|
24479
|
-
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
|
|
24485
|
+
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
|
|
24480
24486
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24481
24487
|
node.template = template;
|
|
24482
24488
|
node.transformFlags |=
|
|
@@ -24914,7 +24920,7 @@ var ts;
|
|
|
24914
24920
|
// @api
|
|
24915
24921
|
function createExpressionWithTypeArguments(expression, typeArguments) {
|
|
24916
24922
|
var node = createBaseNode(228 /* ExpressionWithTypeArguments */);
|
|
24917
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24923
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24918
24924
|
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
24919
24925
|
node.transformFlags |=
|
|
24920
24926
|
propagateChildFlags(node.expression) |
|
|
@@ -24950,7 +24956,7 @@ var ts;
|
|
|
24950
24956
|
// @api
|
|
24951
24957
|
function createNonNullExpression(expression) {
|
|
24952
24958
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24953
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24959
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24954
24960
|
node.transformFlags |=
|
|
24955
24961
|
propagateChildFlags(node.expression) |
|
|
24956
24962
|
1 /* ContainsTypeScript */;
|
|
@@ -24969,7 +24975,7 @@ var ts;
|
|
|
24969
24975
|
function createNonNullChain(expression) {
|
|
24970
24976
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24971
24977
|
node.flags |= 32 /* OptionalChain */;
|
|
24972
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24978
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24973
24979
|
node.transformFlags |=
|
|
24974
24980
|
propagateChildFlags(node.expression) |
|
|
24975
24981
|
1 /* ContainsTypeScript */;
|
|
@@ -27173,7 +27179,7 @@ var ts;
|
|
|
27173
27179
|
}
|
|
27174
27180
|
else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
|
|
27175
27181
|
thisArg = createVoidZero();
|
|
27176
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
|
|
27182
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
|
|
27177
27183
|
}
|
|
27178
27184
|
else if (ts.isPropertyAccessExpression(callee)) {
|
|
27179
27185
|
if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
|
|
@@ -27202,7 +27208,7 @@ var ts;
|
|
|
27202
27208
|
else {
|
|
27203
27209
|
// for `a()` target is `a` and thisArg is `void 0`
|
|
27204
27210
|
thisArg = createVoidZero();
|
|
27205
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
27211
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
27206
27212
|
}
|
|
27207
27213
|
return { target: target, thisArg: thisArg };
|
|
27208
27214
|
}
|
|
@@ -51877,7 +51883,40 @@ var ts;
|
|
|
51877
51883
|
// An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of
|
|
51878
51884
|
// normal mode restrictions
|
|
51879
51885
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) {
|
|
51880
|
-
|
|
51886
|
+
if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) {
|
|
51887
|
+
// ImportEquals in a ESM file resolving to another ESM file
|
|
51888
|
+
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);
|
|
51889
|
+
}
|
|
51890
|
+
else {
|
|
51891
|
+
// CJS file resolving to an ESM file
|
|
51892
|
+
var diagnosticDetails = void 0;
|
|
51893
|
+
var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
|
|
51894
|
+
if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
|
|
51895
|
+
var scope = currentSourceFile.packageJsonScope;
|
|
51896
|
+
var targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : undefined;
|
|
51897
|
+
if (scope && !scope.packageJsonContent.type) {
|
|
51898
|
+
if (targetExt) {
|
|
51899
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51900
|
+
/*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"));
|
|
51901
|
+
}
|
|
51902
|
+
else {
|
|
51903
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51904
|
+
/*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"));
|
|
51905
|
+
}
|
|
51906
|
+
}
|
|
51907
|
+
else {
|
|
51908
|
+
if (targetExt) {
|
|
51909
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51910
|
+
/*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);
|
|
51911
|
+
}
|
|
51912
|
+
else {
|
|
51913
|
+
diagnosticDetails = ts.chainDiagnosticMessages(
|
|
51914
|
+
/*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module);
|
|
51915
|
+
}
|
|
51916
|
+
}
|
|
51917
|
+
}
|
|
51918
|
+
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)));
|
|
51919
|
+
}
|
|
51881
51920
|
}
|
|
51882
51921
|
}
|
|
51883
51922
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
@@ -66383,6 +66422,26 @@ var ts;
|
|
|
66383
66422
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66384
66423
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66385
66424
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66425
|
+
if (!result && (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */)) {
|
|
66426
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66427
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
66428
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66429
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66430
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66431
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66432
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66433
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66434
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
66435
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66436
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66437
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66438
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66439
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66440
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66441
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66442
|
+
result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
66443
|
+
}
|
|
66444
|
+
}
|
|
66386
66445
|
if (result) {
|
|
66387
66446
|
resetErrorInfo(saveErrorInfo);
|
|
66388
66447
|
}
|
|
@@ -66440,28 +66499,6 @@ var ts;
|
|
|
66440
66499
|
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
66441
66500
|
return result;
|
|
66442
66501
|
}
|
|
66443
|
-
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
66444
|
-
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66445
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
66446
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
66447
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
66448
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
66449
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
66450
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
66451
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
66452
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
66453
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
66454
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66455
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66456
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66457
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
66458
|
-
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66459
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66460
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66461
|
-
return result;
|
|
66462
|
-
}
|
|
66463
|
-
}
|
|
66464
|
-
}
|
|
66465
66502
|
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
66466
66503
|
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
66467
66504
|
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
@@ -84196,17 +84233,28 @@ var ts;
|
|
|
84196
84233
|
* the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
|
|
84197
84234
|
*/
|
|
84198
84235
|
function getIterationTypesOfIterable(type, use, errorNode) {
|
|
84236
|
+
var _a, _b;
|
|
84199
84237
|
if (isTypeAny(type)) {
|
|
84200
84238
|
return anyIterationTypes;
|
|
84201
84239
|
}
|
|
84202
84240
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
84203
|
-
var
|
|
84241
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84242
|
+
var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
84204
84243
|
if (iterationTypes_1 === noIterationTypes) {
|
|
84205
84244
|
if (errorNode) {
|
|
84206
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84245
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84246
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84247
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84248
|
+
}
|
|
84207
84249
|
}
|
|
84208
84250
|
return undefined;
|
|
84209
84251
|
}
|
|
84252
|
+
else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
84253
|
+
for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) {
|
|
84254
|
+
var diag = _c[_i];
|
|
84255
|
+
diagnostics.add(diag);
|
|
84256
|
+
}
|
|
84257
|
+
}
|
|
84210
84258
|
return iterationTypes_1;
|
|
84211
84259
|
}
|
|
84212
84260
|
var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
|
|
@@ -84214,19 +84262,27 @@ var ts;
|
|
|
84214
84262
|
if (cachedTypes)
|
|
84215
84263
|
return cachedTypes === noIterationTypes ? undefined : cachedTypes;
|
|
84216
84264
|
var allIterationTypes;
|
|
84217
|
-
for (var
|
|
84218
|
-
var constituent =
|
|
84219
|
-
var
|
|
84265
|
+
for (var _d = 0, _e = type.types; _d < _e.length; _d++) {
|
|
84266
|
+
var constituent = _e[_d];
|
|
84267
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84268
|
+
var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer);
|
|
84220
84269
|
if (iterationTypes_2 === noIterationTypes) {
|
|
84221
84270
|
if (errorNode) {
|
|
84222
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84271
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84272
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84273
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84274
|
+
}
|
|
84223
84275
|
}
|
|
84224
84276
|
setCachedIterationTypes(type, cacheKey, noIterationTypes);
|
|
84225
84277
|
return undefined;
|
|
84226
84278
|
}
|
|
84227
|
-
else {
|
|
84228
|
-
|
|
84279
|
+
else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
84280
|
+
for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) {
|
|
84281
|
+
var diag = _g[_f];
|
|
84282
|
+
diagnostics.add(diag);
|
|
84283
|
+
}
|
|
84229
84284
|
}
|
|
84285
|
+
allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
|
|
84230
84286
|
}
|
|
84231
84287
|
var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
|
|
84232
84288
|
setCachedIterationTypes(type, cacheKey, iterationTypes);
|
|
@@ -84254,47 +84310,62 @@ var ts;
|
|
|
84254
84310
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84255
84311
|
* `getIterationTypesOfIterable` instead.
|
|
84256
84312
|
*/
|
|
84257
|
-
function getIterationTypesOfIterableWorker(type, use, errorNode) {
|
|
84313
|
+
function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) {
|
|
84258
84314
|
if (isTypeAny(type)) {
|
|
84259
84315
|
return anyIterationTypes;
|
|
84260
84316
|
}
|
|
84317
|
+
// If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached.
|
|
84318
|
+
// In addition, we should not cache any new results for this call.
|
|
84319
|
+
var noCache = false;
|
|
84261
84320
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84262
84321
|
var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
|
|
84263
84322
|
getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
|
|
84264
84323
|
if (iterationTypes) {
|
|
84265
|
-
|
|
84266
|
-
|
|
84267
|
-
|
|
84324
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84325
|
+
// ignore the cached value
|
|
84326
|
+
noCache = true;
|
|
84327
|
+
}
|
|
84328
|
+
else {
|
|
84329
|
+
return use & 8 /* ForOfFlag */ ?
|
|
84330
|
+
getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
|
|
84331
|
+
iterationTypes;
|
|
84332
|
+
}
|
|
84268
84333
|
}
|
|
84269
84334
|
}
|
|
84270
84335
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84271
84336
|
var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
|
|
84272
84337
|
getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
|
|
84273
84338
|
if (iterationTypes) {
|
|
84274
|
-
if (
|
|
84275
|
-
//
|
|
84276
|
-
|
|
84277
|
-
return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
|
|
84278
|
-
}
|
|
84339
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84340
|
+
// ignore the cached value
|
|
84341
|
+
noCache = true;
|
|
84279
84342
|
}
|
|
84280
84343
|
else {
|
|
84281
|
-
|
|
84344
|
+
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84345
|
+
// for a sync iterable in an async context, only use the cached types if they are valid.
|
|
84346
|
+
if (iterationTypes !== noIterationTypes) {
|
|
84347
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84348
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84349
|
+
}
|
|
84350
|
+
}
|
|
84351
|
+
else {
|
|
84352
|
+
return iterationTypes;
|
|
84353
|
+
}
|
|
84282
84354
|
}
|
|
84283
84355
|
}
|
|
84284
84356
|
}
|
|
84285
84357
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84286
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
|
|
84358
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84287
84359
|
if (iterationTypes !== noIterationTypes) {
|
|
84288
84360
|
return iterationTypes;
|
|
84289
84361
|
}
|
|
84290
84362
|
}
|
|
84291
84363
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84292
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
|
|
84364
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84293
84365
|
if (iterationTypes !== noIterationTypes) {
|
|
84294
84366
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84295
|
-
|
|
84296
|
-
|
|
84297
|
-
: noIterationTypes);
|
|
84367
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84368
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84298
84369
|
}
|
|
84299
84370
|
else {
|
|
84300
84371
|
return iterationTypes;
|
|
@@ -84315,7 +84386,7 @@ var ts;
|
|
|
84315
84386
|
}
|
|
84316
84387
|
function getIterationTypesOfGlobalIterableType(globalType, resolver) {
|
|
84317
84388
|
var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
|
|
84318
|
-
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84389
|
+
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84319
84390
|
return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
|
|
84320
84391
|
}
|
|
84321
84392
|
/**
|
|
@@ -84369,40 +84440,56 @@ var ts;
|
|
|
84369
84440
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84370
84441
|
* `getIterationTypesOfIterable` instead.
|
|
84371
84442
|
*/
|
|
84372
|
-
function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
|
|
84443
|
+
function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84373
84444
|
var _a;
|
|
84374
84445
|
var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
|
|
84375
84446
|
var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
|
|
84376
84447
|
if (isTypeAny(methodType)) {
|
|
84377
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84448
|
+
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84378
84449
|
}
|
|
84379
84450
|
var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
|
|
84380
84451
|
if (!ts.some(signatures)) {
|
|
84381
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84452
|
+
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84382
84453
|
}
|
|
84383
84454
|
var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
|
|
84384
|
-
var iterationTypes = (_a =
|
|
84385
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84455
|
+
var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes;
|
|
84456
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84386
84457
|
}
|
|
84387
84458
|
function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
|
|
84388
84459
|
var message = allowAsyncIterables
|
|
84389
84460
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
84390
84461
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
84391
|
-
errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84462
|
+
return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84463
|
+
}
|
|
84464
|
+
/**
|
|
84465
|
+
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84466
|
+
*
|
|
84467
|
+
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84468
|
+
* record is returned. Otherwise, `undefined` is returned.
|
|
84469
|
+
*/
|
|
84470
|
+
function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) {
|
|
84471
|
+
return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false);
|
|
84392
84472
|
}
|
|
84393
84473
|
/**
|
|
84394
84474
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84395
84475
|
*
|
|
84396
84476
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84397
84477
|
* record is returned. Otherwise, `undefined` is returned.
|
|
84478
|
+
*
|
|
84479
|
+
* NOTE: You probably don't want to call this directly and should be calling
|
|
84480
|
+
* `getIterationTypesOfIterator` instead.
|
|
84398
84481
|
*/
|
|
84399
|
-
function
|
|
84482
|
+
function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84400
84483
|
if (isTypeAny(type)) {
|
|
84401
84484
|
return anyIterationTypes;
|
|
84402
84485
|
}
|
|
84403
84486
|
var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
|
|
84404
|
-
getIterationTypesOfIteratorFast(type, resolver)
|
|
84405
|
-
|
|
84487
|
+
getIterationTypesOfIteratorFast(type, resolver);
|
|
84488
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84489
|
+
iterationTypes = undefined;
|
|
84490
|
+
noCache = true;
|
|
84491
|
+
}
|
|
84492
|
+
iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache));
|
|
84406
84493
|
return iterationTypes === noIterationTypes ? undefined : iterationTypes;
|
|
84407
84494
|
}
|
|
84408
84495
|
/**
|
|
@@ -84440,7 +84527,7 @@ var ts;
|
|
|
84440
84527
|
// iteration types of their `next`, `return`, and `throw` methods. While we define these as `any`
|
|
84441
84528
|
// and `undefined` in our libs by default, a custom lib *could* use different definitions.
|
|
84442
84529
|
var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
|
|
84443
|
-
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84530
|
+
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84444
84531
|
var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
|
|
84445
84532
|
return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
|
|
84446
84533
|
}
|
|
@@ -84510,8 +84597,8 @@ var ts;
|
|
|
84510
84597
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84511
84598
|
* record is returned. Otherwise, we return `undefined`.
|
|
84512
84599
|
*/
|
|
84513
|
-
function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
|
|
84514
|
-
var _a, _b, _c, _d;
|
|
84600
|
+
function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) {
|
|
84601
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84515
84602
|
var method = getPropertyOfType(type, methodName);
|
|
84516
84603
|
// Ignore 'return' or 'throw' if they are missing.
|
|
84517
84604
|
if (!method && methodName !== "next") {
|
|
@@ -84531,9 +84618,15 @@ var ts;
|
|
|
84531
84618
|
var diagnostic = methodName === "next"
|
|
84532
84619
|
? resolver.mustHaveANextMethodDiagnostic
|
|
84533
84620
|
: resolver.mustBeAMethodDiagnostic;
|
|
84534
|
-
|
|
84621
|
+
if (errorOutputContainer) {
|
|
84622
|
+
(_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []);
|
|
84623
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName));
|
|
84624
|
+
}
|
|
84625
|
+
else {
|
|
84626
|
+
error(errorNode, diagnostic, methodName);
|
|
84627
|
+
}
|
|
84535
84628
|
}
|
|
84536
|
-
return methodName === "next" ?
|
|
84629
|
+
return methodName === "next" ? noIterationTypes : undefined;
|
|
84537
84630
|
}
|
|
84538
84631
|
// If the method signature comes exclusively from the global iterator or generator type,
|
|
84539
84632
|
// create iteration types from its type arguments like `getIterationTypesOfIteratorFast`
|
|
@@ -84545,8 +84638,8 @@ var ts;
|
|
|
84545
84638
|
if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
|
|
84546
84639
|
var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false);
|
|
84547
84640
|
var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false);
|
|
84548
|
-
var isGeneratorMethod = ((
|
|
84549
|
-
var isIteratorMethod = !isGeneratorMethod && ((
|
|
84641
|
+
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;
|
|
84642
|
+
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;
|
|
84550
84643
|
if (isGeneratorMethod || isIteratorMethod) {
|
|
84551
84644
|
var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
|
|
84552
84645
|
var mapper = methodType.mapper;
|
|
@@ -84586,7 +84679,13 @@ var ts;
|
|
|
84586
84679
|
var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
|
|
84587
84680
|
if (iterationTypes === noIterationTypes) {
|
|
84588
84681
|
if (errorNode) {
|
|
84589
|
-
|
|
84682
|
+
if (errorOutputContainer) {
|
|
84683
|
+
(_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []);
|
|
84684
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
|
|
84685
|
+
}
|
|
84686
|
+
else {
|
|
84687
|
+
error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
|
|
84688
|
+
}
|
|
84590
84689
|
}
|
|
84591
84690
|
yieldType = anyType;
|
|
84592
84691
|
returnTypes = ts.append(returnTypes, anyType);
|
|
@@ -84607,13 +84706,13 @@ var ts;
|
|
|
84607
84706
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84608
84707
|
* `getIterationTypesOfIterator` instead.
|
|
84609
84708
|
*/
|
|
84610
|
-
function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
|
|
84709
|
+
function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84611
84710
|
var iterationTypes = combineIterationTypes([
|
|
84612
|
-
getIterationTypesOfMethod(type, resolver, "next", errorNode),
|
|
84613
|
-
getIterationTypesOfMethod(type, resolver, "return", errorNode),
|
|
84614
|
-
getIterationTypesOfMethod(type, resolver, "throw", errorNode),
|
|
84711
|
+
getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer),
|
|
84712
|
+
getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer),
|
|
84713
|
+
getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer),
|
|
84615
84714
|
]);
|
|
84616
|
-
return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84715
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84617
84716
|
}
|
|
84618
84717
|
/**
|
|
84619
84718
|
* Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like,
|
|
@@ -84634,7 +84733,7 @@ var ts;
|
|
|
84634
84733
|
var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
|
|
84635
84734
|
var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
|
|
84636
84735
|
return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
|
|
84637
|
-
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
|
|
84736
|
+
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined);
|
|
84638
84737
|
}
|
|
84639
84738
|
function checkBreakOrContinueStatement(node) {
|
|
84640
84739
|
// Grammar checking
|
|
@@ -122931,8 +123030,6 @@ var ts;
|
|
|
122931
123030
|
if (watcher.files === 0 && watcher.resolutions === 0) {
|
|
122932
123031
|
fileWatchesOfAffectingLocations.delete(path);
|
|
122933
123032
|
watcher.watcher.close();
|
|
122934
|
-
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
122935
|
-
watcher.watcher = ts.noopFileWatcher;
|
|
122936
123033
|
}
|
|
122937
123034
|
});
|
|
122938
123035
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
@@ -123278,20 +123375,27 @@ var ts;
|
|
|
123278
123375
|
}
|
|
123279
123376
|
var paths = new ts.Set();
|
|
123280
123377
|
paths.add(locationToWatch);
|
|
123378
|
+
var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
|
|
123379
|
+
resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
|
|
123380
|
+
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
|
123381
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123382
|
+
paths.forEach(function (path) {
|
|
123383
|
+
if (watcher.resolutions)
|
|
123384
|
+
(affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
|
|
123385
|
+
if (watcher.files)
|
|
123386
|
+
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123387
|
+
packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
|
|
123388
|
+
});
|
|
123389
|
+
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123390
|
+
}) : ts.noopFileWatcher;
|
|
123281
123391
|
var watcher = {
|
|
123282
|
-
watcher:
|
|
123283
|
-
|
|
123284
|
-
|
|
123285
|
-
|
|
123286
|
-
|
|
123287
|
-
|
|
123288
|
-
|
|
123289
|
-
if (watcher.files)
|
|
123290
|
-
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123291
|
-
(_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
|
|
123292
|
-
});
|
|
123293
|
-
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123294
|
-
}) : ts.noopFileWatcher,
|
|
123392
|
+
watcher: actualWatcher !== ts.noopFileWatcher ? {
|
|
123393
|
+
close: function () {
|
|
123394
|
+
actualWatcher.close();
|
|
123395
|
+
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
123396
|
+
actualWatcher = ts.noopFileWatcher;
|
|
123397
|
+
}
|
|
123398
|
+
} : actualWatcher,
|
|
123295
123399
|
resolutions: forResolution ? 1 : 0,
|
|
123296
123400
|
files: forResolution ? 0 : 1,
|
|
123297
123401
|
paths: paths,
|
|
@@ -123705,7 +123809,7 @@ var ts;
|
|
|
123705
123809
|
var info = getInfo(importingSourceFileName, host);
|
|
123706
123810
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
123707
123811
|
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
123708
|
-
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
123812
|
+
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123709
123813
|
}
|
|
123710
123814
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
123711
123815
|
if (options === void 0) { options = {}; }
|
|
@@ -123788,7 +123892,7 @@ var ts;
|
|
|
123788
123892
|
return nodeModulesSpecifiers;
|
|
123789
123893
|
}
|
|
123790
123894
|
if (!specifier && !modulePath.isRedirect) {
|
|
123791
|
-
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
|
|
123895
|
+
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123792
123896
|
if (ts.pathIsBareSpecifier(local)) {
|
|
123793
123897
|
pathsSpecifiers = ts.append(pathsSpecifiers, local);
|
|
123794
123898
|
}
|
|
@@ -123816,7 +123920,7 @@ var ts;
|
|
|
123816
123920
|
var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
|
|
123817
123921
|
return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
|
|
123818
123922
|
}
|
|
123819
|
-
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
|
|
123923
|
+
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) {
|
|
123820
123924
|
var ending = _a.ending, relativePreference = _a.relativePreference;
|
|
123821
123925
|
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
|
|
123822
123926
|
var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
|
|
@@ -123830,9 +123934,8 @@ var ts;
|
|
|
123830
123934
|
if (!relativeToBaseUrl) {
|
|
123831
123935
|
return relativePath;
|
|
123832
123936
|
}
|
|
123833
|
-
var
|
|
123834
|
-
var
|
|
123835
|
-
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
|
|
123937
|
+
var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
|
|
123938
|
+
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
|
|
123836
123939
|
if (!nonRelative) {
|
|
123837
123940
|
return relativePath;
|
|
123838
123941
|
}
|
|
@@ -124067,28 +124170,102 @@ var ts;
|
|
|
124067
124170
|
return ambientModuleDeclare.name.text;
|
|
124068
124171
|
}
|
|
124069
124172
|
}
|
|
124070
|
-
function
|
|
124173
|
+
function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
|
|
124174
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) {
|
|
124175
|
+
return [2 /* JsExtension */];
|
|
124176
|
+
}
|
|
124177
|
+
switch (preferredEnding) {
|
|
124178
|
+
case 2 /* JsExtension */: return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
|
|
124179
|
+
case 1 /* Index */: return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
|
|
124180
|
+
case 0 /* Minimal */: return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
|
|
124181
|
+
default: ts.Debug.assertNever(preferredEnding);
|
|
124182
|
+
}
|
|
124183
|
+
}
|
|
124184
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
124071
124185
|
for (var key in paths) {
|
|
124072
|
-
|
|
124073
|
-
var
|
|
124074
|
-
var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
|
|
124186
|
+
var _loop_36 = function (patternText_1) {
|
|
124187
|
+
var pattern = ts.normalizePath(patternText_1);
|
|
124075
124188
|
var indexOfStar = pattern.indexOf("*");
|
|
124189
|
+
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
124190
|
+
// meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
|
|
124191
|
+
// causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
|
|
124192
|
+
// and matches the '*'. For example:
|
|
124193
|
+
//
|
|
124194
|
+
// Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
|
|
124195
|
+
// ---------------------->------------------------------->--------------------->---------------------------------------------------------------
|
|
124196
|
+
// import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
|
|
124197
|
+
// import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
|
|
124198
|
+
//
|
|
124199
|
+
// (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
|
|
124200
|
+
//
|
|
124201
|
+
// The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
|
|
124202
|
+
// the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
|
|
124203
|
+
// (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
|
|
124204
|
+
// extension for a module specifier.)
|
|
124205
|
+
//
|
|
124206
|
+
// Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
|
|
124207
|
+
// .ts extension) or the possible relative module specifiers representing that file:
|
|
124208
|
+
//
|
|
124209
|
+
// Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
|
|
124210
|
+
// --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
|
|
124211
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
|
|
124212
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
|
|
124213
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
|
|
124214
|
+
// 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
|
|
124215
|
+
// dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
|
|
124216
|
+
//
|
|
124217
|
+
// The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
|
|
124218
|
+
// relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
|
|
124219
|
+
// into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
|
|
124220
|
+
// exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
|
|
124221
|
+
// specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
|
|
124222
|
+
// resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
|
|
124223
|
+
// in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
|
|
124224
|
+
// sorted among the others for a particular value of `importModuleSpecifierEnding`.
|
|
124225
|
+
var candidates = allowedEndings.map(function (ending) { return ({
|
|
124226
|
+
ending: ending,
|
|
124227
|
+
value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
|
|
124228
|
+
}); });
|
|
124229
|
+
if (ts.tryGetExtensionFromPath(pattern)) {
|
|
124230
|
+
candidates.push({ ending: undefined, value: relativeToBaseUrl });
|
|
124231
|
+
}
|
|
124076
124232
|
if (indexOfStar !== -1) {
|
|
124077
|
-
var prefix = pattern.
|
|
124078
|
-
var suffix = pattern.
|
|
124079
|
-
|
|
124080
|
-
|
|
124081
|
-
|
|
124082
|
-
|
|
124083
|
-
|
|
124084
|
-
|
|
124233
|
+
var prefix = pattern.substring(0, indexOfStar);
|
|
124234
|
+
var suffix = pattern.substring(indexOfStar + 1);
|
|
124235
|
+
for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) {
|
|
124236
|
+
var _c = candidates_3[_b], ending = _c.ending, value = _c.value;
|
|
124237
|
+
if (value.length >= prefix.length + suffix.length &&
|
|
124238
|
+
ts.startsWith(value, prefix) &&
|
|
124239
|
+
ts.endsWith(value, suffix) &&
|
|
124240
|
+
validateEnding({ ending: ending, value: value })) {
|
|
124241
|
+
var matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
|
124242
|
+
return { value: key.replace("*", matchedStar) };
|
|
124243
|
+
}
|
|
124085
124244
|
}
|
|
124086
124245
|
}
|
|
124087
|
-
else if (
|
|
124088
|
-
return
|
|
124246
|
+
else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Minimal */ && pattern === c.value; }) ||
|
|
124247
|
+
ts.some(candidates, function (c) { return c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c); })) {
|
|
124248
|
+
return { value: key };
|
|
124089
124249
|
}
|
|
124250
|
+
};
|
|
124251
|
+
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
124252
|
+
var patternText_1 = _a[_i];
|
|
124253
|
+
var state_12 = _loop_36(patternText_1);
|
|
124254
|
+
if (typeof state_12 === "object")
|
|
124255
|
+
return state_12.value;
|
|
124090
124256
|
}
|
|
124091
124257
|
}
|
|
124258
|
+
function validateEnding(_a) {
|
|
124259
|
+
var ending = _a.ending, value = _a.value;
|
|
124260
|
+
// Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
|
|
124261
|
+
// is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
|
|
124262
|
+
// here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
|
|
124263
|
+
// 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
|
|
124264
|
+
// `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
|
|
124265
|
+
// that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
|
|
124266
|
+
// everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
|
|
124267
|
+
return ending !== 0 /* Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
|
|
124268
|
+
}
|
|
124092
124269
|
}
|
|
124093
124270
|
var MatchingMode;
|
|
124094
124271
|
(function (MatchingMode) {
|
|
@@ -124184,10 +124361,10 @@ var ts;
|
|
|
124184
124361
|
return undefined;
|
|
124185
124362
|
}
|
|
124186
124363
|
// Simplify the full file path to something that can be resolved by Node.
|
|
124364
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
124187
124365
|
var moduleSpecifier = path;
|
|
124188
124366
|
var isPackageRootPath = false;
|
|
124189
124367
|
if (!packageNameOnly) {
|
|
124190
|
-
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
124191
124368
|
var packageRootIndex = parts.packageRootIndex;
|
|
124192
124369
|
var moduleFileName = void 0;
|
|
124193
124370
|
while (true) {
|
|
@@ -124236,15 +124413,13 @@ var ts;
|
|
|
124236
124413
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
124237
124414
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
124238
124415
|
var moduleFileToTry = path;
|
|
124416
|
+
var maybeBlockedByTypesVersions = false;
|
|
124239
124417
|
var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
124240
124418
|
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
|
124241
124419
|
var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
|
|
124420
|
+
var importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
124242
124421
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
124243
|
-
|
|
124244
|
-
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
124245
|
-
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
|
124246
|
-
// with, so for now we just stick with the mode of the file.
|
|
124247
|
-
var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124422
|
+
var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124248
124423
|
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
|
124249
124424
|
? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
|
124250
124425
|
: undefined;
|
|
@@ -124263,16 +124438,26 @@ var ts;
|
|
|
124263
124438
|
: undefined;
|
|
124264
124439
|
if (versionPaths) {
|
|
124265
124440
|
var subModuleName = path.slice(packageRootPath.length + 1);
|
|
124266
|
-
var fromPaths = tryGetModuleNameFromPaths(
|
|
124267
|
-
if (fromPaths
|
|
124441
|
+
var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options);
|
|
124442
|
+
if (fromPaths === undefined) {
|
|
124443
|
+
maybeBlockedByTypesVersions = true;
|
|
124444
|
+
}
|
|
124445
|
+
else {
|
|
124268
124446
|
moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
|
|
124269
124447
|
}
|
|
124270
124448
|
}
|
|
124271
124449
|
// If the file is the main module, it can be imported by the package name
|
|
124272
124450
|
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
124273
|
-
if (ts.isString(mainFileRelative)) {
|
|
124451
|
+
if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) {
|
|
124452
|
+
// The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
|
|
124453
|
+
// explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
|
|
124454
|
+
// (The only way this can happen is if some file in a package that's not resolvable from outside the
|
|
124455
|
+
// package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
|
|
124456
|
+
// happens very easily in fourslash tests though, since every test file listed gets included. See
|
|
124457
|
+
// importNameCodeFix_typesVersions.ts for an example.)
|
|
124274
124458
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
124275
124459
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
124460
|
+
// ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
|
|
124276
124461
|
return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
|
|
124277
124462
|
}
|
|
124278
124463
|
}
|
|
@@ -157092,7 +157277,7 @@ var ts;
|
|
|
157092
157277
|
return undefined;
|
|
157093
157278
|
return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
|
|
157094
157279
|
}
|
|
157095
|
-
if (ts.isIdentifier(token) && ts.isCallExpression(parent)) {
|
|
157280
|
+
if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) {
|
|
157096
157281
|
return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile };
|
|
157097
157282
|
}
|
|
157098
157283
|
if (!ts.isPropertyAccessExpression(parent))
|
|
@@ -162337,6 +162522,9 @@ var ts;
|
|
|
162337
162522
|
if (!containingDecl) {
|
|
162338
162523
|
return;
|
|
162339
162524
|
}
|
|
162525
|
+
if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) {
|
|
162526
|
+
return;
|
|
162527
|
+
}
|
|
162340
162528
|
var checker = program.getTypeChecker();
|
|
162341
162529
|
var signatureSymbol = containingDecl.symbol;
|
|
162342
162530
|
if (!signatureSymbol) {
|