typescript 4.7.0-dev.20220215 → 4.7.0-dev.20220216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lib.es2020.intl.d.ts +4 -0
- package/lib/lib.esnext.intl.d.ts +4 -1
- package/lib/protocol.d.ts +7 -0
- package/lib/tsc.js +376 -306
- package/lib/tsserver.js +476 -388
- package/lib/tsserverlibrary.d.ts +24 -18
- package/lib/tsserverlibrary.js +476 -388
- package/lib/typescript.d.ts +16 -17
- package/lib/typescript.js +474 -386
- package/lib/typescriptServices.d.ts +16 -17
- package/lib/typescriptServices.js +474 -386
- package/lib/typingsInstaller.js +459 -381
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -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.20220216";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -5034,6 +5034,8 @@ var ts;
|
|
|
5034
5034
|
TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike";
|
|
5035
5035
|
TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike";
|
|
5036
5036
|
/* @internal */
|
|
5037
|
+
TypeFlags[TypeFlags["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
|
|
5038
|
+
/* @internal */
|
|
5037
5039
|
TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains";
|
|
5038
5040
|
TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
5039
5041
|
TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType";
|
|
@@ -5766,6 +5768,8 @@ var ts;
|
|
|
5766
5768
|
BundleFileSectionKind["NoDefaultLib"] = "no-default-lib";
|
|
5767
5769
|
BundleFileSectionKind["Reference"] = "reference";
|
|
5768
5770
|
BundleFileSectionKind["Type"] = "type";
|
|
5771
|
+
BundleFileSectionKind["TypeResolutionModeRequire"] = "type-require";
|
|
5772
|
+
BundleFileSectionKind["TypeResolutionModeImport"] = "type-import";
|
|
5769
5773
|
BundleFileSectionKind["Lib"] = "lib";
|
|
5770
5774
|
BundleFileSectionKind["Prepend"] = "prepend";
|
|
5771
5775
|
BundleFileSectionKind["Text"] = "text";
|
|
@@ -5882,7 +5886,8 @@ var ts;
|
|
|
5882
5886
|
{ name: "types", optional: true, captureSpan: true },
|
|
5883
5887
|
{ name: "lib", optional: true, captureSpan: true },
|
|
5884
5888
|
{ name: "path", optional: true, captureSpan: true },
|
|
5885
|
-
{ name: "no-default-lib", optional: true }
|
|
5889
|
+
{ name: "no-default-lib", optional: true },
|
|
5890
|
+
{ name: "resolution-mode", optional: true }
|
|
5886
5891
|
],
|
|
5887
5892
|
kind: 1 /* TripleSlashXML */
|
|
5888
5893
|
},
|
|
@@ -8263,6 +8268,8 @@ var ts;
|
|
|
8263
8268
|
Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
|
|
8264
8269
|
An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
|
|
8265
8270
|
Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
|
|
8271
|
+
Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
|
|
8272
|
+
Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
|
|
8266
8273
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
8267
8274
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
8268
8275
|
Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
|
|
@@ -8396,6 +8403,8 @@ var ts;
|
|
|
8396
8403
|
Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
|
|
8397
8404
|
Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
|
|
8398
8405
|
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
|
|
8406
|
+
Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."),
|
|
8407
|
+
resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
|
|
8399
8408
|
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."),
|
|
8400
8409
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8401
8410
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -14279,7 +14288,11 @@ var ts;
|
|
|
14279
14288
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14280
14289
|
for (var i = 0; i < names.length; i++) {
|
|
14281
14290
|
var newResolution = newResolutions[i];
|
|
14282
|
-
var
|
|
14291
|
+
var entry = names[i];
|
|
14292
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
14293
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
14294
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
|
|
14295
|
+
var oldResolution = oldResolutions && oldResolutions.get(name, mode);
|
|
14283
14296
|
var changed = oldResolution
|
|
14284
14297
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14285
14298
|
: newResolution;
|
|
@@ -26874,7 +26887,13 @@ var ts;
|
|
|
26874
26887
|
referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
|
|
26875
26888
|
break;
|
|
26876
26889
|
case "type" /* Type */:
|
|
26877
|
-
typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
|
|
26890
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
26891
|
+
break;
|
|
26892
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26893
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
|
|
26894
|
+
break;
|
|
26895
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26896
|
+
typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
|
|
26878
26897
|
break;
|
|
26879
26898
|
case "lib" /* Lib */:
|
|
26880
26899
|
libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
|
|
@@ -26933,6 +26952,8 @@ var ts;
|
|
|
26933
26952
|
case "no-default-lib" /* NoDefaultLib */:
|
|
26934
26953
|
case "reference" /* Reference */:
|
|
26935
26954
|
case "type" /* Type */:
|
|
26955
|
+
case "type-import" /* TypeResolutionModeImport */:
|
|
26956
|
+
case "type-require" /* TypeResolutionModeRequire */:
|
|
26936
26957
|
case "lib" /* Lib */:
|
|
26937
26958
|
syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
|
|
26938
26959
|
break;
|
|
@@ -30846,7 +30867,7 @@ var ts;
|
|
|
30846
30867
|
initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
|
|
30847
30868
|
// Prime the scanner.
|
|
30848
30869
|
nextToken();
|
|
30849
|
-
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
30870
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false);
|
|
30850
30871
|
var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
|
|
30851
30872
|
clearState();
|
|
30852
30873
|
return isInvalid ? entityName : undefined;
|
|
@@ -32423,7 +32444,7 @@ var ts;
|
|
|
32423
32444
|
}
|
|
32424
32445
|
return createMissingList();
|
|
32425
32446
|
}
|
|
32426
|
-
function parseEntityName(allowReservedWords, diagnosticMessage) {
|
|
32447
|
+
function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) {
|
|
32427
32448
|
var pos = getNodePos();
|
|
32428
32449
|
var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
|
|
32429
32450
|
var dotPos = getNodePos();
|
|
@@ -32434,7 +32455,7 @@ var ts;
|
|
|
32434
32455
|
break;
|
|
32435
32456
|
}
|
|
32436
32457
|
dotPos = getNodePos();
|
|
32437
|
-
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords,
|
|
32458
|
+
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos);
|
|
32438
32459
|
}
|
|
32439
32460
|
return entity;
|
|
32440
32461
|
}
|
|
@@ -32567,7 +32588,7 @@ var ts;
|
|
|
32567
32588
|
}
|
|
32568
32589
|
// TYPES
|
|
32569
32590
|
function parseEntityNameOfTypeReference() {
|
|
32570
|
-
return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
|
|
32591
|
+
return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected);
|
|
32571
32592
|
}
|
|
32572
32593
|
function parseTypeArgumentsOfTypeReference() {
|
|
32573
32594
|
if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) {
|
|
@@ -32700,7 +32721,7 @@ var ts;
|
|
|
32700
32721
|
function parseTypeQuery() {
|
|
32701
32722
|
var pos = getNodePos();
|
|
32702
32723
|
parseExpected(112 /* TypeOfKeyword */);
|
|
32703
|
-
return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos);
|
|
32724
|
+
return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true)), pos);
|
|
32704
32725
|
}
|
|
32705
32726
|
function parseTypeParameter() {
|
|
32706
32727
|
var pos = getNodePos();
|
|
@@ -35271,11 +35292,12 @@ var ts;
|
|
|
35271
35292
|
}
|
|
35272
35293
|
function parseCaseClause() {
|
|
35273
35294
|
var pos = getNodePos();
|
|
35295
|
+
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35274
35296
|
parseExpected(82 /* CaseKeyword */);
|
|
35275
35297
|
var expression = allowInAnd(parseExpression);
|
|
35276
35298
|
parseExpected(58 /* ColonToken */);
|
|
35277
35299
|
var statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
|
|
35278
|
-
return finishNode(factory.createCaseClause(expression, statements), pos);
|
|
35300
|
+
return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
|
|
35279
35301
|
}
|
|
35280
35302
|
function parseDefaultClause() {
|
|
35281
35303
|
var pos = getNodePos();
|
|
@@ -36438,7 +36460,7 @@ var ts;
|
|
|
36438
36460
|
function parseModuleReference() {
|
|
36439
36461
|
return isExternalModuleReference()
|
|
36440
36462
|
? parseExternalModuleReference()
|
|
36441
|
-
: parseEntityName(/*allowReservedWords*/ false);
|
|
36463
|
+
: parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36442
36464
|
}
|
|
36443
36465
|
function parseExternalModuleReference() {
|
|
36444
36466
|
var pos = getNodePos();
|
|
@@ -36720,7 +36742,7 @@ var ts;
|
|
|
36720
36742
|
var pos = getNodePos();
|
|
36721
36743
|
var hasBrace = parseOptional(18 /* OpenBraceToken */);
|
|
36722
36744
|
var p2 = getNodePos();
|
|
36723
|
-
var entityName = parseEntityName(/* allowReservedWords*/ false);
|
|
36745
|
+
var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
|
|
36724
36746
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
36725
36747
|
reScanHashToken(); // rescan #id as # id
|
|
36726
36748
|
nextTokenJSDoc(); // then skip the #
|
|
@@ -37163,7 +37185,7 @@ var ts;
|
|
|
37163
37185
|
// parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
|
|
37164
37186
|
var p2 = getNodePos();
|
|
37165
37187
|
var name = ts.tokenIsIdentifierOrKeyword(token())
|
|
37166
|
-
? parseEntityName(/*allowReservedWords*/ true)
|
|
37188
|
+
? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false)
|
|
37167
37189
|
: undefined;
|
|
37168
37190
|
if (name) {
|
|
37169
37191
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
@@ -37188,11 +37210,13 @@ var ts;
|
|
|
37188
37210
|
&& nextTokenJSDoc() === 59 /* AtToken */
|
|
37189
37211
|
&& ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
|
|
37190
37212
|
var kind = scanner.getTokenValue();
|
|
37191
|
-
if (kind
|
|
37213
|
+
if (isJSDocLinkTag(kind))
|
|
37192
37214
|
return kind;
|
|
37193
|
-
}
|
|
37194
37215
|
}
|
|
37195
37216
|
}
|
|
37217
|
+
function isJSDocLinkTag(kind) {
|
|
37218
|
+
return kind === "link" || kind === "linkcode" || kind === "linkplain";
|
|
37219
|
+
}
|
|
37196
37220
|
function parseUnknownTag(start, tagName, indent, indentText) {
|
|
37197
37221
|
return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
|
|
37198
37222
|
}
|
|
@@ -37298,7 +37322,7 @@ var ts;
|
|
|
37298
37322
|
}
|
|
37299
37323
|
function parseSeeTag(start, tagName, indent, indentText) {
|
|
37300
37324
|
var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
|
|
37301
|
-
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue()
|
|
37325
|
+
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); });
|
|
37302
37326
|
var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
|
|
37303
37327
|
var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
|
|
37304
37328
|
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
|
|
@@ -38165,6 +38189,19 @@ var ts;
|
|
|
38165
38189
|
return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
|
|
38166
38190
|
}
|
|
38167
38191
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
38192
|
+
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
38193
|
+
if (!mode) {
|
|
38194
|
+
return undefined;
|
|
38195
|
+
}
|
|
38196
|
+
if (mode === "import") {
|
|
38197
|
+
return ts.ModuleKind.ESNext;
|
|
38198
|
+
}
|
|
38199
|
+
if (mode === "require") {
|
|
38200
|
+
return ts.ModuleKind.CommonJS;
|
|
38201
|
+
}
|
|
38202
|
+
reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
|
|
38203
|
+
return undefined;
|
|
38204
|
+
}
|
|
38168
38205
|
/*@internal*/
|
|
38169
38206
|
function processCommentPragmas(context, sourceText) {
|
|
38170
38207
|
var pragmas = [];
|
|
@@ -38207,12 +38244,13 @@ var ts;
|
|
|
38207
38244
|
var typeReferenceDirectives_1 = context.typeReferenceDirectives;
|
|
38208
38245
|
var libReferenceDirectives_1 = context.libReferenceDirectives;
|
|
38209
38246
|
ts.forEach(ts.toArray(entryOrList), function (arg) {
|
|
38210
|
-
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
|
|
38247
|
+
var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
|
|
38211
38248
|
if (arg.arguments["no-default-lib"]) {
|
|
38212
38249
|
context.hasNoDefaultLib = true;
|
|
38213
38250
|
}
|
|
38214
38251
|
else if (types) {
|
|
38215
|
-
|
|
38252
|
+
var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
|
|
38253
|
+
typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
|
|
38216
38254
|
}
|
|
38217
38255
|
else if (lib) {
|
|
38218
38256
|
libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
|
|
@@ -41790,14 +41828,14 @@ var ts;
|
|
|
41790
41828
|
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
|
41791
41829
|
* is assumed to be the same as root directory of the project.
|
|
41792
41830
|
*/
|
|
41793
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
|
|
41831
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
|
|
41794
41832
|
var traceEnabled = isTraceEnabled(options, host);
|
|
41795
41833
|
if (redirectedReference) {
|
|
41796
41834
|
options = redirectedReference.commandLine.options;
|
|
41797
41835
|
}
|
|
41798
41836
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41799
41837
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41800
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/
|
|
41838
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
|
|
41801
41839
|
if (result) {
|
|
41802
41840
|
if (traceEnabled) {
|
|
41803
41841
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41832,7 +41870,18 @@ var ts;
|
|
|
41832
41870
|
}
|
|
41833
41871
|
var failedLookupLocations = [];
|
|
41834
41872
|
var features = getDefaultNodeResolutionFeatures(options);
|
|
41835
|
-
|
|
41873
|
+
// Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
|
|
41874
|
+
// setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
|
|
41875
|
+
// set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports
|
|
41876
|
+
// are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best,
|
|
41877
|
+
// in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern
|
|
41878
|
+
// resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution
|
|
41879
|
+
// context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do).
|
|
41880
|
+
if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
|
|
41881
|
+
features |= NodeResolutionFeatures.EsmMode;
|
|
41882
|
+
}
|
|
41883
|
+
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
41884
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
|
|
41836
41885
|
var resolved = primaryLookup();
|
|
41837
41886
|
var primary = true;
|
|
41838
41887
|
if (!resolved) {
|
|
@@ -41852,7 +41901,7 @@ var ts;
|
|
|
41852
41901
|
};
|
|
41853
41902
|
}
|
|
41854
41903
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41855
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/
|
|
41904
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
41856
41905
|
if (traceEnabled)
|
|
41857
41906
|
traceResult(result);
|
|
41858
41907
|
return result;
|
|
@@ -42138,7 +42187,11 @@ var ts;
|
|
|
42138
42187
|
ts.Debug.assert(keys.length === values.length);
|
|
42139
42188
|
var map = createModeAwareCache();
|
|
42140
42189
|
for (var i = 0; i < keys.length; ++i) {
|
|
42141
|
-
|
|
42190
|
+
var entry = keys[i];
|
|
42191
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
42192
|
+
var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
|
|
42193
|
+
var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
|
|
42194
|
+
map.set(name, mode, values[i]);
|
|
42142
42195
|
}
|
|
42143
42196
|
return map;
|
|
42144
42197
|
}
|
|
@@ -47158,8 +47211,7 @@ var ts;
|
|
|
47158
47211
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
47159
47212
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
47160
47213
|
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
47161
|
-
IntersectionState[IntersectionState["
|
|
47162
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
|
|
47214
|
+
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
47163
47215
|
})(IntersectionState || (IntersectionState = {}));
|
|
47164
47216
|
var RecursionFlags;
|
|
47165
47217
|
(function (RecursionFlags) {
|
|
@@ -58880,13 +58932,15 @@ var ts;
|
|
|
58880
58932
|
return signature;
|
|
58881
58933
|
}
|
|
58882
58934
|
function getOrCreateTypeFromSignature(signature) {
|
|
58935
|
+
var _a;
|
|
58883
58936
|
// There are two ways to declare a construct signature, one is by declaring a class constructor
|
|
58884
58937
|
// using the constructor keyword, and the other is declaring a bare construct signature in an
|
|
58885
58938
|
// object type literal or interface (using the new keyword). Each way of declaring a constructor
|
|
58886
58939
|
// will result in a different declaration kind.
|
|
58887
58940
|
if (!signature.isolatedSignatureType) {
|
|
58888
|
-
var kind =
|
|
58889
|
-
|
|
58941
|
+
var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
|
|
58942
|
+
// If declaration is undefined, it is likely to be the signature of the default constructor.
|
|
58943
|
+
var isConstructor = kind === undefined || kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */;
|
|
58890
58944
|
var type = createObjectType(16 /* Anonymous */);
|
|
58891
58945
|
type.members = emptySymbols;
|
|
58892
58946
|
type.properties = ts.emptyArray;
|
|
@@ -59814,7 +59868,7 @@ var ts;
|
|
|
59814
59868
|
}
|
|
59815
59869
|
}
|
|
59816
59870
|
var fixedLength = properties.length;
|
|
59817
|
-
var lengthSymbol = createSymbol(4 /* Property */, "length");
|
|
59871
|
+
var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
|
|
59818
59872
|
if (combinedFlags & 12 /* Variable */) {
|
|
59819
59873
|
lengthSymbol.type = numberType;
|
|
59820
59874
|
}
|
|
@@ -63454,11 +63508,11 @@ var ts;
|
|
|
63454
63508
|
var overflow = false;
|
|
63455
63509
|
var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
|
|
63456
63510
|
var lastSkippedInfo;
|
|
63457
|
-
var incompatibleStack
|
|
63511
|
+
var incompatibleStack;
|
|
63458
63512
|
var inPropertyCheck = false;
|
|
63459
63513
|
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
63460
63514
|
var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
|
|
63461
|
-
if (incompatibleStack
|
|
63515
|
+
if (incompatibleStack) {
|
|
63462
63516
|
reportIncompatibleStack();
|
|
63463
63517
|
}
|
|
63464
63518
|
if (overflow) {
|
|
@@ -63515,19 +63569,19 @@ var ts;
|
|
|
63515
63569
|
return {
|
|
63516
63570
|
errorInfo: errorInfo,
|
|
63517
63571
|
lastSkippedInfo: lastSkippedInfo,
|
|
63518
|
-
incompatibleStack: incompatibleStack.slice(),
|
|
63572
|
+
incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
|
|
63519
63573
|
overrideNextErrorInfo: overrideNextErrorInfo,
|
|
63520
|
-
relatedInfo:
|
|
63574
|
+
relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
|
|
63521
63575
|
};
|
|
63522
63576
|
}
|
|
63523
63577
|
function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
|
|
63524
63578
|
overrideNextErrorInfo++; // Suppress the next relation error
|
|
63525
63579
|
lastSkippedInfo = undefined; // Reset skipped info cache
|
|
63526
|
-
incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
|
|
63580
|
+
(incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
|
|
63527
63581
|
}
|
|
63528
63582
|
function reportIncompatibleStack() {
|
|
63529
|
-
var stack = incompatibleStack;
|
|
63530
|
-
incompatibleStack =
|
|
63583
|
+
var stack = incompatibleStack || [];
|
|
63584
|
+
incompatibleStack = undefined;
|
|
63531
63585
|
var info = lastSkippedInfo;
|
|
63532
63586
|
lastSkippedInfo = undefined;
|
|
63533
63587
|
if (stack.length === 1) {
|
|
@@ -63633,7 +63687,7 @@ var ts;
|
|
|
63633
63687
|
}
|
|
63634
63688
|
function reportError(message, arg0, arg1, arg2, arg3) {
|
|
63635
63689
|
ts.Debug.assert(!!errorNode);
|
|
63636
|
-
if (incompatibleStack
|
|
63690
|
+
if (incompatibleStack)
|
|
63637
63691
|
reportIncompatibleStack();
|
|
63638
63692
|
if (message.elidedInCompatabilityPyramid)
|
|
63639
63693
|
return;
|
|
@@ -63649,7 +63703,7 @@ var ts;
|
|
|
63649
63703
|
}
|
|
63650
63704
|
}
|
|
63651
63705
|
function reportRelationError(message, source, target) {
|
|
63652
|
-
if (incompatibleStack
|
|
63706
|
+
if (incompatibleStack)
|
|
63653
63707
|
reportIncompatibleStack();
|
|
63654
63708
|
var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
|
|
63655
63709
|
var generalizedSource = source;
|
|
@@ -63761,7 +63815,9 @@ var ts;
|
|
|
63761
63815
|
if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
|
|
63762
63816
|
return -1 /* True */;
|
|
63763
63817
|
}
|
|
63764
|
-
|
|
63818
|
+
if (reportErrors) {
|
|
63819
|
+
reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
|
|
63820
|
+
}
|
|
63765
63821
|
return 0 /* False */;
|
|
63766
63822
|
}
|
|
63767
63823
|
// Normalize the source and target types: Turn fresh literal types into regular literal types,
|
|
@@ -63773,7 +63829,12 @@ var ts;
|
|
|
63773
63829
|
if (source === target)
|
|
63774
63830
|
return -1 /* True */;
|
|
63775
63831
|
if (relation === identityRelation) {
|
|
63776
|
-
|
|
63832
|
+
if (source.flags !== target.flags)
|
|
63833
|
+
return 0 /* False */;
|
|
63834
|
+
if (source.flags & 67358815 /* Singleton */)
|
|
63835
|
+
return -1 /* True */;
|
|
63836
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63837
|
+
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63777
63838
|
}
|
|
63778
63839
|
// We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
|
|
63779
63840
|
// and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
|
|
@@ -63783,163 +63844,130 @@ var ts;
|
|
|
63783
63844
|
if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
|
|
63784
63845
|
return -1 /* True */;
|
|
63785
63846
|
}
|
|
63786
|
-
//
|
|
63787
|
-
// If so,
|
|
63788
|
-
|
|
63789
|
-
|
|
63790
|
-
|
|
63791
|
-
|
|
63792
|
-
|
|
63793
|
-
|
|
63794
|
-
|
|
63795
|
-
|
|
63796
|
-
|
|
63797
|
-
|
|
63798
|
-
if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) {
|
|
63799
|
-
target = getNormalizedType(nullStrippedTarget, /*writing*/ true);
|
|
63800
|
-
}
|
|
63801
|
-
if (source === nullStrippedTarget)
|
|
63802
|
-
return -1 /* True */;
|
|
63847
|
+
// See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
|
|
63848
|
+
// plus a single non-nullable type. If so, remove null and/or undefined from the target type.
|
|
63849
|
+
if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
|
|
63850
|
+
var types = target.types;
|
|
63851
|
+
var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
|
|
63852
|
+
types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
|
|
63853
|
+
undefined;
|
|
63854
|
+
if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
|
|
63855
|
+
target = getNormalizedType(candidate, /*writing*/ true);
|
|
63856
|
+
if (source === target)
|
|
63857
|
+
return -1 /* True */;
|
|
63858
|
+
}
|
|
63803
63859
|
}
|
|
63804
63860
|
if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
|
|
63805
63861
|
isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
|
|
63806
63862
|
return -1 /* True */;
|
|
63807
|
-
|
|
63808
|
-
|
|
63809
|
-
|
|
63810
|
-
|
|
63863
|
+
if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
|
|
63864
|
+
var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
|
|
63865
|
+
if (isPerformingExcessPropertyChecks) {
|
|
63866
|
+
if (hasExcessProperties(source, target, reportErrors)) {
|
|
63867
|
+
if (reportErrors) {
|
|
63868
|
+
reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
|
|
63869
|
+
}
|
|
63870
|
+
return 0 /* False */;
|
|
63871
|
+
}
|
|
63872
|
+
}
|
|
63873
|
+
var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
|
|
63874
|
+
source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
|
|
63875
|
+
target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
|
|
63876
|
+
(getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
|
|
63877
|
+
var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
|
|
63878
|
+
if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
|
|
63811
63879
|
if (reportErrors) {
|
|
63812
|
-
|
|
63880
|
+
var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
|
|
63881
|
+
var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
|
|
63882
|
+
var calls = getSignaturesOfType(source, 0 /* Call */);
|
|
63883
|
+
var constructs = getSignaturesOfType(source, 1 /* Construct */);
|
|
63884
|
+
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
|
|
63885
|
+
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
63886
|
+
reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
|
|
63887
|
+
}
|
|
63888
|
+
else {
|
|
63889
|
+
reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
|
|
63890
|
+
}
|
|
63813
63891
|
}
|
|
63814
63892
|
return 0 /* False */;
|
|
63815
63893
|
}
|
|
63816
|
-
|
|
63817
|
-
|
|
63818
|
-
|
|
63819
|
-
|
|
63820
|
-
|
|
63821
|
-
|
|
63822
|
-
|
|
63823
|
-
|
|
63824
|
-
|
|
63825
|
-
|
|
63826
|
-
|
|
63827
|
-
|
|
63828
|
-
|
|
63829
|
-
|
|
63830
|
-
|
|
63831
|
-
|
|
63832
|
-
|
|
63833
|
-
|
|
63894
|
+
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63895
|
+
var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
|
|
63896
|
+
target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
|
|
63897
|
+
var result_7 = skipCaching ?
|
|
63898
|
+
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
63899
|
+
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
63900
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
63901
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
63902
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
63903
|
+
//
|
|
63904
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63905
|
+
//
|
|
63906
|
+
// declare let wrong: { a: { y: string } };
|
|
63907
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63908
|
+
//
|
|
63909
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63910
|
+
// x = y; // Mismatched property in source intersection
|
|
63911
|
+
// }
|
|
63912
|
+
//
|
|
63913
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63914
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63915
|
+
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63916
|
+
isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
|
|
63917
|
+
inPropertyCheck = true;
|
|
63918
|
+
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63919
|
+
inPropertyCheck = false;
|
|
63920
|
+
}
|
|
63921
|
+
if (result_7) {
|
|
63922
|
+
return result_7;
|
|
63834
63923
|
}
|
|
63835
|
-
return 0 /* False */;
|
|
63836
|
-
}
|
|
63837
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63838
|
-
var result = 0 /* False */;
|
|
63839
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
63840
|
-
if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
|
|
63841
|
-
// We skip caching when source or target is a union with no more than three constituents.
|
|
63842
|
-
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63843
63924
|
}
|
|
63844
|
-
|
|
63845
|
-
|
|
63925
|
+
if (reportErrors) {
|
|
63926
|
+
reportErrorResults(originalSource, originalTarget, source, target, headMessage);
|
|
63846
63927
|
}
|
|
63847
|
-
|
|
63848
|
-
|
|
63849
|
-
|
|
63928
|
+
return 0 /* False */;
|
|
63929
|
+
}
|
|
63930
|
+
function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
|
|
63931
|
+
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63932
|
+
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63933
|
+
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63934
|
+
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63935
|
+
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63936
|
+
if (maybeSuppress) {
|
|
63937
|
+
overrideNextErrorInfo--;
|
|
63938
|
+
}
|
|
63939
|
+
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63940
|
+
var currentError = errorInfo;
|
|
63941
|
+
tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
|
|
63942
|
+
if (errorInfo !== currentError) {
|
|
63943
|
+
maybeSuppress = !!errorInfo;
|
|
63944
|
+
}
|
|
63945
|
+
}
|
|
63946
|
+
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63947
|
+
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63948
|
+
}
|
|
63949
|
+
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63950
|
+
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63951
|
+
}
|
|
63952
|
+
else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
|
|
63953
|
+
var targetTypes = target.types;
|
|
63954
|
+
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63955
|
+
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63956
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63957
|
+
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63958
|
+
// do not report top error
|
|
63959
|
+
return;
|
|
63850
63960
|
}
|
|
63851
63961
|
}
|
|
63852
|
-
|
|
63853
|
-
|
|
63854
|
-
// the constituents. When an intersection type contains instantiable types with union type
|
|
63855
|
-
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
63856
|
-
// when the target is a union type. Another is when the intersection contains types belonging
|
|
63857
|
-
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
63858
|
-
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
63859
|
-
// we need to check this constraint against a union on the target side. Also, given a type
|
|
63860
|
-
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
63861
|
-
// 'string & number | number & number' which reduces to just 'number'.
|
|
63862
|
-
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
63863
|
-
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
63864
|
-
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
63865
|
-
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
63866
|
-
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
63867
|
-
if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
|
|
63868
|
-
if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
63869
|
-
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
63870
|
-
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63871
|
-
resetErrorInfo(saveErrorInfo);
|
|
63872
|
-
}
|
|
63873
|
-
}
|
|
63874
|
-
}
|
|
63962
|
+
else {
|
|
63963
|
+
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63875
63964
|
}
|
|
63876
|
-
|
|
63877
|
-
|
|
63878
|
-
|
|
63879
|
-
|
|
63880
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
63881
|
-
//
|
|
63882
|
-
// declare let wrong: { a: { y: string } };
|
|
63883
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
63884
|
-
//
|
|
63885
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
63886
|
-
// x = y; // Mismatched property in source intersection
|
|
63887
|
-
// }
|
|
63888
|
-
//
|
|
63889
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
63890
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
63891
|
-
if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
63892
|
-
isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
|
|
63893
|
-
inPropertyCheck = true;
|
|
63894
|
-
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
63895
|
-
inPropertyCheck = false;
|
|
63896
|
-
}
|
|
63897
|
-
reportErrorResults(source, target, result, isComparingJsxAttributes);
|
|
63898
|
-
return result;
|
|
63899
|
-
function reportErrorResults(source, target, result, isComparingJsxAttributes) {
|
|
63900
|
-
if (!result && reportErrors) {
|
|
63901
|
-
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
|
|
63902
|
-
var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
|
|
63903
|
-
source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
|
|
63904
|
-
target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
|
|
63905
|
-
var maybeSuppress = overrideNextErrorInfo > 0;
|
|
63906
|
-
if (maybeSuppress) {
|
|
63907
|
-
overrideNextErrorInfo--;
|
|
63908
|
-
}
|
|
63909
|
-
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63910
|
-
var currentError = errorInfo;
|
|
63911
|
-
tryElaborateArrayLikeErrors(source, target, reportErrors);
|
|
63912
|
-
if (errorInfo !== currentError) {
|
|
63913
|
-
maybeSuppress = !!errorInfo;
|
|
63914
|
-
}
|
|
63915
|
-
}
|
|
63916
|
-
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
|
|
63917
|
-
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
|
63918
|
-
}
|
|
63919
|
-
else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
|
|
63920
|
-
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
|
63921
|
-
}
|
|
63922
|
-
else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) {
|
|
63923
|
-
var targetTypes = target.types;
|
|
63924
|
-
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
63925
|
-
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
63926
|
-
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
63927
|
-
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
63928
|
-
// do not report top error
|
|
63929
|
-
return result;
|
|
63930
|
-
}
|
|
63931
|
-
}
|
|
63932
|
-
else {
|
|
63933
|
-
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
|
63934
|
-
}
|
|
63935
|
-
if (!headMessage && maybeSuppress) {
|
|
63936
|
-
lastSkippedInfo = [source, target];
|
|
63937
|
-
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63938
|
-
return result;
|
|
63939
|
-
}
|
|
63940
|
-
reportRelationError(headMessage, source, target);
|
|
63941
|
-
}
|
|
63965
|
+
if (!headMessage && maybeSuppress) {
|
|
63966
|
+
lastSkippedInfo = [source, target];
|
|
63967
|
+
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
|
63968
|
+
return;
|
|
63942
63969
|
}
|
|
63970
|
+
reportRelationError(headMessage, source, target);
|
|
63943
63971
|
}
|
|
63944
63972
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
63945
63973
|
if (!ts.tracing) {
|
|
@@ -63966,21 +63994,6 @@ var ts;
|
|
|
63966
63994
|
}
|
|
63967
63995
|
}
|
|
63968
63996
|
}
|
|
63969
|
-
function isIdenticalTo(source, target, recursionFlags) {
|
|
63970
|
-
if (source.flags !== target.flags)
|
|
63971
|
-
return 0 /* False */;
|
|
63972
|
-
if (source.flags & 67358815 /* Singleton */)
|
|
63973
|
-
return -1 /* True */;
|
|
63974
|
-
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63975
|
-
if (source.flags & 3145728 /* UnionOrIntersection */) {
|
|
63976
|
-
var result_7 = eachTypeRelatedToSomeType(source, target);
|
|
63977
|
-
if (result_7) {
|
|
63978
|
-
result_7 &= eachTypeRelatedToSomeType(target, source);
|
|
63979
|
-
}
|
|
63980
|
-
return result_7;
|
|
63981
|
-
}
|
|
63982
|
-
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
63983
|
-
}
|
|
63984
63997
|
function getTypeOfPropertyInTypes(types, name) {
|
|
63985
63998
|
var appendPropType = function (propTypes, type) {
|
|
63986
63999
|
var _a;
|
|
@@ -64079,6 +64092,41 @@ var ts;
|
|
|
64079
64092
|
function shouldCheckAsExcessProperty(prop, container) {
|
|
64080
64093
|
return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
|
|
64081
64094
|
}
|
|
64095
|
+
function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
|
|
64096
|
+
// Note that these checks are specifically ordered to produce correct results. In particular,
|
|
64097
|
+
// we need to deconstruct unions before intersections (because unions are always at the top),
|
|
64098
|
+
// and we need to handle "each" relations before "some" relations for the same kind of type.
|
|
64099
|
+
if (source.flags & 1048576 /* Union */) {
|
|
64100
|
+
return relation === comparableRelation ?
|
|
64101
|
+
someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
|
|
64102
|
+
eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
|
|
64103
|
+
}
|
|
64104
|
+
if (target.flags & 1048576 /* Union */) {
|
|
64105
|
+
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
64106
|
+
}
|
|
64107
|
+
if (target.flags & 2097152 /* Intersection */) {
|
|
64108
|
+
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
64109
|
+
}
|
|
64110
|
+
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
64111
|
+
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
64112
|
+
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
64113
|
+
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
64114
|
+
// appear to be comparable to '2'.
|
|
64115
|
+
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
64116
|
+
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
64117
|
+
if (constraints !== source.types) {
|
|
64118
|
+
source = getIntersectionType(constraints);
|
|
64119
|
+
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
64120
|
+
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
64121
|
+
}
|
|
64122
|
+
}
|
|
64123
|
+
}
|
|
64124
|
+
// Check to see if any constituents of the intersection are immediately related to the target.
|
|
64125
|
+
// Don't report errors though. Elaborating on whether a source constituent is related to the target is
|
|
64126
|
+
// not actually useful and leads to some confusing error messages. Instead, we rely on the caller
|
|
64127
|
+
// checking whether the full intersection viewed as an object is related to the target.
|
|
64128
|
+
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
64129
|
+
}
|
|
64082
64130
|
function eachTypeRelatedToSomeType(source, target) {
|
|
64083
64131
|
var result = -1 /* True */;
|
|
64084
64132
|
var sourceTypes = source.types;
|
|
@@ -64114,8 +64162,11 @@ var ts;
|
|
|
64114
64162
|
}
|
|
64115
64163
|
}
|
|
64116
64164
|
if (reportErrors) {
|
|
64165
|
+
// Elaborate only if we can find a best matching type in the target union
|
|
64117
64166
|
var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
|
|
64118
|
-
|
|
64167
|
+
if (bestMatchingType) {
|
|
64168
|
+
isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
|
|
64169
|
+
}
|
|
64119
64170
|
}
|
|
64120
64171
|
return 0 /* False */;
|
|
64121
64172
|
}
|
|
@@ -64251,7 +64302,7 @@ var ts;
|
|
|
64251
64302
|
if (overflow) {
|
|
64252
64303
|
return 0 /* False */;
|
|
64253
64304
|
}
|
|
64254
|
-
var keyIntersectionState = intersectionState | (inPropertyCheck ?
|
|
64305
|
+
var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
|
|
64255
64306
|
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
64256
64307
|
var entry = relation.get(id);
|
|
64257
64308
|
if (entry !== undefined) {
|
|
@@ -64319,6 +64370,7 @@ var ts;
|
|
|
64319
64370
|
return originalHandler(onlyUnreliable);
|
|
64320
64371
|
};
|
|
64321
64372
|
}
|
|
64373
|
+
var result;
|
|
64322
64374
|
if (expandingFlags === 3 /* Both */) {
|
|
64323
64375
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
|
|
64324
64376
|
sourceId: source.id,
|
|
@@ -64328,8 +64380,13 @@ var ts;
|
|
|
64328
64380
|
depth: sourceDepth,
|
|
64329
64381
|
targetDepth: targetDepth
|
|
64330
64382
|
});
|
|
64383
|
+
result = 3 /* Maybe */;
|
|
64384
|
+
}
|
|
64385
|
+
else {
|
|
64386
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64387
|
+
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
|
|
64388
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64331
64389
|
}
|
|
64332
|
-
var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
|
|
64333
64390
|
if (outofbandVarianceMarkerHandler) {
|
|
64334
64391
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
64335
64392
|
}
|
|
@@ -64361,98 +64418,97 @@ var ts;
|
|
|
64361
64418
|
return result;
|
|
64362
64419
|
}
|
|
64363
64420
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
64364
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
|
|
64365
|
-
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
|
|
64366
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
64367
|
-
return result;
|
|
64368
|
-
}
|
|
64369
|
-
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
|
|
64370
64421
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
64371
64422
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
64372
64423
|
}
|
|
64373
|
-
|
|
64374
|
-
|
|
64375
|
-
|
|
64376
|
-
|
|
64377
|
-
|
|
64378
|
-
|
|
64379
|
-
|
|
64380
|
-
|
|
64381
|
-
|
|
64382
|
-
|
|
64383
|
-
|
|
64384
|
-
|
|
64385
|
-
if (target.flags & 2097152 /* Intersection */) {
|
|
64386
|
-
return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
|
|
64387
|
-
}
|
|
64388
|
-
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
64389
|
-
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
64390
|
-
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
|
|
64391
|
-
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
|
|
64392
|
-
// appear to be comparable to '2'.
|
|
64393
|
-
if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
|
|
64394
|
-
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
|
|
64395
|
-
if (constraints !== source.types) {
|
|
64396
|
-
source = getIntersectionType(constraints);
|
|
64397
|
-
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
64398
|
-
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
64399
|
-
}
|
|
64424
|
+
var result;
|
|
64425
|
+
var originalErrorInfo;
|
|
64426
|
+
var varianceCheckFailed = false;
|
|
64427
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
64428
|
+
var sourceFlags = source.flags;
|
|
64429
|
+
var targetFlags = target.flags;
|
|
64430
|
+
if (relation === identityRelation) {
|
|
64431
|
+
// We've already checked that source.flags and target.flags are identical
|
|
64432
|
+
if (sourceFlags & 3145728 /* UnionOrIntersection */) {
|
|
64433
|
+
var result_8 = eachTypeRelatedToSomeType(source, target);
|
|
64434
|
+
if (result_8) {
|
|
64435
|
+
result_8 &= eachTypeRelatedToSomeType(target, source);
|
|
64400
64436
|
}
|
|
64437
|
+
return result_8;
|
|
64401
64438
|
}
|
|
64402
|
-
|
|
64403
|
-
//
|
|
64404
|
-
// Don't report errors though. Checking whether a constituent is related to the source is not actually
|
|
64405
|
-
// useful and leads to some confusing error messages. Instead it is better to let the below checks
|
|
64406
|
-
// take care of this, or to not elaborate at all. For instance,
|
|
64407
|
-
//
|
|
64408
|
-
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
|
|
64409
|
-
//
|
|
64410
|
-
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
|
|
64411
|
-
// than to report that 'D' is not assignable to 'A' or 'B'.
|
|
64412
|
-
//
|
|
64413
|
-
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
|
|
64414
|
-
// breaking the intersection apart.
|
|
64415
|
-
return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
|
|
64416
|
-
}
|
|
64417
|
-
var flags = source.flags & target.flags;
|
|
64418
|
-
if (relation === identityRelation && !(flags & 524288 /* Object */)) {
|
|
64419
|
-
if (flags & 4194304 /* Index */) {
|
|
64439
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64420
64440
|
return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
|
|
64421
64441
|
}
|
|
64422
|
-
|
|
64423
|
-
|
|
64424
|
-
|
|
64425
|
-
|
|
64426
|
-
return result_8;
|
|
64442
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64443
|
+
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64444
|
+
if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64445
|
+
return result;
|
|
64427
64446
|
}
|
|
64428
64447
|
}
|
|
64429
64448
|
}
|
|
64430
|
-
if (
|
|
64449
|
+
if (sourceFlags & 16777216 /* Conditional */) {
|
|
64431
64450
|
if (source.root.isDistributive === target.root.isDistributive) {
|
|
64432
|
-
if (
|
|
64433
|
-
if (
|
|
64434
|
-
if (
|
|
64435
|
-
if (
|
|
64436
|
-
return
|
|
64451
|
+
if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64452
|
+
if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64453
|
+
if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64454
|
+
if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
64455
|
+
return result;
|
|
64437
64456
|
}
|
|
64438
64457
|
}
|
|
64439
64458
|
}
|
|
64440
64459
|
}
|
|
64441
64460
|
}
|
|
64442
64461
|
}
|
|
64443
|
-
if (
|
|
64462
|
+
if (sourceFlags & 33554432 /* Substitution */) {
|
|
64444
64463
|
return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
|
|
64445
64464
|
}
|
|
64446
|
-
|
|
64465
|
+
if (!(sourceFlags & 524288 /* Object */)) {
|
|
64466
|
+
return 0 /* False */;
|
|
64467
|
+
}
|
|
64468
|
+
}
|
|
64469
|
+
else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
|
|
64470
|
+
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
64471
|
+
return result;
|
|
64472
|
+
}
|
|
64473
|
+
if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
|
|
64474
|
+
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
64475
|
+
// the constituents. When an intersection type contains instantiable types with union type
|
|
64476
|
+
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
64477
|
+
// when the target is a union type. Another is when the intersection contains types belonging
|
|
64478
|
+
// to one of the disjoint domains. For example, given type variables T and U, each with the
|
|
64479
|
+
// constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
|
|
64480
|
+
// we need to check this constraint against a union on the target side. Also, given a type
|
|
64481
|
+
// variable V constrained to 'string | number', 'V & number' has a combined constraint of
|
|
64482
|
+
// 'string & number | number & number' which reduces to just 'number'.
|
|
64483
|
+
// This also handles type parameters, as a type parameter with a union constraint compared against a union
|
|
64484
|
+
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
64485
|
+
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
64486
|
+
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
64487
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
|
|
64488
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
64489
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
64490
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
64491
|
+
resetErrorInfo(saveErrorInfo);
|
|
64492
|
+
return result;
|
|
64493
|
+
}
|
|
64494
|
+
}
|
|
64495
|
+
}
|
|
64496
|
+
// The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
|
|
64497
|
+
// Source is instantiable (e.g. source has union or intersection constraint).
|
|
64498
|
+
// Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64499
|
+
// Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
|
|
64500
|
+
// Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
|
|
64501
|
+
// Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
|
|
64502
|
+
if (!(sourceFlags & 465829888 /* Instantiable */ ||
|
|
64503
|
+
sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
|
|
64504
|
+
sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
|
|
64505
|
+
return 0 /* False */;
|
|
64506
|
+
}
|
|
64447
64507
|
}
|
|
64448
|
-
var result;
|
|
64449
|
-
var originalErrorInfo;
|
|
64450
|
-
var varianceCheckFailed = false;
|
|
64451
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
64452
64508
|
// We limit alias variance probing to only object and conditional types since their alias behavior
|
|
64453
64509
|
// is more predictable than other, interned types, which may or may not have an alias depending on
|
|
64454
64510
|
// the order in which things were checked.
|
|
64455
|
-
if (
|
|
64511
|
+
if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
|
|
64456
64512
|
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
|
|
64457
64513
|
!(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
|
|
64458
64514
|
var variances = getAliasVariances(source.aliasSymbol);
|
|
@@ -64470,7 +64526,7 @@ var ts;
|
|
|
64470
64526
|
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
|
|
64471
64527
|
return result;
|
|
64472
64528
|
}
|
|
64473
|
-
if (
|
|
64529
|
+
if (targetFlags & 262144 /* TypeParameter */) {
|
|
64474
64530
|
// A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q].
|
|
64475
64531
|
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
|
|
64476
64532
|
if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
|
|
@@ -64482,10 +64538,10 @@ var ts;
|
|
|
64482
64538
|
}
|
|
64483
64539
|
}
|
|
64484
64540
|
}
|
|
64485
|
-
else if (
|
|
64541
|
+
else if (targetFlags & 4194304 /* Index */) {
|
|
64486
64542
|
var targetType_1 = target.type;
|
|
64487
64543
|
// A keyof S is related to a keyof T if T is related to S.
|
|
64488
|
-
if (
|
|
64544
|
+
if (sourceFlags & 4194304 /* Index */) {
|
|
64489
64545
|
if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
|
|
64490
64546
|
return result;
|
|
64491
64547
|
}
|
|
@@ -64536,8 +64592,8 @@ var ts;
|
|
|
64536
64592
|
}
|
|
64537
64593
|
}
|
|
64538
64594
|
}
|
|
64539
|
-
else if (
|
|
64540
|
-
if (
|
|
64595
|
+
else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
64596
|
+
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64541
64597
|
// Relate components directly before falling back to constraint relationships
|
|
64542
64598
|
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
|
|
64543
64599
|
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
|
|
@@ -64643,7 +64699,7 @@ var ts;
|
|
|
64643
64699
|
}
|
|
64644
64700
|
}
|
|
64645
64701
|
}
|
|
64646
|
-
else if (
|
|
64702
|
+
else if (targetFlags & 16777216 /* Conditional */) {
|
|
64647
64703
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64648
64704
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64649
64705
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
@@ -64668,8 +64724,8 @@ var ts;
|
|
|
64668
64724
|
}
|
|
64669
64725
|
}
|
|
64670
64726
|
}
|
|
64671
|
-
else if (
|
|
64672
|
-
if (
|
|
64727
|
+
else if (targetFlags & 134217728 /* TemplateLiteral */) {
|
|
64728
|
+
if (sourceFlags & 134217728 /* TemplateLiteral */) {
|
|
64673
64729
|
if (relation === comparableRelation) {
|
|
64674
64730
|
return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
|
|
64675
64731
|
}
|
|
@@ -64681,11 +64737,11 @@ var ts;
|
|
|
64681
64737
|
return -1 /* True */;
|
|
64682
64738
|
}
|
|
64683
64739
|
}
|
|
64684
|
-
if (
|
|
64685
|
-
// IndexedAccess comparisons are handled above in the `
|
|
64686
|
-
if (!(
|
|
64740
|
+
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
64741
|
+
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
64742
|
+
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
64687
64743
|
var constraint = getConstraintOfType(source);
|
|
64688
|
-
if (!constraint || (
|
|
64744
|
+
if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
64689
64745
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
64690
64746
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
64691
64747
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64698,7 +64754,7 @@ var ts;
|
|
|
64698
64754
|
return result;
|
|
64699
64755
|
}
|
|
64700
64756
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
64701
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(
|
|
64757
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
64702
64758
|
resetErrorInfo(saveErrorInfo);
|
|
64703
64759
|
return result;
|
|
64704
64760
|
}
|
|
@@ -64715,14 +64771,14 @@ var ts;
|
|
|
64715
64771
|
}
|
|
64716
64772
|
}
|
|
64717
64773
|
}
|
|
64718
|
-
else if (
|
|
64774
|
+
else if (sourceFlags & 4194304 /* Index */) {
|
|
64719
64775
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
64720
64776
|
resetErrorInfo(saveErrorInfo);
|
|
64721
64777
|
return result;
|
|
64722
64778
|
}
|
|
64723
64779
|
}
|
|
64724
|
-
else if (
|
|
64725
|
-
if (!(
|
|
64780
|
+
else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
64781
|
+
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
64726
64782
|
var constraint = getBaseConstraintOfType(source);
|
|
64727
64783
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
64728
64784
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64730,8 +64786,8 @@ var ts;
|
|
|
64730
64786
|
}
|
|
64731
64787
|
}
|
|
64732
64788
|
}
|
|
64733
|
-
else if (
|
|
64734
|
-
if (
|
|
64789
|
+
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
64790
|
+
if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
|
|
64735
64791
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
64736
64792
|
resetErrorInfo(saveErrorInfo);
|
|
64737
64793
|
return result;
|
|
@@ -64745,14 +64801,14 @@ var ts;
|
|
|
64745
64801
|
}
|
|
64746
64802
|
}
|
|
64747
64803
|
}
|
|
64748
|
-
else if (
|
|
64804
|
+
else if (sourceFlags & 16777216 /* Conditional */) {
|
|
64749
64805
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
64750
64806
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
64751
64807
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
64752
64808
|
resetErrorInfo(saveErrorInfo);
|
|
64753
64809
|
return 3 /* Maybe */;
|
|
64754
64810
|
}
|
|
64755
|
-
if (
|
|
64811
|
+
if (targetFlags & 16777216 /* Conditional */) {
|
|
64756
64812
|
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
|
|
64757
64813
|
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
|
|
64758
64814
|
// and Y1 is related to Y2.
|
|
@@ -64812,9 +64868,10 @@ var ts;
|
|
|
64812
64868
|
}
|
|
64813
64869
|
return 0 /* False */;
|
|
64814
64870
|
}
|
|
64815
|
-
var sourceIsPrimitive = !!(
|
|
64871
|
+
var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
|
|
64816
64872
|
if (relation !== identityRelation) {
|
|
64817
64873
|
source = getApparentType(source);
|
|
64874
|
+
sourceFlags = source.flags;
|
|
64818
64875
|
}
|
|
64819
64876
|
else if (isGenericMappedType(source)) {
|
|
64820
64877
|
return 0 /* False */;
|
|
@@ -64861,7 +64918,7 @@ var ts;
|
|
|
64861
64918
|
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
|
|
64862
64919
|
// to X. Failing both of those we want to check if the aggregation of A and B's members structurally
|
|
64863
64920
|
// relates to X. Thus, we include intersection types on the source side here.
|
|
64864
|
-
if (
|
|
64921
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
|
|
64865
64922
|
// Report structural errors only if we haven't reported any errors yet
|
|
64866
64923
|
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
|
|
64867
64924
|
result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
|
|
@@ -64885,7 +64942,7 @@ var ts;
|
|
|
64885
64942
|
// there exists a constituent of T for every combination of the discriminants of S
|
|
64886
64943
|
// with respect to T. We do not report errors here, as we will use the existing
|
|
64887
64944
|
// error result from checking each constituent of the union.
|
|
64888
|
-
if (
|
|
64945
|
+
if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
|
|
64889
64946
|
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
|
|
64890
64947
|
if (objectOnlyTarget.flags & 1048576 /* Union */) {
|
|
64891
64948
|
var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
|
|
@@ -65409,7 +65466,6 @@ var ts;
|
|
|
65409
65466
|
}
|
|
65410
65467
|
}
|
|
65411
65468
|
var result = -1 /* True */;
|
|
65412
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
65413
65469
|
var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
|
|
65414
65470
|
var sourceObjectFlags = ts.getObjectFlags(source);
|
|
65415
65471
|
var targetObjectFlags = ts.getObjectFlags(target);
|
|
@@ -65450,6 +65506,7 @@ var ts;
|
|
|
65450
65506
|
else {
|
|
65451
65507
|
outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
|
|
65452
65508
|
var t = targetSignatures_1[_i];
|
|
65509
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
65453
65510
|
// Only elaborate errors from the first failure
|
|
65454
65511
|
var shouldElaborateErrors = reportErrors;
|
|
65455
65512
|
for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
|
|
@@ -68620,9 +68677,6 @@ var ts;
|
|
|
68620
68677
|
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
|
|
68621
68678
|
mapType(type, mapper);
|
|
68622
68679
|
}
|
|
68623
|
-
function getConstituentCount(type) {
|
|
68624
|
-
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
68625
|
-
}
|
|
68626
68680
|
function extractTypesOfKind(type, kind) {
|
|
68627
68681
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
68628
68682
|
}
|
|
@@ -73343,6 +73397,9 @@ var ts;
|
|
|
73343
73397
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
73344
73398
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
73345
73399
|
}
|
|
73400
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
|
|
73401
|
+
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
73402
|
+
}
|
|
73346
73403
|
}
|
|
73347
73404
|
else {
|
|
73348
73405
|
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
|
|
@@ -76288,21 +76345,22 @@ var ts;
|
|
|
76288
76345
|
if (links.type === unknownType) {
|
|
76289
76346
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
76290
76347
|
}
|
|
76291
|
-
assignBindingElementTypes(declaration.name);
|
|
76348
|
+
assignBindingElementTypes(declaration.name, links.type);
|
|
76292
76349
|
}
|
|
76293
76350
|
}
|
|
76294
76351
|
}
|
|
76295
76352
|
// When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
|
|
76296
76353
|
// the destructured type into the contained binding elements.
|
|
76297
|
-
function assignBindingElementTypes(pattern) {
|
|
76354
|
+
function assignBindingElementTypes(pattern, parentType) {
|
|
76298
76355
|
for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
|
|
76299
76356
|
var element = _a[_i];
|
|
76300
76357
|
if (!ts.isOmittedExpression(element)) {
|
|
76358
|
+
var type = getBindingElementTypeFromParentType(element, parentType);
|
|
76301
76359
|
if (element.name.kind === 79 /* Identifier */) {
|
|
76302
|
-
getSymbolLinks(getSymbolOfNode(element)).type =
|
|
76360
|
+
getSymbolLinks(getSymbolOfNode(element)).type = type;
|
|
76303
76361
|
}
|
|
76304
76362
|
else {
|
|
76305
|
-
assignBindingElementTypes(element.name);
|
|
76363
|
+
assignBindingElementTypes(element.name, type);
|
|
76306
76364
|
}
|
|
76307
76365
|
}
|
|
76308
76366
|
}
|
|
@@ -80043,28 +80101,24 @@ var ts;
|
|
|
80043
80101
|
if (returnType.flags & 1 /* Any */) {
|
|
80044
80102
|
return;
|
|
80045
80103
|
}
|
|
80104
|
+
var headMessage;
|
|
80046
80105
|
var expectedReturnType;
|
|
80047
|
-
var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
|
80048
|
-
var errorInfo;
|
|
80049
80106
|
switch (node.parent.kind) {
|
|
80050
80107
|
case 256 /* ClassDeclaration */:
|
|
80108
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
80051
80109
|
var classSymbol = getSymbolOfNode(node.parent);
|
|
80052
80110
|
var classConstructorType = getTypeOfSymbol(classSymbol);
|
|
80053
80111
|
expectedReturnType = getUnionType([classConstructorType, voidType]);
|
|
80054
80112
|
break;
|
|
80055
|
-
case 163 /* Parameter */:
|
|
80056
|
-
expectedReturnType = voidType;
|
|
80057
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
80058
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
|
|
80059
|
-
break;
|
|
80060
80113
|
case 166 /* PropertyDeclaration */:
|
|
80114
|
+
case 163 /* Parameter */:
|
|
80115
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
|
|
80061
80116
|
expectedReturnType = voidType;
|
|
80062
|
-
errorInfo = ts.chainDiagnosticMessages(
|
|
80063
|
-
/*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
|
|
80064
80117
|
break;
|
|
80065
80118
|
case 168 /* MethodDeclaration */:
|
|
80066
80119
|
case 171 /* GetAccessor */:
|
|
80067
80120
|
case 172 /* SetAccessor */:
|
|
80121
|
+
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
|
|
80068
80122
|
var methodType = getTypeOfNode(node.parent);
|
|
80069
80123
|
var descriptorType = createTypedPropertyDescriptorType(methodType);
|
|
80070
80124
|
expectedReturnType = getUnionType([descriptorType, voidType]);
|
|
@@ -80072,7 +80126,7 @@ var ts;
|
|
|
80072
80126
|
default:
|
|
80073
80127
|
return ts.Debug.fail();
|
|
80074
80128
|
}
|
|
80075
|
-
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage
|
|
80129
|
+
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
|
|
80076
80130
|
}
|
|
80077
80131
|
/**
|
|
80078
80132
|
* If a TypeNode can be resolved to a value symbol imported from an external module, it is
|
|
@@ -85620,7 +85674,7 @@ var ts;
|
|
|
85620
85674
|
if (resolvedTypeReferenceDirectives) {
|
|
85621
85675
|
// populate reverse mapping: file path -> type reference directive that was resolved to this file
|
|
85622
85676
|
fileToDirective = new ts.Map();
|
|
85623
|
-
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
|
|
85677
|
+
resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
|
|
85624
85678
|
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
|
|
85625
85679
|
return;
|
|
85626
85680
|
}
|
|
@@ -85628,7 +85682,7 @@ var ts;
|
|
|
85628
85682
|
if (file) {
|
|
85629
85683
|
// Add the transitive closure of path references loaded by this file (as long as they are not)
|
|
85630
85684
|
// part of an existing type reference.
|
|
85631
|
-
addReferencedFilesToTypeDirective(file, key);
|
|
85685
|
+
addReferencedFilesToTypeDirective(file, key, mode);
|
|
85632
85686
|
}
|
|
85633
85687
|
});
|
|
85634
85688
|
}
|
|
@@ -85822,16 +85876,16 @@ var ts;
|
|
|
85822
85876
|
}
|
|
85823
85877
|
return false;
|
|
85824
85878
|
}
|
|
85825
|
-
function addReferencedFilesToTypeDirective(file, key) {
|
|
85879
|
+
function addReferencedFilesToTypeDirective(file, key, mode) {
|
|
85826
85880
|
if (fileToDirective.has(file.path))
|
|
85827
85881
|
return;
|
|
85828
|
-
fileToDirective.set(file.path, key);
|
|
85882
|
+
fileToDirective.set(file.path, [key, mode]);
|
|
85829
85883
|
for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
|
|
85830
|
-
var
|
|
85884
|
+
var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
|
|
85831
85885
|
var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
|
|
85832
85886
|
var referencedFile = host.getSourceFile(resolvedFile);
|
|
85833
85887
|
if (referencedFile) {
|
|
85834
|
-
addReferencedFilesToTypeDirective(referencedFile, key);
|
|
85888
|
+
addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
|
|
85835
85889
|
}
|
|
85836
85890
|
}
|
|
85837
85891
|
}
|
|
@@ -87536,28 +87590,27 @@ var ts;
|
|
|
87536
87590
|
}
|
|
87537
87591
|
function findMostOverlappyType(source, unionTarget) {
|
|
87538
87592
|
var bestMatch;
|
|
87539
|
-
|
|
87540
|
-
|
|
87541
|
-
var
|
|
87542
|
-
|
|
87543
|
-
|
|
87544
|
-
|
|
87545
|
-
|
|
87546
|
-
|
|
87547
|
-
|
|
87548
|
-
|
|
87549
|
-
|
|
87550
|
-
|
|
87551
|
-
|
|
87552
|
-
|
|
87553
|
-
|
|
87554
|
-
|
|
87555
|
-
|
|
87556
|
-
|
|
87557
|
-
|
|
87558
|
-
|
|
87559
|
-
|
|
87560
|
-
matchingCount = 1;
|
|
87593
|
+
if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87594
|
+
var matchingCount = 0;
|
|
87595
|
+
for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
|
|
87596
|
+
var target = _a[_i];
|
|
87597
|
+
if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
|
|
87598
|
+
var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
|
|
87599
|
+
if (overlap.flags & 4194304 /* Index */) {
|
|
87600
|
+
// perfect overlap of keys
|
|
87601
|
+
return target;
|
|
87602
|
+
}
|
|
87603
|
+
else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
|
|
87604
|
+
// We only want to account for literal types otherwise.
|
|
87605
|
+
// If we have a union of index types, it seems likely that we
|
|
87606
|
+
// needed to elaborate between two generic mapped types anyway.
|
|
87607
|
+
var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
|
|
87608
|
+
if (len >= matchingCount) {
|
|
87609
|
+
bestMatch = target;
|
|
87610
|
+
matchingCount = len;
|
|
87611
|
+
}
|
|
87612
|
+
}
|
|
87613
|
+
}
|
|
87561
87614
|
}
|
|
87562
87615
|
}
|
|
87563
87616
|
return bestMatch;
|
|
@@ -106600,7 +106653,7 @@ var ts;
|
|
|
106600
106653
|
var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
|
|
106601
106654
|
hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
|
|
106602
106655
|
collectReferences(sourceFile, refs);
|
|
106603
|
-
recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
|
|
106656
|
+
recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
|
|
106604
106657
|
collectLibs(sourceFile, libs);
|
|
106605
106658
|
return sourceFile;
|
|
106606
106659
|
}
|
|
@@ -106655,9 +106708,10 @@ var ts;
|
|
|
106655
106708
|
return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
|
|
106656
106709
|
}
|
|
106657
106710
|
function getFileReferencesForUsedTypeReferences() {
|
|
106658
|
-
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()),
|
|
106711
|
+
return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
|
|
106659
106712
|
}
|
|
106660
|
-
function
|
|
106713
|
+
function getFileReferenceForSpecifierModeTuple(_a) {
|
|
106714
|
+
var typeName = _a[0], mode = _a[1];
|
|
106661
106715
|
// Elide type references for which we have imports
|
|
106662
106716
|
if (emittedImports) {
|
|
106663
106717
|
for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
|
|
@@ -106673,7 +106727,7 @@ var ts;
|
|
|
106673
106727
|
}
|
|
106674
106728
|
}
|
|
106675
106729
|
}
|
|
106676
|
-
return { fileName: typeName, pos: -1, end: -1 };
|
|
106730
|
+
return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
|
|
106677
106731
|
}
|
|
106678
106732
|
function mapReferencesIntoArray(references, outputFilePath) {
|
|
106679
106733
|
return function (file) {
|
|
@@ -106693,7 +106747,7 @@ var ts;
|
|
|
106693
106747
|
// If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration
|
|
106694
106748
|
// via a non-relative name, emit a type reference directive to that non-relative name, rather than
|
|
106695
106749
|
// a relative path to the declaration file
|
|
106696
|
-
recordTypeReferenceDirectivesIfNecessary([specifier]);
|
|
106750
|
+
recordTypeReferenceDirectivesIfNecessary([[specifier, /*mode*/ undefined]]);
|
|
106697
106751
|
return;
|
|
106698
106752
|
}
|
|
106699
106753
|
var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName,
|
|
@@ -111805,9 +111859,12 @@ var ts;
|
|
|
111805
111859
|
for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
|
|
111806
111860
|
var directive = types_24[_d];
|
|
111807
111861
|
var pos = writer.getTextPos();
|
|
111808
|
-
|
|
111862
|
+
var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
|
|
111863
|
+
? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
|
|
111864
|
+
: "";
|
|
111865
|
+
writeComment("/// <reference types=\"" + directive.fileName + "\" " + resolutionMode + "/>");
|
|
111809
111866
|
if (bundleFileInfo)
|
|
111810
|
-
bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName });
|
|
111867
|
+
bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName });
|
|
111811
111868
|
writeLine();
|
|
111812
111869
|
}
|
|
111813
111870
|
for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
|
|
@@ -114414,7 +114471,7 @@ var ts;
|
|
|
114414
114471
|
}
|
|
114415
114472
|
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
|
|
114416
114473
|
/* @internal */
|
|
114417
|
-
function
|
|
114474
|
+
function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
|
|
114418
114475
|
if (names.length === 0) {
|
|
114419
114476
|
return [];
|
|
114420
114477
|
}
|
|
@@ -114423,19 +114480,28 @@ var ts;
|
|
|
114423
114480
|
for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
|
|
114424
114481
|
var name = names_2[_i];
|
|
114425
114482
|
var result = void 0;
|
|
114426
|
-
|
|
114427
|
-
|
|
114483
|
+
var mode = getModeForFileReference(name, containingFileMode);
|
|
114484
|
+
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
|
|
114485
|
+
var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
|
|
114486
|
+
var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
|
|
114487
|
+
if (cache.has(cacheKey)) {
|
|
114488
|
+
result = cache.get(cacheKey);
|
|
114428
114489
|
}
|
|
114429
114490
|
else {
|
|
114430
|
-
cache.set(
|
|
114491
|
+
cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
|
|
114431
114492
|
}
|
|
114432
114493
|
resolutions.push(result);
|
|
114433
114494
|
}
|
|
114434
114495
|
return resolutions;
|
|
114435
114496
|
}
|
|
114436
|
-
ts.
|
|
114497
|
+
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
114437
114498
|
;
|
|
114438
114499
|
/* @internal */
|
|
114500
|
+
function getModeForFileReference(ref, containingFileMode) {
|
|
114501
|
+
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
114502
|
+
}
|
|
114503
|
+
ts.getModeForFileReference = getModeForFileReference;
|
|
114504
|
+
/* @internal */
|
|
114439
114505
|
function getModeForResolutionAtIndex(file, index) {
|
|
114440
114506
|
if (file.impliedNodeFormat === undefined)
|
|
114441
114507
|
return undefined;
|
|
@@ -114538,7 +114604,7 @@ var ts;
|
|
|
114538
114604
|
var _d, _e, _f, _g;
|
|
114539
114605
|
var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
|
|
114540
114606
|
var kind = ref.kind, index = ref.index;
|
|
114541
|
-
var pos, end, packageId;
|
|
114607
|
+
var pos, end, packageId, resolutionMode;
|
|
114542
114608
|
switch (kind) {
|
|
114543
114609
|
case ts.FileIncludeKind.Import:
|
|
114544
114610
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
@@ -114552,8 +114618,8 @@ var ts;
|
|
|
114552
114618
|
(_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
|
|
114553
114619
|
break;
|
|
114554
114620
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
114555
|
-
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
114556
|
-
packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
|
|
114621
|
+
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
|
|
114622
|
+
packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
|
|
114557
114623
|
break;
|
|
114558
114624
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
114559
114625
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -114797,7 +114863,7 @@ var ts;
|
|
|
114797
114863
|
var fileReasons = ts.createMultiMap();
|
|
114798
114864
|
var cachedBindAndCheckDiagnosticsForFile = {};
|
|
114799
114865
|
var cachedDeclarationDiagnosticsForFile = {};
|
|
114800
|
-
var resolvedTypeReferenceDirectives =
|
|
114866
|
+
var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
|
|
114801
114867
|
var fileProcessingDiagnostics;
|
|
114802
114868
|
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
|
|
114803
114869
|
// This works as imported modules are discovered recursively in a depth first manner, specifically:
|
|
@@ -114850,12 +114916,12 @@ var ts;
|
|
|
114850
114916
|
}
|
|
114851
114917
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
114852
114918
|
if (host.resolveTypeReferenceDirectives) {
|
|
114853
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
|
|
114919
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
|
|
114854
114920
|
}
|
|
114855
114921
|
else {
|
|
114856
114922
|
typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
114857
|
-
var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114858
|
-
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return
|
|
114923
|
+
var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
|
|
114924
|
+
actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
|
|
114859
114925
|
}
|
|
114860
114926
|
// Map from a stringified PackageId to the source file with that id.
|
|
114861
114927
|
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
|
|
@@ -114952,7 +115018,8 @@ var ts;
|
|
|
114952
115018
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
114953
115019
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
114954
115020
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
114955
|
-
|
|
115021
|
+
// under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
|
|
115022
|
+
processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
|
|
114956
115023
|
}
|
|
114957
115024
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
114958
115025
|
}
|
|
@@ -115112,9 +115179,10 @@ var ts;
|
|
|
115112
115179
|
return [];
|
|
115113
115180
|
var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
|
|
115114
115181
|
var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
|
|
115182
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
115115
115183
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
|
|
115116
115184
|
ts.performance.mark("beforeResolveTypeReference");
|
|
115117
|
-
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
|
|
115185
|
+
var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
|
|
115118
115186
|
ts.performance.mark("afterResolveTypeReference");
|
|
115119
115187
|
ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
|
|
115120
115188
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -115506,8 +115574,7 @@ var ts;
|
|
|
115506
115574
|
else {
|
|
115507
115575
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
115508
115576
|
}
|
|
115509
|
-
|
|
115510
|
-
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
115577
|
+
var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
|
115511
115578
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
115512
115579
|
// ensure that types resolutions are still correct
|
|
115513
115580
|
var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
@@ -116586,8 +116653,7 @@ var ts;
|
|
|
116586
116653
|
});
|
|
116587
116654
|
}
|
|
116588
116655
|
function processTypeReferenceDirectives(file) {
|
|
116589
|
-
|
|
116590
|
-
var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
116656
|
+
var typeDirectives = file.typeReferenceDirectives;
|
|
116591
116657
|
if (!typeDirectives) {
|
|
116592
116658
|
return;
|
|
116593
116659
|
}
|
|
@@ -116598,17 +116664,21 @@ var ts;
|
|
|
116598
116664
|
// store resolved type directive on the file
|
|
116599
116665
|
var fileName = ts.toFileNameLowerCase(ref.fileName);
|
|
116600
116666
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
116601
|
-
|
|
116667
|
+
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
116668
|
+
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
116669
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext));
|
|
116670
|
+
}
|
|
116671
|
+
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
116602
116672
|
}
|
|
116603
116673
|
}
|
|
116604
|
-
function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116674
|
+
function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116605
116675
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
|
|
116606
|
-
processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
|
|
116676
|
+
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
|
|
116607
116677
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116608
116678
|
}
|
|
116609
|
-
function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
|
|
116679
|
+
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
|
|
116610
116680
|
// If we already found this library as a primary reference - nothing to do
|
|
116611
|
-
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
|
|
116681
|
+
var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
|
|
116612
116682
|
if (previousResolution && previousResolution.primary) {
|
|
116613
116683
|
return;
|
|
116614
116684
|
}
|
|
@@ -116647,7 +116717,7 @@ var ts;
|
|
|
116647
116717
|
addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
|
|
116648
116718
|
}
|
|
116649
116719
|
if (saveResolution) {
|
|
116650
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
|
|
116720
|
+
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
|
|
116651
116721
|
}
|
|
116652
116722
|
}
|
|
116653
116723
|
function pathForLibFile(libFileName) {
|
|
@@ -119465,9 +119535,9 @@ var ts;
|
|
|
119465
119535
|
});
|
|
119466
119536
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
119467
119537
|
}
|
|
119468
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
|
|
119538
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
|
|
119469
119539
|
var _a;
|
|
119470
|
-
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
|
|
119540
|
+
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
|
|
119471
119541
|
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
|
|
119472
119542
|
if (!resolutionHost.getGlobalCache) {
|
|
119473
119543
|
return primaryResult;
|
|
@@ -119488,12 +119558,12 @@ var ts;
|
|
|
119488
119558
|
// Default return the result from the first pass
|
|
119489
119559
|
return primaryResult;
|
|
119490
119560
|
}
|
|
119491
|
-
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
|
|
119492
|
-
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
|
|
119561
|
+
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
|
|
119562
|
+
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
|
|
119493
119563
|
}
|
|
119494
119564
|
function resolveNamesWithLocalCache(_a) {
|
|
119495
119565
|
var _b, _c, _d;
|
|
119496
|
-
var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile;
|
|
119566
|
+
var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
|
|
119497
119567
|
var path = resolutionHost.toPath(containingFile);
|
|
119498
119568
|
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
119499
119569
|
var dirPath = ts.getDirectoryPath(path);
|
|
@@ -119515,8 +119585,15 @@ var ts;
|
|
|
119515
119585
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
119516
119586
|
var i = 0;
|
|
119517
119587
|
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
119518
|
-
var
|
|
119519
|
-
var
|
|
119588
|
+
var entry = names_4[_i];
|
|
119589
|
+
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
119590
|
+
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
119591
|
+
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
119592
|
+
// import's syntax may override the file's default mode.
|
|
119593
|
+
// Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
|
|
119594
|
+
// a default file mode override if applicable.
|
|
119595
|
+
var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
|
|
119596
|
+
containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
119520
119597
|
i++;
|
|
119521
119598
|
var resolution = resolutionsInFile.get(name, mode);
|
|
119522
119599
|
// Resolution is valid if it is present and not invalidated
|
|
@@ -119545,7 +119622,7 @@ var ts;
|
|
|
119545
119622
|
}
|
|
119546
119623
|
}
|
|
119547
119624
|
else {
|
|
119548
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
119625
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
119549
119626
|
perDirectoryResolution.set(name, mode, resolution);
|
|
119550
119627
|
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
119551
119628
|
resolutionHost.onDiscoveredSymlink();
|
|
@@ -119609,7 +119686,7 @@ var ts;
|
|
|
119609
119686
|
return oldResult.resolvedFileName === newResult.resolvedFileName;
|
|
119610
119687
|
}
|
|
119611
119688
|
}
|
|
119612
|
-
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
|
|
119689
|
+
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
|
|
119613
119690
|
return resolveNamesWithLocalCache({
|
|
119614
119691
|
names: typeDirectiveNames,
|
|
119615
119692
|
containingFile: containingFile,
|
|
@@ -119619,6 +119696,7 @@ var ts;
|
|
|
119619
119696
|
loader: resolveTypeReferenceDirective,
|
|
119620
119697
|
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
|
|
119621
119698
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
119699
|
+
containingSourceFileMode: containingFileMode
|
|
119622
119700
|
});
|
|
119623
119701
|
}
|
|
119624
119702
|
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
@@ -121527,7 +121605,7 @@ var ts;
|
|
|
121527
121605
|
}
|
|
121528
121606
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
121529
121607
|
}) :
|
|
121530
|
-
(function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
|
|
121608
|
+
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
121531
121609
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
121532
121610
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
121533
121611
|
synchronizeProgram();
|
|
@@ -122263,9 +122341,9 @@ var ts;
|
|
|
122263
122341
|
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
122264
122342
|
}
|
|
122265
122343
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
122266
|
-
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|
|
122267
|
-
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
|
|
122268
|
-
return ts.
|
|
122344
|
+
var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
|
|
122345
|
+
compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
|
|
122346
|
+
return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
|
|
122269
122347
|
};
|
|
122270
122348
|
}
|
|
122271
122349
|
var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
|
|
@@ -131233,14 +131311,15 @@ var ts;
|
|
|
131233
131311
|
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
|
|
131234
131312
|
return { kind: 1 /* JsDocTagName */ };
|
|
131235
131313
|
}
|
|
131236
|
-
|
|
131314
|
+
var typeExpression = tryGetTypeExpressionFromTag(tag);
|
|
131315
|
+
if (typeExpression) {
|
|
131237
131316
|
currentToken = ts.getTokenAtPosition(sourceFile, position);
|
|
131238
131317
|
if (!currentToken ||
|
|
131239
131318
|
(!ts.isDeclarationName(currentToken) &&
|
|
131240
131319
|
(currentToken.parent.kind !== 345 /* JSDocPropertyTag */ ||
|
|
131241
131320
|
currentToken.parent.name !== currentToken))) {
|
|
131242
131321
|
// Use as type location if inside tag's type expression
|
|
131243
|
-
insideJsDocTagTypeExpression = isCurrentlyEditingNode(
|
|
131322
|
+
insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression);
|
|
131244
131323
|
}
|
|
131245
131324
|
}
|
|
131246
131325
|
if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) {
|
|
@@ -131497,10 +131576,19 @@ var ts;
|
|
|
131497
131576
|
case 341 /* JSDocTypeTag */:
|
|
131498
131577
|
case 343 /* JSDocTypedefTag */:
|
|
131499
131578
|
return true;
|
|
131579
|
+
case 342 /* JSDocTemplateTag */:
|
|
131580
|
+
return !!tag.constraint;
|
|
131500
131581
|
default:
|
|
131501
131582
|
return false;
|
|
131502
131583
|
}
|
|
131503
131584
|
}
|
|
131585
|
+
function tryGetTypeExpressionFromTag(tag) {
|
|
131586
|
+
if (isTagWithTypeExpression(tag)) {
|
|
131587
|
+
var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression;
|
|
131588
|
+
return typeExpression && typeExpression.kind === 307 /* JSDocTypeExpression */ ? typeExpression : undefined;
|
|
131589
|
+
}
|
|
131590
|
+
return undefined;
|
|
131591
|
+
}
|
|
131504
131592
|
function getTypeScriptMemberSymbols() {
|
|
131505
131593
|
// Right of dot member completion list
|
|
131506
131594
|
completionKind = 2 /* PropertyAccess */;
|
|
@@ -134256,7 +134344,7 @@ var ts;
|
|
|
134256
134344
|
}
|
|
134257
134345
|
for (var _c = 0, _d = referencingFile.typeReferenceDirectives; _c < _d.length; _c++) {
|
|
134258
134346
|
var ref = _d[_c];
|
|
134259
|
-
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName);
|
|
134347
|
+
var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat);
|
|
134260
134348
|
if (referenced !== undefined && referenced.resolvedFileName === searchSourceFile.fileName) {
|
|
134261
134349
|
refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
|
|
134262
134350
|
}
|
|
@@ -137478,7 +137566,7 @@ var ts;
|
|
|
137478
137566
|
}
|
|
137479
137567
|
var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
|
137480
137568
|
if (typeReferenceDirective) {
|
|
137481
|
-
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
|
|
137569
|
+
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat);
|
|
137482
137570
|
var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217
|
|
137483
137571
|
return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false };
|
|
137484
137572
|
}
|
|
@@ -164300,7 +164388,7 @@ var ts;
|
|
|
164300
164388
|
if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
|
|
164301
164389
|
this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) {
|
|
164302
164390
|
var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); // TODO: GH#18217
|
|
164303
|
-
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); });
|
|
164391
|
+
return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, ts.isString(name) ? name : name.fileName.toLowerCase()); });
|
|
164304
164392
|
};
|
|
164305
164393
|
}
|
|
164306
164394
|
}
|