@typescript-deploys/pr-build 5.9.0-pr-61291-4 → 5.9.0-pr-61399-3
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/_tsc.js +733 -427
- package/lib/cs/diagnosticMessages.generated.json +4 -4
- package/lib/de/diagnosticMessages.generated.json +4 -4
- package/lib/es/diagnosticMessages.generated.json +4 -4
- package/lib/fr/diagnosticMessages.generated.json +4 -4
- package/lib/it/diagnosticMessages.generated.json +4 -4
- package/lib/ja/diagnosticMessages.generated.json +4 -4
- package/lib/ko/diagnosticMessages.generated.json +4 -4
- package/lib/pl/diagnosticMessages.generated.json +4 -4
- package/lib/pt-br/diagnosticMessages.generated.json +4 -4
- package/lib/ru/diagnosticMessages.generated.json +4 -4
- package/lib/tr/diagnosticMessages.generated.json +4 -4
- package/lib/typescript.d.ts +28 -28
- package/lib/typescript.js +775 -466
- package/lib/zh-cn/diagnosticMessages.generated.json +4 -4
- package/lib/zh-tw/diagnosticMessages.generated.json +4 -4
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -298,6 +298,7 @@ __export(typescript_exports, {
|
|
|
298
298
|
commonOptionsWithBuild: () => commonOptionsWithBuild,
|
|
299
299
|
compact: () => compact,
|
|
300
300
|
compareBooleans: () => compareBooleans,
|
|
301
|
+
compareComparableValues: () => compareComparableValues,
|
|
301
302
|
compareDataObjects: () => compareDataObjects,
|
|
302
303
|
compareDiagnostics: () => compareDiagnostics,
|
|
303
304
|
compareEmitHelpers: () => compareEmitHelpers,
|
|
@@ -2285,7 +2286,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2285
2286
|
|
|
2286
2287
|
// src/compiler/corePublic.ts
|
|
2287
2288
|
var versionMajorMinor = "5.9";
|
|
2288
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2289
|
+
var version = `${versionMajorMinor}.0-insiders.20250311`;
|
|
2289
2290
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2290
2291
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2291
2292
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -2980,7 +2981,7 @@ function binarySearchKey(array, key, keySelector, keyComparer, offset) {
|
|
|
2980
2981
|
while (low <= high) {
|
|
2981
2982
|
const middle = low + (high - low >> 1);
|
|
2982
2983
|
const midKey = keySelector(array[middle], middle);
|
|
2983
|
-
switch (keyComparer(midKey, key)) {
|
|
2984
|
+
switch (Math.sign(keyComparer(midKey, key))) {
|
|
2984
2985
|
case -1 /* LessThan */:
|
|
2985
2986
|
low = middle + 1;
|
|
2986
2987
|
break;
|
|
@@ -4305,8 +4306,8 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
4305
4306
|
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
|
|
4306
4307
|
__tsDebuggerDisplay: {
|
|
4307
4308
|
value() {
|
|
4308
|
-
const typeHeader = this.flags &
|
|
4309
|
-
const remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~
|
|
4309
|
+
const typeHeader = this.flags & 67245055 /* Intrinsic */ ? `IntrinsicType ${this.intrinsicName}${this.debugIntrinsicName ? ` (${this.debugIntrinsicName})` : ""}` : this.flags & 12 /* Nullable */ ? "NullableType" : this.flags & 3072 /* StringOrNumberLiteral */ ? `LiteralType ${JSON.stringify(this.value)}` : this.flags & 8192 /* BigIntLiteral */ ? `LiteralType ${this.value.negative ? "-" : ""}${this.value.base10Value}n` : this.flags & 16384 /* UniqueESSymbol */ ? "UniqueESSymbolType" : this.flags & 65536 /* Enum */ ? "EnumType" : this.flags & 1048576 /* Union */ ? "UnionType" : this.flags & 2097152 /* Intersection */ ? "IntersectionType" : this.flags & 4194304 /* Index */ ? "IndexType" : this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : this.flags & 16777216 /* Conditional */ ? "ConditionalType" : this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : this.flags & 524288 /* Object */ ? this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : this.objectFlags & 4 /* Reference */ ? "TypeReference" : this.objectFlags & 8 /* Tuple */ ? "TupleType" : this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : this.objectFlags & 32 /* Mapped */ ? "MappedType" : this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type";
|
|
4310
|
+
const remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~142607679 /* ObjectTypeKindMask */ : 0;
|
|
4310
4311
|
return `${typeHeader}${this.symbol ? ` '${symbolName(this.symbol)}'` : ""}${remainingObjectFlags ? ` (${formatObjectFlags(remainingObjectFlags)})` : ""}`;
|
|
4311
4312
|
}
|
|
4312
4313
|
},
|
|
@@ -5408,7 +5409,7 @@ var tracingEnabled;
|
|
|
5408
5409
|
const objectFlags = type.objectFlags;
|
|
5409
5410
|
const symbol = type.aliasSymbol ?? type.symbol;
|
|
5410
5411
|
let display;
|
|
5411
|
-
if (objectFlags & 16 /* Anonymous */ | type.flags &
|
|
5412
|
+
if (objectFlags & 16 /* Anonymous */ | type.flags & 15360 /* Literal */) {
|
|
5412
5413
|
try {
|
|
5413
5414
|
display = (_a = type.checker) == null ? void 0 : _a.typeToString(type);
|
|
5414
5415
|
} catch {
|
|
@@ -6428,21 +6429,21 @@ var NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags3) => {
|
|
|
6428
6429
|
var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
6429
6430
|
TypeFlags2[TypeFlags2["Any"] = 1] = "Any";
|
|
6430
6431
|
TypeFlags2[TypeFlags2["Unknown"] = 2] = "Unknown";
|
|
6431
|
-
TypeFlags2[TypeFlags2["
|
|
6432
|
-
TypeFlags2[TypeFlags2["
|
|
6433
|
-
TypeFlags2[TypeFlags2["
|
|
6434
|
-
TypeFlags2[TypeFlags2["
|
|
6435
|
-
TypeFlags2[TypeFlags2["
|
|
6436
|
-
TypeFlags2[TypeFlags2["
|
|
6437
|
-
TypeFlags2[TypeFlags2["
|
|
6438
|
-
TypeFlags2[TypeFlags2["
|
|
6439
|
-
TypeFlags2[TypeFlags2["
|
|
6440
|
-
TypeFlags2[TypeFlags2["
|
|
6441
|
-
TypeFlags2[TypeFlags2["
|
|
6442
|
-
TypeFlags2[TypeFlags2["
|
|
6443
|
-
TypeFlags2[TypeFlags2["
|
|
6444
|
-
TypeFlags2[TypeFlags2["
|
|
6445
|
-
TypeFlags2[TypeFlags2["
|
|
6432
|
+
TypeFlags2[TypeFlags2["Undefined"] = 4] = "Undefined";
|
|
6433
|
+
TypeFlags2[TypeFlags2["Null"] = 8] = "Null";
|
|
6434
|
+
TypeFlags2[TypeFlags2["Void"] = 16] = "Void";
|
|
6435
|
+
TypeFlags2[TypeFlags2["String"] = 32] = "String";
|
|
6436
|
+
TypeFlags2[TypeFlags2["Number"] = 64] = "Number";
|
|
6437
|
+
TypeFlags2[TypeFlags2["BigInt"] = 128] = "BigInt";
|
|
6438
|
+
TypeFlags2[TypeFlags2["Boolean"] = 256] = "Boolean";
|
|
6439
|
+
TypeFlags2[TypeFlags2["ESSymbol"] = 512] = "ESSymbol";
|
|
6440
|
+
TypeFlags2[TypeFlags2["StringLiteral"] = 1024] = "StringLiteral";
|
|
6441
|
+
TypeFlags2[TypeFlags2["NumberLiteral"] = 2048] = "NumberLiteral";
|
|
6442
|
+
TypeFlags2[TypeFlags2["BooleanLiteral"] = 4096] = "BooleanLiteral";
|
|
6443
|
+
TypeFlags2[TypeFlags2["BigIntLiteral"] = 8192] = "BigIntLiteral";
|
|
6444
|
+
TypeFlags2[TypeFlags2["UniqueESSymbol"] = 16384] = "UniqueESSymbol";
|
|
6445
|
+
TypeFlags2[TypeFlags2["EnumLiteral"] = 32768] = "EnumLiteral";
|
|
6446
|
+
TypeFlags2[TypeFlags2["Enum"] = 65536] = "Enum";
|
|
6446
6447
|
TypeFlags2[TypeFlags2["Never"] = 131072] = "Never";
|
|
6447
6448
|
TypeFlags2[TypeFlags2["TypeParameter"] = 262144] = "TypeParameter";
|
|
6448
6449
|
TypeFlags2[TypeFlags2["Object"] = 524288] = "Object";
|
|
@@ -6458,25 +6459,25 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6458
6459
|
TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1";
|
|
6459
6460
|
TypeFlags2[TypeFlags2["Reserved2"] = 1073741824] = "Reserved2";
|
|
6460
6461
|
TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown";
|
|
6461
|
-
TypeFlags2[TypeFlags2["Nullable"] =
|
|
6462
|
-
TypeFlags2[TypeFlags2["Literal"] =
|
|
6463
|
-
TypeFlags2[TypeFlags2["Unit"] =
|
|
6464
|
-
TypeFlags2[TypeFlags2["Freshable"] =
|
|
6465
|
-
TypeFlags2[TypeFlags2["StringOrNumberLiteral"] =
|
|
6466
|
-
TypeFlags2[TypeFlags2["StringOrNumberLiteralOrUnique"] =
|
|
6467
|
-
TypeFlags2[TypeFlags2["DefinitelyFalsy"] =
|
|
6468
|
-
TypeFlags2[TypeFlags2["PossiblyFalsy"] =
|
|
6469
|
-
TypeFlags2[TypeFlags2["Intrinsic"] =
|
|
6470
|
-
TypeFlags2[TypeFlags2["StringLike"] =
|
|
6471
|
-
TypeFlags2[TypeFlags2["NumberLike"] =
|
|
6472
|
-
TypeFlags2[TypeFlags2["BigIntLike"] =
|
|
6473
|
-
TypeFlags2[TypeFlags2["BooleanLike"] =
|
|
6474
|
-
TypeFlags2[TypeFlags2["EnumLike"] =
|
|
6475
|
-
TypeFlags2[TypeFlags2["ESSymbolLike"] =
|
|
6476
|
-
TypeFlags2[TypeFlags2["VoidLike"] =
|
|
6462
|
+
TypeFlags2[TypeFlags2["Nullable"] = 12] = "Nullable";
|
|
6463
|
+
TypeFlags2[TypeFlags2["Literal"] = 15360] = "Literal";
|
|
6464
|
+
TypeFlags2[TypeFlags2["Unit"] = 97292] = "Unit";
|
|
6465
|
+
TypeFlags2[TypeFlags2["Freshable"] = 80896] = "Freshable";
|
|
6466
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteral"] = 3072] = "StringOrNumberLiteral";
|
|
6467
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteralOrUnique"] = 19456] = "StringOrNumberLiteralOrUnique";
|
|
6468
|
+
TypeFlags2[TypeFlags2["DefinitelyFalsy"] = 15388] = "DefinitelyFalsy";
|
|
6469
|
+
TypeFlags2[TypeFlags2["PossiblyFalsy"] = 15868] = "PossiblyFalsy";
|
|
6470
|
+
TypeFlags2[TypeFlags2["Intrinsic"] = 67245055] = "Intrinsic";
|
|
6471
|
+
TypeFlags2[TypeFlags2["StringLike"] = 402654240] = "StringLike";
|
|
6472
|
+
TypeFlags2[TypeFlags2["NumberLike"] = 67648] = "NumberLike";
|
|
6473
|
+
TypeFlags2[TypeFlags2["BigIntLike"] = 8320] = "BigIntLike";
|
|
6474
|
+
TypeFlags2[TypeFlags2["BooleanLike"] = 4352] = "BooleanLike";
|
|
6475
|
+
TypeFlags2[TypeFlags2["EnumLike"] = 98304] = "EnumLike";
|
|
6476
|
+
TypeFlags2[TypeFlags2["ESSymbolLike"] = 16896] = "ESSymbolLike";
|
|
6477
|
+
TypeFlags2[TypeFlags2["VoidLike"] = 20] = "VoidLike";
|
|
6477
6478
|
TypeFlags2[TypeFlags2["Primitive"] = 402784252] = "Primitive";
|
|
6478
|
-
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] =
|
|
6479
|
-
TypeFlags2[TypeFlags2["DisjointDomains"] =
|
|
6479
|
+
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] = 470417376] = "DefinitelyNonNullable";
|
|
6480
|
+
TypeFlags2[TypeFlags2["DisjointDomains"] = 469860348] = "DisjointDomains";
|
|
6480
6481
|
TypeFlags2[TypeFlags2["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
6481
6482
|
TypeFlags2[TypeFlags2["StructuredType"] = 3670016] = "StructuredType";
|
|
6482
6483
|
TypeFlags2[TypeFlags2["TypeVariable"] = 8650752] = "TypeVariable";
|
|
@@ -6484,10 +6485,10 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6484
6485
|
TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
|
|
6485
6486
|
TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
|
|
6486
6487
|
TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
|
|
6487
|
-
TypeFlags2[TypeFlags2["ObjectFlagsType"] =
|
|
6488
|
+
TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3801101] = "ObjectFlagsType";
|
|
6488
6489
|
TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
|
|
6489
|
-
TypeFlags2[TypeFlags2["Singleton"] =
|
|
6490
|
-
TypeFlags2[TypeFlags2["Narrowable"] =
|
|
6490
|
+
TypeFlags2[TypeFlags2["Singleton"] = 67240959] = "Singleton";
|
|
6491
|
+
TypeFlags2[TypeFlags2["Narrowable"] = 536707043] = "Narrowable";
|
|
6491
6492
|
TypeFlags2[TypeFlags2["IncludesMask"] = 473694207] = "IncludesMask";
|
|
6492
6493
|
TypeFlags2[TypeFlags2["IncludesMissingType"] = 262144 /* TypeParameter */] = "IncludesMissingType";
|
|
6493
6494
|
TypeFlags2[TypeFlags2["IncludesNonWideningType"] = 4194304 /* Index */] = "IncludesNonWideningType";
|
|
@@ -6496,7 +6497,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6496
6497
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
6497
6498
|
TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable";
|
|
6498
6499
|
TypeFlags2[TypeFlags2["IncludesError"] = 1073741824 /* Reserved2 */] = "IncludesError";
|
|
6499
|
-
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] =
|
|
6500
|
+
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36306963] = "NotPrimitiveUnion";
|
|
6500
6501
|
return TypeFlags2;
|
|
6501
6502
|
})(TypeFlags || {});
|
|
6502
6503
|
var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
@@ -6526,11 +6527,11 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6526
6527
|
ObjectFlags3[ObjectFlags3["RequiresWidening"] = 196608] = "RequiresWidening";
|
|
6527
6528
|
ObjectFlags3[ObjectFlags3["PropagatingFlags"] = 458752] = "PropagatingFlags";
|
|
6528
6529
|
ObjectFlags3[ObjectFlags3["InstantiatedMapped"] = 96] = "InstantiatedMapped";
|
|
6529
|
-
ObjectFlags3[ObjectFlags3["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask";
|
|
6530
6530
|
ObjectFlags3[ObjectFlags3["ContainsSpread"] = 2097152] = "ContainsSpread";
|
|
6531
6531
|
ObjectFlags3[ObjectFlags3["ObjectRestType"] = 4194304] = "ObjectRestType";
|
|
6532
6532
|
ObjectFlags3[ObjectFlags3["InstantiationExpressionType"] = 8388608] = "InstantiationExpressionType";
|
|
6533
6533
|
ObjectFlags3[ObjectFlags3["SingleSignatureType"] = 134217728] = "SingleSignatureType";
|
|
6534
|
+
ObjectFlags3[ObjectFlags3["ObjectTypeKindMask"] = 142607679] = "ObjectTypeKindMask";
|
|
6534
6535
|
ObjectFlags3[ObjectFlags3["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone";
|
|
6535
6536
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated";
|
|
6536
6537
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists";
|
|
@@ -10323,7 +10324,6 @@ var Diagnostics = {
|
|
|
10323
10324
|
One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value: diag(4126, 1 /* Error */, "One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value_4126", "One value of '{0}.{1}' is the string '{2}', and the other is assumed to be an unknown numeric value."),
|
|
10324
10325
|
This_member_cannot_have_an_override_modifier_because_its_name_is_dynamic: diag(4127, 1 /* Error */, "This_member_cannot_have_an_override_modifier_because_its_name_is_dynamic_4127", "This member cannot have an 'override' modifier because its name is dynamic."),
|
|
10325
10326
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_name_is_dynamic: diag(4128, 1 /* Error */, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_name_is_dynamic_4128", "This member cannot have a JSDoc comment with an '@override' tag because its name is dynamic."),
|
|
10326
|
-
Private_or_protected_member_0_cannot_be_accessed_via_indexed_access: diag(4129, 1 /* Error */, "Private_or_protected_member_0_cannot_be_accessed_via_indexed_access_4129", "Private or protected member '{0}' cannot be accessed via indexed access."),
|
|
10327
10327
|
The_current_host_does_not_support_the_0_option: diag(5001, 1 /* Error */, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
|
|
10328
10328
|
Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, 1 /* Error */, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
|
|
10329
10329
|
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, 1 /* Error */, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
|
|
@@ -21355,7 +21355,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
|
|
|
21355
21355
|
return (_a = symbol.declarations) == null ? void 0 : _a.find(isClassLike);
|
|
21356
21356
|
}
|
|
21357
21357
|
function getObjectFlags(type) {
|
|
21358
|
-
return type.flags &
|
|
21358
|
+
return type.flags & 3801101 /* ObjectFlagsType */ ? type.objectFlags : 0;
|
|
21359
21359
|
}
|
|
21360
21360
|
function isUMDExportSymbol(symbol) {
|
|
21361
21361
|
return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
|
|
@@ -23246,13 +23246,13 @@ function intrinsicTagNameToString(node) {
|
|
|
23246
23246
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
23247
23247
|
}
|
|
23248
23248
|
function isTypeUsableAsPropertyName(type) {
|
|
23249
|
-
return !!(type.flags &
|
|
23249
|
+
return !!(type.flags & 19456 /* StringOrNumberLiteralOrUnique */);
|
|
23250
23250
|
}
|
|
23251
23251
|
function getPropertyNameFromType(type) {
|
|
23252
|
-
if (type.flags &
|
|
23252
|
+
if (type.flags & 16384 /* UniqueESSymbol */) {
|
|
23253
23253
|
return type.escapedName;
|
|
23254
23254
|
}
|
|
23255
|
-
if (type.flags & (
|
|
23255
|
+
if (type.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */)) {
|
|
23256
23256
|
return escapeLeadingUnderscores("" + type.value);
|
|
23257
23257
|
}
|
|
23258
23258
|
return Debug.fail();
|
|
@@ -50774,6 +50774,7 @@ function createTypeChecker(host) {
|
|
|
50774
50774
|
};
|
|
50775
50775
|
var cancellationToken;
|
|
50776
50776
|
var scanner2;
|
|
50777
|
+
var fileIndexMap = new Map(host.getSourceFiles().map((file, i) => [file, i]));
|
|
50777
50778
|
var Symbol48 = objectAllocator.getSymbolConstructor();
|
|
50778
50779
|
var Type29 = objectAllocator.getTypeConstructor();
|
|
50779
50780
|
var Signature13 = objectAllocator.getSignatureConstructor();
|
|
@@ -51355,10 +51356,10 @@ function createTypeChecker(host) {
|
|
|
51355
51356
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */, "non-inferrable");
|
|
51356
51357
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
51357
51358
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
51358
|
-
var undefinedType = createIntrinsicType(
|
|
51359
|
-
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(
|
|
51359
|
+
var undefinedType = createIntrinsicType(4 /* Undefined */, "undefined");
|
|
51360
|
+
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(4 /* Undefined */, "undefined", 65536 /* ContainsWideningType */, "widening");
|
|
51360
51361
|
var missingType = createIntrinsicType(
|
|
51361
|
-
|
|
51362
|
+
4 /* Undefined */,
|
|
51362
51363
|
"undefined",
|
|
51363
51364
|
/*objectFlags*/
|
|
51364
51365
|
void 0,
|
|
@@ -51366,33 +51367,33 @@ function createTypeChecker(host) {
|
|
|
51366
51367
|
);
|
|
51367
51368
|
var undefinedOrMissingType = exactOptionalPropertyTypes ? missingType : undefinedType;
|
|
51368
51369
|
var optionalType = createIntrinsicType(
|
|
51369
|
-
|
|
51370
|
+
4 /* Undefined */,
|
|
51370
51371
|
"undefined",
|
|
51371
51372
|
/*objectFlags*/
|
|
51372
51373
|
void 0,
|
|
51373
51374
|
"optional"
|
|
51374
51375
|
);
|
|
51375
|
-
var nullType = createIntrinsicType(
|
|
51376
|
-
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(
|
|
51377
|
-
var stringType = createIntrinsicType(
|
|
51378
|
-
var numberType = createIntrinsicType(
|
|
51379
|
-
var bigintType = createIntrinsicType(
|
|
51376
|
+
var nullType = createIntrinsicType(8 /* Null */, "null");
|
|
51377
|
+
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(8 /* Null */, "null", 65536 /* ContainsWideningType */, "widening");
|
|
51378
|
+
var stringType = createIntrinsicType(32 /* String */, "string");
|
|
51379
|
+
var numberType = createIntrinsicType(64 /* Number */, "number");
|
|
51380
|
+
var bigintType = createIntrinsicType(128 /* BigInt */, "bigint");
|
|
51380
51381
|
var falseType = createIntrinsicType(
|
|
51381
|
-
|
|
51382
|
+
4096 /* BooleanLiteral */,
|
|
51382
51383
|
"false",
|
|
51383
51384
|
/*objectFlags*/
|
|
51384
51385
|
void 0,
|
|
51385
51386
|
"fresh"
|
|
51386
51387
|
);
|
|
51387
|
-
var regularFalseType = createIntrinsicType(
|
|
51388
|
+
var regularFalseType = createIntrinsicType(4096 /* BooleanLiteral */, "false");
|
|
51388
51389
|
var trueType = createIntrinsicType(
|
|
51389
|
-
|
|
51390
|
+
4096 /* BooleanLiteral */,
|
|
51390
51391
|
"true",
|
|
51391
51392
|
/*objectFlags*/
|
|
51392
51393
|
void 0,
|
|
51393
51394
|
"fresh"
|
|
51394
51395
|
);
|
|
51395
|
-
var regularTrueType = createIntrinsicType(
|
|
51396
|
+
var regularTrueType = createIntrinsicType(4096 /* BooleanLiteral */, "true");
|
|
51396
51397
|
trueType.regularType = regularTrueType;
|
|
51397
51398
|
trueType.freshType = trueType;
|
|
51398
51399
|
regularTrueType.regularType = regularTrueType;
|
|
@@ -51402,8 +51403,8 @@ function createTypeChecker(host) {
|
|
|
51402
51403
|
regularFalseType.regularType = regularFalseType;
|
|
51403
51404
|
regularFalseType.freshType = falseType;
|
|
51404
51405
|
var booleanType = getUnionType([regularFalseType, regularTrueType]);
|
|
51405
|
-
var esSymbolType = createIntrinsicType(
|
|
51406
|
-
var voidType = createIntrinsicType(
|
|
51406
|
+
var esSymbolType = createIntrinsicType(512 /* ESSymbol */, "symbol");
|
|
51407
|
+
var voidType = createIntrinsicType(16 /* Void */, "void");
|
|
51407
51408
|
var neverType = createIntrinsicType(131072 /* Never */, "never");
|
|
51408
51409
|
var silentNeverType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */, "silent");
|
|
51409
51410
|
var implicitNeverType = createIntrinsicType(
|
|
@@ -52690,7 +52691,7 @@ function createTypeChecker(host) {
|
|
|
52690
52691
|
const type = getDeclaredTypeOfSymbol(symbol);
|
|
52691
52692
|
return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(
|
|
52692
52693
|
type,
|
|
52693
|
-
|
|
52694
|
+
3072 /* StringOrNumberLiteral */,
|
|
52694
52695
|
/*strict*/
|
|
52695
52696
|
true
|
|
52696
52697
|
);
|
|
@@ -54397,7 +54398,7 @@ function createTypeChecker(host) {
|
|
|
54397
54398
|
return type;
|
|
54398
54399
|
}
|
|
54399
54400
|
function createTypeofType() {
|
|
54400
|
-
return getUnionType(
|
|
54401
|
+
return getUnionType(map([...typeofNEFacts.keys()].sort(), getStringLiteralType));
|
|
54401
54402
|
}
|
|
54402
54403
|
function createTypeParameter(symbol) {
|
|
54403
54404
|
return createTypeWithSymbol(262144 /* TypeParameter */, symbol);
|
|
@@ -55218,7 +55219,7 @@ function createTypeChecker(host) {
|
|
|
55218
55219
|
if (name && isComputedPropertyName(name)) return name;
|
|
55219
55220
|
}
|
|
55220
55221
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
55221
|
-
if (nameType && nameType.flags & (
|
|
55222
|
+
if (nameType && nameType.flags & (32768 /* EnumLiteral */ | 16384 /* UniqueESSymbol */)) {
|
|
55222
55223
|
context.enclosingDeclaration = nameType.symbol.valueDeclaration;
|
|
55223
55224
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, meaning));
|
|
55224
55225
|
}
|
|
@@ -55326,23 +55327,23 @@ function createTypeChecker(host) {
|
|
|
55326
55327
|
if (type.flags & 2 /* Unknown */) {
|
|
55327
55328
|
return factory.createKeywordTypeNode(159 /* UnknownKeyword */);
|
|
55328
55329
|
}
|
|
55329
|
-
if (type.flags &
|
|
55330
|
+
if (type.flags & 32 /* String */) {
|
|
55330
55331
|
context.approximateLength += 6;
|
|
55331
55332
|
return factory.createKeywordTypeNode(154 /* StringKeyword */);
|
|
55332
55333
|
}
|
|
55333
|
-
if (type.flags &
|
|
55334
|
+
if (type.flags & 64 /* Number */) {
|
|
55334
55335
|
context.approximateLength += 6;
|
|
55335
55336
|
return factory.createKeywordTypeNode(150 /* NumberKeyword */);
|
|
55336
55337
|
}
|
|
55337
|
-
if (type.flags &
|
|
55338
|
+
if (type.flags & 128 /* BigInt */) {
|
|
55338
55339
|
context.approximateLength += 6;
|
|
55339
55340
|
return factory.createKeywordTypeNode(163 /* BigIntKeyword */);
|
|
55340
55341
|
}
|
|
55341
|
-
if (type.flags &
|
|
55342
|
+
if (type.flags & 256 /* Boolean */ && !type.aliasSymbol) {
|
|
55342
55343
|
context.approximateLength += 7;
|
|
55343
55344
|
return factory.createKeywordTypeNode(136 /* BooleanKeyword */);
|
|
55344
55345
|
}
|
|
55345
|
-
if (type.flags &
|
|
55346
|
+
if (type.flags & 98304 /* EnumLike */) {
|
|
55346
55347
|
if (type.symbol.flags & 8 /* EnumMember */) {
|
|
55347
55348
|
const parentSymbol = getParentOfSymbol(type.symbol);
|
|
55348
55349
|
const parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */);
|
|
@@ -55371,24 +55372,24 @@ function createTypeChecker(host) {
|
|
|
55371
55372
|
}
|
|
55372
55373
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
55373
55374
|
}
|
|
55374
|
-
if (type.flags &
|
|
55375
|
+
if (type.flags & 1024 /* StringLiteral */) {
|
|
55375
55376
|
context.approximateLength += type.value.length + 2;
|
|
55376
55377
|
return factory.createLiteralTypeNode(setEmitFlags(factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */));
|
|
55377
55378
|
}
|
|
55378
|
-
if (type.flags &
|
|
55379
|
+
if (type.flags & 2048 /* NumberLiteral */) {
|
|
55379
55380
|
const value = type.value;
|
|
55380
55381
|
context.approximateLength += ("" + value).length;
|
|
55381
55382
|
return factory.createLiteralTypeNode(value < 0 ? factory.createPrefixUnaryExpression(41 /* MinusToken */, factory.createNumericLiteral(-value)) : factory.createNumericLiteral(value));
|
|
55382
55383
|
}
|
|
55383
|
-
if (type.flags &
|
|
55384
|
+
if (type.flags & 8192 /* BigIntLiteral */) {
|
|
55384
55385
|
context.approximateLength += pseudoBigIntToString(type.value).length + 1;
|
|
55385
55386
|
return factory.createLiteralTypeNode(factory.createBigIntLiteral(type.value));
|
|
55386
55387
|
}
|
|
55387
|
-
if (type.flags &
|
|
55388
|
+
if (type.flags & 4096 /* BooleanLiteral */) {
|
|
55388
55389
|
context.approximateLength += type.intrinsicName.length;
|
|
55389
55390
|
return factory.createLiteralTypeNode(type.intrinsicName === "true" ? factory.createTrue() : factory.createFalse());
|
|
55390
55391
|
}
|
|
55391
|
-
if (type.flags &
|
|
55392
|
+
if (type.flags & 16384 /* UniqueESSymbol */) {
|
|
55392
55393
|
if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) {
|
|
55393
55394
|
if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
|
|
55394
55395
|
context.approximateLength += 6;
|
|
@@ -55401,15 +55402,15 @@ function createTypeChecker(host) {
|
|
|
55401
55402
|
context.approximateLength += 13;
|
|
55402
55403
|
return factory.createTypeOperatorNode(158 /* UniqueKeyword */, factory.createKeywordTypeNode(155 /* SymbolKeyword */));
|
|
55403
55404
|
}
|
|
55404
|
-
if (type.flags &
|
|
55405
|
+
if (type.flags & 16 /* Void */) {
|
|
55405
55406
|
context.approximateLength += 4;
|
|
55406
55407
|
return factory.createKeywordTypeNode(116 /* VoidKeyword */);
|
|
55407
55408
|
}
|
|
55408
|
-
if (type.flags &
|
|
55409
|
+
if (type.flags & 4 /* Undefined */) {
|
|
55409
55410
|
context.approximateLength += 9;
|
|
55410
55411
|
return factory.createKeywordTypeNode(157 /* UndefinedKeyword */);
|
|
55411
55412
|
}
|
|
55412
|
-
if (type.flags &
|
|
55413
|
+
if (type.flags & 8 /* Null */) {
|
|
55413
55414
|
context.approximateLength += 4;
|
|
55414
55415
|
return factory.createLiteralTypeNode(factory.createNull());
|
|
55415
55416
|
}
|
|
@@ -55417,7 +55418,7 @@ function createTypeChecker(host) {
|
|
|
55417
55418
|
context.approximateLength += 5;
|
|
55418
55419
|
return factory.createKeywordTypeNode(146 /* NeverKeyword */);
|
|
55419
55420
|
}
|
|
55420
|
-
if (type.flags &
|
|
55421
|
+
if (type.flags & 512 /* ESSymbol */) {
|
|
55421
55422
|
context.approximateLength += 6;
|
|
55422
55423
|
return factory.createKeywordTypeNode(155 /* SymbolKeyword */);
|
|
55423
55424
|
}
|
|
@@ -56206,7 +56207,7 @@ function createTypeChecker(host) {
|
|
|
56206
56207
|
}
|
|
56207
56208
|
const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
56208
56209
|
if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
|
|
56209
|
-
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags &
|
|
56210
|
+
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 4 /* Undefined */)), 0 /* Call */);
|
|
56210
56211
|
for (const signature of signatures) {
|
|
56211
56212
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 173 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
56212
56213
|
typeElements.push(preserveCommentsOn(methodDeclaration, signature.declaration || propertySymbol.valueDeclaration));
|
|
@@ -57246,11 +57247,11 @@ function createTypeChecker(host) {
|
|
|
57246
57247
|
}
|
|
57247
57248
|
if (isComputedPropertyName(name)) {
|
|
57248
57249
|
const type = checkExpression(name.expression);
|
|
57249
|
-
return !!(type.flags &
|
|
57250
|
+
return !!(type.flags & 402654240 /* StringLike */);
|
|
57250
57251
|
}
|
|
57251
57252
|
if (isElementAccessExpression(name)) {
|
|
57252
57253
|
const type = checkExpression(name.argumentExpression);
|
|
57253
|
-
return !!(type.flags &
|
|
57254
|
+
return !!(type.flags & 402654240 /* StringLike */);
|
|
57254
57255
|
}
|
|
57255
57256
|
return isStringLiteral(name);
|
|
57256
57257
|
}
|
|
@@ -57276,7 +57277,7 @@ function createTypeChecker(host) {
|
|
|
57276
57277
|
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote, stringNamed, isMethod) {
|
|
57277
57278
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
57278
57279
|
if (nameType) {
|
|
57279
|
-
if (nameType.flags &
|
|
57280
|
+
if (nameType.flags & 3072 /* StringOrNumberLiteral */) {
|
|
57280
57281
|
const name = "" + nameType.value;
|
|
57281
57282
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && (stringNamed || !isNumericLiteralName(name))) {
|
|
57282
57283
|
return factory.createStringLiteral(name, !!singleQuote);
|
|
@@ -57286,7 +57287,7 @@ function createTypeChecker(host) {
|
|
|
57286
57287
|
}
|
|
57287
57288
|
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
|
|
57288
57289
|
}
|
|
57289
|
-
if (nameType.flags &
|
|
57290
|
+
if (nameType.flags & 16384 /* UniqueESSymbol */) {
|
|
57290
57291
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
|
|
57291
57292
|
}
|
|
57292
57293
|
}
|
|
@@ -57328,7 +57329,7 @@ function createTypeChecker(host) {
|
|
|
57328
57329
|
return enclosingDeclaration;
|
|
57329
57330
|
}
|
|
57330
57331
|
function serializeInferredTypeForDeclaration(symbol, context, type) {
|
|
57331
|
-
if (type.flags &
|
|
57332
|
+
if (type.flags & 16384 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === context.enclosingFile))) {
|
|
57332
57333
|
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
57333
57334
|
}
|
|
57334
57335
|
const result = typeToTypeNodeHelper(type, context);
|
|
@@ -57561,7 +57562,7 @@ function createTypeChecker(host) {
|
|
|
57561
57562
|
}
|
|
57562
57563
|
function serializeExistingTypeNode(context, typeNode, addUndefined) {
|
|
57563
57564
|
const type = getTypeFromTypeNode2(context, typeNode);
|
|
57564
|
-
if (addUndefined && !someType(type, (t) => !!(t.flags &
|
|
57565
|
+
if (addUndefined && !someType(type, (t) => !!(t.flags & 4 /* Undefined */)) && canReuseTypeNode(context, typeNode)) {
|
|
57565
57566
|
const clone2 = syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode);
|
|
57566
57567
|
if (clone2) {
|
|
57567
57568
|
return factory.createUnionTypeNode([clone2, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
@@ -59100,9 +59101,9 @@ function createTypeChecker(host) {
|
|
|
59100
59101
|
for (let i = 0; i < types.length; i++) {
|
|
59101
59102
|
const t = types[i];
|
|
59102
59103
|
flags |= t.flags;
|
|
59103
|
-
if (!(t.flags &
|
|
59104
|
-
if (t.flags & (
|
|
59105
|
-
const baseType = t.flags &
|
|
59104
|
+
if (!(t.flags & 12 /* Nullable */)) {
|
|
59105
|
+
if (t.flags & (4096 /* BooleanLiteral */ | 98304 /* EnumLike */)) {
|
|
59106
|
+
const baseType = t.flags & 4096 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLikeType(t);
|
|
59106
59107
|
if (baseType.flags & 1048576 /* Union */) {
|
|
59107
59108
|
const count = baseType.types.length;
|
|
59108
59109
|
if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
|
|
@@ -59115,8 +59116,8 @@ function createTypeChecker(host) {
|
|
|
59115
59116
|
result.push(t);
|
|
59116
59117
|
}
|
|
59117
59118
|
}
|
|
59118
|
-
if (flags &
|
|
59119
|
-
if (flags &
|
|
59119
|
+
if (flags & 8 /* Null */) result.push(nullType);
|
|
59120
|
+
if (flags & 4 /* Undefined */) result.push(undefinedType);
|
|
59120
59121
|
return result || types;
|
|
59121
59122
|
}
|
|
59122
59123
|
function visibilityToString(flags) {
|
|
@@ -59146,7 +59147,7 @@ function createTypeChecker(host) {
|
|
|
59146
59147
|
function getNameOfSymbolFromNameType(symbol, context) {
|
|
59147
59148
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
59148
59149
|
if (nameType) {
|
|
59149
|
-
if (nameType.flags &
|
|
59150
|
+
if (nameType.flags & 3072 /* StringOrNumberLiteral */) {
|
|
59150
59151
|
const name = "" + nameType.value;
|
|
59151
59152
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
59152
59153
|
return `"${escapeString(name, 34 /* doubleQuote */)}"`;
|
|
@@ -59156,7 +59157,7 @@ function createTypeChecker(host) {
|
|
|
59156
59157
|
}
|
|
59157
59158
|
return name;
|
|
59158
59159
|
}
|
|
59159
|
-
if (nameType.flags &
|
|
59160
|
+
if (nameType.flags & 16384 /* UniqueESSymbol */) {
|
|
59160
59161
|
return `[${getNameOfSymbolAsWritten(nameType.symbol, context)}]`;
|
|
59161
59162
|
}
|
|
59162
59163
|
}
|
|
@@ -59181,7 +59182,7 @@ function createTypeChecker(host) {
|
|
|
59181
59182
|
}
|
|
59182
59183
|
if (isComputedPropertyName(name2) && !(getCheckFlags(symbol) & 4096 /* Late */)) {
|
|
59183
59184
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
59184
|
-
if (nameType && nameType.flags &
|
|
59185
|
+
if (nameType && nameType.flags & 3072 /* StringOrNumberLiteral */) {
|
|
59185
59186
|
const result = getNameOfSymbolFromNameType(symbol, context);
|
|
59186
59187
|
if (result !== void 0) {
|
|
59187
59188
|
return result;
|
|
@@ -59462,7 +59463,7 @@ function createTypeChecker(host) {
|
|
|
59462
59463
|
);
|
|
59463
59464
|
}
|
|
59464
59465
|
function getRestType(source, properties, symbol) {
|
|
59465
|
-
source = filterType(source, (t) => !(t.flags &
|
|
59466
|
+
source = filterType(source, (t) => !(t.flags & 12 /* Nullable */));
|
|
59466
59467
|
if (source.flags & 131072 /* Never */) {
|
|
59467
59468
|
return emptyObjectType;
|
|
59468
59469
|
}
|
|
@@ -59473,7 +59474,7 @@ function createTypeChecker(host) {
|
|
|
59473
59474
|
const spreadableProperties = [];
|
|
59474
59475
|
const unspreadableToRestKeys = [];
|
|
59475
59476
|
for (const prop of getPropertiesOfType(source)) {
|
|
59476
|
-
const literalTypeFromProperty = getLiteralTypeFromProperty(prop,
|
|
59477
|
+
const literalTypeFromProperty = getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */);
|
|
59477
59478
|
if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) && isSpreadableProperty(prop)) {
|
|
59478
59479
|
spreadableProperties.push(prop);
|
|
59479
59480
|
} else {
|
|
@@ -59506,7 +59507,7 @@ function createTypeChecker(host) {
|
|
|
59506
59507
|
return result;
|
|
59507
59508
|
}
|
|
59508
59509
|
function isGenericTypeWithUndefinedConstraint(type) {
|
|
59509
|
-
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType,
|
|
59510
|
+
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 4 /* Undefined */);
|
|
59510
59511
|
}
|
|
59511
59512
|
function getNonUndefinedType(type) {
|
|
59512
59513
|
const typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, (t) => t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t) : type;
|
|
@@ -59560,7 +59561,7 @@ function createTypeChecker(host) {
|
|
|
59560
59561
|
}
|
|
59561
59562
|
function getLiteralPropertyNameText(name) {
|
|
59562
59563
|
const type = getLiteralTypeFromPropertyName(name);
|
|
59563
|
-
return type.flags & (
|
|
59564
|
+
return type.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
59564
59565
|
}
|
|
59565
59566
|
function getTypeForBindingElement(declaration) {
|
|
59566
59567
|
const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
@@ -59900,7 +59901,7 @@ function createTypeChecker(host) {
|
|
|
59900
59901
|
definedInConstructor = true;
|
|
59901
59902
|
}
|
|
59902
59903
|
}
|
|
59903
|
-
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~
|
|
59904
|
+
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~12 /* Nullable */)) ? constructorTypes : types;
|
|
59904
59905
|
type = getUnionType(sourceTypes);
|
|
59905
59906
|
}
|
|
59906
59907
|
}
|
|
@@ -59910,7 +59911,7 @@ function createTypeChecker(host) {
|
|
|
59910
59911
|
false,
|
|
59911
59912
|
definedInMethod && !definedInConstructor
|
|
59912
59913
|
));
|
|
59913
|
-
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~
|
|
59914
|
+
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~12 /* Nullable */)) === neverType) {
|
|
59914
59915
|
reportImplicitAny(symbol.valueDeclaration, anyType);
|
|
59915
59916
|
return anyType;
|
|
59916
59917
|
}
|
|
@@ -60208,13 +60209,13 @@ function createTypeChecker(host) {
|
|
|
60208
60209
|
}
|
|
60209
60210
|
function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors2) {
|
|
60210
60211
|
if (type) {
|
|
60211
|
-
if (type.flags &
|
|
60212
|
+
if (type.flags & 512 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) {
|
|
60212
60213
|
type = getESSymbolLikeTypeForNode(declaration);
|
|
60213
60214
|
}
|
|
60214
60215
|
if (reportErrors2) {
|
|
60215
60216
|
reportErrorsFromWidening(declaration, type);
|
|
60216
60217
|
}
|
|
60217
|
-
if (type.flags &
|
|
60218
|
+
if (type.flags & 16384 /* UniqueESSymbol */ && (isBindingElement(declaration) || !tryGetTypeFromEffectiveTypeNode(declaration)) && type.symbol !== getSymbolOfDeclaration(declaration)) {
|
|
60218
60219
|
type = esSymbolType;
|
|
60219
60220
|
}
|
|
60220
60221
|
return getWidenedType(type);
|
|
@@ -61051,7 +61052,7 @@ function createTypeChecker(host) {
|
|
|
61051
61052
|
return links.declaredType;
|
|
61052
61053
|
}
|
|
61053
61054
|
function getBaseTypeOfEnumLikeType(type) {
|
|
61054
|
-
return type.flags &
|
|
61055
|
+
return type.flags & 98304 /* EnumLike */ && type.symbol.flags & 8 /* EnumMember */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
|
|
61055
61056
|
}
|
|
61056
61057
|
function getDeclaredTypeOfEnum(symbol) {
|
|
61057
61058
|
const links = getSymbolLinks(symbol);
|
|
@@ -61082,7 +61083,7 @@ function createTypeChecker(host) {
|
|
|
61082
61083
|
void 0
|
|
61083
61084
|
) : createComputedEnumType(symbol);
|
|
61084
61085
|
if (enumType.flags & 1048576 /* Union */) {
|
|
61085
|
-
enumType.flags |=
|
|
61086
|
+
enumType.flags |= 32768 /* EnumLiteral */;
|
|
61086
61087
|
enumType.symbol = symbol;
|
|
61087
61088
|
}
|
|
61088
61089
|
links.declaredType = enumType;
|
|
@@ -61090,8 +61091,8 @@ function createTypeChecker(host) {
|
|
|
61090
61091
|
return links.declaredType;
|
|
61091
61092
|
}
|
|
61092
61093
|
function createComputedEnumType(symbol) {
|
|
61093
|
-
const regularType = createTypeWithSymbol(
|
|
61094
|
-
const freshType = createTypeWithSymbol(
|
|
61094
|
+
const regularType = createTypeWithSymbol(65536 /* Enum */, symbol);
|
|
61095
|
+
const freshType = createTypeWithSymbol(65536 /* Enum */, symbol);
|
|
61095
61096
|
regularType.regularType = regularType;
|
|
61096
61097
|
regularType.freshType = freshType;
|
|
61097
61098
|
freshType.regularType = regularType;
|
|
@@ -61293,7 +61294,7 @@ function createTypeChecker(host) {
|
|
|
61293
61294
|
const earlySymbol = earlySymbols && earlySymbols.get(memberName);
|
|
61294
61295
|
if (!(parent2.flags & 32 /* Class */) && lateSymbol.flags & getExcludedSymbolFlags(symbolFlags)) {
|
|
61295
61296
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
61296
|
-
const name = !(type.flags &
|
|
61297
|
+
const name = !(type.flags & 16384 /* UniqueESSymbol */) && unescapeLeadingUnderscores(memberName) || declarationNameToString(declName);
|
|
61297
61298
|
forEach(declarations, (declaration) => error2(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
61298
61299
|
error2(declName || decl, Diagnostics.Duplicate_property_0, name);
|
|
61299
61300
|
lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
|
|
@@ -61988,7 +61989,7 @@ function createTypeChecker(host) {
|
|
|
61988
61989
|
if (baseConstructorIndexInfo) {
|
|
61989
61990
|
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
|
61990
61991
|
}
|
|
61991
|
-
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags &
|
|
61992
|
+
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 65536 /* Enum */ || some(type.properties, (prop) => !!(getTypeOfSymbol(prop).flags & 67648 /* NumberLike */)))) {
|
|
61992
61993
|
indexInfos = append(indexInfos, enumNumberIndexInfo);
|
|
61993
61994
|
}
|
|
61994
61995
|
}
|
|
@@ -62049,7 +62050,7 @@ function createTypeChecker(host) {
|
|
|
62049
62050
|
const limitedConstraint = getLimitedConstraint(type);
|
|
62050
62051
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
62051
62052
|
if (limitedConstraint) {
|
|
62052
|
-
const propertyNameType = getLiteralTypeFromProperty(prop,
|
|
62053
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */);
|
|
62053
62054
|
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
62054
62055
|
continue;
|
|
62055
62056
|
}
|
|
@@ -62102,7 +62103,7 @@ function createTypeChecker(host) {
|
|
|
62102
62103
|
}
|
|
62103
62104
|
if (type.flags & 2097152 /* Intersection */) {
|
|
62104
62105
|
const types = type.types;
|
|
62105
|
-
if (types.length === 2 && !!(types[0].flags & (
|
|
62106
|
+
if (types.length === 2 && !!(types[0].flags & (32 /* String */ | 64 /* Number */ | 128 /* BigInt */)) && types[1] === emptyTypeLiteralType) {
|
|
62106
62107
|
return type;
|
|
62107
62108
|
}
|
|
62108
62109
|
return getIntersectionType(sameMap(type.types, getLowerBoundOfKeyType));
|
|
@@ -62120,7 +62121,7 @@ function createTypeChecker(host) {
|
|
|
62120
62121
|
cb(stringType);
|
|
62121
62122
|
} else {
|
|
62122
62123
|
for (const info of getIndexInfosOfType(type)) {
|
|
62123
|
-
if (!stringsOnly || info.keyType.flags & (
|
|
62124
|
+
if (!stringsOnly || info.keyType.flags & (32 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
62124
62125
|
cb(info.keyType);
|
|
62125
62126
|
}
|
|
62126
62127
|
}
|
|
@@ -62138,7 +62139,7 @@ function createTypeChecker(host) {
|
|
|
62138
62139
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
62139
62140
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
62140
62141
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
62141
|
-
const include =
|
|
62142
|
+
const include = 19456 /* StringOrNumberLiteralOrUnique */;
|
|
62142
62143
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
62143
62144
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
62144
62145
|
modifiersType,
|
|
@@ -62178,8 +62179,8 @@ function createTypeChecker(host) {
|
|
|
62178
62179
|
}
|
|
62179
62180
|
members.set(propName, prop);
|
|
62180
62181
|
}
|
|
62181
|
-
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ |
|
|
62182
|
-
const indexKeyType = propNameType.flags & (1 /* Any */ |
|
|
62182
|
+
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 65536 /* Enum */)) {
|
|
62183
|
+
const indexKeyType = propNameType.flags & (1 /* Any */ | 32 /* String */) ? stringType : propNameType.flags & (64 /* Number */ | 65536 /* Enum */) ? numberType : propNameType;
|
|
62183
62184
|
const propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType));
|
|
62184
62185
|
const modifiersIndexInfo = getApplicableIndexInfo(modifiersType, propNameType);
|
|
62185
62186
|
const isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || !(templateModifiers & 2 /* ExcludeReadonly */) && (modifiersIndexInfo == null ? void 0 : modifiersIndexInfo.isReadonly));
|
|
@@ -62204,7 +62205,7 @@ function createTypeChecker(host) {
|
|
|
62204
62205
|
const templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType);
|
|
62205
62206
|
const mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.links.keyType);
|
|
62206
62207
|
const propType = instantiateType(templateType, mapper);
|
|
62207
|
-
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType,
|
|
62208
|
+
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 4 /* Undefined */ | 16 /* Void */) ? getOptionalType(
|
|
62208
62209
|
propType,
|
|
62209
62210
|
/*isProperty*/
|
|
62210
62211
|
true
|
|
@@ -62498,14 +62499,14 @@ function createTypeChecker(host) {
|
|
|
62498
62499
|
constraints = append(constraints, t);
|
|
62499
62500
|
}
|
|
62500
62501
|
}
|
|
62501
|
-
} else if (t.flags &
|
|
62502
|
+
} else if (t.flags & 469860348 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
62502
62503
|
hasDisjointDomainType = true;
|
|
62503
62504
|
}
|
|
62504
62505
|
}
|
|
62505
62506
|
if (constraints && (targetIsUnion || hasDisjointDomainType)) {
|
|
62506
62507
|
if (hasDisjointDomainType) {
|
|
62507
62508
|
for (const t of types) {
|
|
62508
|
-
if (t.flags &
|
|
62509
|
+
if (t.flags & 469860348 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
62509
62510
|
constraints = append(constraints, t);
|
|
62510
62511
|
}
|
|
62511
62512
|
}
|
|
@@ -62706,7 +62707,7 @@ function createTypeChecker(host) {
|
|
|
62706
62707
|
function getApparentType(type) {
|
|
62707
62708
|
const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
|
|
62708
62709
|
const objectFlags = getObjectFlags(t);
|
|
62709
|
-
return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags &
|
|
62710
|
+
return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags & 402654240 /* StringLike */ ? globalStringType : t.flags & 67648 /* NumberLike */ ? globalNumberType : t.flags & 8320 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 4352 /* BooleanLike */ ? globalBooleanType : t.flags & 16896 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? stringNumberSymbolType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
|
|
62710
62711
|
}
|
|
62711
62712
|
function getReducedApparentType(type) {
|
|
62712
62713
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
@@ -63058,7 +63059,7 @@ function createTypeChecker(host) {
|
|
|
63058
63059
|
)) : applicableInfo ? applicableInfo : stringIndexInfo && isApplicableIndexType(keyType, stringType) ? stringIndexInfo : void 0;
|
|
63059
63060
|
}
|
|
63060
63061
|
function isApplicableIndexType(source, target) {
|
|
63061
|
-
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags &
|
|
63062
|
+
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags & 1024 /* StringLiteral */) && isNumericLiteralName(source.value));
|
|
63062
63063
|
}
|
|
63063
63064
|
function getIndexInfosOfStructuredType(type) {
|
|
63064
63065
|
if (type.flags & 3670016 /* StructuredType */) {
|
|
@@ -63387,7 +63388,7 @@ function createTypeChecker(host) {
|
|
|
63387
63388
|
}
|
|
63388
63389
|
if (type || jsdocPredicate) {
|
|
63389
63390
|
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
63390
|
-
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags &
|
|
63391
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 256 /* Boolean */) && getParameterCount(signature) > 0) {
|
|
63391
63392
|
const { declaration } = signature;
|
|
63392
63393
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
63393
63394
|
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
@@ -63672,7 +63673,7 @@ function createTypeChecker(host) {
|
|
|
63672
63673
|
return emptyArray;
|
|
63673
63674
|
}
|
|
63674
63675
|
function isValidIndexKeyType(type) {
|
|
63675
|
-
return !!(type.flags & (
|
|
63676
|
+
return !!(type.flags & (32 /* String */ | 64 /* Number */ | 512 /* ESSymbol */)) || isPatternLiteralType(type) || !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && some(type.types, isValidIndexKeyType);
|
|
63676
63677
|
}
|
|
63677
63678
|
function getConstraintDeclaration(type) {
|
|
63678
63679
|
return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
|
|
@@ -64173,7 +64174,7 @@ function createTypeChecker(host) {
|
|
|
64173
64174
|
}
|
|
64174
64175
|
function getTypeFromJSDocNullableTypeNode(node) {
|
|
64175
64176
|
const type = getTypeFromTypeNode(node.type);
|
|
64176
|
-
return strictNullChecks ? getNullableType(type,
|
|
64177
|
+
return strictNullChecks ? getNullableType(type, 8 /* Null */) : type;
|
|
64177
64178
|
}
|
|
64178
64179
|
function getTypeFromTypeReference(node) {
|
|
64179
64180
|
const links = getNodeLinks(node);
|
|
@@ -64946,10 +64947,10 @@ function createTypeChecker(host) {
|
|
|
64946
64947
|
return type.id;
|
|
64947
64948
|
}
|
|
64948
64949
|
function containsType(types, type) {
|
|
64949
|
-
return binarySearch(types, type,
|
|
64950
|
+
return binarySearch(types, type, identity, compareTypes) >= 0;
|
|
64950
64951
|
}
|
|
64951
64952
|
function insertType(types, type) {
|
|
64952
|
-
const index = binarySearch(types, type,
|
|
64953
|
+
const index = binarySearch(types, type, identity, compareTypes);
|
|
64953
64954
|
if (index < 0) {
|
|
64954
64955
|
types.splice(~index, 0, type);
|
|
64955
64956
|
return true;
|
|
@@ -64964,11 +64965,10 @@ function createTypeChecker(host) {
|
|
|
64964
64965
|
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) includes |= 536870912 /* IncludesConstrainedTypeVariable */;
|
|
64965
64966
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
64966
64967
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
64967
|
-
if (!strictNullChecks && flags &
|
|
64968
|
+
if (!strictNullChecks && flags & 12 /* Nullable */) {
|
|
64968
64969
|
if (!(getObjectFlags(type) & 65536 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */;
|
|
64969
64970
|
} else {
|
|
64970
|
-
const
|
|
64971
|
-
const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues);
|
|
64971
|
+
const index = binarySearch(typeSet, type, identity, compareTypes);
|
|
64972
64972
|
if (index < 0) {
|
|
64973
64973
|
typeSet.splice(~index, 0, type);
|
|
64974
64974
|
}
|
|
@@ -65046,7 +65046,7 @@ function createTypeChecker(host) {
|
|
|
65046
65046
|
i--;
|
|
65047
65047
|
const t = types[i];
|
|
65048
65048
|
const flags = t.flags;
|
|
65049
|
-
const remove = flags & (
|
|
65049
|
+
const remove = flags & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 32 /* String */ || flags & 2048 /* NumberLiteral */ && includes & 64 /* Number */ || flags & 8192 /* BigIntLiteral */ && includes & 128 /* BigInt */ || flags & 16384 /* UniqueESSymbol */ && includes & 512 /* ESSymbol */ || reduceVoidUndefined && flags & 4 /* Undefined */ && includes & 16 /* Void */ || isFreshLiteralType(t) && containsType(types, t.regularType);
|
|
65050
65050
|
if (remove) {
|
|
65051
65051
|
orderedRemoveItemAt(types, i);
|
|
65052
65052
|
}
|
|
@@ -65059,7 +65059,7 @@ function createTypeChecker(host) {
|
|
|
65059
65059
|
while (i > 0) {
|
|
65060
65060
|
i--;
|
|
65061
65061
|
const t = types[i];
|
|
65062
|
-
if (t.flags &
|
|
65062
|
+
if (t.flags & 1024 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
|
|
65063
65063
|
orderedRemoveItemAt(types, i);
|
|
65064
65064
|
}
|
|
65065
65065
|
}
|
|
@@ -65157,15 +65157,15 @@ function createTypeChecker(host) {
|
|
|
65157
65157
|
if (includes & 3 /* AnyOrUnknown */) {
|
|
65158
65158
|
return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType : unknownType;
|
|
65159
65159
|
}
|
|
65160
|
-
if (includes &
|
|
65160
|
+
if (includes & 4 /* Undefined */) {
|
|
65161
65161
|
if (typeSet.length >= 2 && typeSet[0] === undefinedType && typeSet[1] === missingType) {
|
|
65162
65162
|
orderedRemoveItemAt(typeSet, 1);
|
|
65163
65163
|
}
|
|
65164
65164
|
}
|
|
65165
|
-
if (includes & (
|
|
65165
|
+
if (includes & (65536 /* Enum */ | 15360 /* Literal */ | 16384 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16 /* Void */ && includes & 4 /* Undefined */) {
|
|
65166
65166
|
removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */));
|
|
65167
65167
|
}
|
|
65168
|
-
if (includes &
|
|
65168
|
+
if (includes & 1024 /* StringLiteral */ && includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
65169
65169
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
65170
65170
|
}
|
|
65171
65171
|
if (includes & 536870912 /* IncludesConstrainedTypeVariable */) {
|
|
@@ -65178,7 +65178,7 @@ function createTypeChecker(host) {
|
|
|
65178
65178
|
}
|
|
65179
65179
|
}
|
|
65180
65180
|
if (typeSet.length === 0) {
|
|
65181
|
-
return includes &
|
|
65181
|
+
return includes & 8 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : includes & 4 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType;
|
|
65182
65182
|
}
|
|
65183
65183
|
}
|
|
65184
65184
|
if (!origin && includes & 1048576 /* Union */) {
|
|
@@ -65201,7 +65201,7 @@ function createTypeChecker(host) {
|
|
|
65201
65201
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
65202
65202
|
}
|
|
65203
65203
|
}
|
|
65204
|
-
const objectFlags = (includes &
|
|
65204
|
+
const objectFlags = (includes & 36306963 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
65205
65205
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
65206
65206
|
}
|
|
65207
65207
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -65246,14 +65246,14 @@ function createTypeChecker(host) {
|
|
|
65246
65246
|
type.objectFlags = precomputedObjectFlags | getPropagatingFlagsOfTypes(
|
|
65247
65247
|
types,
|
|
65248
65248
|
/*excludeKinds*/
|
|
65249
|
-
|
|
65249
|
+
12 /* Nullable */
|
|
65250
65250
|
);
|
|
65251
65251
|
type.types = types;
|
|
65252
65252
|
type.origin = origin;
|
|
65253
65253
|
type.aliasSymbol = aliasSymbol;
|
|
65254
65254
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
65255
|
-
if (types.length === 2 && types[0].flags &
|
|
65256
|
-
type.flags |=
|
|
65255
|
+
if (types.length === 2 && types[0].flags & 4096 /* BooleanLiteral */ && types[1].flags & 4096 /* BooleanLiteral */) {
|
|
65256
|
+
type.flags |= 256 /* Boolean */;
|
|
65257
65257
|
type.intrinsicName = "boolean";
|
|
65258
65258
|
}
|
|
65259
65259
|
unionTypes.set(id, type);
|
|
@@ -65282,13 +65282,13 @@ function createTypeChecker(host) {
|
|
|
65282
65282
|
if (flags & 3 /* AnyOrUnknown */) {
|
|
65283
65283
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
65284
65284
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
65285
|
-
} else if (strictNullChecks || !(flags &
|
|
65285
|
+
} else if (strictNullChecks || !(flags & 12 /* Nullable */)) {
|
|
65286
65286
|
if (type === missingType) {
|
|
65287
65287
|
includes |= 262144 /* IncludesMissingType */;
|
|
65288
65288
|
type = undefinedType;
|
|
65289
65289
|
}
|
|
65290
65290
|
if (!typeSet.has(type.id.toString())) {
|
|
65291
|
-
if (type.flags &
|
|
65291
|
+
if (type.flags & 97292 /* Unit */ && includes & 97292 /* Unit */) {
|
|
65292
65292
|
includes |= 67108864 /* NonPrimitive */;
|
|
65293
65293
|
}
|
|
65294
65294
|
typeSet.set(type.id.toString(), type);
|
|
@@ -65309,7 +65309,7 @@ function createTypeChecker(host) {
|
|
|
65309
65309
|
while (i > 0) {
|
|
65310
65310
|
i--;
|
|
65311
65311
|
const t = types[i];
|
|
65312
|
-
const remove = t.flags &
|
|
65312
|
+
const remove = t.flags & 32 /* String */ && includes & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || t.flags & 64 /* Number */ && includes & 2048 /* NumberLiteral */ || t.flags & 128 /* BigInt */ && includes & 8192 /* BigIntLiteral */ || t.flags & 512 /* ESSymbol */ && includes & 16384 /* UniqueESSymbol */ || t.flags & 16 /* Void */ && includes & 4 /* Undefined */ || isEmptyAnonymousObjectType(t) && includes & 470417376 /* DefinitelyNonNullable */;
|
|
65313
65313
|
if (remove) {
|
|
65314
65314
|
orderedRemoveItemAt(types, i);
|
|
65315
65315
|
}
|
|
@@ -65324,7 +65324,7 @@ function createTypeChecker(host) {
|
|
|
65324
65324
|
if (type === undefinedType) {
|
|
65325
65325
|
return containsType(u.types, missingType);
|
|
65326
65326
|
}
|
|
65327
|
-
const primitive = type.flags &
|
|
65327
|
+
const primitive = type.flags & 1024 /* StringLiteral */ ? stringType : type.flags & (65536 /* Enum */ | 2048 /* NumberLiteral */) ? numberType : type.flags & 8192 /* BigIntLiteral */ ? bigintType : type.flags & 16384 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
65328
65328
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
65329
65329
|
return false;
|
|
65330
65330
|
}
|
|
@@ -65334,7 +65334,7 @@ function createTypeChecker(host) {
|
|
|
65334
65334
|
}
|
|
65335
65335
|
function extractRedundantTemplateLiterals(types) {
|
|
65336
65336
|
let i = types.length;
|
|
65337
|
-
const literals = filter(types, (t) => !!(t.flags &
|
|
65337
|
+
const literals = filter(types, (t) => !!(t.flags & 1024 /* StringLiteral */));
|
|
65338
65338
|
while (i > 0) {
|
|
65339
65339
|
i--;
|
|
65340
65340
|
const t = types[i];
|
|
@@ -65400,7 +65400,7 @@ function createTypeChecker(host) {
|
|
|
65400
65400
|
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
65401
65401
|
types,
|
|
65402
65402
|
/*excludeKinds*/
|
|
65403
|
-
|
|
65403
|
+
12 /* Nullable */
|
|
65404
65404
|
);
|
|
65405
65405
|
result.types = types;
|
|
65406
65406
|
result.aliasSymbol = aliasSymbol;
|
|
@@ -65415,19 +65415,19 @@ function createTypeChecker(host) {
|
|
|
65415
65415
|
if (includes & 131072 /* Never */) {
|
|
65416
65416
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
65417
65417
|
}
|
|
65418
|
-
if (strictNullChecks && includes &
|
|
65418
|
+
if (strictNullChecks && includes & 12 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || includes & 67108864 /* NonPrimitive */ && includes & (469860348 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || includes & 402654240 /* StringLike */ && includes & (469860348 /* DisjointDomains */ & ~402654240 /* StringLike */) || includes & 67648 /* NumberLike */ && includes & (469860348 /* DisjointDomains */ & ~67648 /* NumberLike */) || includes & 8320 /* BigIntLike */ && includes & (469860348 /* DisjointDomains */ & ~8320 /* BigIntLike */) || includes & 16896 /* ESSymbolLike */ && includes & (469860348 /* DisjointDomains */ & ~16896 /* ESSymbolLike */) || includes & 20 /* VoidLike */ && includes & (469860348 /* DisjointDomains */ & ~20 /* VoidLike */)) {
|
|
65419
65419
|
return neverType;
|
|
65420
65420
|
}
|
|
65421
|
-
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes &
|
|
65421
|
+
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 1024 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) {
|
|
65422
65422
|
return neverType;
|
|
65423
65423
|
}
|
|
65424
65424
|
if (includes & 1 /* Any */) {
|
|
65425
65425
|
return includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType;
|
|
65426
65426
|
}
|
|
65427
|
-
if (!strictNullChecks && includes &
|
|
65428
|
-
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes &
|
|
65427
|
+
if (!strictNullChecks && includes & 12 /* Nullable */) {
|
|
65428
|
+
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes & 4 /* Undefined */ ? undefinedType : nullType;
|
|
65429
65429
|
}
|
|
65430
|
-
if (includes &
|
|
65430
|
+
if (includes & 32 /* String */ && includes & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 64 /* Number */ && includes & 2048 /* NumberLiteral */ || includes & 128 /* BigInt */ && includes & 8192 /* BigIntLiteral */ || includes & 512 /* ESSymbol */ && includes & 16384 /* UniqueESSymbol */ || includes & 16 /* Void */ && includes & 4 /* Undefined */ || includes & 16777216 /* IncludesEmptyObject */ && includes & 470417376 /* DefinitelyNonNullable */) {
|
|
65431
65431
|
if (!(flags & 1 /* NoSupertypeReduction */)) removeRedundantSupertypes(typeSet, includes);
|
|
65432
65432
|
}
|
|
65433
65433
|
if (includes & 262144 /* IncludesMissingType */) {
|
|
@@ -65464,12 +65464,12 @@ function createTypeChecker(host) {
|
|
|
65464
65464
|
if (includes & 1048576 /* Union */) {
|
|
65465
65465
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
65466
65466
|
result = getIntersectionType(typeSet, flags, aliasSymbol, aliasTypeArguments);
|
|
65467
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags &
|
|
65467
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 4 /* Undefined */))) {
|
|
65468
65468
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
65469
|
-
removeFromEach(typeSet,
|
|
65469
|
+
removeFromEach(typeSet, 4 /* Undefined */);
|
|
65470
65470
|
result = getUnionType([getIntersectionType(typeSet, flags), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
65471
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags &
|
|
65472
|
-
removeFromEach(typeSet,
|
|
65471
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 8 /* Null */ || t.types[1].flags & 8 /* Null */)))) {
|
|
65472
|
+
removeFromEach(typeSet, 8 /* Null */);
|
|
65473
65473
|
result = getUnionType([getIntersectionType(typeSet, flags), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
65474
65474
|
} else if (typeSet.length >= 3 && types.length > 2) {
|
|
65475
65475
|
const middle = Math.floor(typeSet.length / 2);
|
|
@@ -65534,7 +65534,7 @@ function createTypeChecker(host) {
|
|
|
65534
65534
|
const types = map(node.types, getTypeFromTypeNode);
|
|
65535
65535
|
const emptyIndex = types.length === 2 ? types.indexOf(emptyTypeLiteralType) : -1;
|
|
65536
65536
|
const t = emptyIndex >= 0 ? types[1 - emptyIndex] : unknownType;
|
|
65537
|
-
const noSupertypeReduction = !!(t.flags & (
|
|
65537
|
+
const noSupertypeReduction = !!(t.flags & (32 /* String */ | 64 /* Number */ | 128 /* BigInt */) || t.flags & 134217728 /* TemplateLiteral */ && isPatternLiteralType(t));
|
|
65538
65538
|
links.resolvedType = getIntersectionType(types, noSupertypeReduction ? 1 /* NoSupertypeReduction */ : 0, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
65539
65539
|
}
|
|
65540
65540
|
return links.resolvedType;
|
|
@@ -65568,11 +65568,11 @@ function createTypeChecker(host) {
|
|
|
65568
65568
|
forEachType(constraintType, addMemberForKeyType);
|
|
65569
65569
|
} else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
65570
65570
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
65571
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType,
|
|
65571
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 19456 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
|
|
65572
65572
|
} else {
|
|
65573
65573
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
65574
65574
|
}
|
|
65575
|
-
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ |
|
|
65575
|
+
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ | 32 /* String */))) : getUnionType(keyTypes);
|
|
65576
65576
|
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
65577
65577
|
return constraintType;
|
|
65578
65578
|
}
|
|
@@ -65627,7 +65627,7 @@ function createTypeChecker(host) {
|
|
|
65627
65627
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
65628
65628
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
65629
65629
|
const propertyTypes = map(getPropertiesOfType(type), (prop) => getLiteralTypeFromProperty(prop, include));
|
|
65630
|
-
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include &
|
|
65630
|
+
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 64 /* Number */ ? stringOrNumberType : info.keyType : neverType);
|
|
65631
65631
|
return getUnionType(
|
|
65632
65632
|
concatenate(propertyTypes, indexKeyTypes),
|
|
65633
65633
|
1 /* Literal */,
|
|
@@ -65643,7 +65643,7 @@ function createTypeChecker(host) {
|
|
|
65643
65643
|
}
|
|
65644
65644
|
function getIndexType(type, indexFlags = 0 /* None */) {
|
|
65645
65645
|
type = getReducedType(type);
|
|
65646
|
-
return isNoInferType(type) ? getNoInferType(getIndexType(type.baseType, indexFlags)) : shouldDeferIndexType(type, indexFlags) ? getIndexTypeForGenericType(type, indexFlags) : type.flags & 1048576 /* Union */ ? getIntersectionType(map(type.types, (t) => getIndexType(t, indexFlags))) : type.flags & 2097152 /* Intersection */ ? getUnionType(map(type.types, (t) => getIndexType(t, indexFlags))) : getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, indexFlags) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : type.flags & (1 /* Any */ | 131072 /* Never */) ? stringNumberSymbolType : getLiteralTypeFromProperties(type, (indexFlags & 2 /* NoIndexSignatures */ ?
|
|
65646
|
+
return isNoInferType(type) ? getNoInferType(getIndexType(type.baseType, indexFlags)) : shouldDeferIndexType(type, indexFlags) ? getIndexTypeForGenericType(type, indexFlags) : type.flags & 1048576 /* Union */ ? getIntersectionType(map(type.types, (t) => getIndexType(t, indexFlags))) : type.flags & 2097152 /* Intersection */ ? getUnionType(map(type.types, (t) => getIndexType(t, indexFlags))) : getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, indexFlags) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : type.flags & (1 /* Any */ | 131072 /* Never */) ? stringNumberSymbolType : getLiteralTypeFromProperties(type, (indexFlags & 2 /* NoIndexSignatures */ ? 1024 /* StringLiteral */ : 402654240 /* StringLike */) | (indexFlags & 1 /* StringsOnly */ ? 0 : 67648 /* NumberLike */ | 16896 /* ESSymbolLike */), indexFlags === 0 /* None */);
|
|
65647
65647
|
}
|
|
65648
65648
|
function getExtractStringType(type) {
|
|
65649
65649
|
const extractTypeAlias = getGlobalExtractSymbol();
|
|
@@ -65701,7 +65701,7 @@ function createTypeChecker(host) {
|
|
|
65701
65701
|
}
|
|
65702
65702
|
newTexts.push(text);
|
|
65703
65703
|
if (every(newTexts, (t) => t === "")) {
|
|
65704
|
-
if (every(newTypes, (t) => !!(t.flags &
|
|
65704
|
+
if (every(newTypes, (t) => !!(t.flags & 32 /* String */))) {
|
|
65705
65705
|
return stringType;
|
|
65706
65706
|
}
|
|
65707
65707
|
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
@@ -65717,7 +65717,7 @@ function createTypeChecker(host) {
|
|
|
65717
65717
|
function addSpans(texts2, types2) {
|
|
65718
65718
|
for (let i = 0; i < types2.length; i++) {
|
|
65719
65719
|
const t = types2[i];
|
|
65720
|
-
if (t.flags & (
|
|
65720
|
+
if (t.flags & (15360 /* Literal */ | 8 /* Null */ | 4 /* Undefined */)) {
|
|
65721
65721
|
text += getTemplateStringForType(t) || "";
|
|
65722
65722
|
text += texts2[i + 1];
|
|
65723
65723
|
} else if (t.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -65736,7 +65736,7 @@ function createTypeChecker(host) {
|
|
|
65736
65736
|
}
|
|
65737
65737
|
}
|
|
65738
65738
|
function getTemplateStringForType(type) {
|
|
65739
|
-
return type.flags &
|
|
65739
|
+
return type.flags & 1024 /* StringLiteral */ ? type.value : type.flags & 2048 /* NumberLiteral */ ? "" + type.value : type.flags & 8192 /* BigIntLiteral */ ? pseudoBigIntToString(type.value) : type.flags & (4096 /* BooleanLiteral */ | 12 /* Nullable */) ? type.intrinsicName : void 0;
|
|
65740
65740
|
}
|
|
65741
65741
|
function createTemplateLiteralType(texts, types) {
|
|
65742
65742
|
const type = createType(134217728 /* TemplateLiteral */);
|
|
@@ -65745,9 +65745,9 @@ function createTypeChecker(host) {
|
|
|
65745
65745
|
return type;
|
|
65746
65746
|
}
|
|
65747
65747
|
function getStringMappingType(symbol, type) {
|
|
65748
|
-
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags &
|
|
65748
|
+
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 1024 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
|
|
65749
65749
|
// Mapping<Mapping<T>> === Mapping<T>
|
|
65750
|
-
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ |
|
|
65750
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ | 32 /* String */ | 268435456 /* StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : (
|
|
65751
65751
|
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
65752
65752
|
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) : type
|
|
65753
65753
|
)
|
|
@@ -65885,7 +65885,7 @@ function createTypeChecker(host) {
|
|
|
65885
65885
|
}
|
|
65886
65886
|
}
|
|
65887
65887
|
}
|
|
65888
|
-
if (!(indexType.flags &
|
|
65888
|
+
if (!(indexType.flags & 12 /* Nullable */) && isTypeAssignableToKind(indexType, 402654240 /* StringLike */ | 67648 /* NumberLike */ | 16896 /* ESSymbolLike */)) {
|
|
65889
65889
|
if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
|
|
65890
65890
|
return objectType;
|
|
65891
65891
|
}
|
|
@@ -65901,13 +65901,13 @@ function createTypeChecker(host) {
|
|
|
65901
65901
|
}
|
|
65902
65902
|
return void 0;
|
|
65903
65903
|
}
|
|
65904
|
-
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType,
|
|
65904
|
+
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 32 /* String */ | 64 /* Number */)) {
|
|
65905
65905
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
65906
65906
|
error2(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
|
|
65907
65907
|
return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
|
|
65908
65908
|
}
|
|
65909
65909
|
errorIfWritingToReadonlyIndex(indexInfo);
|
|
65910
|
-
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags &
|
|
65910
|
+
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags & 32768 /* EnumLiteral */ && getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
|
|
65911
65911
|
return getUnionType([indexInfo.type, missingType]);
|
|
65912
65912
|
}
|
|
65913
65913
|
return indexInfo.type;
|
|
@@ -65920,10 +65920,10 @@ function createTypeChecker(host) {
|
|
|
65920
65920
|
}
|
|
65921
65921
|
if (accessExpression && !isConstEnumObjectType(objectType)) {
|
|
65922
65922
|
if (isObjectLiteralType2(objectType)) {
|
|
65923
|
-
if (noImplicitAny && indexType.flags & (
|
|
65923
|
+
if (noImplicitAny && indexType.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */)) {
|
|
65924
65924
|
diagnostics.add(createDiagnosticForNode(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)));
|
|
65925
65925
|
return undefinedType;
|
|
65926
|
-
} else if (indexType.flags & (
|
|
65926
|
+
} else if (indexType.flags & (64 /* Number */ | 32 /* String */)) {
|
|
65927
65927
|
const types = map(objectType.properties, (property) => {
|
|
65928
65928
|
return getTypeOfSymbol(property);
|
|
65929
65929
|
});
|
|
@@ -65950,7 +65950,7 @@ function createTypeChecker(host) {
|
|
|
65950
65950
|
error2(accessExpression, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion2);
|
|
65951
65951
|
} else {
|
|
65952
65952
|
let errorInfo;
|
|
65953
|
-
if (indexType.flags &
|
|
65953
|
+
if (indexType.flags & 32768 /* EnumLiteral */) {
|
|
65954
65954
|
errorInfo = chainDiagnosticMessages(
|
|
65955
65955
|
/*details*/
|
|
65956
65956
|
void 0,
|
|
@@ -65958,7 +65958,7 @@ function createTypeChecker(host) {
|
|
|
65958
65958
|
"[" + typeToString(indexType) + "]",
|
|
65959
65959
|
typeToString(objectType)
|
|
65960
65960
|
);
|
|
65961
|
-
} else if (indexType.flags &
|
|
65961
|
+
} else if (indexType.flags & 16384 /* UniqueESSymbol */) {
|
|
65962
65962
|
const symbolName2 = getFullyQualifiedName(indexType.symbol, accessExpression);
|
|
65963
65963
|
errorInfo = chainDiagnosticMessages(
|
|
65964
65964
|
/*details*/
|
|
@@ -65967,7 +65967,7 @@ function createTypeChecker(host) {
|
|
|
65967
65967
|
"[" + symbolName2 + "]",
|
|
65968
65968
|
typeToString(objectType)
|
|
65969
65969
|
);
|
|
65970
|
-
} else if (indexType.flags &
|
|
65970
|
+
} else if (indexType.flags & 1024 /* StringLiteral */) {
|
|
65971
65971
|
errorInfo = chainDiagnosticMessages(
|
|
65972
65972
|
/*details*/
|
|
65973
65973
|
void 0,
|
|
@@ -65975,7 +65975,7 @@ function createTypeChecker(host) {
|
|
|
65975
65975
|
indexType.value,
|
|
65976
65976
|
typeToString(objectType)
|
|
65977
65977
|
);
|
|
65978
|
-
} else if (indexType.flags &
|
|
65978
|
+
} else if (indexType.flags & 2048 /* NumberLiteral */) {
|
|
65979
65979
|
errorInfo = chainDiagnosticMessages(
|
|
65980
65980
|
/*details*/
|
|
65981
65981
|
void 0,
|
|
@@ -65983,7 +65983,7 @@ function createTypeChecker(host) {
|
|
|
65983
65983
|
indexType.value,
|
|
65984
65984
|
typeToString(objectType)
|
|
65985
65985
|
);
|
|
65986
|
-
} else if (indexType.flags & (
|
|
65986
|
+
} else if (indexType.flags & (64 /* Number */ | 32 /* String */)) {
|
|
65987
65987
|
errorInfo = chainDiagnosticMessages(
|
|
65988
65988
|
/*details*/
|
|
65989
65989
|
void 0,
|
|
@@ -66014,9 +66014,9 @@ function createTypeChecker(host) {
|
|
|
66014
66014
|
}
|
|
66015
66015
|
if (accessNode) {
|
|
66016
66016
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
66017
|
-
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (
|
|
66017
|
+
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */)) {
|
|
66018
66018
|
error2(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
|
|
66019
|
-
} else if (indexType.flags & (
|
|
66019
|
+
} else if (indexType.flags & (32 /* String */ | 64 /* Number */)) {
|
|
66020
66020
|
error2(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
|
|
66021
66021
|
} else {
|
|
66022
66022
|
const typeString = indexNode.kind === 10 /* BigIntLiteral */ ? "bigint" : typeToString(indexType);
|
|
@@ -66040,7 +66040,7 @@ function createTypeChecker(host) {
|
|
|
66040
66040
|
if (type.flags & 2097152 /* Intersection */) {
|
|
66041
66041
|
let seenPlaceholder = false;
|
|
66042
66042
|
for (const t of type.types) {
|
|
66043
|
-
if (t.flags & (
|
|
66043
|
+
if (t.flags & (15360 /* Literal */ | 12 /* Nullable */) || isPatternLiteralPlaceholderType(t)) {
|
|
66044
66044
|
seenPlaceholder = true;
|
|
66045
66045
|
} else if (!(t.flags & 524288 /* Object */)) {
|
|
66046
66046
|
return false;
|
|
@@ -66048,7 +66048,7 @@ function createTypeChecker(host) {
|
|
|
66048
66048
|
}
|
|
66049
66049
|
return seenPlaceholder;
|
|
66050
66050
|
}
|
|
66051
|
-
return !!(type.flags & (1 /* Any */ |
|
|
66051
|
+
return !!(type.flags & (1 /* Any */ | 32 /* String */ | 64 /* Number */ | 128 /* BigInt */)) || isPatternLiteralType(type);
|
|
66052
66052
|
}
|
|
66053
66053
|
function isPatternLiteralType(type) {
|
|
66054
66054
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
@@ -66113,10 +66113,10 @@ function createTypeChecker(host) {
|
|
|
66113
66113
|
return type[cache] = distributedOverObject;
|
|
66114
66114
|
}
|
|
66115
66115
|
}
|
|
66116
|
-
if (isGenericTupleType(objectType) && indexType.flags &
|
|
66116
|
+
if (isGenericTupleType(objectType) && indexType.flags & 67648 /* NumberLike */) {
|
|
66117
66117
|
const elementType = getElementTypeOfSliceOfTupleType(
|
|
66118
66118
|
objectType,
|
|
66119
|
-
indexType.flags &
|
|
66119
|
+
indexType.flags & 64 /* Number */ ? 0 : objectType.target.fixedLength,
|
|
66120
66120
|
/*endSkipCount*/
|
|
66121
66121
|
0,
|
|
66122
66122
|
writing
|
|
@@ -66169,14 +66169,14 @@ function createTypeChecker(host) {
|
|
|
66169
66169
|
}
|
|
66170
66170
|
function couldAccessOptionalProperty(objectType, indexType) {
|
|
66171
66171
|
const indexConstraint = getBaseConstraintOfType(indexType);
|
|
66172
|
-
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p,
|
|
66172
|
+
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p, 19456 /* StringOrNumberLiteralOrUnique */), indexConstraint));
|
|
66173
66173
|
}
|
|
66174
66174
|
function getIndexedAccessType(objectType, indexType, accessFlags = 0 /* None */, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
66175
66175
|
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
66176
66176
|
}
|
|
66177
66177
|
function indexTypeLessThan(indexType, limit) {
|
|
66178
66178
|
return everyType(indexType, (t) => {
|
|
66179
|
-
if (t.flags &
|
|
66179
|
+
if (t.flags & 3072 /* StringOrNumberLiteral */) {
|
|
66180
66180
|
const propName = getPropertyNameFromType(t);
|
|
66181
66181
|
if (isNumericLiteralName(propName)) {
|
|
66182
66182
|
const index = +propName;
|
|
@@ -66191,7 +66191,7 @@ function createTypeChecker(host) {
|
|
|
66191
66191
|
return wildcardType;
|
|
66192
66192
|
}
|
|
66193
66193
|
objectType = getReducedType(objectType);
|
|
66194
|
-
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags &
|
|
66194
|
+
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 12 /* Nullable */) && isTypeAssignableToKind(indexType, 32 /* String */ | 64 /* Number */)) {
|
|
66195
66195
|
indexType = stringType;
|
|
66196
66196
|
}
|
|
66197
66197
|
if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) accessFlags |= 1 /* IncludeUndefined */;
|
|
@@ -66208,7 +66208,7 @@ function createTypeChecker(host) {
|
|
|
66208
66208
|
return type;
|
|
66209
66209
|
}
|
|
66210
66210
|
const apparentObjectType = getReducedApparentType(objectType);
|
|
66211
|
-
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags &
|
|
66211
|
+
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 256 /* Boolean */)) {
|
|
66212
66212
|
const propTypes = [];
|
|
66213
66213
|
let wasMissingProp = false;
|
|
66214
66214
|
for (const t of indexType.types) {
|
|
@@ -66541,7 +66541,7 @@ function createTypeChecker(host) {
|
|
|
66541
66541
|
return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type);
|
|
66542
66542
|
}
|
|
66543
66543
|
function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
|
|
66544
|
-
return isEmptyObjectType(type) || !!(type.flags & (
|
|
66544
|
+
return isEmptyObjectType(type) || !!(type.flags & (8 /* Null */ | 4 /* Undefined */ | 4352 /* BooleanLike */ | 67648 /* NumberLike */ | 8320 /* BigIntLike */ | 402654240 /* StringLike */ | 98304 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */));
|
|
66545
66545
|
}
|
|
66546
66546
|
function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
|
|
66547
66547
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
@@ -66604,7 +66604,7 @@ function createTypeChecker(host) {
|
|
|
66604
66604
|
if (right.flags & 1048576 /* Union */) {
|
|
66605
66605
|
return checkCrossProductUnion([left, right]) ? mapType(right, (t) => getSpreadType(left, t, symbol, objectFlags, readonly)) : errorType;
|
|
66606
66606
|
}
|
|
66607
|
-
if (right.flags & (
|
|
66607
|
+
if (right.flags & (4352 /* BooleanLike */ | 67648 /* NumberLike */ | 8320 /* BigIntLike */ | 402654240 /* StringLike */ | 98304 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) {
|
|
66608
66608
|
return left;
|
|
66609
66609
|
}
|
|
66610
66610
|
if (isGenericObjectType(left) || isGenericObjectType(right)) {
|
|
@@ -66686,7 +66686,7 @@ function createTypeChecker(host) {
|
|
|
66686
66686
|
return type;
|
|
66687
66687
|
}
|
|
66688
66688
|
function getFreshTypeOfLiteralType(type) {
|
|
66689
|
-
if (type.flags &
|
|
66689
|
+
if (type.flags & 80896 /* Freshable */) {
|
|
66690
66690
|
if (!type.freshType) {
|
|
66691
66691
|
const freshType = createLiteralType(type.flags, type.value, type.symbol, type);
|
|
66692
66692
|
freshType.freshType = freshType;
|
|
@@ -66697,28 +66697,28 @@ function createTypeChecker(host) {
|
|
|
66697
66697
|
return type;
|
|
66698
66698
|
}
|
|
66699
66699
|
function getRegularTypeOfLiteralType(type) {
|
|
66700
|
-
return type.flags &
|
|
66700
|
+
return type.flags & 80896 /* Freshable */ ? type.regularType : type.flags & 1048576 /* Union */ ? type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType)) : type;
|
|
66701
66701
|
}
|
|
66702
66702
|
function isFreshLiteralType(type) {
|
|
66703
|
-
return !!(type.flags &
|
|
66703
|
+
return !!(type.flags & 80896 /* Freshable */) && type.freshType === type;
|
|
66704
66704
|
}
|
|
66705
66705
|
function getStringLiteralType(value) {
|
|
66706
66706
|
let type;
|
|
66707
|
-
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(
|
|
66707
|
+
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(1024 /* StringLiteral */, value)), type);
|
|
66708
66708
|
}
|
|
66709
66709
|
function getNumberLiteralType(value) {
|
|
66710
66710
|
let type;
|
|
66711
|
-
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(
|
|
66711
|
+
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(2048 /* NumberLiteral */, value)), type);
|
|
66712
66712
|
}
|
|
66713
66713
|
function getBigIntLiteralType(value) {
|
|
66714
66714
|
let type;
|
|
66715
66715
|
const key = pseudoBigIntToString(value);
|
|
66716
|
-
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(
|
|
66716
|
+
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(8192 /* BigIntLiteral */, value)), type);
|
|
66717
66717
|
}
|
|
66718
66718
|
function getEnumLiteralType(value, enumId, symbol) {
|
|
66719
66719
|
let type;
|
|
66720
66720
|
const key = `${enumId}${typeof value === "string" ? "@" : "#"}${value}`;
|
|
66721
|
-
const flags =
|
|
66721
|
+
const flags = 32768 /* EnumLiteral */ | (typeof value === "string" ? 1024 /* StringLiteral */ : 2048 /* NumberLiteral */);
|
|
66722
66722
|
return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type);
|
|
66723
66723
|
}
|
|
66724
66724
|
function getTypeFromLiteralTypeNode(node) {
|
|
@@ -66732,7 +66732,7 @@ function createTypeChecker(host) {
|
|
|
66732
66732
|
return links.resolvedType;
|
|
66733
66733
|
}
|
|
66734
66734
|
function createUniqueESSymbolType(symbol) {
|
|
66735
|
-
const type = createTypeWithSymbol(
|
|
66735
|
+
const type = createTypeWithSymbol(16384 /* UniqueESSymbol */, symbol);
|
|
66736
66736
|
type.escapedName = `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}`;
|
|
66737
66737
|
return type;
|
|
66738
66738
|
}
|
|
@@ -67120,7 +67120,7 @@ function createTypeChecker(host) {
|
|
|
67120
67120
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
67121
67121
|
target.instantiations.set(id, result);
|
|
67122
67122
|
const resultObjectFlags = getObjectFlags(result);
|
|
67123
|
-
if (result.flags &
|
|
67123
|
+
if (result.flags & 3801101 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
67124
67124
|
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
67125
67125
|
if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
67126
67126
|
if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
|
|
@@ -67249,7 +67249,7 @@ function createTypeChecker(host) {
|
|
|
67249
67249
|
const templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
|
|
67250
67250
|
const propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
|
|
67251
67251
|
const modifiers = getMappedTypeModifiers(type);
|
|
67252
|
-
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType,
|
|
67252
|
+
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 4 /* Undefined */ | 16 /* Void */) ? getOptionalType(
|
|
67253
67253
|
propType,
|
|
67254
67254
|
/*isProperty*/
|
|
67255
67255
|
true
|
|
@@ -67796,7 +67796,7 @@ function createTypeChecker(host) {
|
|
|
67796
67796
|
createDiagnosticForNode(
|
|
67797
67797
|
targetNode,
|
|
67798
67798
|
Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1,
|
|
67799
|
-
propertyName && !(nameType.flags &
|
|
67799
|
+
propertyName && !(nameType.flags & 16384 /* UniqueESSymbol */) ? unescapeLeadingUnderscores(propertyName) : typeToString(nameType),
|
|
67800
67800
|
typeToString(target)
|
|
67801
67801
|
)
|
|
67802
67802
|
);
|
|
@@ -68039,7 +68039,7 @@ function createTypeChecker(host) {
|
|
|
68039
68039
|
if (!length(node.properties)) return;
|
|
68040
68040
|
for (const prop of node.properties) {
|
|
68041
68041
|
if (isSpreadAssignment(prop)) continue;
|
|
68042
|
-
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop),
|
|
68042
|
+
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop), 19456 /* StringOrNumberLiteralOrUnique */);
|
|
68043
68043
|
if (!type || type.flags & 131072 /* Never */) {
|
|
68044
68044
|
continue;
|
|
68045
68045
|
}
|
|
@@ -68089,7 +68089,7 @@ function createTypeChecker(host) {
|
|
|
68089
68089
|
}
|
|
68090
68090
|
return false;
|
|
68091
68091
|
}
|
|
68092
|
-
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
68092
|
+
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes2, reportUnreliableMarkers) {
|
|
68093
68093
|
if (source === target) {
|
|
68094
68094
|
return -1 /* True */;
|
|
68095
68095
|
}
|
|
@@ -68114,7 +68114,7 @@ function createTypeChecker(host) {
|
|
|
68114
68114
|
target,
|
|
68115
68115
|
/*inferenceContext*/
|
|
68116
68116
|
void 0,
|
|
68117
|
-
|
|
68117
|
+
compareTypes2
|
|
68118
68118
|
);
|
|
68119
68119
|
}
|
|
68120
68120
|
const sourceCount = getParameterCount(source);
|
|
@@ -68130,12 +68130,12 @@ function createTypeChecker(host) {
|
|
|
68130
68130
|
if (sourceThisType && sourceThisType !== voidType) {
|
|
68131
68131
|
const targetThisType = getThisTypeOfSignature(target);
|
|
68132
68132
|
if (targetThisType) {
|
|
68133
|
-
const related = !strictVariance &&
|
|
68133
|
+
const related = !strictVariance && compareTypes2(
|
|
68134
68134
|
sourceThisType,
|
|
68135
68135
|
targetThisType,
|
|
68136
68136
|
/*reportErrors*/
|
|
68137
68137
|
false
|
|
68138
|
-
) ||
|
|
68138
|
+
) || compareTypes2(targetThisType, sourceThisType, reportErrors2);
|
|
68139
68139
|
if (!related) {
|
|
68140
68140
|
if (reportErrors2) {
|
|
68141
68141
|
errorReporter(Diagnostics.The_this_types_of_each_signature_are_incompatible);
|
|
@@ -68154,13 +68154,13 @@ function createTypeChecker(host) {
|
|
|
68154
68154
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
68155
68155
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
68156
68156
|
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
68157
|
-
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
68157
|
+
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes2, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes2(
|
|
68158
68158
|
sourceType,
|
|
68159
68159
|
targetType,
|
|
68160
68160
|
/*reportErrors*/
|
|
68161
68161
|
false
|
|
68162
|
-
) ||
|
|
68163
|
-
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) &&
|
|
68162
|
+
) || compareTypes2(targetType, sourceType, reportErrors2);
|
|
68163
|
+
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes2(
|
|
68164
68164
|
sourceType,
|
|
68165
68165
|
targetType,
|
|
68166
68166
|
/*reportErrors*/
|
|
@@ -68187,7 +68187,7 @@ function createTypeChecker(host) {
|
|
|
68187
68187
|
if (targetTypePredicate) {
|
|
68188
68188
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
68189
68189
|
if (sourceTypePredicate) {
|
|
68190
|
-
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter,
|
|
68190
|
+
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter, compareTypes2);
|
|
68191
68191
|
} else if (isIdentifierTypePredicate(targetTypePredicate) || isThisTypePredicate(targetTypePredicate)) {
|
|
68192
68192
|
if (reportErrors2) {
|
|
68193
68193
|
errorReporter(Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
|
|
@@ -68195,12 +68195,12 @@ function createTypeChecker(host) {
|
|
|
68195
68195
|
return 0 /* False */;
|
|
68196
68196
|
}
|
|
68197
68197
|
} else {
|
|
68198
|
-
result &= checkMode & 1 /* BivariantCallback */ &&
|
|
68198
|
+
result &= checkMode & 1 /* BivariantCallback */ && compareTypes2(
|
|
68199
68199
|
targetReturnType,
|
|
68200
68200
|
sourceReturnType,
|
|
68201
68201
|
/*reportErrors*/
|
|
68202
68202
|
false
|
|
68203
|
-
) ||
|
|
68203
|
+
) || compareTypes2(sourceReturnType, targetReturnType, reportErrors2);
|
|
68204
68204
|
if (!result && reportErrors2 && incompatibleErrorReporter) {
|
|
68205
68205
|
incompatibleErrorReporter(sourceReturnType, targetReturnType);
|
|
68206
68206
|
}
|
|
@@ -68208,7 +68208,7 @@ function createTypeChecker(host) {
|
|
|
68208
68208
|
}
|
|
68209
68209
|
return result;
|
|
68210
68210
|
}
|
|
68211
|
-
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter,
|
|
68211
|
+
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter, compareTypes2) {
|
|
68212
68212
|
if (source.kind !== target.kind) {
|
|
68213
68213
|
if (reportErrors2) {
|
|
68214
68214
|
errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
|
|
@@ -68225,7 +68225,7 @@ function createTypeChecker(host) {
|
|
|
68225
68225
|
return 0 /* False */;
|
|
68226
68226
|
}
|
|
68227
68227
|
}
|
|
68228
|
-
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
68228
|
+
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ? compareTypes2(source.type, target.type, reportErrors2) : 0 /* False */;
|
|
68229
68229
|
if (related === 0 /* False */ && reportErrors2) {
|
|
68230
68230
|
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
|
|
68231
68231
|
}
|
|
@@ -68259,18 +68259,18 @@ function createTypeChecker(host) {
|
|
|
68259
68259
|
if (strictNullChecks && type.flags & 1048576 /* Union */) {
|
|
68260
68260
|
if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
|
|
68261
68261
|
const types = type.types;
|
|
68262
|
-
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags &
|
|
68262
|
+
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 4 /* Undefined */ && types[1].flags & 8 /* Null */ && some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
|
|
68263
68263
|
}
|
|
68264
68264
|
return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
|
|
68265
68265
|
}
|
|
68266
68266
|
return false;
|
|
68267
68267
|
}
|
|
68268
68268
|
function containsUndefinedType(type) {
|
|
68269
|
-
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags &
|
|
68269
|
+
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 4 /* Undefined */);
|
|
68270
68270
|
}
|
|
68271
68271
|
function containsNonMissingUndefinedType(type) {
|
|
68272
68272
|
const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
|
|
68273
|
-
return !!(candidate.flags &
|
|
68273
|
+
return !!(candidate.flags & 4 /* Undefined */) && candidate !== missingType;
|
|
68274
68274
|
}
|
|
68275
68275
|
function isStringIndexSignatureOnlyType(type) {
|
|
68276
68276
|
return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || type.flags & 3145728 /* UnionOrIntersection */ && every(type.types, isStringIndexSignatureOnlyType) || false;
|
|
@@ -68341,25 +68341,25 @@ function createTypeChecker(host) {
|
|
|
68341
68341
|
if (t & 1 /* Any */ || s & 131072 /* Never */ || source === wildcardType) return true;
|
|
68342
68342
|
if (t & 2 /* Unknown */ && !(relation === strictSubtypeRelation && s & 1 /* Any */)) return true;
|
|
68343
68343
|
if (t & 131072 /* Never */) return false;
|
|
68344
|
-
if (s &
|
|
68345
|
-
if (s &
|
|
68346
|
-
if (s &
|
|
68347
|
-
if (s &
|
|
68348
|
-
if (s &
|
|
68349
|
-
if (s &
|
|
68350
|
-
if (s &
|
|
68351
|
-
if (s &
|
|
68352
|
-
if (s &
|
|
68344
|
+
if (s & 402654240 /* StringLike */ && t & 32 /* String */) return true;
|
|
68345
|
+
if (s & 1024 /* StringLiteral */ && s & 32768 /* EnumLiteral */ && t & 1024 /* StringLiteral */ && !(t & 32768 /* EnumLiteral */) && source.value === target.value) return true;
|
|
68346
|
+
if (s & 67648 /* NumberLike */ && t & 64 /* Number */) return true;
|
|
68347
|
+
if (s & 2048 /* NumberLiteral */ && s & 32768 /* EnumLiteral */ && t & 2048 /* NumberLiteral */ && !(t & 32768 /* EnumLiteral */) && source.value === target.value) return true;
|
|
68348
|
+
if (s & 8320 /* BigIntLike */ && t & 128 /* BigInt */) return true;
|
|
68349
|
+
if (s & 4352 /* BooleanLike */ && t & 256 /* Boolean */) return true;
|
|
68350
|
+
if (s & 16896 /* ESSymbolLike */ && t & 512 /* ESSymbol */) return true;
|
|
68351
|
+
if (s & 65536 /* Enum */ && t & 65536 /* Enum */ && source.symbol.escapedName === target.symbol.escapedName && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
68352
|
+
if (s & 32768 /* EnumLiteral */ && t & 32768 /* EnumLiteral */) {
|
|
68353
68353
|
if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
68354
|
-
if (s &
|
|
68354
|
+
if (s & 15360 /* Literal */ && t & 15360 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
68355
68355
|
}
|
|
68356
|
-
if (s &
|
|
68357
|
-
if (s &
|
|
68356
|
+
if (s & 4 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (4 /* Undefined */ | 16 /* Void */))) return true;
|
|
68357
|
+
if (s & 8 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 8 /* Null */)) return true;
|
|
68358
68358
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(getObjectFlags(source) & 8192 /* FreshLiteral */))) return true;
|
|
68359
68359
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
68360
68360
|
if (s & 1 /* Any */) return true;
|
|
68361
|
-
if (s &
|
|
68362
|
-
if (s &
|
|
68361
|
+
if (s & 64 /* Number */ && (t & 65536 /* Enum */ || t & 2048 /* NumberLiteral */ && t & 32768 /* EnumLiteral */)) return true;
|
|
68362
|
+
if (s & 2048 /* NumberLiteral */ && !(s & 32768 /* EnumLiteral */) && (t & 65536 /* Enum */ || t & 2048 /* NumberLiteral */ && t & 32768 /* EnumLiteral */ && source.value === target.value)) return true;
|
|
68363
68363
|
if (isUnknownLikeUnionType(target)) return true;
|
|
68364
68364
|
}
|
|
68365
68365
|
return false;
|
|
@@ -68380,7 +68380,7 @@ function createTypeChecker(host) {
|
|
|
68380
68380
|
}
|
|
68381
68381
|
} else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
|
|
68382
68382
|
if (source.flags !== target.flags) return false;
|
|
68383
|
-
if (source.flags &
|
|
68383
|
+
if (source.flags & 67240959 /* Singleton */) return true;
|
|
68384
68384
|
}
|
|
68385
68385
|
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
68386
68386
|
const related = relation.get(getRelationKey(
|
|
@@ -68434,7 +68434,7 @@ function createTypeChecker(host) {
|
|
|
68434
68434
|
let hasNullableOrEmpty = false;
|
|
68435
68435
|
for (const t of type.types) {
|
|
68436
68436
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
68437
|
-
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags &
|
|
68437
|
+
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 12 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
68438
68438
|
if (hasInstantiable && hasNullableOrEmpty) return true;
|
|
68439
68439
|
}
|
|
68440
68440
|
return false;
|
|
@@ -68704,7 +68704,7 @@ function createTypeChecker(host) {
|
|
|
68704
68704
|
} else if (exactOptionalPropertyTypes && getExactOptionalUnassignableProperties(source2, target2).length) {
|
|
68705
68705
|
message = Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties;
|
|
68706
68706
|
} else {
|
|
68707
|
-
if (source2.flags &
|
|
68707
|
+
if (source2.flags & 1024 /* StringLiteral */ && target2.flags & 1048576 /* Union */) {
|
|
68708
68708
|
const suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source2, target2);
|
|
68709
68709
|
if (suggestedType) {
|
|
68710
68710
|
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType));
|
|
@@ -68773,7 +68773,7 @@ function createTypeChecker(host) {
|
|
|
68773
68773
|
if (source2 === target2) return -1 /* True */;
|
|
68774
68774
|
if (relation === identityRelation) {
|
|
68775
68775
|
if (source2.flags !== target2.flags) return 0 /* False */;
|
|
68776
|
-
if (source2.flags &
|
|
68776
|
+
if (source2.flags & 67240959 /* Singleton */) return -1 /* True */;
|
|
68777
68777
|
traceUnionsOrIntersectionsTooLarge(source2, target2);
|
|
68778
68778
|
return recursiveTypeRelatedTo(
|
|
68779
68779
|
source2,
|
|
@@ -68787,10 +68787,10 @@ function createTypeChecker(host) {
|
|
|
68787
68787
|
if (source2.flags & 262144 /* TypeParameter */ && getConstraintOfType(source2) === target2) {
|
|
68788
68788
|
return -1 /* True */;
|
|
68789
68789
|
}
|
|
68790
|
-
if (source2.flags &
|
|
68790
|
+
if (source2.flags & 470417376 /* DefinitelyNonNullable */ && target2.flags & 1048576 /* Union */) {
|
|
68791
68791
|
const types = target2.types;
|
|
68792
|
-
const candidate = types.length === 2 && types[0].flags &
|
|
68793
|
-
if (candidate && !(candidate.flags &
|
|
68792
|
+
const candidate = types.length === 2 && types[0].flags & 12 /* Nullable */ ? types[1] : types.length === 3 && types[0].flags & 12 /* Nullable */ && types[1].flags & 12 /* Nullable */ ? types[2] : void 0;
|
|
68793
|
+
if (candidate && !(candidate.flags & 12 /* Nullable */)) {
|
|
68794
68794
|
target2 = getNormalizedType(
|
|
68795
68795
|
candidate,
|
|
68796
68796
|
/*writing*/
|
|
@@ -69092,9 +69092,9 @@ function createTypeChecker(host) {
|
|
|
69092
69092
|
if (containsType(targetTypes, source2)) {
|
|
69093
69093
|
return -1 /* True */;
|
|
69094
69094
|
}
|
|
69095
|
-
if (relation !== comparableRelation && getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags &
|
|
69095
|
+
if (relation !== comparableRelation && getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 32768 /* EnumLiteral */) && (source2.flags & (1024 /* StringLiteral */ | 4096 /* BooleanLiteral */ | 8192 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 2048 /* NumberLiteral */)) {
|
|
69096
69096
|
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
69097
|
-
const primitive = source2.flags &
|
|
69097
|
+
const primitive = source2.flags & 1024 /* StringLiteral */ ? stringType : source2.flags & 2048 /* NumberLiteral */ ? numberType : source2.flags & 8192 /* BigIntLiteral */ ? bigintType : void 0;
|
|
69098
69098
|
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
69099
69099
|
}
|
|
69100
69100
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
@@ -69189,8 +69189,8 @@ function createTypeChecker(host) {
|
|
|
69189
69189
|
return 0 /* False */;
|
|
69190
69190
|
}
|
|
69191
69191
|
function getUndefinedStrippedTargetIfNeeded(source2, target2) {
|
|
69192
|
-
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags &
|
|
69193
|
-
return extractTypesOfKind(target2, ~
|
|
69192
|
+
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags & 4 /* Undefined */) && target2.types[0].flags & 4 /* Undefined */) {
|
|
69193
|
+
return extractTypesOfKind(target2, ~4 /* Undefined */);
|
|
69194
69194
|
}
|
|
69195
69195
|
return target2;
|
|
69196
69196
|
}
|
|
@@ -69532,7 +69532,7 @@ function createTypeChecker(host) {
|
|
|
69532
69532
|
const mappedKeys = [];
|
|
69533
69533
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
69534
69534
|
modifiersType,
|
|
69535
|
-
|
|
69535
|
+
19456 /* StringOrNumberLiteralOrUnique */,
|
|
69536
69536
|
/*stringsOnly*/
|
|
69537
69537
|
false,
|
|
69538
69538
|
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
@@ -69791,7 +69791,7 @@ function createTypeChecker(host) {
|
|
|
69791
69791
|
if (includeOptional ? !(filteredByApplicability.flags & 131072 /* Never */) : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
|
|
69792
69792
|
const templateType2 = getTemplateTypeFromMappedType(target2);
|
|
69793
69793
|
const typeParameter = getTypeParameterFromMappedType(target2);
|
|
69794
|
-
const nonNullComponent = extractTypesOfKind(templateType2, ~
|
|
69794
|
+
const nonNullComponent = extractTypesOfKind(templateType2, ~12 /* Nullable */);
|
|
69795
69795
|
if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
|
|
69796
69796
|
if (result2 = isRelatedTo(source2, nonNullComponent.objectType, 2 /* Target */, reportErrors2)) {
|
|
69797
69797
|
return result2;
|
|
@@ -70452,7 +70452,7 @@ function createTypeChecker(host) {
|
|
|
70452
70452
|
for (const sourceProp of excludeProperties(getPropertiesOfType(source2), excludedProperties)) {
|
|
70453
70453
|
if (!getPropertyOfObjectType(target2, sourceProp.escapedName)) {
|
|
70454
70454
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
70455
|
-
if (!(sourceType.flags &
|
|
70455
|
+
if (!(sourceType.flags & 4 /* Undefined */)) {
|
|
70456
70456
|
if (reportErrors2) {
|
|
70457
70457
|
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target2));
|
|
70458
70458
|
}
|
|
@@ -70680,9 +70680,9 @@ function createTypeChecker(host) {
|
|
|
70680
70680
|
if (isIgnoredJsxProperty(source2, prop)) {
|
|
70681
70681
|
continue;
|
|
70682
70682
|
}
|
|
70683
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
70683
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */), keyType)) {
|
|
70684
70684
|
const propType = getNonMissingTypeOfSymbol(prop);
|
|
70685
|
-
const type = exactOptionalPropertyTypes || propType.flags &
|
|
70685
|
+
const type = exactOptionalPropertyTypes || propType.flags & 4 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) ? propType : getTypeWithFacts(propType, 524288 /* NEUndefined */);
|
|
70686
70686
|
const related = isRelatedTo(
|
|
70687
70687
|
type,
|
|
70688
70688
|
targetInfo.type,
|
|
@@ -70796,7 +70796,7 @@ function createTypeChecker(host) {
|
|
|
70796
70796
|
}
|
|
70797
70797
|
}
|
|
70798
70798
|
function typeCouldHaveTopLevelSingletonTypes(type) {
|
|
70799
|
-
if (type.flags &
|
|
70799
|
+
if (type.flags & 256 /* Boolean */) {
|
|
70800
70800
|
return false;
|
|
70801
70801
|
}
|
|
70802
70802
|
if (type.flags & 3145728 /* UnionOrIntersection */) {
|
|
@@ -70815,7 +70815,7 @@ function createTypeChecker(host) {
|
|
|
70815
70815
|
return getPropertiesOfType(target).filter((targetProp) => isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)));
|
|
70816
70816
|
}
|
|
70817
70817
|
function isExactOptionalPropertyMismatch(source, target) {
|
|
70818
|
-
return !!source && !!target && maybeTypeOfKind(source,
|
|
70818
|
+
return !!source && !!target && maybeTypeOfKind(source, 4 /* Undefined */) && !!containsMissingType(target);
|
|
70819
70819
|
}
|
|
70820
70820
|
function getExactOptionalProperties(type) {
|
|
70821
70821
|
return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
|
|
@@ -70941,7 +70941,7 @@ function createTypeChecker(host) {
|
|
|
70941
70941
|
}
|
|
70942
70942
|
function hasCovariantVoidArgument(typeArguments, variances) {
|
|
70943
70943
|
for (let i = 0; i < variances.length; i++) {
|
|
70944
|
-
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags &
|
|
70944
|
+
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16 /* Void */) {
|
|
70945
70945
|
return true;
|
|
70946
70946
|
}
|
|
70947
70947
|
}
|
|
@@ -71098,7 +71098,7 @@ function createTypeChecker(host) {
|
|
|
71098
71098
|
function isPropertyIdenticalTo(sourceProp, targetProp) {
|
|
71099
71099
|
return compareProperties2(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
|
|
71100
71100
|
}
|
|
71101
|
-
function compareProperties2(sourceProp, targetProp,
|
|
71101
|
+
function compareProperties2(sourceProp, targetProp, compareTypes2) {
|
|
71102
71102
|
if (sourceProp === targetProp) {
|
|
71103
71103
|
return -1 /* True */;
|
|
71104
71104
|
}
|
|
@@ -71119,7 +71119,7 @@ function createTypeChecker(host) {
|
|
|
71119
71119
|
if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
|
|
71120
71120
|
return 0 /* False */;
|
|
71121
71121
|
}
|
|
71122
|
-
return
|
|
71122
|
+
return compareTypes2(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
71123
71123
|
}
|
|
71124
71124
|
function isMatchingSignature(source, target, partialMatch) {
|
|
71125
71125
|
const sourceParameterCount = getParameterCount(source);
|
|
@@ -71136,7 +71136,7 @@ function createTypeChecker(host) {
|
|
|
71136
71136
|
}
|
|
71137
71137
|
return false;
|
|
71138
71138
|
}
|
|
71139
|
-
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes,
|
|
71139
|
+
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes2) {
|
|
71140
71140
|
if (source === target) {
|
|
71141
71141
|
return -1 /* True */;
|
|
71142
71142
|
}
|
|
@@ -71151,7 +71151,7 @@ function createTypeChecker(host) {
|
|
|
71151
71151
|
for (let i = 0; i < target.typeParameters.length; i++) {
|
|
71152
71152
|
const s = source.typeParameters[i];
|
|
71153
71153
|
const t = target.typeParameters[i];
|
|
71154
|
-
if (!(s === t ||
|
|
71154
|
+
if (!(s === t || compareTypes2(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes2(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
|
|
71155
71155
|
return 0 /* False */;
|
|
71156
71156
|
}
|
|
71157
71157
|
}
|
|
@@ -71168,7 +71168,7 @@ function createTypeChecker(host) {
|
|
|
71168
71168
|
if (sourceThisType) {
|
|
71169
71169
|
const targetThisType = getThisTypeOfSignature(target);
|
|
71170
71170
|
if (targetThisType) {
|
|
71171
|
-
const related =
|
|
71171
|
+
const related = compareTypes2(sourceThisType, targetThisType);
|
|
71172
71172
|
if (!related) {
|
|
71173
71173
|
return 0 /* False */;
|
|
71174
71174
|
}
|
|
@@ -71180,7 +71180,7 @@ function createTypeChecker(host) {
|
|
|
71180
71180
|
for (let i = 0; i < targetLen; i++) {
|
|
71181
71181
|
const s = getTypeAtPosition(source, i);
|
|
71182
71182
|
const t = getTypeAtPosition(target, i);
|
|
71183
|
-
const related =
|
|
71183
|
+
const related = compareTypes2(t, s);
|
|
71184
71184
|
if (!related) {
|
|
71185
71185
|
return 0 /* False */;
|
|
71186
71186
|
}
|
|
@@ -71189,12 +71189,12 @@ function createTypeChecker(host) {
|
|
|
71189
71189
|
if (!ignoreReturnTypes) {
|
|
71190
71190
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
71191
71191
|
const targetTypePredicate = getTypePredicateOfSignature(target);
|
|
71192
|
-
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate,
|
|
71192
|
+
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes2) : compareTypes2(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
|
71193
71193
|
}
|
|
71194
71194
|
return result;
|
|
71195
71195
|
}
|
|
71196
|
-
function compareTypePredicatesIdentical(source, target,
|
|
71197
|
-
return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
71196
|
+
function compareTypePredicatesIdentical(source, target, compareTypes2) {
|
|
71197
|
+
return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : source.type && target.type ? compareTypes2(source.type, target.type) : 0 /* False */;
|
|
71198
71198
|
}
|
|
71199
71199
|
function literalTypesWithSameBaseType(types) {
|
|
71200
71200
|
let commonBaseType;
|
|
@@ -71216,9 +71216,9 @@ function createTypeChecker(host) {
|
|
|
71216
71216
|
if (types.length === 1) {
|
|
71217
71217
|
return types[0];
|
|
71218
71218
|
}
|
|
71219
|
-
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags &
|
|
71219
|
+
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags & 12 /* Nullable */))) : types;
|
|
71220
71220
|
const superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? getUnionType(primaryTypes) : reduceLeft(primaryTypes, (s, t) => isTypeSubtypeOf(s, t) ? t : s);
|
|
71221
|
-
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) &
|
|
71221
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 12 /* Nullable */);
|
|
71222
71222
|
}
|
|
71223
71223
|
function getCommonSubtype(types) {
|
|
71224
71224
|
return reduceLeft(types, (s, t) => isTypeSubtypeOf(t, s) ? t : s);
|
|
@@ -71239,10 +71239,10 @@ function createTypeChecker(host) {
|
|
|
71239
71239
|
return isArrayType(type) ? getTypeArguments(type)[0] : void 0;
|
|
71240
71240
|
}
|
|
71241
71241
|
function isArrayLikeType(type) {
|
|
71242
|
-
return isArrayType(type) || !(type.flags &
|
|
71242
|
+
return isArrayType(type) || !(type.flags & 12 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType);
|
|
71243
71243
|
}
|
|
71244
71244
|
function isMutableArrayLikeType(type) {
|
|
71245
|
-
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ |
|
|
71245
|
+
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ | 12 /* Nullable */)) && isTypeAssignableTo(type, anyArrayType);
|
|
71246
71246
|
}
|
|
71247
71247
|
function getSingleBaseForNonAugmentingSubtype(type) {
|
|
71248
71248
|
if (!(getObjectFlags(type) & 4 /* Reference */) || !(getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
@@ -71282,7 +71282,7 @@ function createTypeChecker(host) {
|
|
|
71282
71282
|
}
|
|
71283
71283
|
function isTupleLikeType(type) {
|
|
71284
71284
|
let lengthType;
|
|
71285
|
-
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags &
|
|
71285
|
+
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags & 2048 /* NumberLiteral */));
|
|
71286
71286
|
}
|
|
71287
71287
|
function isArrayOrTupleLikeType(type) {
|
|
71288
71288
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
@@ -71298,10 +71298,10 @@ function createTypeChecker(host) {
|
|
|
71298
71298
|
return void 0;
|
|
71299
71299
|
}
|
|
71300
71300
|
function isNeitherUnitTypeNorNever(type) {
|
|
71301
|
-
return !(type.flags & (
|
|
71301
|
+
return !(type.flags & (97292 /* Unit */ | 131072 /* Never */));
|
|
71302
71302
|
}
|
|
71303
71303
|
function isUnitType(type) {
|
|
71304
|
-
return !!(type.flags &
|
|
71304
|
+
return !!(type.flags & 97292 /* Unit */);
|
|
71305
71305
|
}
|
|
71306
71306
|
function isUnitLikeType(type) {
|
|
71307
71307
|
const t = getBaseConstraintOrType(type);
|
|
@@ -71311,23 +71311,23 @@ function createTypeChecker(host) {
|
|
|
71311
71311
|
return type.flags & 2097152 /* Intersection */ ? find(type.types, isUnitType) || type : type;
|
|
71312
71312
|
}
|
|
71313
71313
|
function isLiteralType(type) {
|
|
71314
|
-
return type.flags &
|
|
71314
|
+
return type.flags & 256 /* Boolean */ ? true : type.flags & 1048576 /* Union */ ? type.flags & 32768 /* EnumLiteral */ ? true : every(type.types, isUnitType) : isUnitType(type);
|
|
71315
71315
|
}
|
|
71316
71316
|
function getBaseTypeOfLiteralType(type) {
|
|
71317
|
-
return type.flags &
|
|
71317
|
+
return type.flags & 98304 /* EnumLike */ ? getBaseTypeOfEnumLikeType(type) : type.flags & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : type.flags & 2048 /* NumberLiteral */ ? numberType : type.flags & 8192 /* BigIntLiteral */ ? bigintType : type.flags & 4096 /* BooleanLiteral */ ? booleanType : type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) : type;
|
|
71318
71318
|
}
|
|
71319
71319
|
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
71320
71320
|
const key = `B${getTypeId(type)}`;
|
|
71321
71321
|
return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
71322
71322
|
}
|
|
71323
71323
|
function getBaseTypeOfLiteralTypeForComparison(type) {
|
|
71324
|
-
return type.flags & (
|
|
71324
|
+
return type.flags & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : type.flags & (2048 /* NumberLiteral */ | 65536 /* Enum */) ? numberType : type.flags & 8192 /* BigIntLiteral */ ? bigintType : type.flags & 4096 /* BooleanLiteral */ ? booleanType : type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralTypeForComparison) : type;
|
|
71325
71325
|
}
|
|
71326
71326
|
function getWidenedLiteralType(type) {
|
|
71327
|
-
return type.flags &
|
|
71327
|
+
return type.flags & 98304 /* EnumLike */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLikeType(type) : type.flags & 1024 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : type.flags & 2048 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : type.flags & 8192 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : type.flags & 4096 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : type;
|
|
71328
71328
|
}
|
|
71329
71329
|
function getWidenedUniqueESSymbolType(type) {
|
|
71330
|
-
return type.flags &
|
|
71330
|
+
return type.flags & 16384 /* UniqueESSymbol */ ? esSymbolType : type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type;
|
|
71331
71331
|
}
|
|
71332
71332
|
function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
|
|
71333
71333
|
if (!isLiteralOfContextualType(type, contextualType)) {
|
|
@@ -71404,11 +71404,11 @@ function createTypeChecker(host) {
|
|
|
71404
71404
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
71405
71405
|
}
|
|
71406
71406
|
function getDefinitelyFalsyPartOfType(type) {
|
|
71407
|
-
return type.flags &
|
|
71407
|
+
return type.flags & 32 /* String */ ? emptyStringType : type.flags & 64 /* Number */ ? zeroType : type.flags & 128 /* BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || type.flags & (16 /* Void */ | 4 /* Undefined */ | 8 /* Null */ | 3 /* AnyOrUnknown */) || type.flags & 1024 /* StringLiteral */ && type.value === "" || type.flags & 2048 /* NumberLiteral */ && type.value === 0 || type.flags & 8192 /* BigIntLiteral */ && isZeroBigInt(type) ? type : neverType;
|
|
71408
71408
|
}
|
|
71409
71409
|
function getNullableType(type, flags) {
|
|
71410
|
-
const missing = flags & ~type.flags & (
|
|
71411
|
-
return missing === 0 ? type : missing ===
|
|
71410
|
+
const missing = flags & ~type.flags & (4 /* Undefined */ | 8 /* Null */);
|
|
71411
|
+
return missing === 0 ? type : missing === 4 /* Undefined */ ? getUnionType([type, undefinedType]) : missing === 8 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]);
|
|
71412
71412
|
}
|
|
71413
71413
|
function getOptionalType(type, isProperty = false) {
|
|
71414
71414
|
Debug.assert(strictNullChecks);
|
|
@@ -71451,7 +71451,7 @@ function createTypeChecker(host) {
|
|
|
71451
71451
|
return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */);
|
|
71452
71452
|
}
|
|
71453
71453
|
function isCoercibleUnderDoubleEquals(source, target) {
|
|
71454
|
-
return (source.flags & (
|
|
71454
|
+
return (source.flags & (64 /* Number */ | 32 /* String */ | 4096 /* BooleanLiteral */)) !== 0 && (target.flags & (64 /* Number */ | 32 /* String */ | 256 /* Boolean */)) !== 0;
|
|
71455
71455
|
}
|
|
71456
71456
|
function isObjectTypeWithInferableIndex(type) {
|
|
71457
71457
|
const objectFlags = getObjectFlags(type);
|
|
@@ -71584,7 +71584,7 @@ function createTypeChecker(host) {
|
|
|
71584
71584
|
return type.widened;
|
|
71585
71585
|
}
|
|
71586
71586
|
let result;
|
|
71587
|
-
if (type.flags & (1 /* Any */ |
|
|
71587
|
+
if (type.flags & (1 /* Any */ | 12 /* Nullable */)) {
|
|
71588
71588
|
result = anyType;
|
|
71589
71589
|
} else if (isObjectLiteralType2(type)) {
|
|
71590
71590
|
result = getWidenedTypeOfObjectLiteral(type, context);
|
|
@@ -71596,7 +71596,7 @@ function createTypeChecker(host) {
|
|
|
71596
71596
|
void 0,
|
|
71597
71597
|
type.types
|
|
71598
71598
|
);
|
|
71599
|
-
const widenedTypes = sameMap(type.types, (t) => t.flags &
|
|
71599
|
+
const widenedTypes = sameMap(type.types, (t) => t.flags & 12 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext));
|
|
71600
71600
|
result = getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */);
|
|
71601
71601
|
} else if (type.flags & 2097152 /* Intersection */) {
|
|
71602
71602
|
result = getIntersectionType(sameMap(type.types, getWidenedType));
|
|
@@ -71796,18 +71796,18 @@ function createTypeChecker(host) {
|
|
|
71796
71796
|
callback(getReturnTypeOfSignature(source), targetReturnType);
|
|
71797
71797
|
}
|
|
71798
71798
|
}
|
|
71799
|
-
function createInferenceContext(typeParameters, signature, flags,
|
|
71800
|
-
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags,
|
|
71799
|
+
function createInferenceContext(typeParameters, signature, flags, compareTypes2) {
|
|
71800
|
+
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes2 || compareTypesAssignable);
|
|
71801
71801
|
}
|
|
71802
71802
|
function cloneInferenceContext(context, extraFlags = 0) {
|
|
71803
71803
|
return context && createInferenceContextWorker(map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
|
|
71804
71804
|
}
|
|
71805
|
-
function createInferenceContextWorker(inferences, signature, flags,
|
|
71805
|
+
function createInferenceContextWorker(inferences, signature, flags, compareTypes2) {
|
|
71806
71806
|
const context = {
|
|
71807
71807
|
inferences,
|
|
71808
71808
|
signature,
|
|
71809
71809
|
flags,
|
|
71810
|
-
compareTypes,
|
|
71810
|
+
compareTypes: compareTypes2,
|
|
71811
71811
|
mapper: reportUnmeasurableMapper,
|
|
71812
71812
|
// initialize to a noop mapper so the context object is available, but the underlying object shape is right upon construction
|
|
71813
71813
|
nonFixingMapper: reportUnmeasurableMapper
|
|
@@ -71894,8 +71894,8 @@ function createTypeChecker(host) {
|
|
|
71894
71894
|
if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
|
|
71895
71895
|
return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
|
|
71896
71896
|
}
|
|
71897
|
-
const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 134217728 /* SingleSignatureType */ && !!length(type.outerTypeParameters) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags &
|
|
71898
|
-
if (type.flags &
|
|
71897
|
+
const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 134217728 /* SingleSignatureType */ && !!length(type.outerTypeParameters) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 32768 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
|
|
71898
|
+
if (type.flags & 3801101 /* ObjectFlagsType */) {
|
|
71899
71899
|
type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
71900
71900
|
}
|
|
71901
71901
|
return result;
|
|
@@ -71917,7 +71917,7 @@ function createTypeChecker(host) {
|
|
|
71917
71917
|
function createEmptyObjectTypeFromStringLiteral(type) {
|
|
71918
71918
|
const members = createSymbolTable();
|
|
71919
71919
|
forEachType(type, (t) => {
|
|
71920
|
-
if (!(t.flags &
|
|
71920
|
+
if (!(t.flags & 1024 /* StringLiteral */)) {
|
|
71921
71921
|
return;
|
|
71922
71922
|
}
|
|
71923
71923
|
const name = escapeLeadingUnderscores(t.value);
|
|
@@ -71929,7 +71929,7 @@ function createTypeChecker(host) {
|
|
|
71929
71929
|
}
|
|
71930
71930
|
members.set(name, literalProp);
|
|
71931
71931
|
});
|
|
71932
|
-
const indexInfos = type.flags &
|
|
71932
|
+
const indexInfos = type.flags & 32 /* String */ ? [createIndexInfo(
|
|
71933
71933
|
stringType,
|
|
71934
71934
|
emptyObjectType,
|
|
71935
71935
|
/*isReadonly*/
|
|
@@ -72031,7 +72031,7 @@ function createTypeChecker(host) {
|
|
|
72031
72031
|
yield targetProp;
|
|
72032
72032
|
} else if (matchDiscriminantProperties) {
|
|
72033
72033
|
const targetType = getTypeOfSymbol(targetProp);
|
|
72034
|
-
if (targetType.flags &
|
|
72034
|
+
if (targetType.flags & 97292 /* Unit */) {
|
|
72035
72035
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
72036
72036
|
if (!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) {
|
|
72037
72037
|
yield targetProp;
|
|
@@ -72094,7 +72094,7 @@ function createTypeChecker(host) {
|
|
|
72094
72094
|
if (target.flags & 1 /* Any */) {
|
|
72095
72095
|
return true;
|
|
72096
72096
|
}
|
|
72097
|
-
if (target.flags & (
|
|
72097
|
+
if (target.flags & (32 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
72098
72098
|
return isTypeAssignableTo(source, target);
|
|
72099
72099
|
}
|
|
72100
72100
|
if (target.flags & 268435456 /* StringMapping */) {
|
|
@@ -72112,20 +72112,20 @@ function createTypeChecker(host) {
|
|
|
72112
72112
|
if (target.flags & 2097152 /* Intersection */) {
|
|
72113
72113
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
72114
72114
|
}
|
|
72115
|
-
if (target.flags &
|
|
72115
|
+
if (target.flags & 32 /* String */ || isTypeAssignableTo(source, target)) {
|
|
72116
72116
|
return true;
|
|
72117
72117
|
}
|
|
72118
|
-
if (source.flags &
|
|
72118
|
+
if (source.flags & 1024 /* StringLiteral */) {
|
|
72119
72119
|
const value = source.value;
|
|
72120
|
-
return !!(target.flags &
|
|
72120
|
+
return !!(target.flags & 64 /* Number */ && isValidNumberString(
|
|
72121
72121
|
value,
|
|
72122
72122
|
/*roundTripOnly*/
|
|
72123
72123
|
false
|
|
72124
|
-
) || target.flags &
|
|
72124
|
+
) || target.flags & 128 /* BigInt */ && isValidBigIntString(
|
|
72125
72125
|
value,
|
|
72126
72126
|
/*roundTripOnly*/
|
|
72127
72127
|
false
|
|
72128
|
-
) || target.flags & (
|
|
72128
|
+
) || target.flags & (4096 /* BooleanLiteral */ | 12 /* Nullable */) && value === target.intrinsicName || target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(source, target) || target.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source, target));
|
|
72129
72129
|
}
|
|
72130
72130
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
72131
72131
|
const texts = source.texts;
|
|
@@ -72134,7 +72134,7 @@ function createTypeChecker(host) {
|
|
|
72134
72134
|
return false;
|
|
72135
72135
|
}
|
|
72136
72136
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
72137
|
-
return source.flags &
|
|
72137
|
+
return source.flags & 1024 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arrayIsEqualTo(source.texts, target.texts) ? map(source.types, (s, i) => {
|
|
72138
72138
|
return isTypeAssignableTo(getBaseConstraintOrType(s), getBaseConstraintOrType(target.types[i])) ? s : getStringLikeTypeForType(s);
|
|
72139
72139
|
}) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
|
|
72140
72140
|
}
|
|
@@ -72143,7 +72143,7 @@ function createTypeChecker(host) {
|
|
|
72143
72143
|
return !!inferences && every(inferences, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]));
|
|
72144
72144
|
}
|
|
72145
72145
|
function getStringLikeTypeForType(type) {
|
|
72146
|
-
return type.flags & (1 /* Any */ |
|
|
72146
|
+
return type.flags & (1 /* Any */ | 402654240 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
|
|
72147
72147
|
}
|
|
72148
72148
|
function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) {
|
|
72149
72149
|
const lastSourceIndex = sourceTexts.length - 1;
|
|
@@ -72338,7 +72338,7 @@ function createTypeChecker(host) {
|
|
|
72338
72338
|
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
|
|
72339
72339
|
} else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
|
|
72340
72340
|
inferFromContravariantTypes(source.type, target.type);
|
|
72341
|
-
} else if ((isLiteralType(source) || source.flags &
|
|
72341
|
+
} else if ((isLiteralType(source) || source.flags & 32 /* String */) && target.flags & 4194304 /* Index */) {
|
|
72342
72342
|
const empty = createEmptyObjectTypeFromStringLiteral(source);
|
|
72343
72343
|
inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
72344
72344
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
@@ -72593,29 +72593,29 @@ function createTypeChecker(host) {
|
|
|
72593
72593
|
for (let i = 0; i < types.length; i++) {
|
|
72594
72594
|
const source2 = matches ? matches[i] : neverType;
|
|
72595
72595
|
const target2 = types[i];
|
|
72596
|
-
if (source2.flags &
|
|
72596
|
+
if (source2.flags & 1024 /* StringLiteral */ && target2.flags & 8650752 /* TypeVariable */) {
|
|
72597
72597
|
const inferenceContext = getInferenceInfoForType(target2);
|
|
72598
72598
|
const constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : void 0;
|
|
72599
72599
|
if (constraint && !isTypeAny(constraint)) {
|
|
72600
72600
|
const constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
|
|
72601
72601
|
let allTypeFlags = reduceLeft(constraintTypes, (flags, t) => flags | t.flags, 0);
|
|
72602
|
-
if (!(allTypeFlags &
|
|
72602
|
+
if (!(allTypeFlags & 32 /* String */)) {
|
|
72603
72603
|
const str = source2.value;
|
|
72604
|
-
if (allTypeFlags &
|
|
72604
|
+
if (allTypeFlags & 67648 /* NumberLike */ && !isValidNumberString(
|
|
72605
72605
|
str,
|
|
72606
72606
|
/*roundTripOnly*/
|
|
72607
72607
|
true
|
|
72608
72608
|
)) {
|
|
72609
|
-
allTypeFlags &= ~
|
|
72609
|
+
allTypeFlags &= ~67648 /* NumberLike */;
|
|
72610
72610
|
}
|
|
72611
|
-
if (allTypeFlags &
|
|
72611
|
+
if (allTypeFlags & 8320 /* BigIntLike */ && !isValidBigIntString(
|
|
72612
72612
|
str,
|
|
72613
72613
|
/*roundTripOnly*/
|
|
72614
72614
|
true
|
|
72615
72615
|
)) {
|
|
72616
|
-
allTypeFlags &= ~
|
|
72616
|
+
allTypeFlags &= ~8320 /* BigIntLike */;
|
|
72617
72617
|
}
|
|
72618
|
-
const matchingType = reduceLeft(constraintTypes, (left, right) => !(right.flags & allTypeFlags) ? left : left.flags &
|
|
72618
|
+
const matchingType = reduceLeft(constraintTypes, (left, right) => !(right.flags & allTypeFlags) ? left : left.flags & 32 /* String */ ? left : right.flags & 32 /* String */ ? source2 : left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source2, right) ? source2 : left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str === applyStringMapping(right.symbol, str) ? source2 : left.flags & 1024 /* StringLiteral */ ? left : right.flags & 1024 /* StringLiteral */ && right.value === str ? right : left.flags & 64 /* Number */ ? left : right.flags & 64 /* Number */ ? getNumberLiteralType(+str) : left.flags & 65536 /* Enum */ ? left : right.flags & 65536 /* Enum */ ? getNumberLiteralType(+str) : left.flags & 2048 /* NumberLiteral */ ? left : right.flags & 2048 /* NumberLiteral */ && right.value === +str ? right : left.flags & 128 /* BigInt */ ? left : right.flags & 128 /* BigInt */ ? parseBigIntLiteralType(str) : left.flags & 8192 /* BigIntLiteral */ ? left : right.flags & 8192 /* BigIntLiteral */ && pseudoBigIntToString(right.value) === str ? right : left.flags & 256 /* Boolean */ ? left : right.flags & 256 /* Boolean */ ? str === "true" ? trueType : str === "false" ? falseType : booleanType : left.flags & 4096 /* BooleanLiteral */ ? left : right.flags & 4096 /* BooleanLiteral */ && right.intrinsicName === str ? right : left.flags & 4 /* Undefined */ ? left : right.flags & 4 /* Undefined */ && right.intrinsicName === str ? right : left.flags & 8 /* Null */ ? left : right.flags & 8 /* Null */ && right.intrinsicName === str ? right : left, neverType);
|
|
72619
72619
|
if (!(matchingType.flags & 131072 /* Never */)) {
|
|
72620
72620
|
inferFromTypes(matchingType, target2);
|
|
72621
72621
|
continue;
|
|
@@ -72775,7 +72775,7 @@ function createTypeChecker(host) {
|
|
|
72775
72775
|
for (const targetInfo of indexInfos) {
|
|
72776
72776
|
const propTypes = [];
|
|
72777
72777
|
for (const prop of getPropertiesOfType(source)) {
|
|
72778
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
72778
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) {
|
|
72779
72779
|
const propType = getTypeOfSymbol(prop);
|
|
72780
72780
|
propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType);
|
|
72781
72781
|
}
|
|
@@ -72799,7 +72799,7 @@ function createTypeChecker(host) {
|
|
|
72799
72799
|
}
|
|
72800
72800
|
}
|
|
72801
72801
|
function isTypeOrBaseIdenticalTo(s, t) {
|
|
72802
|
-
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags &
|
|
72802
|
+
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags & 32 /* String */ && s.flags & 1024 /* StringLiteral */ || t.flags & 64 /* Number */ && s.flags & 2048 /* NumberLiteral */);
|
|
72803
72803
|
}
|
|
72804
72804
|
function isTypeCloselyMatchedBy(s, t) {
|
|
72805
72805
|
return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
|
|
@@ -73051,7 +73051,7 @@ function createTypeChecker(host) {
|
|
|
73051
73051
|
return void 0;
|
|
73052
73052
|
}
|
|
73053
73053
|
function tryGetNameFromType(type) {
|
|
73054
|
-
return type.flags &
|
|
73054
|
+
return type.flags & 16384 /* UniqueESSymbol */ ? type.escapedName : type.flags & 3072 /* StringOrNumberLiteral */ ? escapeLeadingUnderscores("" + type.value) : void 0;
|
|
73055
73055
|
}
|
|
73056
73056
|
function tryGetElementAccessExpressionName(node) {
|
|
73057
73057
|
return isStringOrNumericLiteralLike(node.argumentExpression) ? escapeLeadingUnderscores(node.argumentExpression.text) : isEntityNameExpression(node.argumentExpression) ? tryGetNameFromEntityNameExpression(node.argumentExpression) : void 0;
|
|
@@ -73230,7 +73230,7 @@ function createTypeChecker(host) {
|
|
|
73230
73230
|
}
|
|
73231
73231
|
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
73232
73232
|
const filteredType = filterType(declaredType, (t) => typeMaybeAssignableTo(assignedType, t));
|
|
73233
|
-
const reducedType = assignedType.flags &
|
|
73233
|
+
const reducedType = assignedType.flags & 4096 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
73234
73234
|
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
73235
73235
|
}
|
|
73236
73236
|
function isFunctionObjectType(type) {
|
|
@@ -73251,31 +73251,31 @@ function createTypeChecker(host) {
|
|
|
73251
73251
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
73252
73252
|
}
|
|
73253
73253
|
const flags = type.flags;
|
|
73254
|
-
if (flags & (
|
|
73254
|
+
if (flags & (32 /* String */ | 268435456 /* StringMapping */)) {
|
|
73255
73255
|
return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
|
|
73256
73256
|
}
|
|
73257
|
-
if (flags & (
|
|
73258
|
-
const isEmpty = flags &
|
|
73257
|
+
if (flags & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) {
|
|
73258
|
+
const isEmpty = flags & 1024 /* StringLiteral */ && type.value === "";
|
|
73259
73259
|
return strictNullChecks ? isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
|
|
73260
73260
|
}
|
|
73261
|
-
if (flags & (
|
|
73261
|
+
if (flags & (64 /* Number */ | 65536 /* Enum */)) {
|
|
73262
73262
|
return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */;
|
|
73263
73263
|
}
|
|
73264
|
-
if (flags &
|
|
73264
|
+
if (flags & 2048 /* NumberLiteral */) {
|
|
73265
73265
|
const isZero = type.value === 0;
|
|
73266
73266
|
return strictNullChecks ? isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */;
|
|
73267
73267
|
}
|
|
73268
|
-
if (flags &
|
|
73268
|
+
if (flags & 128 /* BigInt */) {
|
|
73269
73269
|
return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */;
|
|
73270
73270
|
}
|
|
73271
|
-
if (flags &
|
|
73271
|
+
if (flags & 8192 /* BigIntLiteral */) {
|
|
73272
73272
|
const isZero = isZeroBigInt(type);
|
|
73273
73273
|
return strictNullChecks ? isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */;
|
|
73274
73274
|
}
|
|
73275
|
-
if (flags &
|
|
73275
|
+
if (flags & 256 /* Boolean */) {
|
|
73276
73276
|
return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */;
|
|
73277
73277
|
}
|
|
73278
|
-
if (flags &
|
|
73278
|
+
if (flags & 4352 /* BooleanLike */) {
|
|
73279
73279
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
73280
73280
|
}
|
|
73281
73281
|
if (flags & 524288 /* Object */) {
|
|
@@ -73285,16 +73285,16 @@ function createTypeChecker(host) {
|
|
|
73285
73285
|
}
|
|
73286
73286
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
73287
73287
|
}
|
|
73288
|
-
if (flags &
|
|
73288
|
+
if (flags & 16 /* Void */) {
|
|
73289
73289
|
return 9830144 /* VoidFacts */;
|
|
73290
73290
|
}
|
|
73291
|
-
if (flags &
|
|
73291
|
+
if (flags & 4 /* Undefined */) {
|
|
73292
73292
|
return 26607360 /* UndefinedFacts */;
|
|
73293
73293
|
}
|
|
73294
|
-
if (flags &
|
|
73294
|
+
if (flags & 8 /* Null */) {
|
|
73295
73295
|
return 42917664 /* NullFacts */;
|
|
73296
73296
|
}
|
|
73297
|
-
if (flags &
|
|
73297
|
+
if (flags & 16896 /* ESSymbolLike */) {
|
|
73298
73298
|
return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
|
|
73299
73299
|
}
|
|
73300
73300
|
if (flags & 67108864 /* NonPrimitive */) {
|
|
@@ -73517,7 +73517,7 @@ function createTypeChecker(host) {
|
|
|
73517
73517
|
}
|
|
73518
73518
|
return true;
|
|
73519
73519
|
}
|
|
73520
|
-
if (source.flags &
|
|
73520
|
+
if (source.flags & 98304 /* EnumLike */ && getBaseTypeOfEnumLikeType(source) === target) {
|
|
73521
73521
|
return true;
|
|
73522
73522
|
}
|
|
73523
73523
|
return containsType(target.types, source);
|
|
@@ -73602,8 +73602,8 @@ function createTypeChecker(host) {
|
|
|
73602
73602
|
return filterType(type, (t) => (t.flags & kind) !== 0);
|
|
73603
73603
|
}
|
|
73604
73604
|
function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
|
|
73605
|
-
if (maybeTypeOfKind(typeWithPrimitives,
|
|
73606
|
-
return mapType(typeWithPrimitives, (t) => t.flags &
|
|
73605
|
+
if (maybeTypeOfKind(typeWithPrimitives, 32 /* String */ | 134217728 /* TemplateLiteral */ | 64 /* Number */ | 128 /* BigInt */) && maybeTypeOfKind(typeWithLiterals, 1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 2048 /* NumberLiteral */ | 8192 /* BigIntLiteral */)) {
|
|
73606
|
+
return mapType(typeWithPrimitives, (t) => t.flags & 32 /* String */ ? extractTypesOfKind(typeWithLiterals, 32 /* String */ | 1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 32 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 1024 /* StringLiteral */) : t.flags & 64 /* Number */ ? extractTypesOfKind(typeWithLiterals, 64 /* Number */ | 2048 /* NumberLiteral */) : t.flags & 128 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 128 /* BigInt */ | 8192 /* BigIntLiteral */) : t);
|
|
73607
73607
|
}
|
|
73608
73608
|
return typeWithPrimitives;
|
|
73609
73609
|
}
|
|
@@ -73658,7 +73658,7 @@ function createTypeChecker(host) {
|
|
|
73658
73658
|
const root = getReferenceRoot(node);
|
|
73659
73659
|
const parent2 = root.parent;
|
|
73660
73660
|
const isLengthPushOrUnshift = isPropertyAccessExpression(parent2) && (parent2.name.escapedText === "length" || parent2.parent.kind === 213 /* CallExpression */ && isIdentifier(parent2.name) && isPushOrUnshiftIdentifier(parent2.name));
|
|
73661
|
-
const isElementAssignment = parent2.kind === 212 /* ElementAccessExpression */ && parent2.expression === root && parent2.parent.kind === 226 /* BinaryExpression */ && parent2.parent.operatorToken.kind === 64 /* EqualsToken */ && parent2.parent.left === parent2 && !isAssignmentTarget(parent2.parent) && isTypeAssignableToKind(getTypeOfExpression(parent2.argumentExpression),
|
|
73661
|
+
const isElementAssignment = parent2.kind === 212 /* ElementAccessExpression */ && parent2.expression === root && parent2.parent.kind === 226 /* BinaryExpression */ && parent2.parent.operatorToken.kind === 64 /* EqualsToken */ && parent2.parent.left === parent2 && !isAssignmentTarget(parent2.parent) && isTypeAssignableToKind(getTypeOfExpression(parent2.argumentExpression), 67648 /* NumberLike */);
|
|
73662
73662
|
return isLengthPushOrUnshift || isElementAssignment;
|
|
73663
73663
|
}
|
|
73664
73664
|
function isDeclarationWithExplicitTypeAnnotation(node) {
|
|
@@ -74146,7 +74146,7 @@ function createTypeChecker(host) {
|
|
|
74146
74146
|
}
|
|
74147
74147
|
} else {
|
|
74148
74148
|
const indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
|
|
74149
|
-
if (isTypeAssignableToKind(indexType,
|
|
74149
|
+
if (isTypeAssignableToKind(indexType, 67648 /* NumberLike */)) {
|
|
74150
74150
|
evolvedType2 = addEvolvingArrayElementType(evolvedType2, node.right);
|
|
74151
74151
|
}
|
|
74152
74152
|
}
|
|
@@ -74184,9 +74184,9 @@ function createTypeChecker(host) {
|
|
|
74184
74184
|
} else {
|
|
74185
74185
|
if (strictNullChecks) {
|
|
74186
74186
|
if (optionalChainContainsReference(expr, reference)) {
|
|
74187
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (
|
|
74187
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (4 /* Undefined */ | 131072 /* Never */)));
|
|
74188
74188
|
} else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
|
|
74189
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags &
|
|
74189
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags & 1024 /* StringLiteral */ && t.value === "undefined"));
|
|
74190
74190
|
}
|
|
74191
74191
|
}
|
|
74192
74192
|
const access = getDiscriminantPropertyAccess(expr, type);
|
|
@@ -74360,7 +74360,7 @@ function createTypeChecker(host) {
|
|
|
74360
74360
|
return type;
|
|
74361
74361
|
}
|
|
74362
74362
|
const optionalChain = isOptionalChain(access);
|
|
74363
|
-
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type,
|
|
74363
|
+
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type, 12 /* Nullable */);
|
|
74364
74364
|
let propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName);
|
|
74365
74365
|
if (!propType) {
|
|
74366
74366
|
return type;
|
|
@@ -74582,7 +74582,7 @@ function createTypeChecker(host) {
|
|
|
74582
74582
|
}
|
|
74583
74583
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
74584
74584
|
const equalsOperator = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
74585
|
-
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ?
|
|
74585
|
+
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ? 12 /* Nullable */ : 4 /* Undefined */;
|
|
74586
74586
|
const valueType = getTypeOfExpression(value);
|
|
74587
74587
|
const removeNullable = equalsOperator !== assumeTrue && everyType(valueType, (t) => !!(t.flags & nullableFlags)) || equalsOperator === assumeTrue && everyType(valueType, (t) => !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)));
|
|
74588
74588
|
return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
|
|
@@ -74596,11 +74596,11 @@ function createTypeChecker(host) {
|
|
|
74596
74596
|
}
|
|
74597
74597
|
const valueType = getTypeOfExpression(value);
|
|
74598
74598
|
const doubleEquals = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */;
|
|
74599
|
-
if (valueType.flags &
|
|
74599
|
+
if (valueType.flags & 12 /* Nullable */) {
|
|
74600
74600
|
if (!strictNullChecks) {
|
|
74601
74601
|
return type;
|
|
74602
74602
|
}
|
|
74603
|
-
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags &
|
|
74603
|
+
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 8 /* Null */ ? assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
|
|
74604
74604
|
return getAdjustedTypeWithFacts(type, facts);
|
|
74605
74605
|
}
|
|
74606
74606
|
if (assumeTrue) {
|
|
@@ -74675,7 +74675,7 @@ function createTypeChecker(host) {
|
|
|
74675
74675
|
if (!hasDefaultClause) {
|
|
74676
74676
|
return caseType;
|
|
74677
74677
|
}
|
|
74678
|
-
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags &
|
|
74678
|
+
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags & 4 /* Undefined */ ? undefinedType : getRegularTypeOfLiteralType(extractUnitType(t)))));
|
|
74679
74679
|
return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
|
|
74680
74680
|
}
|
|
74681
74681
|
function narrowTypeByTypeName(type, typeName) {
|
|
@@ -75166,10 +75166,10 @@ function createTypeChecker(host) {
|
|
|
75166
75166
|
return parent2.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 166 /* QualifiedName */ || parent2.kind === 213 /* CallExpression */ && parent2.expression === node || parent2.kind === 214 /* NewExpression */ && parent2.expression === node || parent2.kind === 212 /* ElementAccessExpression */ && parent2.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent2.argumentExpression)));
|
|
75167
75167
|
}
|
|
75168
75168
|
function isGenericTypeWithUnionConstraint(type) {
|
|
75169
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (
|
|
75169
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (12 /* Nullable */ | 1048576 /* Union */));
|
|
75170
75170
|
}
|
|
75171
75171
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
75172
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type),
|
|
75172
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 12 /* Nullable */));
|
|
75173
75173
|
}
|
|
75174
75174
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
75175
75175
|
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 32 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
|
|
@@ -75728,7 +75728,7 @@ function createTypeChecker(host) {
|
|
|
75728
75728
|
flowContainer = getControlFlowContainer(flowContainer);
|
|
75729
75729
|
}
|
|
75730
75730
|
const isNeverInitialized = immediateDeclaration && isVariableDeclaration(immediateDeclaration) && !immediateDeclaration.initializer && !immediateDeclaration.exclamationToken && isMutableLocalVariableDeclaration(immediateDeclaration) && !isSymbolAssignedDefinitely(symbol);
|
|
75731
|
-
const assumeInitialized = isParameter2 || isAlias || isOuterVariable && !isNeverInitialized || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ |
|
|
75731
|
+
const assumeInitialized = isParameter2 || isAlias || isOuterVariable && !isNeverInitialized || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16 /* Void */)) !== 0 || isInTypeQuery(node) || isInAmbientOrTypeNode(node) || node.parent.kind === 281 /* ExportSpecifier */) || node.parent.kind === 235 /* NonNullExpression */ || declaration.kind === 260 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 33554432 /* Ambient */;
|
|
75732
75732
|
const initialType = isAutomaticTypeInNonNull ? undefinedType : assumeInitialized ? isParameter2 ? removeOptionalityFromDeclaredType(type, declaration) : type : typeIsAutomatic ? undefinedType : getOptionalType(type);
|
|
75733
75733
|
const flowType = isAutomaticTypeInNonNull ? getNonNullableType(getFlowTypeOfReference(node, type, initialType, flowContainer)) : getFlowTypeOfReference(node, type, initialType, flowContainer);
|
|
75734
75734
|
if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
|
|
@@ -76416,7 +76416,7 @@ function createTypeChecker(host) {
|
|
|
76416
76416
|
const functionFlags = getFunctionFlags(functionDecl);
|
|
76417
76417
|
if (functionFlags & 1 /* Generator */) {
|
|
76418
76418
|
return filterType(returnType2, (t) => {
|
|
76419
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
76419
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || checkGeneratorInstantiationAssignabilityToReturnType(
|
|
76420
76420
|
t,
|
|
76421
76421
|
functionFlags,
|
|
76422
76422
|
/*errorNode*/
|
|
@@ -76426,7 +76426,7 @@ function createTypeChecker(host) {
|
|
|
76426
76426
|
}
|
|
76427
76427
|
if (functionFlags & 2 /* Async */) {
|
|
76428
76428
|
return filterType(returnType2, (t) => {
|
|
76429
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
76429
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || !!getAwaitedTypeOfPromise(t);
|
|
76430
76430
|
});
|
|
76431
76431
|
}
|
|
76432
76432
|
return returnType2;
|
|
@@ -77185,7 +77185,7 @@ function createTypeChecker(host) {
|
|
|
77185
77185
|
return getOrCreateTypeFromSignature(fakeSignature);
|
|
77186
77186
|
}
|
|
77187
77187
|
const tagType = checkExpressionCached(context.tagName);
|
|
77188
|
-
if (tagType.flags &
|
|
77188
|
+
if (tagType.flags & 1024 /* StringLiteral */) {
|
|
77189
77189
|
const result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
|
|
77190
77190
|
if (!result) {
|
|
77191
77191
|
return errorType;
|
|
@@ -77557,7 +77557,7 @@ function createTypeChecker(host) {
|
|
|
77557
77557
|
}
|
|
77558
77558
|
}
|
|
77559
77559
|
function isNumericComputedName(name) {
|
|
77560
|
-
return isTypeAssignableToKind(checkComputedPropertyName(name),
|
|
77560
|
+
return isTypeAssignableToKind(checkComputedPropertyName(name), 67648 /* NumberLike */);
|
|
77561
77561
|
}
|
|
77562
77562
|
function checkComputedPropertyName(node) {
|
|
77563
77563
|
const links = getNodeLinks(node.expression);
|
|
@@ -77575,7 +77575,7 @@ function createTypeChecker(host) {
|
|
|
77575
77575
|
getNodeLinks(node.parent.parent).flags |= 32768 /* BlockScopedBindingInLoop */;
|
|
77576
77576
|
}
|
|
77577
77577
|
}
|
|
77578
|
-
if (links.resolvedType.flags &
|
|
77578
|
+
if (links.resolvedType.flags & 12 /* Nullable */ || !isTypeAssignableToKind(links.resolvedType, 402654240 /* StringLike */ | 67648 /* NumberLike */ | 16896 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
|
|
77579
77579
|
error2(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
|
|
77580
77580
|
}
|
|
77581
77581
|
}
|
|
@@ -77589,7 +77589,7 @@ function createTypeChecker(host) {
|
|
|
77589
77589
|
function isSymbolWithSymbolName(symbol) {
|
|
77590
77590
|
var _a;
|
|
77591
77591
|
const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
|
|
77592
|
-
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name),
|
|
77592
|
+
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 512 /* ESSymbol */);
|
|
77593
77593
|
}
|
|
77594
77594
|
function isSymbolWithComputedName(symbol) {
|
|
77595
77595
|
var _a;
|
|
@@ -77745,7 +77745,7 @@ function createTypeChecker(host) {
|
|
|
77745
77745
|
Debug.assert(memberDecl.kind === 177 /* GetAccessor */ || memberDecl.kind === 178 /* SetAccessor */);
|
|
77746
77746
|
checkNodeDeferred(memberDecl);
|
|
77747
77747
|
}
|
|
77748
|
-
if (computedNameType && !(computedNameType.flags &
|
|
77748
|
+
if (computedNameType && !(computedNameType.flags & 19456 /* StringOrNumberLiteralOrUnique */)) {
|
|
77749
77749
|
if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
|
|
77750
77750
|
if (isTypeAssignableTo(computedNameType, numberType)) {
|
|
77751
77751
|
hasComputedNumberProperty = true;
|
|
@@ -78158,9 +78158,9 @@ function createTypeChecker(host) {
|
|
|
78158
78158
|
return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
|
|
78159
78159
|
}
|
|
78160
78160
|
function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
|
|
78161
|
-
if (elementType.flags &
|
|
78161
|
+
if (elementType.flags & 32 /* String */) {
|
|
78162
78162
|
return [anySignature];
|
|
78163
|
-
} else if (elementType.flags &
|
|
78163
|
+
} else if (elementType.flags & 1024 /* StringLiteral */) {
|
|
78164
78164
|
const intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
|
|
78165
78165
|
if (!intrinsicType) {
|
|
78166
78166
|
error2(caller, Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
|
|
@@ -78542,7 +78542,7 @@ function createTypeChecker(host) {
|
|
|
78542
78542
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
78543
78543
|
reportError(node, facts);
|
|
78544
78544
|
const t = getNonNullableType(type);
|
|
78545
|
-
return t.flags & (
|
|
78545
|
+
return t.flags & (12 /* Nullable */ | 131072 /* Never */) ? errorType : t;
|
|
78546
78546
|
}
|
|
78547
78547
|
return type;
|
|
78548
78548
|
}
|
|
@@ -78551,7 +78551,7 @@ function createTypeChecker(host) {
|
|
|
78551
78551
|
}
|
|
78552
78552
|
function checkNonNullNonVoidType(type, node) {
|
|
78553
78553
|
const nonNullType = checkNonNullType(type, node);
|
|
78554
|
-
if (nonNullType.flags &
|
|
78554
|
+
if (nonNullType.flags & 16 /* Void */) {
|
|
78555
78555
|
if (isEntityNameExpression(node)) {
|
|
78556
78556
|
const nodeText2 = entityNameToString(node);
|
|
78557
78557
|
if (isIdentifier(node) && nodeText2 === "undefined") {
|
|
@@ -79098,7 +79098,7 @@ function createTypeChecker(host) {
|
|
|
79098
79098
|
return suggestion;
|
|
79099
79099
|
}
|
|
79100
79100
|
function getSuggestedTypeForNonexistentStringLiteralType(source, target) {
|
|
79101
|
-
const candidates = target.types.filter((type) => !!(type.flags &
|
|
79101
|
+
const candidates = target.types.filter((type) => !!(type.flags & 1024 /* StringLiteral */));
|
|
79102
79102
|
return getSpellingSuggestion(source.value, candidates, (type) => type.value);
|
|
79103
79103
|
}
|
|
79104
79104
|
function getSpellingSuggestionForName(name, symbols, meaning) {
|
|
@@ -79330,10 +79330,10 @@ function createTypeChecker(host) {
|
|
|
79330
79330
|
return findIndex(args, isSpreadArgument);
|
|
79331
79331
|
}
|
|
79332
79332
|
function acceptsVoid(t) {
|
|
79333
|
-
return !!(t.flags &
|
|
79333
|
+
return !!(t.flags & 16 /* Void */);
|
|
79334
79334
|
}
|
|
79335
79335
|
function acceptsVoidUndefinedUnknownOrAny(t) {
|
|
79336
|
-
return !!(t.flags & (
|
|
79336
|
+
return !!(t.flags & (16 /* Void */ | 4 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */));
|
|
79337
79337
|
}
|
|
79338
79338
|
function hasCorrectArity(node, args, signature, signatureHelpTrailingComma = false) {
|
|
79339
79339
|
if (isJsxOpeningFragment(node)) return true;
|
|
@@ -79432,8 +79432,8 @@ function createTypeChecker(host) {
|
|
|
79432
79432
|
}
|
|
79433
79433
|
return void 0;
|
|
79434
79434
|
}
|
|
79435
|
-
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext,
|
|
79436
|
-
const context = createInferenceContext(getTypeParametersForMapper(signature), signature, 0 /* None */,
|
|
79435
|
+
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes2) {
|
|
79436
|
+
const context = createInferenceContext(getTypeParametersForMapper(signature), signature, 0 /* None */, compareTypes2);
|
|
79437
79437
|
const restType = getEffectiveRestType(contextualSignature);
|
|
79438
79438
|
const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
|
|
79439
79439
|
const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
|
|
@@ -81168,10 +81168,10 @@ function createTypeChecker(host) {
|
|
|
81168
81168
|
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
|
|
81169
81169
|
}
|
|
81170
81170
|
const returnType = getReturnTypeOfSignature(signature);
|
|
81171
|
-
if (returnType.flags &
|
|
81171
|
+
if (returnType.flags & 16896 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) {
|
|
81172
81172
|
return getESSymbolLikeTypeForNode(walkUpParenthesizedExpressions(node.parent));
|
|
81173
81173
|
}
|
|
81174
|
-
if (node.kind === 213 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 244 /* ExpressionStatement */ && returnType.flags &
|
|
81174
|
+
if (node.kind === 213 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 244 /* ExpressionStatement */ && returnType.flags & 16 /* Void */ && getTypePredicateOfSignature(signature)) {
|
|
81175
81175
|
if (!isDottedName(node.expression)) {
|
|
81176
81176
|
error2(node.expression, Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
|
|
81177
81177
|
} else if (!getEffectsSignature(node)) {
|
|
@@ -81261,7 +81261,7 @@ function createTypeChecker(host) {
|
|
|
81261
81261
|
for (let i = 2; i < node.arguments.length; ++i) {
|
|
81262
81262
|
checkExpressionCached(node.arguments[i]);
|
|
81263
81263
|
}
|
|
81264
|
-
if (specifierType.flags &
|
|
81264
|
+
if (specifierType.flags & 4 /* Undefined */ || specifierType.flags & 8 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) {
|
|
81265
81265
|
error2(specifier, Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
|
|
81266
81266
|
}
|
|
81267
81267
|
if (optionsType) {
|
|
@@ -81270,7 +81270,7 @@ function createTypeChecker(host) {
|
|
|
81270
81270
|
true
|
|
81271
81271
|
);
|
|
81272
81272
|
if (importCallOptionsType !== emptyObjectType) {
|
|
81273
|
-
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType,
|
|
81273
|
+
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 4 /* Undefined */), node.arguments[1]);
|
|
81274
81274
|
}
|
|
81275
81275
|
}
|
|
81276
81276
|
const moduleSymbol = resolveExternalModuleName(node, specifier);
|
|
@@ -81393,6 +81393,11 @@ function createTypeChecker(host) {
|
|
|
81393
81393
|
if (file && fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) {
|
|
81394
81394
|
grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
|
|
81395
81395
|
}
|
|
81396
|
+
if (compilerOptions.erasableSyntaxOnly) {
|
|
81397
|
+
const start = node.type.pos - "<".length;
|
|
81398
|
+
const end = skipTrivia(file.text, node.type.end) + ">".length;
|
|
81399
|
+
diagnostics.add(createFileDiagnostic(file, start, end - start, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled));
|
|
81400
|
+
}
|
|
81396
81401
|
}
|
|
81397
81402
|
return checkAssertionWorker(node, checkMode);
|
|
81398
81403
|
}
|
|
@@ -82311,7 +82316,7 @@ function createTypeChecker(host) {
|
|
|
82311
82316
|
/*contextFlags*/
|
|
82312
82317
|
void 0
|
|
82313
82318
|
);
|
|
82314
|
-
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags &
|
|
82319
|
+
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 4 /* Undefined */ ? undefinedType : voidType;
|
|
82315
82320
|
return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
|
|
82316
82321
|
// Async function
|
|
82317
82322
|
returnType2
|
|
@@ -82557,10 +82562,10 @@ function createTypeChecker(host) {
|
|
|
82557
82562
|
true
|
|
82558
82563
|
);
|
|
82559
82564
|
const returnType = checkExpressionCached(expr);
|
|
82560
|
-
if (!(returnType.flags &
|
|
82565
|
+
if (!(returnType.flags & 256 /* Boolean */)) return void 0;
|
|
82561
82566
|
return forEach(func.parameters, (param, i) => {
|
|
82562
82567
|
const initType = getTypeOfSymbol(param.symbol);
|
|
82563
|
-
if (!initType || initType.flags &
|
|
82568
|
+
if (!initType || initType.flags & 256 /* Boolean */ || !isIdentifier(param.name) || isSymbolAssigned(param.symbol) || isRestParameter(param)) {
|
|
82564
82569
|
return;
|
|
82565
82570
|
}
|
|
82566
82571
|
const trueType2 = checkIfExpressionRefinesParameter(func, expr, param, initType);
|
|
@@ -82590,7 +82595,7 @@ function createTypeChecker(host) {
|
|
|
82590
82595
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
82591
82596
|
const functionFlags = getFunctionFlags(func);
|
|
82592
82597
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
82593
|
-
if (type && (maybeTypeOfKind(type,
|
|
82598
|
+
if (type && (maybeTypeOfKind(type, 16 /* Void */) || type.flags & (1 /* Any */ | 4 /* Undefined */))) {
|
|
82594
82599
|
return;
|
|
82595
82600
|
}
|
|
82596
82601
|
if (func.kind === 173 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 241 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -82962,11 +82967,11 @@ function createTypeChecker(host) {
|
|
|
82962
82967
|
case 41 /* MinusToken */:
|
|
82963
82968
|
case 55 /* TildeToken */:
|
|
82964
82969
|
checkNonNullType(operandType, node.operand);
|
|
82965
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
82970
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 16896 /* ESSymbolLike */)) {
|
|
82966
82971
|
error2(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator));
|
|
82967
82972
|
}
|
|
82968
82973
|
if (node.operator === 40 /* PlusToken */) {
|
|
82969
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
82974
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 8320 /* BigIntLike */)) {
|
|
82970
82975
|
error2(node.operand, Diagnostics.Operator_0_cannot_be_applied_to_type_1, tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
|
|
82971
82976
|
}
|
|
82972
82977
|
return numberType;
|
|
@@ -83010,8 +83015,8 @@ function createTypeChecker(host) {
|
|
|
83010
83015
|
return getUnaryResultType(operandType);
|
|
83011
83016
|
}
|
|
83012
83017
|
function getUnaryResultType(operandType) {
|
|
83013
|
-
if (maybeTypeOfKind(operandType,
|
|
83014
|
-
return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType,
|
|
83018
|
+
if (maybeTypeOfKind(operandType, 8320 /* BigIntLike */)) {
|
|
83019
|
+
return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 67648 /* NumberLike */) ? numberOrBigIntType : bigintType;
|
|
83015
83020
|
}
|
|
83016
83021
|
return numberType;
|
|
83017
83022
|
}
|
|
@@ -83040,10 +83045,10 @@ function createTypeChecker(host) {
|
|
|
83040
83045
|
if (source.flags & kind) {
|
|
83041
83046
|
return true;
|
|
83042
83047
|
}
|
|
83043
|
-
if (strict && source.flags & (3 /* AnyOrUnknown */ |
|
|
83048
|
+
if (strict && source.flags & (3 /* AnyOrUnknown */ | 16 /* Void */ | 4 /* Undefined */ | 8 /* Null */)) {
|
|
83044
83049
|
return false;
|
|
83045
83050
|
}
|
|
83046
|
-
return !!(kind &
|
|
83051
|
+
return !!(kind & 67648 /* NumberLike */) && isTypeAssignableTo(source, numberType) || !!(kind & 8320 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || !!(kind & 402654240 /* StringLike */) && isTypeAssignableTo(source, stringType) || !!(kind & 4352 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || !!(kind & 16 /* Void */) && isTypeAssignableTo(source, voidType) || !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || !!(kind & 8 /* Null */) && isTypeAssignableTo(source, nullType) || !!(kind & 4 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || !!(kind & 512 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType);
|
|
83047
83052
|
}
|
|
83048
83053
|
function allTypesAssignableToKind(source, kind, strict) {
|
|
83049
83054
|
return source.flags & 1048576 /* Union */ ? every(source.types, (subType) => allTypesAssignableToKind(subType, kind, strict)) : isTypeAssignableToKind(source, kind, strict);
|
|
@@ -83316,7 +83321,7 @@ function createTypeChecker(host) {
|
|
|
83316
83321
|
}
|
|
83317
83322
|
}
|
|
83318
83323
|
function isTypeEqualityComparableTo(source, target) {
|
|
83319
|
-
return (target.flags &
|
|
83324
|
+
return (target.flags & 12 /* Nullable */) !== 0 || isTypeComparableTo(source, target);
|
|
83320
83325
|
}
|
|
83321
83326
|
function createCheckBinaryExpression() {
|
|
83322
83327
|
const trampoline = createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState);
|
|
@@ -83567,7 +83572,7 @@ function createTypeChecker(host) {
|
|
|
83567
83572
|
leftType = checkNonNullType(leftType, left);
|
|
83568
83573
|
rightType = checkNonNullType(rightType, right);
|
|
83569
83574
|
let suggestedOperator;
|
|
83570
|
-
if (leftType.flags &
|
|
83575
|
+
if (leftType.flags & 4352 /* BooleanLike */ && rightType.flags & 4352 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
|
|
83571
83576
|
error2(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
|
|
83572
83577
|
return numberType;
|
|
83573
83578
|
} else {
|
|
@@ -83587,7 +83592,7 @@ function createTypeChecker(host) {
|
|
|
83587
83592
|
);
|
|
83588
83593
|
let resultType2;
|
|
83589
83594
|
if (isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */) || // Or, if neither could be bigint, implicit coercion results in a number result
|
|
83590
|
-
!(maybeTypeOfKind(leftType,
|
|
83595
|
+
!(maybeTypeOfKind(leftType, 8320 /* BigIntLike */) || maybeTypeOfKind(rightType, 8320 /* BigIntLike */))) {
|
|
83591
83596
|
resultType2 = numberType;
|
|
83592
83597
|
} else if (bothAreBigIntLike(leftType, rightType)) {
|
|
83593
83598
|
switch (operator) {
|
|
@@ -83639,43 +83644,43 @@ function createTypeChecker(host) {
|
|
|
83639
83644
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
83640
83645
|
return silentNeverType;
|
|
83641
83646
|
}
|
|
83642
|
-
if (!isTypeAssignableToKind(leftType,
|
|
83647
|
+
if (!isTypeAssignableToKind(leftType, 402654240 /* StringLike */) && !isTypeAssignableToKind(rightType, 402654240 /* StringLike */)) {
|
|
83643
83648
|
leftType = checkNonNullType(leftType, left);
|
|
83644
83649
|
rightType = checkNonNullType(rightType, right);
|
|
83645
83650
|
}
|
|
83646
83651
|
let resultType;
|
|
83647
83652
|
if (isTypeAssignableToKind(
|
|
83648
83653
|
leftType,
|
|
83649
|
-
|
|
83654
|
+
67648 /* NumberLike */,
|
|
83650
83655
|
/*strict*/
|
|
83651
83656
|
true
|
|
83652
83657
|
) && isTypeAssignableToKind(
|
|
83653
83658
|
rightType,
|
|
83654
|
-
|
|
83659
|
+
67648 /* NumberLike */,
|
|
83655
83660
|
/*strict*/
|
|
83656
83661
|
true
|
|
83657
83662
|
)) {
|
|
83658
83663
|
resultType = numberType;
|
|
83659
83664
|
} else if (isTypeAssignableToKind(
|
|
83660
83665
|
leftType,
|
|
83661
|
-
|
|
83666
|
+
8320 /* BigIntLike */,
|
|
83662
83667
|
/*strict*/
|
|
83663
83668
|
true
|
|
83664
83669
|
) && isTypeAssignableToKind(
|
|
83665
83670
|
rightType,
|
|
83666
|
-
|
|
83671
|
+
8320 /* BigIntLike */,
|
|
83667
83672
|
/*strict*/
|
|
83668
83673
|
true
|
|
83669
83674
|
)) {
|
|
83670
83675
|
resultType = bigintType;
|
|
83671
83676
|
} else if (isTypeAssignableToKind(
|
|
83672
83677
|
leftType,
|
|
83673
|
-
|
|
83678
|
+
402654240 /* StringLike */,
|
|
83674
83679
|
/*strict*/
|
|
83675
83680
|
true
|
|
83676
83681
|
) || isTypeAssignableToKind(
|
|
83677
83682
|
rightType,
|
|
83678
|
-
|
|
83683
|
+
402654240 /* StringLike */,
|
|
83679
83684
|
/*strict*/
|
|
83680
83685
|
true
|
|
83681
83686
|
)) {
|
|
@@ -83687,7 +83692,7 @@ function createTypeChecker(host) {
|
|
|
83687
83692
|
return resultType;
|
|
83688
83693
|
}
|
|
83689
83694
|
if (!resultType) {
|
|
83690
|
-
const closeEnoughKind =
|
|
83695
|
+
const closeEnoughKind = 67648 /* NumberLike */ | 8320 /* BigIntLike */ | 402654240 /* StringLike */ | 3 /* AnyOrUnknown */;
|
|
83691
83696
|
reportOperatorError(
|
|
83692
83697
|
(left2, right2) => isTypeAssignableToKind(left2, closeEnoughKind) && isTypeAssignableToKind(right2, closeEnoughKind)
|
|
83693
83698
|
);
|
|
@@ -83784,7 +83789,7 @@ function createTypeChecker(host) {
|
|
|
83784
83789
|
return Debug.fail();
|
|
83785
83790
|
}
|
|
83786
83791
|
function bothAreBigIntLike(left2, right2) {
|
|
83787
|
-
return isTypeAssignableToKind(left2,
|
|
83792
|
+
return isTypeAssignableToKind(left2, 8320 /* BigIntLike */) && isTypeAssignableToKind(right2, 8320 /* BigIntLike */);
|
|
83788
83793
|
}
|
|
83789
83794
|
function checkAssignmentDeclaration(kind, rightType2) {
|
|
83790
83795
|
if (kind === 2 /* ModuleExports */) {
|
|
@@ -83814,7 +83819,7 @@ function createTypeChecker(host) {
|
|
|
83814
83819
|
(isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
|
|
83815
83820
|
}
|
|
83816
83821
|
function checkForDisallowedESSymbolOperand(operator2) {
|
|
83817
|
-
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType,
|
|
83822
|
+
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 16896 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 16896 /* ESSymbolLike */) ? right : void 0;
|
|
83818
83823
|
if (offendingSymbolOperand) {
|
|
83819
83824
|
error2(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator2));
|
|
83820
83825
|
return false;
|
|
@@ -83853,7 +83858,7 @@ function createTypeChecker(host) {
|
|
|
83853
83858
|
}
|
|
83854
83859
|
if (checkReferenceExpression(left, Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access)) {
|
|
83855
83860
|
let headMessage;
|
|
83856
|
-
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType,
|
|
83861
|
+
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 4 /* Undefined */)) {
|
|
83857
83862
|
const target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText);
|
|
83858
83863
|
if (isExactOptionalPropertyMismatch(valueType, target)) {
|
|
83859
83864
|
headMessage = Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target;
|
|
@@ -84042,7 +84047,7 @@ function createTypeChecker(host) {
|
|
|
84042
84047
|
const types = [];
|
|
84043
84048
|
for (const span of node.templateSpans) {
|
|
84044
84049
|
const type = checkExpression(span.expression);
|
|
84045
|
-
if (maybeTypeOfKindConsideringBaseConstraint(type,
|
|
84050
|
+
if (maybeTypeOfKindConsideringBaseConstraint(type, 16896 /* ESSymbolLike */)) {
|
|
84046
84051
|
error2(span.expression, Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
|
|
84047
84052
|
}
|
|
84048
84053
|
texts.push(span.literal.text);
|
|
@@ -84062,7 +84067,7 @@ function createTypeChecker(host) {
|
|
|
84062
84067
|
return stringType;
|
|
84063
84068
|
}
|
|
84064
84069
|
function isTemplateLiteralContextualType(type) {
|
|
84065
|
-
return !!(type.flags & (
|
|
84070
|
+
return !!(type.flags & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402654240 /* StringLike */));
|
|
84066
84071
|
}
|
|
84067
84072
|
function getContextNode2(node) {
|
|
84068
84073
|
if (isJsxAttributes(node) && !isJsxSelfClosingElement(node.parent)) {
|
|
@@ -84083,7 +84088,7 @@ function createTypeChecker(host) {
|
|
|
84083
84088
|
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
84084
84089
|
inferenceContext.intraExpressionInferenceSites = void 0;
|
|
84085
84090
|
}
|
|
84086
|
-
const result = maybeTypeOfKind(type,
|
|
84091
|
+
const result = maybeTypeOfKind(type, 15360 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(
|
|
84087
84092
|
contextualType,
|
|
84088
84093
|
node,
|
|
84089
84094
|
/*contextFlags*/
|
|
@@ -84227,9 +84232,9 @@ function createTypeChecker(host) {
|
|
|
84227
84232
|
}
|
|
84228
84233
|
if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
84229
84234
|
const constraint = getBaseConstraintOfType(contextualType) || unknownType;
|
|
84230
|
-
return maybeTypeOfKind(constraint,
|
|
84235
|
+
return maybeTypeOfKind(constraint, 32 /* String */) && maybeTypeOfKind(candidateType, 1024 /* StringLiteral */) || maybeTypeOfKind(constraint, 64 /* Number */) && maybeTypeOfKind(candidateType, 2048 /* NumberLiteral */) || maybeTypeOfKind(constraint, 128 /* BigInt */) && maybeTypeOfKind(candidateType, 8192 /* BigIntLiteral */) || maybeTypeOfKind(constraint, 512 /* ESSymbol */) && maybeTypeOfKind(candidateType, 16384 /* UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint);
|
|
84231
84236
|
}
|
|
84232
|
-
return !!(contextualType.flags & (
|
|
84237
|
+
return !!(contextualType.flags & (1024 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 1024 /* StringLiteral */) || contextualType.flags & 2048 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 2048 /* NumberLiteral */) || contextualType.flags & 8192 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 8192 /* BigIntLiteral */) || contextualType.flags & 4096 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 4096 /* BooleanLiteral */) || contextualType.flags & 16384 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 16384 /* UniqueESSymbol */));
|
|
84233
84238
|
}
|
|
84234
84239
|
return false;
|
|
84235
84240
|
}
|
|
@@ -85330,18 +85335,6 @@ function createTypeChecker(host) {
|
|
|
85330
85335
|
}
|
|
85331
85336
|
function checkIndexedAccessIndexType(type, accessNode) {
|
|
85332
85337
|
if (!(type.flags & 8388608 /* IndexedAccess */)) {
|
|
85333
|
-
if (isIndexedAccessTypeNode(accessNode)) {
|
|
85334
|
-
const indexType2 = getTypeFromTypeNode(accessNode.indexType);
|
|
85335
|
-
const objectType2 = getTypeFromTypeNode(accessNode.objectType);
|
|
85336
|
-
const propertyName2 = getPropertyNameFromIndex(indexType2, accessNode);
|
|
85337
|
-
if (propertyName2) {
|
|
85338
|
-
const propertySymbol = forEachType(getApparentType(objectType2), (t) => getPropertyOfType(t, propertyName2));
|
|
85339
|
-
if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 6 /* NonPublicAccessibilityModifier */) {
|
|
85340
|
-
error2(accessNode, Diagnostics.Private_or_protected_member_0_cannot_be_accessed_via_indexed_access, unescapeLeadingUnderscores(propertyName2));
|
|
85341
|
-
return errorType;
|
|
85342
|
-
}
|
|
85343
|
-
}
|
|
85344
|
-
}
|
|
85345
85338
|
return type;
|
|
85346
85339
|
}
|
|
85347
85340
|
const objectType = type.objectType;
|
|
@@ -85354,12 +85347,14 @@ function createTypeChecker(host) {
|
|
|
85354
85347
|
}
|
|
85355
85348
|
return type;
|
|
85356
85349
|
}
|
|
85357
|
-
|
|
85358
|
-
|
|
85359
|
-
|
|
85360
|
-
|
|
85361
|
-
|
|
85362
|
-
|
|
85350
|
+
if (isGenericObjectType(objectType)) {
|
|
85351
|
+
const propertyName = getPropertyNameFromIndex(indexType, accessNode);
|
|
85352
|
+
if (propertyName) {
|
|
85353
|
+
const propertySymbol = forEachType(getApparentType(objectType), (t) => getPropertyOfType(t, propertyName));
|
|
85354
|
+
if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 6 /* NonPublicAccessibilityModifier */) {
|
|
85355
|
+
error2(accessNode, Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, unescapeLeadingUnderscores(propertyName));
|
|
85356
|
+
return errorType;
|
|
85357
|
+
}
|
|
85363
85358
|
}
|
|
85364
85359
|
}
|
|
85365
85360
|
error2(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
|
@@ -87100,7 +87095,7 @@ function createTypeChecker(host) {
|
|
|
87100
87095
|
return;
|
|
87101
87096
|
}
|
|
87102
87097
|
const type = location === condExpr2 ? condType : checkExpression(location);
|
|
87103
|
-
if (type.flags &
|
|
87098
|
+
if (type.flags & 32768 /* EnumLiteral */ && isPropertyAccessExpression(location) && (getNodeLinks(location.expression).resolvedSymbol ?? unknownSymbol).flags & 384 /* Enum */) {
|
|
87104
87099
|
error2(location, Diagnostics.This_condition_will_always_return_0, !!type.value ? "true" : "false");
|
|
87105
87100
|
return;
|
|
87106
87101
|
}
|
|
@@ -87192,7 +87187,7 @@ function createTypeChecker(host) {
|
|
|
87192
87187
|
checkSourceElement(node.statement);
|
|
87193
87188
|
}
|
|
87194
87189
|
function checkTruthinessOfType(type, node) {
|
|
87195
|
-
if (type.flags &
|
|
87190
|
+
if (type.flags & 16 /* Void */) {
|
|
87196
87191
|
error2(node, Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
|
|
87197
87192
|
} else {
|
|
87198
87193
|
const semantics = getSyntacticTruthySemantics(node);
|
|
@@ -87380,11 +87375,11 @@ function createTypeChecker(host) {
|
|
|
87380
87375
|
if (use & 4 /* AllowsStringInputFlag */) {
|
|
87381
87376
|
if (arrayType.flags & 1048576 /* Union */) {
|
|
87382
87377
|
const arrayTypes = inputType.types;
|
|
87383
|
-
const filteredTypes = filter(arrayTypes, (t) => !(t.flags &
|
|
87378
|
+
const filteredTypes = filter(arrayTypes, (t) => !(t.flags & 402654240 /* StringLike */));
|
|
87384
87379
|
if (filteredTypes !== arrayTypes) {
|
|
87385
87380
|
arrayType = getUnionType(filteredTypes, 2 /* Subtype */);
|
|
87386
87381
|
}
|
|
87387
|
-
} else if (arrayType.flags &
|
|
87382
|
+
} else if (arrayType.flags & 402654240 /* StringLike */) {
|
|
87388
87383
|
arrayType = neverType;
|
|
87389
87384
|
}
|
|
87390
87385
|
hasStringConstituent = arrayType !== inputType;
|
|
@@ -87409,7 +87404,7 @@ function createTypeChecker(host) {
|
|
|
87409
87404
|
}
|
|
87410
87405
|
const arrayElementType = getIndexTypeOfType(arrayType, numberType);
|
|
87411
87406
|
if (hasStringConstituent && arrayElementType) {
|
|
87412
|
-
if (arrayElementType.flags &
|
|
87407
|
+
if (arrayElementType.flags & 402654240 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) {
|
|
87413
87408
|
return stringType;
|
|
87414
87409
|
}
|
|
87415
87410
|
return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */);
|
|
@@ -87460,7 +87455,7 @@ function createTypeChecker(host) {
|
|
|
87460
87455
|
return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
|
|
87461
87456
|
}
|
|
87462
87457
|
function createIterationTypes(yieldType = neverType, returnType = neverType, nextType = unknownType) {
|
|
87463
|
-
if (yieldType.flags &
|
|
87458
|
+
if (yieldType.flags & 67245055 /* Intrinsic */ && returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16 /* Void */ | 4 /* Undefined */) && nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16 /* Void */ | 4 /* Undefined */)) {
|
|
87464
87459
|
const id = getTypeListId([yieldType, returnType, nextType]);
|
|
87465
87460
|
let iterationTypes = iterationTypesCache.get(id);
|
|
87466
87461
|
if (!iterationTypes) {
|
|
@@ -87956,7 +87951,7 @@ function createTypeChecker(host) {
|
|
|
87956
87951
|
}
|
|
87957
87952
|
function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
|
|
87958
87953
|
const type = unwrapReturnType(returnType, getFunctionFlags(func));
|
|
87959
|
-
return !!(type && (maybeTypeOfKind(type,
|
|
87954
|
+
return !!(type && (maybeTypeOfKind(type, 16 /* Void */) || type.flags & (1 /* Any */ | 4 /* Undefined */)));
|
|
87960
87955
|
}
|
|
87961
87956
|
function checkReturnStatement(node) {
|
|
87962
87957
|
if (checkGrammarStatementInAmbientContext(node)) {
|
|
@@ -88153,7 +88148,7 @@ function createTypeChecker(host) {
|
|
|
88153
88148
|
if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) {
|
|
88154
88149
|
checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(
|
|
88155
88150
|
prop,
|
|
88156
|
-
|
|
88151
|
+
19456 /* StringOrNumberLiteralOrUnique */,
|
|
88157
88152
|
/*includeNonPublic*/
|
|
88158
88153
|
true
|
|
88159
88154
|
), getNonMissingTypeOfSymbol(prop));
|
|
@@ -89624,7 +89619,7 @@ function createTypeChecker(host) {
|
|
|
89624
89619
|
true
|
|
89625
89620
|
);
|
|
89626
89621
|
if (importAttributesType !== emptyObjectType) {
|
|
89627
|
-
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType,
|
|
89622
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 4 /* Undefined */), node);
|
|
89628
89623
|
}
|
|
89629
89624
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
89630
89625
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
@@ -91176,7 +91171,7 @@ function createTypeChecker(host) {
|
|
|
91176
91171
|
return getStringLiteralType(name.text);
|
|
91177
91172
|
case 167 /* ComputedPropertyName */:
|
|
91178
91173
|
const nameType = checkComputedPropertyName(name);
|
|
91179
|
-
return isTypeAssignableToKind(nameType,
|
|
91174
|
+
return isTypeAssignableToKind(nameType, 16896 /* ESSymbolLike */) ? nameType : stringType;
|
|
91180
91175
|
default:
|
|
91181
91176
|
return Debug.fail("Unsupported property name.");
|
|
91182
91177
|
}
|
|
@@ -91697,19 +91692,19 @@ function createTypeChecker(host) {
|
|
|
91697
91692
|
return isTypeOnly ? 11 /* ObjectType */ : 0 /* Unknown */;
|
|
91698
91693
|
} else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
91699
91694
|
return 11 /* ObjectType */;
|
|
91700
|
-
} else if (isTypeAssignableToKind(type,
|
|
91695
|
+
} else if (isTypeAssignableToKind(type, 16 /* Void */ | 12 /* Nullable */ | 131072 /* Never */)) {
|
|
91701
91696
|
return 2 /* VoidNullableOrNeverType */;
|
|
91702
|
-
} else if (isTypeAssignableToKind(type,
|
|
91697
|
+
} else if (isTypeAssignableToKind(type, 4352 /* BooleanLike */)) {
|
|
91703
91698
|
return 6 /* BooleanType */;
|
|
91704
|
-
} else if (isTypeAssignableToKind(type,
|
|
91699
|
+
} else if (isTypeAssignableToKind(type, 67648 /* NumberLike */)) {
|
|
91705
91700
|
return 3 /* NumberLikeType */;
|
|
91706
|
-
} else if (isTypeAssignableToKind(type,
|
|
91701
|
+
} else if (isTypeAssignableToKind(type, 8320 /* BigIntLike */)) {
|
|
91707
91702
|
return 4 /* BigIntLikeType */;
|
|
91708
|
-
} else if (isTypeAssignableToKind(type,
|
|
91703
|
+
} else if (isTypeAssignableToKind(type, 402654240 /* StringLike */)) {
|
|
91709
91704
|
return 5 /* StringLikeType */;
|
|
91710
91705
|
} else if (isTupleType(type)) {
|
|
91711
91706
|
return 7 /* ArrayLikeType */;
|
|
91712
|
-
} else if (isTypeAssignableToKind(type,
|
|
91707
|
+
} else if (isTypeAssignableToKind(type, 16896 /* ESSymbolLike */)) {
|
|
91713
91708
|
return 8 /* ESSymbolType */;
|
|
91714
91709
|
} else if (isFunctionType(type)) {
|
|
91715
91710
|
return 10 /* TypeWithCallSignature */;
|
|
@@ -91852,7 +91847,7 @@ function createTypeChecker(host) {
|
|
|
91852
91847
|
return false;
|
|
91853
91848
|
}
|
|
91854
91849
|
function literalTypeToNode(type, enclosing, tracker) {
|
|
91855
|
-
const enumResult = type.flags &
|
|
91850
|
+
const enumResult = type.flags & 98304 /* EnumLike */ ? nodeBuilder.symbolToExpression(
|
|
91856
91851
|
type.symbol,
|
|
91857
91852
|
111551 /* Value */,
|
|
91858
91853
|
enclosing,
|
|
@@ -92871,7 +92866,7 @@ function createTypeChecker(host) {
|
|
|
92871
92866
|
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
|
|
92872
92867
|
}
|
|
92873
92868
|
const type = getTypeFromTypeNode(parameter.type);
|
|
92874
|
-
if (someType(type, (t) => !!(t.flags &
|
|
92869
|
+
if (someType(type, (t) => !!(t.flags & 19456 /* StringOrNumberLiteralOrUnique */)) || isGenericType(type)) {
|
|
92875
92870
|
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead);
|
|
92876
92871
|
}
|
|
92877
92872
|
if (!everyType(type, isValidIndexKeyType)) {
|
|
@@ -93402,7 +93397,7 @@ function createTypeChecker(host) {
|
|
|
93402
93397
|
}
|
|
93403
93398
|
function isSimpleLiteralEnumReference(expr) {
|
|
93404
93399
|
if ((isPropertyAccessExpression(expr) || isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression)) && isEntityNameExpression(expr.expression)) {
|
|
93405
|
-
return !!(checkExpressionCached(expr).flags &
|
|
93400
|
+
return !!(checkExpressionCached(expr).flags & 98304 /* EnumLike */);
|
|
93406
93401
|
}
|
|
93407
93402
|
}
|
|
93408
93403
|
function checkAmbientInitializer(node) {
|
|
@@ -93892,6 +93887,319 @@ function createTypeChecker(host) {
|
|
|
93892
93887
|
Debug.assert(specifier && nodeIsSynthesized(specifier) && specifier.text === "tslib", `Expected sourceFile.imports[0] to be the synthesized tslib import`);
|
|
93893
93888
|
return specifier;
|
|
93894
93889
|
}
|
|
93890
|
+
function compareSymbols(s1, s2) {
|
|
93891
|
+
if (s1 === s2) return 0;
|
|
93892
|
+
if (s1 === void 0) return 1;
|
|
93893
|
+
if (s2 === void 0) return -1;
|
|
93894
|
+
if (length(s1.declarations) !== 0 && length(s2.declarations) !== 0) {
|
|
93895
|
+
const r2 = compareNodes(s1.declarations[0], s2.declarations[0]);
|
|
93896
|
+
if (r2 !== 0) return r2;
|
|
93897
|
+
} else if (length(s1.declarations) !== 0) {
|
|
93898
|
+
return -1;
|
|
93899
|
+
} else if (length(s2.declarations) !== 0) {
|
|
93900
|
+
return 1;
|
|
93901
|
+
}
|
|
93902
|
+
const r = compareComparableValues(s1.escapedName, s2.escapedName);
|
|
93903
|
+
if (r !== 0) return r;
|
|
93904
|
+
return getSymbolId(s1) - getSymbolId(s2);
|
|
93905
|
+
}
|
|
93906
|
+
function compareNodes(n1, n2) {
|
|
93907
|
+
if (n1 === n2) return 0;
|
|
93908
|
+
if (n1 === void 0) return 1;
|
|
93909
|
+
if (n2 === void 0) return -1;
|
|
93910
|
+
const f1 = fileIndexMap.get(getSourceFileOfNode(n1));
|
|
93911
|
+
const f2 = fileIndexMap.get(getSourceFileOfNode(n2));
|
|
93912
|
+
if (f1 !== f2) {
|
|
93913
|
+
return f1 - f2;
|
|
93914
|
+
}
|
|
93915
|
+
return n1.pos - n2.pos;
|
|
93916
|
+
}
|
|
93917
|
+
function compareTypes(t1, t2) {
|
|
93918
|
+
if (t1 === t2) return 0;
|
|
93919
|
+
if (t1 === void 0) return 1;
|
|
93920
|
+
if (t2 === void 0) return -1;
|
|
93921
|
+
let c = getSortOrderFlags(t1) - getSortOrderFlags(t2);
|
|
93922
|
+
if (c !== 0) return c;
|
|
93923
|
+
c = compareTypeNames(t1, t2);
|
|
93924
|
+
if (c !== 0) return c;
|
|
93925
|
+
if (t1.flags & (1 /* Any */ | 2 /* Unknown */ | 32 /* String */ | 64 /* Number */ | 256 /* Boolean */ | 128 /* BigInt */ | 512 /* ESSymbol */ | 16 /* Void */ | 4 /* Undefined */ | 8 /* Null */ | 131072 /* Never */ | 67108864 /* NonPrimitive */)) {
|
|
93926
|
+
} else if (t1.flags & 524288 /* Object */) {
|
|
93927
|
+
const c2 = compareSymbols(t1.symbol, t2.symbol);
|
|
93928
|
+
if (c2 !== 0) return c2;
|
|
93929
|
+
if (getObjectFlags(t1) & 4 /* Reference */ && getObjectFlags(t2) & 4 /* Reference */) {
|
|
93930
|
+
const r1 = t1;
|
|
93931
|
+
const r2 = t2;
|
|
93932
|
+
if (getObjectFlags(r1.target) & 8 /* Tuple */ && getObjectFlags(r2.target) & 8 /* Tuple */) {
|
|
93933
|
+
const c3 = compareTupleTypes(r1.target, r2.target);
|
|
93934
|
+
if (c3 !== 0) {
|
|
93935
|
+
return c3;
|
|
93936
|
+
}
|
|
93937
|
+
}
|
|
93938
|
+
if (r1.node === void 0 && r2.node === void 0) {
|
|
93939
|
+
const c3 = compareTypeLists(t1.resolvedTypeArguments, t2.resolvedTypeArguments);
|
|
93940
|
+
if (c3 !== 0) {
|
|
93941
|
+
return c3;
|
|
93942
|
+
}
|
|
93943
|
+
} else {
|
|
93944
|
+
let c3 = compareNodes(r1.node, r2.node);
|
|
93945
|
+
if (c3 !== 0) {
|
|
93946
|
+
return c3;
|
|
93947
|
+
}
|
|
93948
|
+
c3 = compareTypeMappers(t1.mapper, t2.mapper);
|
|
93949
|
+
if (c3 !== 0) {
|
|
93950
|
+
return c3;
|
|
93951
|
+
}
|
|
93952
|
+
}
|
|
93953
|
+
} else if (getObjectFlags(t1) & 4 /* Reference */) {
|
|
93954
|
+
return -1;
|
|
93955
|
+
} else if (getObjectFlags(t2) & 4 /* Reference */) {
|
|
93956
|
+
return 1;
|
|
93957
|
+
} else {
|
|
93958
|
+
let c3 = getObjectFlags(t1) & 142607679 /* ObjectTypeKindMask */ - getObjectFlags(t2) & 142607679 /* ObjectTypeKindMask */;
|
|
93959
|
+
if (c3 !== 0) {
|
|
93960
|
+
return c3;
|
|
93961
|
+
}
|
|
93962
|
+
c3 = compareTypeMappers(t1.mapper, t2.mapper);
|
|
93963
|
+
if (c3 !== 0) {
|
|
93964
|
+
return c3;
|
|
93965
|
+
}
|
|
93966
|
+
}
|
|
93967
|
+
} else if (t1.flags & 1048576 /* Union */) {
|
|
93968
|
+
const o1 = t1.origin;
|
|
93969
|
+
const o2 = t2.origin;
|
|
93970
|
+
if (o1 === void 0 && o2 === void 0) {
|
|
93971
|
+
const c2 = compareTypeLists(t1.types, t2.types);
|
|
93972
|
+
if (c2 !== 0) {
|
|
93973
|
+
return c2;
|
|
93974
|
+
}
|
|
93975
|
+
} else if (o1 === void 0) {
|
|
93976
|
+
return 1;
|
|
93977
|
+
} else if (o2 === void 0) {
|
|
93978
|
+
return -1;
|
|
93979
|
+
} else {
|
|
93980
|
+
const c2 = compareTypes(o1, o2);
|
|
93981
|
+
if (c2 !== 0) {
|
|
93982
|
+
return c2;
|
|
93983
|
+
}
|
|
93984
|
+
}
|
|
93985
|
+
} else if (t1.flags & 2097152 /* Intersection */) {
|
|
93986
|
+
const c2 = compareTypeLists(t1.types, t2.types);
|
|
93987
|
+
if (c2 !== 0) {
|
|
93988
|
+
return c2;
|
|
93989
|
+
}
|
|
93990
|
+
} else if (t1.flags & (32768 /* EnumLiteral */ | 16384 /* UniqueESSymbol */)) {
|
|
93991
|
+
const c2 = compareSymbols(t1.symbol, t2.symbol);
|
|
93992
|
+
if (c2 !== 0) {
|
|
93993
|
+
return c2;
|
|
93994
|
+
}
|
|
93995
|
+
} else if (t1.flags & 1024 /* StringLiteral */) {
|
|
93996
|
+
const c2 = compareComparableValues(t1.value, t2.value);
|
|
93997
|
+
if (c2 !== 0) {
|
|
93998
|
+
return c2;
|
|
93999
|
+
}
|
|
94000
|
+
} else if (t1.flags & 2048 /* NumberLiteral */) {
|
|
94001
|
+
const c2 = compareComparableValues(t1.value, t2.value);
|
|
94002
|
+
if (c2 !== 0) {
|
|
94003
|
+
return c2;
|
|
94004
|
+
}
|
|
94005
|
+
} else if (t1.flags & 4096 /* BooleanLiteral */) {
|
|
94006
|
+
const b1 = t1.intrinsicName === "true";
|
|
94007
|
+
const b2 = t2.intrinsicName === "true";
|
|
94008
|
+
if (b1 !== b2) {
|
|
94009
|
+
if (b1) {
|
|
94010
|
+
return 1;
|
|
94011
|
+
}
|
|
94012
|
+
return -1;
|
|
94013
|
+
}
|
|
94014
|
+
} else if (t1.flags & 262144 /* TypeParameter */) {
|
|
94015
|
+
const c2 = compareSymbols(t1.symbol, t2.symbol);
|
|
94016
|
+
if (c2 !== 0) {
|
|
94017
|
+
return c2;
|
|
94018
|
+
}
|
|
94019
|
+
} else if (t1.flags & 4194304 /* Index */) {
|
|
94020
|
+
let c2 = compareTypes(t1.type, t2.type);
|
|
94021
|
+
if (c2 !== 0) {
|
|
94022
|
+
return c2;
|
|
94023
|
+
}
|
|
94024
|
+
c2 = t1.flags - t2.flags;
|
|
94025
|
+
if (c2 !== 0) {
|
|
94026
|
+
return c2;
|
|
94027
|
+
}
|
|
94028
|
+
} else if (t1.flags & 8388608 /* IndexedAccess */) {
|
|
94029
|
+
let c2 = compareTypes(t1.objectType, t2.objectType);
|
|
94030
|
+
if (c2 !== 0) {
|
|
94031
|
+
return c2;
|
|
94032
|
+
}
|
|
94033
|
+
c2 = compareTypes(t1.indexType, t2.indexType);
|
|
94034
|
+
if (c2 !== 0) {
|
|
94035
|
+
return c2;
|
|
94036
|
+
}
|
|
94037
|
+
} else if (t1.flags & 16777216 /* Conditional */) {
|
|
94038
|
+
let c2 = compareNodes(t1.root.node, t2.root.node);
|
|
94039
|
+
if (c2 !== 0) {
|
|
94040
|
+
return c2;
|
|
94041
|
+
}
|
|
94042
|
+
c2 = compareTypeMappers(t1.mapper, t2.mapper);
|
|
94043
|
+
if (c2 !== 0) {
|
|
94044
|
+
return c2;
|
|
94045
|
+
}
|
|
94046
|
+
} else if (t1.flags & 33554432 /* Substitution */) {
|
|
94047
|
+
let c2 = compareTypes(t1.baseType, t2.baseType);
|
|
94048
|
+
if (c2 !== 0) {
|
|
94049
|
+
return c2;
|
|
94050
|
+
}
|
|
94051
|
+
c2 = compareTypes(t1.constraint, t2.constraint);
|
|
94052
|
+
if (c2 !== 0) {
|
|
94053
|
+
return c2;
|
|
94054
|
+
}
|
|
94055
|
+
} else if (t1.flags & 134217728 /* TemplateLiteral */) {
|
|
94056
|
+
let c2 = slicesCompareString(t1.texts, t2.texts);
|
|
94057
|
+
if (c2 !== 0) {
|
|
94058
|
+
return c2;
|
|
94059
|
+
}
|
|
94060
|
+
c2 = compareTypeLists(t1.types, t2.types);
|
|
94061
|
+
if (c2 !== 0) {
|
|
94062
|
+
return c2;
|
|
94063
|
+
}
|
|
94064
|
+
} else if (t1.flags & 268435456 /* StringMapping */) {
|
|
94065
|
+
const c2 = compareTypes(t1.type, t2.type);
|
|
94066
|
+
if (c2 !== 0) {
|
|
94067
|
+
return c2;
|
|
94068
|
+
}
|
|
94069
|
+
}
|
|
94070
|
+
return t1.id - t2.id;
|
|
94071
|
+
function slicesCompareString(s1, s2) {
|
|
94072
|
+
for (let i = 0; i < s1.length; i++) {
|
|
94073
|
+
if (i > s2.length) {
|
|
94074
|
+
return 1;
|
|
94075
|
+
}
|
|
94076
|
+
const v1 = s1[i];
|
|
94077
|
+
const v2 = s2[i];
|
|
94078
|
+
const c2 = compareComparableValues(v1, v2);
|
|
94079
|
+
if (c2 !== 0) return c2;
|
|
94080
|
+
}
|
|
94081
|
+
if (s1.length < s2.length) {
|
|
94082
|
+
return -1;
|
|
94083
|
+
}
|
|
94084
|
+
return 0;
|
|
94085
|
+
}
|
|
94086
|
+
}
|
|
94087
|
+
function getSortOrderFlags(t) {
|
|
94088
|
+
return (t.flags & 65536 /* Enum */) >> 1 | t.flags & ~65536 /* Enum */;
|
|
94089
|
+
}
|
|
94090
|
+
function compareTypeNames(t1, t2) {
|
|
94091
|
+
const s1 = getTypeNameSymbol(t1);
|
|
94092
|
+
const s2 = getTypeNameSymbol(t2);
|
|
94093
|
+
if (s1 === s2) {
|
|
94094
|
+
if (t1.aliasTypeArguments !== void 0) {
|
|
94095
|
+
return compareTypeLists(t1.aliasTypeArguments, t2.aliasTypeArguments);
|
|
94096
|
+
}
|
|
94097
|
+
return 0;
|
|
94098
|
+
}
|
|
94099
|
+
if (s1 === void 0) {
|
|
94100
|
+
return 1;
|
|
94101
|
+
}
|
|
94102
|
+
if (s2 === void 0) {
|
|
94103
|
+
return -1;
|
|
94104
|
+
}
|
|
94105
|
+
return compareComparableValues(s1.escapedName, s2.escapedName);
|
|
94106
|
+
}
|
|
94107
|
+
function getTypeNameSymbol(t) {
|
|
94108
|
+
if (t.aliasSymbol !== void 0) {
|
|
94109
|
+
return t.aliasSymbol;
|
|
94110
|
+
}
|
|
94111
|
+
if (t.flags & (262144 /* TypeParameter */ | 268435456 /* StringMapping */) || getObjectFlags(t) & (3 /* ClassOrInterface */ | 4 /* Reference */)) {
|
|
94112
|
+
return t.symbol;
|
|
94113
|
+
}
|
|
94114
|
+
return void 0;
|
|
94115
|
+
}
|
|
94116
|
+
function compareTupleTypes(t1, t2) {
|
|
94117
|
+
var _a;
|
|
94118
|
+
if (t1 === t2) {
|
|
94119
|
+
return 0;
|
|
94120
|
+
}
|
|
94121
|
+
if (t1.readonly === t2.readonly) {
|
|
94122
|
+
return t1.readonly ? 1 : -1;
|
|
94123
|
+
}
|
|
94124
|
+
if (t1.elementFlags.length !== t2.elementFlags.length) {
|
|
94125
|
+
return t1.elementFlags.length - t2.elementFlags.length;
|
|
94126
|
+
}
|
|
94127
|
+
for (let i = 0; i < t1.elementFlags.length; i++) {
|
|
94128
|
+
const c = t1.elementFlags[i] - t2.elementFlags[i];
|
|
94129
|
+
if (c !== 0) {
|
|
94130
|
+
return c;
|
|
94131
|
+
}
|
|
94132
|
+
}
|
|
94133
|
+
for (let i = 0; i < (((_a = t1.labeledElementDeclarations) == null ? void 0 : _a.length) ?? 0); i++) {
|
|
94134
|
+
const c = compareElementLabels(t1.labeledElementDeclarations[i], t2.labeledElementDeclarations[i]);
|
|
94135
|
+
if (c !== 0) {
|
|
94136
|
+
return c;
|
|
94137
|
+
}
|
|
94138
|
+
}
|
|
94139
|
+
return 0;
|
|
94140
|
+
}
|
|
94141
|
+
function compareElementLabels(n1, n2) {
|
|
94142
|
+
if (n1 === n2) {
|
|
94143
|
+
return 0;
|
|
94144
|
+
}
|
|
94145
|
+
if (n1 === void 0) {
|
|
94146
|
+
return -1;
|
|
94147
|
+
}
|
|
94148
|
+
if (n2 === void 0) {
|
|
94149
|
+
return 1;
|
|
94150
|
+
}
|
|
94151
|
+
return compareComparableValues(n1.name.escapedText, n2.name.escapedText);
|
|
94152
|
+
}
|
|
94153
|
+
function compareTypeLists(s1, s2) {
|
|
94154
|
+
if (length(s1) !== length(s2)) {
|
|
94155
|
+
return length(s1) - length(s2);
|
|
94156
|
+
}
|
|
94157
|
+
for (let i = 0; i < length(s1); i++) {
|
|
94158
|
+
const c = compareTypes(s1[i], s2 == null ? void 0 : s2[i]);
|
|
94159
|
+
if (c !== 0) return c;
|
|
94160
|
+
}
|
|
94161
|
+
return 0;
|
|
94162
|
+
}
|
|
94163
|
+
function compareTypeMappers(m1, m2) {
|
|
94164
|
+
if (m1 === m2) {
|
|
94165
|
+
return 0;
|
|
94166
|
+
}
|
|
94167
|
+
if (m1 === void 0) {
|
|
94168
|
+
return 1;
|
|
94169
|
+
}
|
|
94170
|
+
if (m2 === void 0) {
|
|
94171
|
+
return -1;
|
|
94172
|
+
}
|
|
94173
|
+
const kind1 = m1.kind;
|
|
94174
|
+
const kind2 = m2.kind;
|
|
94175
|
+
if (kind1 !== kind2) {
|
|
94176
|
+
return kind1 - kind2;
|
|
94177
|
+
}
|
|
94178
|
+
switch (kind1) {
|
|
94179
|
+
case 0 /* Simple */: {
|
|
94180
|
+
const c = compareTypes(m1.source, m2.source);
|
|
94181
|
+
if (c !== 0) {
|
|
94182
|
+
return c;
|
|
94183
|
+
}
|
|
94184
|
+
return compareTypes(m1.target, m2.target);
|
|
94185
|
+
}
|
|
94186
|
+
case 1 /* Array */: {
|
|
94187
|
+
const c = compareTypeLists(m1.sources, m2.sources);
|
|
94188
|
+
if (c !== 0) {
|
|
94189
|
+
return c;
|
|
94190
|
+
}
|
|
94191
|
+
return compareTypeLists(m1.targets, m2.targets);
|
|
94192
|
+
}
|
|
94193
|
+
case 5 /* Merged */: {
|
|
94194
|
+
const c = compareTypeMappers(m1.mapper1, m2.mapper1);
|
|
94195
|
+
if (c !== 0) {
|
|
94196
|
+
return c;
|
|
94197
|
+
}
|
|
94198
|
+
return compareTypeMappers(m1.mapper2, m2.mapper2);
|
|
94199
|
+
}
|
|
94200
|
+
}
|
|
94201
|
+
return 0;
|
|
94202
|
+
}
|
|
93895
94203
|
}
|
|
93896
94204
|
function isNotAccessor(declaration) {
|
|
93897
94205
|
return !isAccessor(declaration);
|
|
@@ -137602,18 +137910,17 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
137602
137910
|
);
|
|
137603
137911
|
}
|
|
137604
137912
|
function reuseTypeParameters(typeParameters, context) {
|
|
137605
|
-
return typeParameters == null ? void 0 : typeParameters.map(
|
|
137606
|
-
|
|
137607
|
-
|
|
137608
|
-
|
|
137609
|
-
|
|
137610
|
-
|
|
137611
|
-
|
|
137612
|
-
|
|
137613
|
-
|
|
137614
|
-
|
|
137615
|
-
|
|
137616
|
-
);
|
|
137913
|
+
return typeParameters == null ? void 0 : typeParameters.map((tp) => {
|
|
137914
|
+
var _a;
|
|
137915
|
+
const { node: tpName } = resolver.trackExistingEntityName(context, tp.name);
|
|
137916
|
+
return factory.updateTypeParameterDeclaration(
|
|
137917
|
+
tp,
|
|
137918
|
+
(_a = tp.modifiers) == null ? void 0 : _a.map((m) => reuseNode(context, m)),
|
|
137919
|
+
tpName,
|
|
137920
|
+
serializeExistingTypeNodeWithFallback(tp.constraint, context),
|
|
137921
|
+
serializeExistingTypeNodeWithFallback(tp.default, context)
|
|
137922
|
+
);
|
|
137923
|
+
});
|
|
137617
137924
|
}
|
|
137618
137925
|
function typeFromObjectLiteralMethod(method, name, context, isConstContext) {
|
|
137619
137926
|
const returnType = createReturnFromSignature(
|
|
@@ -139665,7 +139972,7 @@ function isStringOrRegularExpressionOrTemplateLiteral(kind) {
|
|
|
139665
139972
|
return false;
|
|
139666
139973
|
}
|
|
139667
139974
|
function areIntersectedTypesAvoidingStringReduction(checker, t1, t2) {
|
|
139668
|
-
return !!(t1.flags &
|
|
139975
|
+
return !!(t1.flags & 32 /* String */) && checker.isEmptyAnonymousObjectType(t2);
|
|
139669
139976
|
}
|
|
139670
139977
|
function isStringAndEmptyAnonymousObjectIntersection(type) {
|
|
139671
139978
|
if (!type.isIntersection()) {
|
|
@@ -150220,7 +150527,7 @@ function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFi
|
|
|
150220
150527
|
const start = first(statements).getStart();
|
|
150221
150528
|
const end = last(statements).end;
|
|
150222
150529
|
expressionDiagnostic = createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected);
|
|
150223
|
-
} else if (checker.getTypeAtLocation(expression).flags & (
|
|
150530
|
+
} else if (checker.getTypeAtLocation(expression).flags & (16 /* Void */ | 131072 /* Never */)) {
|
|
150224
150531
|
expressionDiagnostic = createDiagnosticForNode(expression, Messages.uselessConstantType);
|
|
150225
150532
|
}
|
|
150226
150533
|
for (const scope of scopes) {
|
|
@@ -151277,13 +151584,13 @@ var TypeObject = class {
|
|
|
151277
151584
|
return !!(this.flags & 3145728 /* UnionOrIntersection */);
|
|
151278
151585
|
}
|
|
151279
151586
|
isLiteral() {
|
|
151280
|
-
return !!(this.flags & (
|
|
151587
|
+
return !!(this.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */ | 8192 /* BigIntLiteral */));
|
|
151281
151588
|
}
|
|
151282
151589
|
isStringLiteral() {
|
|
151283
|
-
return !!(this.flags &
|
|
151590
|
+
return !!(this.flags & 1024 /* StringLiteral */);
|
|
151284
151591
|
}
|
|
151285
151592
|
isNumberLiteral() {
|
|
151286
|
-
return !!(this.flags &
|
|
151593
|
+
return !!(this.flags & 2048 /* NumberLiteral */);
|
|
151287
151594
|
}
|
|
151288
151595
|
isTypeParameter() {
|
|
151289
151596
|
return !!(this.flags & 262144 /* TypeParameter */);
|
|
@@ -160013,7 +160320,7 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
|
160013
160320
|
return { kind: 0 /* TypeLikeDeclaration */, token, call, modifierFlags, parentDeclaration: declaration, declSourceFile, isJSFile };
|
|
160014
160321
|
}
|
|
160015
160322
|
const enumDeclaration = find(symbol.declarations, isEnumDeclaration);
|
|
160016
|
-
if (enumDeclaration && !(leftExpressionType.flags &
|
|
160323
|
+
if (enumDeclaration && !(leftExpressionType.flags & 98304 /* EnumLike */) && !isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
160017
160324
|
return { kind: 1 /* Enum */, token, parentDeclaration: enumDeclaration };
|
|
160018
160325
|
}
|
|
160019
160326
|
return void 0;
|
|
@@ -160189,7 +160496,7 @@ function addMethodDeclaration(context, changes, callExpression, name, modifierFl
|
|
|
160189
160496
|
function addEnumMemberDeclaration(changes, checker, { token, parentDeclaration }) {
|
|
160190
160497
|
const hasStringInitializer = some(parentDeclaration.members, (member) => {
|
|
160191
160498
|
const type = checker.getTypeAtLocation(member);
|
|
160192
|
-
return !!(type && type.flags &
|
|
160499
|
+
return !!(type && type.flags & 402654240 /* StringLike */);
|
|
160193
160500
|
});
|
|
160194
160501
|
const sourceFile = parentDeclaration.getSourceFile();
|
|
160195
160502
|
const enumMember = factory.createEnumMember(token, hasStringInitializer ? factory.createStringLiteral(token.text) : void 0);
|
|
@@ -160277,23 +160584,23 @@ function tryGetValueFromType(context, checker, importAdder, quotePreference, typ
|
|
|
160277
160584
|
if (type.flags & 3 /* AnyOrUnknown */) {
|
|
160278
160585
|
return createUndefined();
|
|
160279
160586
|
}
|
|
160280
|
-
if (type.flags & (
|
|
160587
|
+
if (type.flags & (32 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
160281
160588
|
return factory.createStringLiteral(
|
|
160282
160589
|
"",
|
|
160283
160590
|
/* isSingleQuote */
|
|
160284
160591
|
quotePreference === 0 /* Single */
|
|
160285
160592
|
);
|
|
160286
160593
|
}
|
|
160287
|
-
if (type.flags &
|
|
160594
|
+
if (type.flags & 64 /* Number */) {
|
|
160288
160595
|
return factory.createNumericLiteral(0);
|
|
160289
160596
|
}
|
|
160290
|
-
if (type.flags &
|
|
160597
|
+
if (type.flags & 128 /* BigInt */) {
|
|
160291
160598
|
return factory.createBigIntLiteral("0n");
|
|
160292
160599
|
}
|
|
160293
|
-
if (type.flags &
|
|
160600
|
+
if (type.flags & 256 /* Boolean */) {
|
|
160294
160601
|
return factory.createFalse();
|
|
160295
160602
|
}
|
|
160296
|
-
if (type.flags &
|
|
160603
|
+
if (type.flags & 98304 /* EnumLike */) {
|
|
160297
160604
|
const enumMember = type.symbol.exports ? firstOrUndefinedIterator(type.symbol.exports.values()) : type.symbol;
|
|
160298
160605
|
const symbol = type.symbol.parent && type.symbol.parent.flags & 256 /* RegularEnum */ ? type.symbol.parent : type.symbol;
|
|
160299
160606
|
const name = checker.symbolToExpression(
|
|
@@ -160306,26 +160613,26 @@ function tryGetValueFromType(context, checker, importAdder, quotePreference, typ
|
|
|
160306
160613
|
);
|
|
160307
160614
|
return enumMember === void 0 || name === void 0 ? factory.createNumericLiteral(0) : factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember));
|
|
160308
160615
|
}
|
|
160309
|
-
if (type.flags &
|
|
160616
|
+
if (type.flags & 2048 /* NumberLiteral */) {
|
|
160310
160617
|
return factory.createNumericLiteral(type.value);
|
|
160311
160618
|
}
|
|
160312
|
-
if (type.flags &
|
|
160619
|
+
if (type.flags & 8192 /* BigIntLiteral */) {
|
|
160313
160620
|
return factory.createBigIntLiteral(type.value);
|
|
160314
160621
|
}
|
|
160315
|
-
if (type.flags &
|
|
160622
|
+
if (type.flags & 1024 /* StringLiteral */) {
|
|
160316
160623
|
return factory.createStringLiteral(
|
|
160317
160624
|
type.value,
|
|
160318
160625
|
/* isSingleQuote */
|
|
160319
160626
|
quotePreference === 0 /* Single */
|
|
160320
160627
|
);
|
|
160321
160628
|
}
|
|
160322
|
-
if (type.flags &
|
|
160629
|
+
if (type.flags & 4096 /* BooleanLiteral */) {
|
|
160323
160630
|
return type === checker.getFalseType() || type === checker.getFalseType(
|
|
160324
160631
|
/*fresh*/
|
|
160325
160632
|
true
|
|
160326
160633
|
) ? factory.createFalse() : factory.createTrue();
|
|
160327
160634
|
}
|
|
160328
|
-
if (type.flags &
|
|
160635
|
+
if (type.flags & 8 /* Null */) {
|
|
160329
160636
|
return factory.createNull();
|
|
160330
160637
|
}
|
|
160331
160638
|
if (type.flags & 1048576 /* Union */) {
|
|
@@ -161771,7 +162078,7 @@ registerCodeFix({
|
|
|
161771
162078
|
const info = getInfo15(err.file, err.start, checker);
|
|
161772
162079
|
if (!info) return;
|
|
161773
162080
|
const { typeNode, type } = info;
|
|
161774
|
-
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId56 === fixIdNullable ? checker.getNullableType(type,
|
|
162081
|
+
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId56 === fixIdNullable ? checker.getNullableType(type, 4 /* Undefined */) : type;
|
|
161775
162082
|
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
161776
162083
|
});
|
|
161777
162084
|
}
|
|
@@ -162060,7 +162367,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
162060
162367
|
}
|
|
162061
162368
|
const variableDeclaration = findAncestor(targetNode, isVariableDeclaration);
|
|
162062
162369
|
const type = variableDeclaration && typeChecker.getTypeAtLocation(variableDeclaration);
|
|
162063
|
-
if (type && type.flags &
|
|
162370
|
+
if (type && type.flags & 16384 /* UniqueESSymbol */) {
|
|
162064
162371
|
return void 0;
|
|
162065
162372
|
}
|
|
162066
162373
|
if (!(isExpressionTarget || isShorthandPropertyAssignmentTarget)) return void 0;
|
|
@@ -162541,7 +162848,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
162541
162848
|
mutatedTarget: false
|
|
162542
162849
|
};
|
|
162543
162850
|
function getFlags(type2) {
|
|
162544
|
-
return (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type2.flags &
|
|
162851
|
+
return (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type2.flags & 16384 /* UniqueESSymbol */ ? 1048576 /* AllowUniqueESSymbolType */ : 0 /* None */;
|
|
162545
162852
|
}
|
|
162546
162853
|
}
|
|
162547
162854
|
function createTypeOfFromEntityNameExpression(node) {
|
|
@@ -163515,7 +163822,7 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163515
163822
|
case 32 /* GreaterThanToken */:
|
|
163516
163823
|
case 34 /* GreaterThanEqualsToken */:
|
|
163517
163824
|
const operandType = checker.getTypeAtLocation(parent2.left === node ? parent2.right : parent2.left);
|
|
163518
|
-
if (operandType.flags &
|
|
163825
|
+
if (operandType.flags & 98304 /* EnumLike */) {
|
|
163519
163826
|
addCandidateType(usage, operandType);
|
|
163520
163827
|
} else {
|
|
163521
163828
|
usage.isNumber = true;
|
|
@@ -163524,11 +163831,11 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163524
163831
|
case 65 /* PlusEqualsToken */:
|
|
163525
163832
|
case 40 /* PlusToken */:
|
|
163526
163833
|
const otherOperandType = checker.getTypeAtLocation(parent2.left === node ? parent2.right : parent2.left);
|
|
163527
|
-
if (otherOperandType.flags &
|
|
163834
|
+
if (otherOperandType.flags & 98304 /* EnumLike */) {
|
|
163528
163835
|
addCandidateType(usage, otherOperandType);
|
|
163529
|
-
} else if (otherOperandType.flags &
|
|
163836
|
+
} else if (otherOperandType.flags & 67648 /* NumberLike */) {
|
|
163530
163837
|
usage.isNumber = true;
|
|
163531
|
-
} else if (otherOperandType.flags &
|
|
163838
|
+
} else if (otherOperandType.flags & 402654240 /* StringLike */) {
|
|
163532
163839
|
usage.isString = true;
|
|
163533
163840
|
} else if (otherOperandType.flags & 1 /* Any */) {
|
|
163534
163841
|
} else {
|
|
@@ -163605,7 +163912,7 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163605
163912
|
const indexType = checker.getTypeAtLocation(parent2.argumentExpression);
|
|
163606
163913
|
const indexUsage = createEmptyUsage();
|
|
163607
163914
|
calculateUsageOfNode(parent2, indexUsage);
|
|
163608
|
-
if (indexType.flags &
|
|
163915
|
+
if (indexType.flags & 67648 /* NumberLike */) {
|
|
163609
163916
|
usage.numberIndex = indexUsage;
|
|
163610
163917
|
} else {
|
|
163611
163918
|
usage.stringIndex = indexUsage;
|
|
@@ -163643,11 +163950,11 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163643
163950
|
low: (t) => t === stringNumber
|
|
163644
163951
|
},
|
|
163645
163952
|
{
|
|
163646
|
-
high: (t) => !(t.flags & (1 /* Any */ |
|
|
163647
|
-
low: (t) => !!(t.flags & (1 /* Any */ |
|
|
163953
|
+
high: (t) => !(t.flags & (1 /* Any */ | 16 /* Void */)),
|
|
163954
|
+
low: (t) => !!(t.flags & (1 /* Any */ | 16 /* Void */))
|
|
163648
163955
|
},
|
|
163649
163956
|
{
|
|
163650
|
-
high: (t) => !(t.flags & (
|
|
163957
|
+
high: (t) => !(t.flags & (12 /* Nullable */ | 1 /* Any */ | 16 /* Void */)) && !(getObjectFlags(t) & 16 /* Anonymous */),
|
|
163651
163958
|
low: (t) => !!(getObjectFlags(t) & 16 /* Anonymous */)
|
|
163652
163959
|
}
|
|
163653
163960
|
];
|
|
@@ -165160,7 +165467,7 @@ function getInitializer(checker, propertyDeclaration) {
|
|
|
165160
165467
|
return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type));
|
|
165161
165468
|
}
|
|
165162
165469
|
function getDefaultValueFromType(checker, type) {
|
|
165163
|
-
if (type.flags &
|
|
165470
|
+
if (type.flags & 4096 /* BooleanLiteral */) {
|
|
165164
165471
|
return type === checker.getFalseType() || type === checker.getFalseType(
|
|
165165
165472
|
/*fresh*/
|
|
165166
165473
|
true
|
|
@@ -165169,7 +165476,7 @@ function getDefaultValueFromType(checker, type) {
|
|
|
165169
165476
|
return factory.createStringLiteral(type.value);
|
|
165170
165477
|
} else if (type.isNumberLiteral()) {
|
|
165171
165478
|
return factory.createNumericLiteral(type.value);
|
|
165172
|
-
} else if (type.flags &
|
|
165479
|
+
} else if (type.flags & 8192 /* BigIntLiteral */) {
|
|
165173
165480
|
return factory.createBigIntLiteral(type.value);
|
|
165174
165481
|
} else if (type.isUnion()) {
|
|
165175
165482
|
return firstDefined(type.types, (t) => getDefaultValueFromType(checker, t));
|
|
@@ -166334,7 +166641,7 @@ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, i
|
|
|
166334
166641
|
} else {
|
|
166335
166642
|
if (initializer) {
|
|
166336
166643
|
const inferredType = checker.getTypeAtLocation(initializer.parent);
|
|
166337
|
-
if (!(inferredType.flags & (1 /* Any */ |
|
|
166644
|
+
if (!(inferredType.flags & (1 /* Any */ | 16 /* Void */))) {
|
|
166338
166645
|
const sourceFile = initializer.getSourceFile();
|
|
166339
166646
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
166340
166647
|
const builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */;
|
|
@@ -166566,7 +166873,7 @@ function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options,
|
|
|
166566
166873
|
const importAdder = ts_codefix_exports.createImportAdder(sourceFile, program, preferences, host);
|
|
166567
166874
|
const elements = [];
|
|
166568
166875
|
for (const type of switchType.types) {
|
|
166569
|
-
if (type.flags &
|
|
166876
|
+
if (type.flags & 32768 /* EnumLiteral */) {
|
|
166570
166877
|
Debug.assert(type.symbol, "An enum member type should have a symbol");
|
|
166571
166878
|
Debug.assert(type.symbol.parent, "An enum member type should have a parent symbol (the enum symbol)");
|
|
166572
166879
|
const enumValue = type.symbol.valueDeclaration && checker.getConstantValue(type.symbol.valueDeclaration);
|
|
@@ -166860,8 +167167,8 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
|
|
|
166860
167167
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none" && !(isJsxAttribute(location.parent) && location.parent.initializer)) {
|
|
166861
167168
|
let useBraces2 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
166862
167169
|
const type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
166863
|
-
if (preferences.jsxAttributeCompletionStyle === "auto" && !(type.flags &
|
|
166864
|
-
if (type.flags &
|
|
167170
|
+
if (preferences.jsxAttributeCompletionStyle === "auto" && !(type.flags & 4352 /* BooleanLike */) && !(type.flags & 1048576 /* Union */ && find(type.types, (type2) => !!(type2.flags & 4352 /* BooleanLike */)))) {
|
|
167171
|
+
if (type.flags & 402654240 /* StringLike */ || type.flags & 1048576 /* Union */ && every(type.types, (type2) => !!(type2.flags & (402654240 /* StringLike */ | 4 /* Undefined */) || isStringAndEmptyAnonymousObjectIntersection(type2)))) {
|
|
166865
167172
|
insertText = `${escapeSnippetText(name)}=${quote(sourceFile, preferences, "$1")}`;
|
|
166866
167173
|
isSnippet = true;
|
|
166867
167174
|
} else {
|
|
@@ -168118,7 +168425,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
168118
168425
|
const isLiteralExpected = !tryCast(previousToken, isStringLiteralLike) && !isJsxIdentifierExpected;
|
|
168119
168426
|
const literals = !isLiteralExpected ? [] : mapDefined(
|
|
168120
168427
|
contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]),
|
|
168121
|
-
(t) => t.isLiteral() && !(t.flags &
|
|
168428
|
+
(t) => t.isLiteral() && !(t.flags & 32768 /* EnumLiteral */) ? t.value : void 0
|
|
168122
168429
|
);
|
|
168123
168430
|
const recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker);
|
|
168124
168431
|
return {
|
|
@@ -170222,7 +170529,7 @@ function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, check
|
|
|
170222
170529
|
type = propType;
|
|
170223
170530
|
}
|
|
170224
170531
|
}
|
|
170225
|
-
isNewIdentifier = isNewIdentifier || !!(type.flags &
|
|
170532
|
+
isNewIdentifier = isNewIdentifier || !!(type.flags & 32 /* String */);
|
|
170226
170533
|
return getStringLiteralTypes(type, uniques);
|
|
170227
170534
|
});
|
|
170228
170535
|
return length(types) ? { kind: 2 /* Types */, types, isNewIdentifier } : void 0;
|
|
@@ -170253,7 +170560,7 @@ function stringLiteralCompletionsForObjectLiteral(checker, objectLiteralExpressi
|
|
|
170253
170560
|
function getStringLiteralTypes(type, uniques = /* @__PURE__ */ new Set()) {
|
|
170254
170561
|
if (!type) return emptyArray;
|
|
170255
170562
|
type = skipConstraint(type);
|
|
170256
|
-
return type.isUnion() ? flatMap(type.types, (t) => getStringLiteralTypes(t, uniques)) : type.isStringLiteral() && !(type.flags &
|
|
170563
|
+
return type.isUnion() ? flatMap(type.types, (t) => getStringLiteralTypes(t, uniques)) : type.isStringLiteral() && !(type.flags & 32768 /* EnumLiteral */) && addToSeen(uniques, type.value) ? [type] : emptyArray;
|
|
170257
170564
|
}
|
|
170258
170565
|
function nameAndKind(name, kind, extension) {
|
|
170259
170566
|
return { name, kind, extension };
|
|
@@ -173696,7 +174003,7 @@ function getTypeDefinitionAtPosition(typeChecker, sourceFile, position) {
|
|
|
173696
174003
|
return typeDefinitions.length ? [...getFirstTypeArgumentDefinitions(typeChecker, resolvedType, node, failedAliasResolution), ...typeDefinitions] : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, skipAlias(symbol, typeChecker), node, failedAliasResolution) : void 0;
|
|
173697
174004
|
}
|
|
173698
174005
|
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
173699
|
-
return flatMap(type.isUnion() && !(type.flags &
|
|
174006
|
+
return flatMap(type.isUnion() && !(type.flags & 65536 /* Enum */) ? type.types : [type], (t) => t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution));
|
|
173700
174007
|
}
|
|
173701
174008
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
173702
174009
|
if (type.symbol === symbol || // At `const f = () => {}`, the symbol is `f` and the type symbol is at `() => {}`
|
|
@@ -176400,7 +176707,7 @@ function getRenameInfoForNode(node, typeChecker, sourceFile, program, preference
|
|
|
176400
176707
|
if (!symbol) {
|
|
176401
176708
|
if (isStringLiteralLike(node)) {
|
|
176402
176709
|
const type = getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker);
|
|
176403
|
-
if (type && (type.flags &
|
|
176710
|
+
if (type && (type.flags & 1024 /* StringLiteral */ || type.flags & 1048576 /* Union */ && every(type.types, (type2) => !!(type2.flags & 1024 /* StringLiteral */)))) {
|
|
176404
176711
|
return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile);
|
|
176405
176712
|
}
|
|
176406
176713
|
} else if (isLabelName(node)) {
|
|
@@ -182435,6 +182742,7 @@ __export(ts_exports2, {
|
|
|
182435
182742
|
commonOptionsWithBuild: () => commonOptionsWithBuild,
|
|
182436
182743
|
compact: () => compact,
|
|
182437
182744
|
compareBooleans: () => compareBooleans,
|
|
182745
|
+
compareComparableValues: () => compareComparableValues,
|
|
182438
182746
|
compareDataObjects: () => compareDataObjects,
|
|
182439
182747
|
compareDiagnostics: () => compareDiagnostics,
|
|
182440
182748
|
compareEmitHelpers: () => compareEmitHelpers,
|
|
@@ -197188,6 +197496,7 @@ if (typeof console !== "undefined") {
|
|
|
197188
197496
|
commonOptionsWithBuild,
|
|
197189
197497
|
compact,
|
|
197190
197498
|
compareBooleans,
|
|
197499
|
+
compareComparableValues,
|
|
197191
197500
|
compareDataObjects,
|
|
197192
197501
|
compareDiagnostics,
|
|
197193
197502
|
compareEmitHelpers,
|