@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/_tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.9";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20250311`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -635,7 +635,7 @@ function binarySearchKey(array, key, keySelector, keyComparer, offset) {
|
|
|
635
635
|
while (low <= high) {
|
|
636
636
|
const middle = low + (high - low >> 1);
|
|
637
637
|
const midKey = keySelector(array[middle], middle);
|
|
638
|
-
switch (keyComparer(midKey, key)) {
|
|
638
|
+
switch (Math.sign(keyComparer(midKey, key))) {
|
|
639
639
|
case -1 /* LessThan */:
|
|
640
640
|
low = middle + 1;
|
|
641
641
|
break;
|
|
@@ -1735,8 +1735,8 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
1735
1735
|
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
|
|
1736
1736
|
__tsDebuggerDisplay: {
|
|
1737
1737
|
value() {
|
|
1738
|
-
const typeHeader = this.flags &
|
|
1739
|
-
const remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~
|
|
1738
|
+
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";
|
|
1739
|
+
const remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~142607679 /* ObjectTypeKindMask */ : 0;
|
|
1740
1740
|
return `${typeHeader}${this.symbol ? ` '${symbolName(this.symbol)}'` : ""}${remainingObjectFlags ? ` (${formatObjectFlags(remainingObjectFlags)})` : ""}`;
|
|
1741
1741
|
}
|
|
1742
1742
|
},
|
|
@@ -2819,7 +2819,7 @@ var tracingEnabled;
|
|
|
2819
2819
|
const objectFlags = type.objectFlags;
|
|
2820
2820
|
const symbol = type.aliasSymbol ?? type.symbol;
|
|
2821
2821
|
let display;
|
|
2822
|
-
if (objectFlags & 16 /* Anonymous */ | type.flags &
|
|
2822
|
+
if (objectFlags & 16 /* Anonymous */ | type.flags & 15360 /* Literal */) {
|
|
2823
2823
|
try {
|
|
2824
2824
|
display = (_a = type.checker) == null ? void 0 : _a.typeToString(type);
|
|
2825
2825
|
} catch {
|
|
@@ -3570,21 +3570,21 @@ var NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags3) => {
|
|
|
3570
3570
|
var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
3571
3571
|
TypeFlags2[TypeFlags2["Any"] = 1] = "Any";
|
|
3572
3572
|
TypeFlags2[TypeFlags2["Unknown"] = 2] = "Unknown";
|
|
3573
|
-
TypeFlags2[TypeFlags2["
|
|
3574
|
-
TypeFlags2[TypeFlags2["
|
|
3575
|
-
TypeFlags2[TypeFlags2["
|
|
3576
|
-
TypeFlags2[TypeFlags2["
|
|
3577
|
-
TypeFlags2[TypeFlags2["
|
|
3578
|
-
TypeFlags2[TypeFlags2["
|
|
3579
|
-
TypeFlags2[TypeFlags2["
|
|
3580
|
-
TypeFlags2[TypeFlags2["
|
|
3581
|
-
TypeFlags2[TypeFlags2["
|
|
3582
|
-
TypeFlags2[TypeFlags2["
|
|
3583
|
-
TypeFlags2[TypeFlags2["
|
|
3584
|
-
TypeFlags2[TypeFlags2["
|
|
3585
|
-
TypeFlags2[TypeFlags2["
|
|
3586
|
-
TypeFlags2[TypeFlags2["
|
|
3587
|
-
TypeFlags2[TypeFlags2["
|
|
3573
|
+
TypeFlags2[TypeFlags2["Undefined"] = 4] = "Undefined";
|
|
3574
|
+
TypeFlags2[TypeFlags2["Null"] = 8] = "Null";
|
|
3575
|
+
TypeFlags2[TypeFlags2["Void"] = 16] = "Void";
|
|
3576
|
+
TypeFlags2[TypeFlags2["String"] = 32] = "String";
|
|
3577
|
+
TypeFlags2[TypeFlags2["Number"] = 64] = "Number";
|
|
3578
|
+
TypeFlags2[TypeFlags2["BigInt"] = 128] = "BigInt";
|
|
3579
|
+
TypeFlags2[TypeFlags2["Boolean"] = 256] = "Boolean";
|
|
3580
|
+
TypeFlags2[TypeFlags2["ESSymbol"] = 512] = "ESSymbol";
|
|
3581
|
+
TypeFlags2[TypeFlags2["StringLiteral"] = 1024] = "StringLiteral";
|
|
3582
|
+
TypeFlags2[TypeFlags2["NumberLiteral"] = 2048] = "NumberLiteral";
|
|
3583
|
+
TypeFlags2[TypeFlags2["BooleanLiteral"] = 4096] = "BooleanLiteral";
|
|
3584
|
+
TypeFlags2[TypeFlags2["BigIntLiteral"] = 8192] = "BigIntLiteral";
|
|
3585
|
+
TypeFlags2[TypeFlags2["UniqueESSymbol"] = 16384] = "UniqueESSymbol";
|
|
3586
|
+
TypeFlags2[TypeFlags2["EnumLiteral"] = 32768] = "EnumLiteral";
|
|
3587
|
+
TypeFlags2[TypeFlags2["Enum"] = 65536] = "Enum";
|
|
3588
3588
|
TypeFlags2[TypeFlags2["Never"] = 131072] = "Never";
|
|
3589
3589
|
TypeFlags2[TypeFlags2["TypeParameter"] = 262144] = "TypeParameter";
|
|
3590
3590
|
TypeFlags2[TypeFlags2["Object"] = 524288] = "Object";
|
|
@@ -3600,25 +3600,25 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
3600
3600
|
TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1";
|
|
3601
3601
|
TypeFlags2[TypeFlags2["Reserved2"] = 1073741824] = "Reserved2";
|
|
3602
3602
|
TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown";
|
|
3603
|
-
TypeFlags2[TypeFlags2["Nullable"] =
|
|
3604
|
-
TypeFlags2[TypeFlags2["Literal"] =
|
|
3605
|
-
TypeFlags2[TypeFlags2["Unit"] =
|
|
3606
|
-
TypeFlags2[TypeFlags2["Freshable"] =
|
|
3607
|
-
TypeFlags2[TypeFlags2["StringOrNumberLiteral"] =
|
|
3608
|
-
TypeFlags2[TypeFlags2["StringOrNumberLiteralOrUnique"] =
|
|
3609
|
-
TypeFlags2[TypeFlags2["DefinitelyFalsy"] =
|
|
3610
|
-
TypeFlags2[TypeFlags2["PossiblyFalsy"] =
|
|
3611
|
-
TypeFlags2[TypeFlags2["Intrinsic"] =
|
|
3612
|
-
TypeFlags2[TypeFlags2["StringLike"] =
|
|
3613
|
-
TypeFlags2[TypeFlags2["NumberLike"] =
|
|
3614
|
-
TypeFlags2[TypeFlags2["BigIntLike"] =
|
|
3615
|
-
TypeFlags2[TypeFlags2["BooleanLike"] =
|
|
3616
|
-
TypeFlags2[TypeFlags2["EnumLike"] =
|
|
3617
|
-
TypeFlags2[TypeFlags2["ESSymbolLike"] =
|
|
3618
|
-
TypeFlags2[TypeFlags2["VoidLike"] =
|
|
3603
|
+
TypeFlags2[TypeFlags2["Nullable"] = 12] = "Nullable";
|
|
3604
|
+
TypeFlags2[TypeFlags2["Literal"] = 15360] = "Literal";
|
|
3605
|
+
TypeFlags2[TypeFlags2["Unit"] = 97292] = "Unit";
|
|
3606
|
+
TypeFlags2[TypeFlags2["Freshable"] = 80896] = "Freshable";
|
|
3607
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteral"] = 3072] = "StringOrNumberLiteral";
|
|
3608
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteralOrUnique"] = 19456] = "StringOrNumberLiteralOrUnique";
|
|
3609
|
+
TypeFlags2[TypeFlags2["DefinitelyFalsy"] = 15388] = "DefinitelyFalsy";
|
|
3610
|
+
TypeFlags2[TypeFlags2["PossiblyFalsy"] = 15868] = "PossiblyFalsy";
|
|
3611
|
+
TypeFlags2[TypeFlags2["Intrinsic"] = 67245055] = "Intrinsic";
|
|
3612
|
+
TypeFlags2[TypeFlags2["StringLike"] = 402654240] = "StringLike";
|
|
3613
|
+
TypeFlags2[TypeFlags2["NumberLike"] = 67648] = "NumberLike";
|
|
3614
|
+
TypeFlags2[TypeFlags2["BigIntLike"] = 8320] = "BigIntLike";
|
|
3615
|
+
TypeFlags2[TypeFlags2["BooleanLike"] = 4352] = "BooleanLike";
|
|
3616
|
+
TypeFlags2[TypeFlags2["EnumLike"] = 98304] = "EnumLike";
|
|
3617
|
+
TypeFlags2[TypeFlags2["ESSymbolLike"] = 16896] = "ESSymbolLike";
|
|
3618
|
+
TypeFlags2[TypeFlags2["VoidLike"] = 20] = "VoidLike";
|
|
3619
3619
|
TypeFlags2[TypeFlags2["Primitive"] = 402784252] = "Primitive";
|
|
3620
|
-
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] =
|
|
3621
|
-
TypeFlags2[TypeFlags2["DisjointDomains"] =
|
|
3620
|
+
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] = 470417376] = "DefinitelyNonNullable";
|
|
3621
|
+
TypeFlags2[TypeFlags2["DisjointDomains"] = 469860348] = "DisjointDomains";
|
|
3622
3622
|
TypeFlags2[TypeFlags2["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
3623
3623
|
TypeFlags2[TypeFlags2["StructuredType"] = 3670016] = "StructuredType";
|
|
3624
3624
|
TypeFlags2[TypeFlags2["TypeVariable"] = 8650752] = "TypeVariable";
|
|
@@ -3626,10 +3626,10 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
3626
3626
|
TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
|
|
3627
3627
|
TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
|
|
3628
3628
|
TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
|
|
3629
|
-
TypeFlags2[TypeFlags2["ObjectFlagsType"] =
|
|
3629
|
+
TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3801101] = "ObjectFlagsType";
|
|
3630
3630
|
TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
|
|
3631
|
-
TypeFlags2[TypeFlags2["Singleton"] =
|
|
3632
|
-
TypeFlags2[TypeFlags2["Narrowable"] =
|
|
3631
|
+
TypeFlags2[TypeFlags2["Singleton"] = 67240959] = "Singleton";
|
|
3632
|
+
TypeFlags2[TypeFlags2["Narrowable"] = 536707043] = "Narrowable";
|
|
3633
3633
|
TypeFlags2[TypeFlags2["IncludesMask"] = 473694207] = "IncludesMask";
|
|
3634
3634
|
TypeFlags2[TypeFlags2["IncludesMissingType"] = 262144 /* TypeParameter */] = "IncludesMissingType";
|
|
3635
3635
|
TypeFlags2[TypeFlags2["IncludesNonWideningType"] = 4194304 /* Index */] = "IncludesNonWideningType";
|
|
@@ -3638,7 +3638,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
3638
3638
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
3639
3639
|
TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable";
|
|
3640
3640
|
TypeFlags2[TypeFlags2["IncludesError"] = 1073741824 /* Reserved2 */] = "IncludesError";
|
|
3641
|
-
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] =
|
|
3641
|
+
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36306963] = "NotPrimitiveUnion";
|
|
3642
3642
|
return TypeFlags2;
|
|
3643
3643
|
})(TypeFlags || {});
|
|
3644
3644
|
var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
@@ -3668,11 +3668,11 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
3668
3668
|
ObjectFlags3[ObjectFlags3["RequiresWidening"] = 196608] = "RequiresWidening";
|
|
3669
3669
|
ObjectFlags3[ObjectFlags3["PropagatingFlags"] = 458752] = "PropagatingFlags";
|
|
3670
3670
|
ObjectFlags3[ObjectFlags3["InstantiatedMapped"] = 96] = "InstantiatedMapped";
|
|
3671
|
-
ObjectFlags3[ObjectFlags3["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask";
|
|
3672
3671
|
ObjectFlags3[ObjectFlags3["ContainsSpread"] = 2097152] = "ContainsSpread";
|
|
3673
3672
|
ObjectFlags3[ObjectFlags3["ObjectRestType"] = 4194304] = "ObjectRestType";
|
|
3674
3673
|
ObjectFlags3[ObjectFlags3["InstantiationExpressionType"] = 8388608] = "InstantiationExpressionType";
|
|
3675
3674
|
ObjectFlags3[ObjectFlags3["SingleSignatureType"] = 134217728] = "SingleSignatureType";
|
|
3675
|
+
ObjectFlags3[ObjectFlags3["ObjectTypeKindMask"] = 142607679] = "ObjectTypeKindMask";
|
|
3676
3676
|
ObjectFlags3[ObjectFlags3["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone";
|
|
3677
3677
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated";
|
|
3678
3678
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists";
|
|
@@ -6937,7 +6937,6 @@ var Diagnostics = {
|
|
|
6937
6937
|
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."),
|
|
6938
6938
|
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."),
|
|
6939
6939
|
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."),
|
|
6940
|
-
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."),
|
|
6941
6940
|
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."),
|
|
6942
6941
|
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."),
|
|
6943
6942
|
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}'."),
|
|
@@ -17457,7 +17456,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
|
|
|
17457
17456
|
return (_a = symbol.declarations) == null ? void 0 : _a.find(isClassLike);
|
|
17458
17457
|
}
|
|
17459
17458
|
function getObjectFlags(type) {
|
|
17460
|
-
return type.flags &
|
|
17459
|
+
return type.flags & 3801101 /* ObjectFlagsType */ ? type.objectFlags : 0;
|
|
17461
17460
|
}
|
|
17462
17461
|
function isUMDExportSymbol(symbol) {
|
|
17463
17462
|
return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
|
|
@@ -19249,13 +19248,13 @@ function intrinsicTagNameToString(node) {
|
|
|
19249
19248
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
19250
19249
|
}
|
|
19251
19250
|
function isTypeUsableAsPropertyName(type) {
|
|
19252
|
-
return !!(type.flags &
|
|
19251
|
+
return !!(type.flags & 19456 /* StringOrNumberLiteralOrUnique */);
|
|
19253
19252
|
}
|
|
19254
19253
|
function getPropertyNameFromType(type) {
|
|
19255
|
-
if (type.flags &
|
|
19254
|
+
if (type.flags & 16384 /* UniqueESSymbol */) {
|
|
19256
19255
|
return type.escapedName;
|
|
19257
19256
|
}
|
|
19258
|
-
if (type.flags & (
|
|
19257
|
+
if (type.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */)) {
|
|
19259
19258
|
return escapeLeadingUnderscores("" + type.value);
|
|
19260
19259
|
}
|
|
19261
19260
|
return Debug.fail();
|
|
@@ -46164,6 +46163,7 @@ function createTypeChecker(host) {
|
|
|
46164
46163
|
};
|
|
46165
46164
|
var cancellationToken;
|
|
46166
46165
|
var scanner;
|
|
46166
|
+
var fileIndexMap = new Map(host.getSourceFiles().map((file, i) => [file, i]));
|
|
46167
46167
|
var Symbol13 = objectAllocator.getSymbolConstructor();
|
|
46168
46168
|
var Type7 = objectAllocator.getTypeConstructor();
|
|
46169
46169
|
var Signature5 = objectAllocator.getSignatureConstructor();
|
|
@@ -46745,10 +46745,10 @@ function createTypeChecker(host) {
|
|
|
46745
46745
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */, "non-inferrable");
|
|
46746
46746
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
46747
46747
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
46748
|
-
var undefinedType = createIntrinsicType(
|
|
46749
|
-
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(
|
|
46748
|
+
var undefinedType = createIntrinsicType(4 /* Undefined */, "undefined");
|
|
46749
|
+
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(4 /* Undefined */, "undefined", 65536 /* ContainsWideningType */, "widening");
|
|
46750
46750
|
var missingType = createIntrinsicType(
|
|
46751
|
-
|
|
46751
|
+
4 /* Undefined */,
|
|
46752
46752
|
"undefined",
|
|
46753
46753
|
/*objectFlags*/
|
|
46754
46754
|
void 0,
|
|
@@ -46756,33 +46756,33 @@ function createTypeChecker(host) {
|
|
|
46756
46756
|
);
|
|
46757
46757
|
var undefinedOrMissingType = exactOptionalPropertyTypes ? missingType : undefinedType;
|
|
46758
46758
|
var optionalType = createIntrinsicType(
|
|
46759
|
-
|
|
46759
|
+
4 /* Undefined */,
|
|
46760
46760
|
"undefined",
|
|
46761
46761
|
/*objectFlags*/
|
|
46762
46762
|
void 0,
|
|
46763
46763
|
"optional"
|
|
46764
46764
|
);
|
|
46765
|
-
var nullType = createIntrinsicType(
|
|
46766
|
-
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(
|
|
46767
|
-
var stringType = createIntrinsicType(
|
|
46768
|
-
var numberType = createIntrinsicType(
|
|
46769
|
-
var bigintType = createIntrinsicType(
|
|
46765
|
+
var nullType = createIntrinsicType(8 /* Null */, "null");
|
|
46766
|
+
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(8 /* Null */, "null", 65536 /* ContainsWideningType */, "widening");
|
|
46767
|
+
var stringType = createIntrinsicType(32 /* String */, "string");
|
|
46768
|
+
var numberType = createIntrinsicType(64 /* Number */, "number");
|
|
46769
|
+
var bigintType = createIntrinsicType(128 /* BigInt */, "bigint");
|
|
46770
46770
|
var falseType = createIntrinsicType(
|
|
46771
|
-
|
|
46771
|
+
4096 /* BooleanLiteral */,
|
|
46772
46772
|
"false",
|
|
46773
46773
|
/*objectFlags*/
|
|
46774
46774
|
void 0,
|
|
46775
46775
|
"fresh"
|
|
46776
46776
|
);
|
|
46777
|
-
var regularFalseType = createIntrinsicType(
|
|
46777
|
+
var regularFalseType = createIntrinsicType(4096 /* BooleanLiteral */, "false");
|
|
46778
46778
|
var trueType = createIntrinsicType(
|
|
46779
|
-
|
|
46779
|
+
4096 /* BooleanLiteral */,
|
|
46780
46780
|
"true",
|
|
46781
46781
|
/*objectFlags*/
|
|
46782
46782
|
void 0,
|
|
46783
46783
|
"fresh"
|
|
46784
46784
|
);
|
|
46785
|
-
var regularTrueType = createIntrinsicType(
|
|
46785
|
+
var regularTrueType = createIntrinsicType(4096 /* BooleanLiteral */, "true");
|
|
46786
46786
|
trueType.regularType = regularTrueType;
|
|
46787
46787
|
trueType.freshType = trueType;
|
|
46788
46788
|
regularTrueType.regularType = regularTrueType;
|
|
@@ -46792,8 +46792,8 @@ function createTypeChecker(host) {
|
|
|
46792
46792
|
regularFalseType.regularType = regularFalseType;
|
|
46793
46793
|
regularFalseType.freshType = falseType;
|
|
46794
46794
|
var booleanType = getUnionType([regularFalseType, regularTrueType]);
|
|
46795
|
-
var esSymbolType = createIntrinsicType(
|
|
46796
|
-
var voidType = createIntrinsicType(
|
|
46795
|
+
var esSymbolType = createIntrinsicType(512 /* ESSymbol */, "symbol");
|
|
46796
|
+
var voidType = createIntrinsicType(16 /* Void */, "void");
|
|
46797
46797
|
var neverType = createIntrinsicType(131072 /* Never */, "never");
|
|
46798
46798
|
var silentNeverType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */, "silent");
|
|
46799
46799
|
var implicitNeverType = createIntrinsicType(
|
|
@@ -48080,7 +48080,7 @@ function createTypeChecker(host) {
|
|
|
48080
48080
|
const type = getDeclaredTypeOfSymbol(symbol);
|
|
48081
48081
|
return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(
|
|
48082
48082
|
type,
|
|
48083
|
-
|
|
48083
|
+
3072 /* StringOrNumberLiteral */,
|
|
48084
48084
|
/*strict*/
|
|
48085
48085
|
true
|
|
48086
48086
|
);
|
|
@@ -49787,7 +49787,7 @@ function createTypeChecker(host) {
|
|
|
49787
49787
|
return type;
|
|
49788
49788
|
}
|
|
49789
49789
|
function createTypeofType() {
|
|
49790
|
-
return getUnionType(
|
|
49790
|
+
return getUnionType(map([...typeofNEFacts.keys()].sort(), getStringLiteralType));
|
|
49791
49791
|
}
|
|
49792
49792
|
function createTypeParameter(symbol) {
|
|
49793
49793
|
return createTypeWithSymbol(262144 /* TypeParameter */, symbol);
|
|
@@ -50608,7 +50608,7 @@ function createTypeChecker(host) {
|
|
|
50608
50608
|
if (name && isComputedPropertyName(name)) return name;
|
|
50609
50609
|
}
|
|
50610
50610
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
50611
|
-
if (nameType && nameType.flags & (
|
|
50611
|
+
if (nameType && nameType.flags & (32768 /* EnumLiteral */ | 16384 /* UniqueESSymbol */)) {
|
|
50612
50612
|
context.enclosingDeclaration = nameType.symbol.valueDeclaration;
|
|
50613
50613
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, meaning));
|
|
50614
50614
|
}
|
|
@@ -50716,23 +50716,23 @@ function createTypeChecker(host) {
|
|
|
50716
50716
|
if (type.flags & 2 /* Unknown */) {
|
|
50717
50717
|
return factory.createKeywordTypeNode(159 /* UnknownKeyword */);
|
|
50718
50718
|
}
|
|
50719
|
-
if (type.flags &
|
|
50719
|
+
if (type.flags & 32 /* String */) {
|
|
50720
50720
|
context.approximateLength += 6;
|
|
50721
50721
|
return factory.createKeywordTypeNode(154 /* StringKeyword */);
|
|
50722
50722
|
}
|
|
50723
|
-
if (type.flags &
|
|
50723
|
+
if (type.flags & 64 /* Number */) {
|
|
50724
50724
|
context.approximateLength += 6;
|
|
50725
50725
|
return factory.createKeywordTypeNode(150 /* NumberKeyword */);
|
|
50726
50726
|
}
|
|
50727
|
-
if (type.flags &
|
|
50727
|
+
if (type.flags & 128 /* BigInt */) {
|
|
50728
50728
|
context.approximateLength += 6;
|
|
50729
50729
|
return factory.createKeywordTypeNode(163 /* BigIntKeyword */);
|
|
50730
50730
|
}
|
|
50731
|
-
if (type.flags &
|
|
50731
|
+
if (type.flags & 256 /* Boolean */ && !type.aliasSymbol) {
|
|
50732
50732
|
context.approximateLength += 7;
|
|
50733
50733
|
return factory.createKeywordTypeNode(136 /* BooleanKeyword */);
|
|
50734
50734
|
}
|
|
50735
|
-
if (type.flags &
|
|
50735
|
+
if (type.flags & 98304 /* EnumLike */) {
|
|
50736
50736
|
if (type.symbol.flags & 8 /* EnumMember */) {
|
|
50737
50737
|
const parentSymbol = getParentOfSymbol(type.symbol);
|
|
50738
50738
|
const parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */);
|
|
@@ -50761,24 +50761,24 @@ function createTypeChecker(host) {
|
|
|
50761
50761
|
}
|
|
50762
50762
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
50763
50763
|
}
|
|
50764
|
-
if (type.flags &
|
|
50764
|
+
if (type.flags & 1024 /* StringLiteral */) {
|
|
50765
50765
|
context.approximateLength += type.value.length + 2;
|
|
50766
50766
|
return factory.createLiteralTypeNode(setEmitFlags(factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */));
|
|
50767
50767
|
}
|
|
50768
|
-
if (type.flags &
|
|
50768
|
+
if (type.flags & 2048 /* NumberLiteral */) {
|
|
50769
50769
|
const value = type.value;
|
|
50770
50770
|
context.approximateLength += ("" + value).length;
|
|
50771
50771
|
return factory.createLiteralTypeNode(value < 0 ? factory.createPrefixUnaryExpression(41 /* MinusToken */, factory.createNumericLiteral(-value)) : factory.createNumericLiteral(value));
|
|
50772
50772
|
}
|
|
50773
|
-
if (type.flags &
|
|
50773
|
+
if (type.flags & 8192 /* BigIntLiteral */) {
|
|
50774
50774
|
context.approximateLength += pseudoBigIntToString(type.value).length + 1;
|
|
50775
50775
|
return factory.createLiteralTypeNode(factory.createBigIntLiteral(type.value));
|
|
50776
50776
|
}
|
|
50777
|
-
if (type.flags &
|
|
50777
|
+
if (type.flags & 4096 /* BooleanLiteral */) {
|
|
50778
50778
|
context.approximateLength += type.intrinsicName.length;
|
|
50779
50779
|
return factory.createLiteralTypeNode(type.intrinsicName === "true" ? factory.createTrue() : factory.createFalse());
|
|
50780
50780
|
}
|
|
50781
|
-
if (type.flags &
|
|
50781
|
+
if (type.flags & 16384 /* UniqueESSymbol */) {
|
|
50782
50782
|
if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) {
|
|
50783
50783
|
if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
|
|
50784
50784
|
context.approximateLength += 6;
|
|
@@ -50791,15 +50791,15 @@ function createTypeChecker(host) {
|
|
|
50791
50791
|
context.approximateLength += 13;
|
|
50792
50792
|
return factory.createTypeOperatorNode(158 /* UniqueKeyword */, factory.createKeywordTypeNode(155 /* SymbolKeyword */));
|
|
50793
50793
|
}
|
|
50794
|
-
if (type.flags &
|
|
50794
|
+
if (type.flags & 16 /* Void */) {
|
|
50795
50795
|
context.approximateLength += 4;
|
|
50796
50796
|
return factory.createKeywordTypeNode(116 /* VoidKeyword */);
|
|
50797
50797
|
}
|
|
50798
|
-
if (type.flags &
|
|
50798
|
+
if (type.flags & 4 /* Undefined */) {
|
|
50799
50799
|
context.approximateLength += 9;
|
|
50800
50800
|
return factory.createKeywordTypeNode(157 /* UndefinedKeyword */);
|
|
50801
50801
|
}
|
|
50802
|
-
if (type.flags &
|
|
50802
|
+
if (type.flags & 8 /* Null */) {
|
|
50803
50803
|
context.approximateLength += 4;
|
|
50804
50804
|
return factory.createLiteralTypeNode(factory.createNull());
|
|
50805
50805
|
}
|
|
@@ -50807,7 +50807,7 @@ function createTypeChecker(host) {
|
|
|
50807
50807
|
context.approximateLength += 5;
|
|
50808
50808
|
return factory.createKeywordTypeNode(146 /* NeverKeyword */);
|
|
50809
50809
|
}
|
|
50810
|
-
if (type.flags &
|
|
50810
|
+
if (type.flags & 512 /* ESSymbol */) {
|
|
50811
50811
|
context.approximateLength += 6;
|
|
50812
50812
|
return factory.createKeywordTypeNode(155 /* SymbolKeyword */);
|
|
50813
50813
|
}
|
|
@@ -51596,7 +51596,7 @@ function createTypeChecker(host) {
|
|
|
51596
51596
|
}
|
|
51597
51597
|
const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
51598
51598
|
if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
|
|
51599
|
-
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags &
|
|
51599
|
+
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 4 /* Undefined */)), 0 /* Call */);
|
|
51600
51600
|
for (const signature of signatures) {
|
|
51601
51601
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 173 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
51602
51602
|
typeElements.push(preserveCommentsOn(methodDeclaration, signature.declaration || propertySymbol.valueDeclaration));
|
|
@@ -52636,11 +52636,11 @@ function createTypeChecker(host) {
|
|
|
52636
52636
|
}
|
|
52637
52637
|
if (isComputedPropertyName(name)) {
|
|
52638
52638
|
const type = checkExpression(name.expression);
|
|
52639
|
-
return !!(type.flags &
|
|
52639
|
+
return !!(type.flags & 402654240 /* StringLike */);
|
|
52640
52640
|
}
|
|
52641
52641
|
if (isElementAccessExpression(name)) {
|
|
52642
52642
|
const type = checkExpression(name.argumentExpression);
|
|
52643
|
-
return !!(type.flags &
|
|
52643
|
+
return !!(type.flags & 402654240 /* StringLike */);
|
|
52644
52644
|
}
|
|
52645
52645
|
return isStringLiteral(name);
|
|
52646
52646
|
}
|
|
@@ -52666,7 +52666,7 @@ function createTypeChecker(host) {
|
|
|
52666
52666
|
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote, stringNamed, isMethod) {
|
|
52667
52667
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
52668
52668
|
if (nameType) {
|
|
52669
|
-
if (nameType.flags &
|
|
52669
|
+
if (nameType.flags & 3072 /* StringOrNumberLiteral */) {
|
|
52670
52670
|
const name = "" + nameType.value;
|
|
52671
52671
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && (stringNamed || !isNumericLiteralName(name))) {
|
|
52672
52672
|
return factory.createStringLiteral(name, !!singleQuote);
|
|
@@ -52676,7 +52676,7 @@ function createTypeChecker(host) {
|
|
|
52676
52676
|
}
|
|
52677
52677
|
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
|
|
52678
52678
|
}
|
|
52679
|
-
if (nameType.flags &
|
|
52679
|
+
if (nameType.flags & 16384 /* UniqueESSymbol */) {
|
|
52680
52680
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
|
|
52681
52681
|
}
|
|
52682
52682
|
}
|
|
@@ -52718,7 +52718,7 @@ function createTypeChecker(host) {
|
|
|
52718
52718
|
return enclosingDeclaration;
|
|
52719
52719
|
}
|
|
52720
52720
|
function serializeInferredTypeForDeclaration(symbol, context, type) {
|
|
52721
|
-
if (type.flags &
|
|
52721
|
+
if (type.flags & 16384 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === context.enclosingFile))) {
|
|
52722
52722
|
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
52723
52723
|
}
|
|
52724
52724
|
const result = typeToTypeNodeHelper(type, context);
|
|
@@ -52951,7 +52951,7 @@ function createTypeChecker(host) {
|
|
|
52951
52951
|
}
|
|
52952
52952
|
function serializeExistingTypeNode(context, typeNode, addUndefined) {
|
|
52953
52953
|
const type = getTypeFromTypeNode2(context, typeNode);
|
|
52954
|
-
if (addUndefined && !someType(type, (t) => !!(t.flags &
|
|
52954
|
+
if (addUndefined && !someType(type, (t) => !!(t.flags & 4 /* Undefined */)) && canReuseTypeNode(context, typeNode)) {
|
|
52955
52955
|
const clone = syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode);
|
|
52956
52956
|
if (clone) {
|
|
52957
52957
|
return factory.createUnionTypeNode([clone, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
@@ -54490,9 +54490,9 @@ function createTypeChecker(host) {
|
|
|
54490
54490
|
for (let i = 0; i < types.length; i++) {
|
|
54491
54491
|
const t = types[i];
|
|
54492
54492
|
flags |= t.flags;
|
|
54493
|
-
if (!(t.flags &
|
|
54494
|
-
if (t.flags & (
|
|
54495
|
-
const baseType = t.flags &
|
|
54493
|
+
if (!(t.flags & 12 /* Nullable */)) {
|
|
54494
|
+
if (t.flags & (4096 /* BooleanLiteral */ | 98304 /* EnumLike */)) {
|
|
54495
|
+
const baseType = t.flags & 4096 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLikeType(t);
|
|
54496
54496
|
if (baseType.flags & 1048576 /* Union */) {
|
|
54497
54497
|
const count = baseType.types.length;
|
|
54498
54498
|
if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
|
|
@@ -54505,8 +54505,8 @@ function createTypeChecker(host) {
|
|
|
54505
54505
|
result.push(t);
|
|
54506
54506
|
}
|
|
54507
54507
|
}
|
|
54508
|
-
if (flags &
|
|
54509
|
-
if (flags &
|
|
54508
|
+
if (flags & 8 /* Null */) result.push(nullType);
|
|
54509
|
+
if (flags & 4 /* Undefined */) result.push(undefinedType);
|
|
54510
54510
|
return result || types;
|
|
54511
54511
|
}
|
|
54512
54512
|
function visibilityToString(flags) {
|
|
@@ -54536,7 +54536,7 @@ function createTypeChecker(host) {
|
|
|
54536
54536
|
function getNameOfSymbolFromNameType(symbol, context) {
|
|
54537
54537
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
54538
54538
|
if (nameType) {
|
|
54539
|
-
if (nameType.flags &
|
|
54539
|
+
if (nameType.flags & 3072 /* StringOrNumberLiteral */) {
|
|
54540
54540
|
const name = "" + nameType.value;
|
|
54541
54541
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
54542
54542
|
return `"${escapeString(name, 34 /* doubleQuote */)}"`;
|
|
@@ -54546,7 +54546,7 @@ function createTypeChecker(host) {
|
|
|
54546
54546
|
}
|
|
54547
54547
|
return name;
|
|
54548
54548
|
}
|
|
54549
|
-
if (nameType.flags &
|
|
54549
|
+
if (nameType.flags & 16384 /* UniqueESSymbol */) {
|
|
54550
54550
|
return `[${getNameOfSymbolAsWritten(nameType.symbol, context)}]`;
|
|
54551
54551
|
}
|
|
54552
54552
|
}
|
|
@@ -54571,7 +54571,7 @@ function createTypeChecker(host) {
|
|
|
54571
54571
|
}
|
|
54572
54572
|
if (isComputedPropertyName(name2) && !(getCheckFlags(symbol) & 4096 /* Late */)) {
|
|
54573
54573
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
54574
|
-
if (nameType && nameType.flags &
|
|
54574
|
+
if (nameType && nameType.flags & 3072 /* StringOrNumberLiteral */) {
|
|
54575
54575
|
const result = getNameOfSymbolFromNameType(symbol, context);
|
|
54576
54576
|
if (result !== void 0) {
|
|
54577
54577
|
return result;
|
|
@@ -54852,7 +54852,7 @@ function createTypeChecker(host) {
|
|
|
54852
54852
|
);
|
|
54853
54853
|
}
|
|
54854
54854
|
function getRestType(source, properties, symbol) {
|
|
54855
|
-
source = filterType(source, (t) => !(t.flags &
|
|
54855
|
+
source = filterType(source, (t) => !(t.flags & 12 /* Nullable */));
|
|
54856
54856
|
if (source.flags & 131072 /* Never */) {
|
|
54857
54857
|
return emptyObjectType;
|
|
54858
54858
|
}
|
|
@@ -54863,7 +54863,7 @@ function createTypeChecker(host) {
|
|
|
54863
54863
|
const spreadableProperties = [];
|
|
54864
54864
|
const unspreadableToRestKeys = [];
|
|
54865
54865
|
for (const prop of getPropertiesOfType(source)) {
|
|
54866
|
-
const literalTypeFromProperty = getLiteralTypeFromProperty(prop,
|
|
54866
|
+
const literalTypeFromProperty = getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */);
|
|
54867
54867
|
if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) && isSpreadableProperty(prop)) {
|
|
54868
54868
|
spreadableProperties.push(prop);
|
|
54869
54869
|
} else {
|
|
@@ -54896,7 +54896,7 @@ function createTypeChecker(host) {
|
|
|
54896
54896
|
return result;
|
|
54897
54897
|
}
|
|
54898
54898
|
function isGenericTypeWithUndefinedConstraint(type) {
|
|
54899
|
-
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType,
|
|
54899
|
+
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 4 /* Undefined */);
|
|
54900
54900
|
}
|
|
54901
54901
|
function getNonUndefinedType(type) {
|
|
54902
54902
|
const typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, (t) => t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t) : type;
|
|
@@ -54950,7 +54950,7 @@ function createTypeChecker(host) {
|
|
|
54950
54950
|
}
|
|
54951
54951
|
function getLiteralPropertyNameText(name) {
|
|
54952
54952
|
const type = getLiteralTypeFromPropertyName(name);
|
|
54953
|
-
return type.flags & (
|
|
54953
|
+
return type.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
54954
54954
|
}
|
|
54955
54955
|
function getTypeForBindingElement(declaration) {
|
|
54956
54956
|
const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
@@ -55290,7 +55290,7 @@ function createTypeChecker(host) {
|
|
|
55290
55290
|
definedInConstructor = true;
|
|
55291
55291
|
}
|
|
55292
55292
|
}
|
|
55293
|
-
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~
|
|
55293
|
+
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~12 /* Nullable */)) ? constructorTypes : types;
|
|
55294
55294
|
type = getUnionType(sourceTypes);
|
|
55295
55295
|
}
|
|
55296
55296
|
}
|
|
@@ -55300,7 +55300,7 @@ function createTypeChecker(host) {
|
|
|
55300
55300
|
false,
|
|
55301
55301
|
definedInMethod && !definedInConstructor
|
|
55302
55302
|
));
|
|
55303
|
-
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~
|
|
55303
|
+
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~12 /* Nullable */)) === neverType) {
|
|
55304
55304
|
reportImplicitAny(symbol.valueDeclaration, anyType);
|
|
55305
55305
|
return anyType;
|
|
55306
55306
|
}
|
|
@@ -55598,13 +55598,13 @@ function createTypeChecker(host) {
|
|
|
55598
55598
|
}
|
|
55599
55599
|
function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors2) {
|
|
55600
55600
|
if (type) {
|
|
55601
|
-
if (type.flags &
|
|
55601
|
+
if (type.flags & 512 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) {
|
|
55602
55602
|
type = getESSymbolLikeTypeForNode(declaration);
|
|
55603
55603
|
}
|
|
55604
55604
|
if (reportErrors2) {
|
|
55605
55605
|
reportErrorsFromWidening(declaration, type);
|
|
55606
55606
|
}
|
|
55607
|
-
if (type.flags &
|
|
55607
|
+
if (type.flags & 16384 /* UniqueESSymbol */ && (isBindingElement(declaration) || !tryGetTypeFromEffectiveTypeNode(declaration)) && type.symbol !== getSymbolOfDeclaration(declaration)) {
|
|
55608
55608
|
type = esSymbolType;
|
|
55609
55609
|
}
|
|
55610
55610
|
return getWidenedType(type);
|
|
@@ -56441,7 +56441,7 @@ function createTypeChecker(host) {
|
|
|
56441
56441
|
return links.declaredType;
|
|
56442
56442
|
}
|
|
56443
56443
|
function getBaseTypeOfEnumLikeType(type) {
|
|
56444
|
-
return type.flags &
|
|
56444
|
+
return type.flags & 98304 /* EnumLike */ && type.symbol.flags & 8 /* EnumMember */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
|
|
56445
56445
|
}
|
|
56446
56446
|
function getDeclaredTypeOfEnum(symbol) {
|
|
56447
56447
|
const links = getSymbolLinks(symbol);
|
|
@@ -56472,7 +56472,7 @@ function createTypeChecker(host) {
|
|
|
56472
56472
|
void 0
|
|
56473
56473
|
) : createComputedEnumType(symbol);
|
|
56474
56474
|
if (enumType.flags & 1048576 /* Union */) {
|
|
56475
|
-
enumType.flags |=
|
|
56475
|
+
enumType.flags |= 32768 /* EnumLiteral */;
|
|
56476
56476
|
enumType.symbol = symbol;
|
|
56477
56477
|
}
|
|
56478
56478
|
links.declaredType = enumType;
|
|
@@ -56480,8 +56480,8 @@ function createTypeChecker(host) {
|
|
|
56480
56480
|
return links.declaredType;
|
|
56481
56481
|
}
|
|
56482
56482
|
function createComputedEnumType(symbol) {
|
|
56483
|
-
const regularType = createTypeWithSymbol(
|
|
56484
|
-
const freshType = createTypeWithSymbol(
|
|
56483
|
+
const regularType = createTypeWithSymbol(65536 /* Enum */, symbol);
|
|
56484
|
+
const freshType = createTypeWithSymbol(65536 /* Enum */, symbol);
|
|
56485
56485
|
regularType.regularType = regularType;
|
|
56486
56486
|
regularType.freshType = freshType;
|
|
56487
56487
|
freshType.regularType = regularType;
|
|
@@ -56683,7 +56683,7 @@ function createTypeChecker(host) {
|
|
|
56683
56683
|
const earlySymbol = earlySymbols && earlySymbols.get(memberName);
|
|
56684
56684
|
if (!(parent.flags & 32 /* Class */) && lateSymbol.flags & getExcludedSymbolFlags(symbolFlags)) {
|
|
56685
56685
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
56686
|
-
const name = !(type.flags &
|
|
56686
|
+
const name = !(type.flags & 16384 /* UniqueESSymbol */) && unescapeLeadingUnderscores(memberName) || declarationNameToString(declName);
|
|
56687
56687
|
forEach(declarations, (declaration) => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
56688
56688
|
error(declName || decl, Diagnostics.Duplicate_property_0, name);
|
|
56689
56689
|
lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
|
|
@@ -57378,7 +57378,7 @@ function createTypeChecker(host) {
|
|
|
57378
57378
|
if (baseConstructorIndexInfo) {
|
|
57379
57379
|
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
|
57380
57380
|
}
|
|
57381
|
-
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags &
|
|
57381
|
+
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 65536 /* Enum */ || some(type.properties, (prop) => !!(getTypeOfSymbol(prop).flags & 67648 /* NumberLike */)))) {
|
|
57382
57382
|
indexInfos = append(indexInfos, enumNumberIndexInfo);
|
|
57383
57383
|
}
|
|
57384
57384
|
}
|
|
@@ -57439,7 +57439,7 @@ function createTypeChecker(host) {
|
|
|
57439
57439
|
const limitedConstraint = getLimitedConstraint(type);
|
|
57440
57440
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
57441
57441
|
if (limitedConstraint) {
|
|
57442
|
-
const propertyNameType = getLiteralTypeFromProperty(prop,
|
|
57442
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */);
|
|
57443
57443
|
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
57444
57444
|
continue;
|
|
57445
57445
|
}
|
|
@@ -57492,7 +57492,7 @@ function createTypeChecker(host) {
|
|
|
57492
57492
|
}
|
|
57493
57493
|
if (type.flags & 2097152 /* Intersection */) {
|
|
57494
57494
|
const types = type.types;
|
|
57495
|
-
if (types.length === 2 && !!(types[0].flags & (
|
|
57495
|
+
if (types.length === 2 && !!(types[0].flags & (32 /* String */ | 64 /* Number */ | 128 /* BigInt */)) && types[1] === emptyTypeLiteralType) {
|
|
57496
57496
|
return type;
|
|
57497
57497
|
}
|
|
57498
57498
|
return getIntersectionType(sameMap(type.types, getLowerBoundOfKeyType));
|
|
@@ -57510,7 +57510,7 @@ function createTypeChecker(host) {
|
|
|
57510
57510
|
cb(stringType);
|
|
57511
57511
|
} else {
|
|
57512
57512
|
for (const info of getIndexInfosOfType(type)) {
|
|
57513
|
-
if (!stringsOnly || info.keyType.flags & (
|
|
57513
|
+
if (!stringsOnly || info.keyType.flags & (32 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
57514
57514
|
cb(info.keyType);
|
|
57515
57515
|
}
|
|
57516
57516
|
}
|
|
@@ -57528,7 +57528,7 @@ function createTypeChecker(host) {
|
|
|
57528
57528
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
57529
57529
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
57530
57530
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
57531
|
-
const include =
|
|
57531
|
+
const include = 19456 /* StringOrNumberLiteralOrUnique */;
|
|
57532
57532
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
57533
57533
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
57534
57534
|
modifiersType,
|
|
@@ -57568,8 +57568,8 @@ function createTypeChecker(host) {
|
|
|
57568
57568
|
}
|
|
57569
57569
|
members.set(propName, prop);
|
|
57570
57570
|
}
|
|
57571
|
-
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ |
|
|
57572
|
-
const indexKeyType = propNameType.flags & (1 /* Any */ |
|
|
57571
|
+
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 65536 /* Enum */)) {
|
|
57572
|
+
const indexKeyType = propNameType.flags & (1 /* Any */ | 32 /* String */) ? stringType : propNameType.flags & (64 /* Number */ | 65536 /* Enum */) ? numberType : propNameType;
|
|
57573
57573
|
const propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType));
|
|
57574
57574
|
const modifiersIndexInfo = getApplicableIndexInfo(modifiersType, propNameType);
|
|
57575
57575
|
const isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || !(templateModifiers & 2 /* ExcludeReadonly */) && (modifiersIndexInfo == null ? void 0 : modifiersIndexInfo.isReadonly));
|
|
@@ -57594,7 +57594,7 @@ function createTypeChecker(host) {
|
|
|
57594
57594
|
const templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType);
|
|
57595
57595
|
const mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.links.keyType);
|
|
57596
57596
|
const propType = instantiateType(templateType, mapper);
|
|
57597
|
-
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType,
|
|
57597
|
+
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 4 /* Undefined */ | 16 /* Void */) ? getOptionalType(
|
|
57598
57598
|
propType,
|
|
57599
57599
|
/*isProperty*/
|
|
57600
57600
|
true
|
|
@@ -57888,14 +57888,14 @@ function createTypeChecker(host) {
|
|
|
57888
57888
|
constraints = append(constraints, t);
|
|
57889
57889
|
}
|
|
57890
57890
|
}
|
|
57891
|
-
} else if (t.flags &
|
|
57891
|
+
} else if (t.flags & 469860348 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
57892
57892
|
hasDisjointDomainType = true;
|
|
57893
57893
|
}
|
|
57894
57894
|
}
|
|
57895
57895
|
if (constraints && (targetIsUnion || hasDisjointDomainType)) {
|
|
57896
57896
|
if (hasDisjointDomainType) {
|
|
57897
57897
|
for (const t of types) {
|
|
57898
|
-
if (t.flags &
|
|
57898
|
+
if (t.flags & 469860348 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
57899
57899
|
constraints = append(constraints, t);
|
|
57900
57900
|
}
|
|
57901
57901
|
}
|
|
@@ -58096,7 +58096,7 @@ function createTypeChecker(host) {
|
|
|
58096
58096
|
function getApparentType(type) {
|
|
58097
58097
|
const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
|
|
58098
58098
|
const objectFlags = getObjectFlags(t);
|
|
58099
|
-
return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags &
|
|
58099
|
+
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;
|
|
58100
58100
|
}
|
|
58101
58101
|
function getReducedApparentType(type) {
|
|
58102
58102
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
@@ -58448,7 +58448,7 @@ function createTypeChecker(host) {
|
|
|
58448
58448
|
)) : applicableInfo ? applicableInfo : stringIndexInfo && isApplicableIndexType(keyType, stringType) ? stringIndexInfo : void 0;
|
|
58449
58449
|
}
|
|
58450
58450
|
function isApplicableIndexType(source, target) {
|
|
58451
|
-
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags &
|
|
58451
|
+
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags & 1024 /* StringLiteral */) && isNumericLiteralName(source.value));
|
|
58452
58452
|
}
|
|
58453
58453
|
function getIndexInfosOfStructuredType(type) {
|
|
58454
58454
|
if (type.flags & 3670016 /* StructuredType */) {
|
|
@@ -58777,7 +58777,7 @@ function createTypeChecker(host) {
|
|
|
58777
58777
|
}
|
|
58778
58778
|
if (type || jsdocPredicate) {
|
|
58779
58779
|
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
58780
|
-
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags &
|
|
58780
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 256 /* Boolean */) && getParameterCount(signature) > 0) {
|
|
58781
58781
|
const { declaration } = signature;
|
|
58782
58782
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
58783
58783
|
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
@@ -59062,7 +59062,7 @@ function createTypeChecker(host) {
|
|
|
59062
59062
|
return emptyArray;
|
|
59063
59063
|
}
|
|
59064
59064
|
function isValidIndexKeyType(type) {
|
|
59065
|
-
return !!(type.flags & (
|
|
59065
|
+
return !!(type.flags & (32 /* String */ | 64 /* Number */ | 512 /* ESSymbol */)) || isPatternLiteralType(type) || !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && some(type.types, isValidIndexKeyType);
|
|
59066
59066
|
}
|
|
59067
59067
|
function getConstraintDeclaration(type) {
|
|
59068
59068
|
return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
|
|
@@ -59563,7 +59563,7 @@ function createTypeChecker(host) {
|
|
|
59563
59563
|
}
|
|
59564
59564
|
function getTypeFromJSDocNullableTypeNode(node) {
|
|
59565
59565
|
const type = getTypeFromTypeNode(node.type);
|
|
59566
|
-
return strictNullChecks ? getNullableType(type,
|
|
59566
|
+
return strictNullChecks ? getNullableType(type, 8 /* Null */) : type;
|
|
59567
59567
|
}
|
|
59568
59568
|
function getTypeFromTypeReference(node) {
|
|
59569
59569
|
const links = getNodeLinks(node);
|
|
@@ -60336,10 +60336,10 @@ function createTypeChecker(host) {
|
|
|
60336
60336
|
return type.id;
|
|
60337
60337
|
}
|
|
60338
60338
|
function containsType(types, type) {
|
|
60339
|
-
return binarySearch(types, type,
|
|
60339
|
+
return binarySearch(types, type, identity, compareTypes) >= 0;
|
|
60340
60340
|
}
|
|
60341
60341
|
function insertType(types, type) {
|
|
60342
|
-
const index = binarySearch(types, type,
|
|
60342
|
+
const index = binarySearch(types, type, identity, compareTypes);
|
|
60343
60343
|
if (index < 0) {
|
|
60344
60344
|
types.splice(~index, 0, type);
|
|
60345
60345
|
return true;
|
|
@@ -60354,11 +60354,10 @@ function createTypeChecker(host) {
|
|
|
60354
60354
|
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) includes |= 536870912 /* IncludesConstrainedTypeVariable */;
|
|
60355
60355
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
60356
60356
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
60357
|
-
if (!strictNullChecks && flags &
|
|
60357
|
+
if (!strictNullChecks && flags & 12 /* Nullable */) {
|
|
60358
60358
|
if (!(getObjectFlags(type) & 65536 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */;
|
|
60359
60359
|
} else {
|
|
60360
|
-
const
|
|
60361
|
-
const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues);
|
|
60360
|
+
const index = binarySearch(typeSet, type, identity, compareTypes);
|
|
60362
60361
|
if (index < 0) {
|
|
60363
60362
|
typeSet.splice(~index, 0, type);
|
|
60364
60363
|
}
|
|
@@ -60436,7 +60435,7 @@ function createTypeChecker(host) {
|
|
|
60436
60435
|
i--;
|
|
60437
60436
|
const t = types[i];
|
|
60438
60437
|
const flags = t.flags;
|
|
60439
|
-
const remove = flags & (
|
|
60438
|
+
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);
|
|
60440
60439
|
if (remove) {
|
|
60441
60440
|
orderedRemoveItemAt(types, i);
|
|
60442
60441
|
}
|
|
@@ -60449,7 +60448,7 @@ function createTypeChecker(host) {
|
|
|
60449
60448
|
while (i > 0) {
|
|
60450
60449
|
i--;
|
|
60451
60450
|
const t = types[i];
|
|
60452
|
-
if (t.flags &
|
|
60451
|
+
if (t.flags & 1024 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
|
|
60453
60452
|
orderedRemoveItemAt(types, i);
|
|
60454
60453
|
}
|
|
60455
60454
|
}
|
|
@@ -60547,15 +60546,15 @@ function createTypeChecker(host) {
|
|
|
60547
60546
|
if (includes & 3 /* AnyOrUnknown */) {
|
|
60548
60547
|
return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType : unknownType;
|
|
60549
60548
|
}
|
|
60550
|
-
if (includes &
|
|
60549
|
+
if (includes & 4 /* Undefined */) {
|
|
60551
60550
|
if (typeSet.length >= 2 && typeSet[0] === undefinedType && typeSet[1] === missingType) {
|
|
60552
60551
|
orderedRemoveItemAt(typeSet, 1);
|
|
60553
60552
|
}
|
|
60554
60553
|
}
|
|
60555
|
-
if (includes & (
|
|
60554
|
+
if (includes & (65536 /* Enum */ | 15360 /* Literal */ | 16384 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16 /* Void */ && includes & 4 /* Undefined */) {
|
|
60556
60555
|
removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */));
|
|
60557
60556
|
}
|
|
60558
|
-
if (includes &
|
|
60557
|
+
if (includes & 1024 /* StringLiteral */ && includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
60559
60558
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
60560
60559
|
}
|
|
60561
60560
|
if (includes & 536870912 /* IncludesConstrainedTypeVariable */) {
|
|
@@ -60568,7 +60567,7 @@ function createTypeChecker(host) {
|
|
|
60568
60567
|
}
|
|
60569
60568
|
}
|
|
60570
60569
|
if (typeSet.length === 0) {
|
|
60571
|
-
return includes &
|
|
60570
|
+
return includes & 8 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : includes & 4 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType;
|
|
60572
60571
|
}
|
|
60573
60572
|
}
|
|
60574
60573
|
if (!origin && includes & 1048576 /* Union */) {
|
|
@@ -60591,7 +60590,7 @@ function createTypeChecker(host) {
|
|
|
60591
60590
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
60592
60591
|
}
|
|
60593
60592
|
}
|
|
60594
|
-
const objectFlags = (includes &
|
|
60593
|
+
const objectFlags = (includes & 36306963 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
60595
60594
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
60596
60595
|
}
|
|
60597
60596
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -60636,14 +60635,14 @@ function createTypeChecker(host) {
|
|
|
60636
60635
|
type.objectFlags = precomputedObjectFlags | getPropagatingFlagsOfTypes(
|
|
60637
60636
|
types,
|
|
60638
60637
|
/*excludeKinds*/
|
|
60639
|
-
|
|
60638
|
+
12 /* Nullable */
|
|
60640
60639
|
);
|
|
60641
60640
|
type.types = types;
|
|
60642
60641
|
type.origin = origin;
|
|
60643
60642
|
type.aliasSymbol = aliasSymbol;
|
|
60644
60643
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
60645
|
-
if (types.length === 2 && types[0].flags &
|
|
60646
|
-
type.flags |=
|
|
60644
|
+
if (types.length === 2 && types[0].flags & 4096 /* BooleanLiteral */ && types[1].flags & 4096 /* BooleanLiteral */) {
|
|
60645
|
+
type.flags |= 256 /* Boolean */;
|
|
60647
60646
|
type.intrinsicName = "boolean";
|
|
60648
60647
|
}
|
|
60649
60648
|
unionTypes.set(id, type);
|
|
@@ -60672,13 +60671,13 @@ function createTypeChecker(host) {
|
|
|
60672
60671
|
if (flags & 3 /* AnyOrUnknown */) {
|
|
60673
60672
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
60674
60673
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
60675
|
-
} else if (strictNullChecks || !(flags &
|
|
60674
|
+
} else if (strictNullChecks || !(flags & 12 /* Nullable */)) {
|
|
60676
60675
|
if (type === missingType) {
|
|
60677
60676
|
includes |= 262144 /* IncludesMissingType */;
|
|
60678
60677
|
type = undefinedType;
|
|
60679
60678
|
}
|
|
60680
60679
|
if (!typeSet.has(type.id.toString())) {
|
|
60681
|
-
if (type.flags &
|
|
60680
|
+
if (type.flags & 97292 /* Unit */ && includes & 97292 /* Unit */) {
|
|
60682
60681
|
includes |= 67108864 /* NonPrimitive */;
|
|
60683
60682
|
}
|
|
60684
60683
|
typeSet.set(type.id.toString(), type);
|
|
@@ -60699,7 +60698,7 @@ function createTypeChecker(host) {
|
|
|
60699
60698
|
while (i > 0) {
|
|
60700
60699
|
i--;
|
|
60701
60700
|
const t = types[i];
|
|
60702
|
-
const remove = t.flags &
|
|
60701
|
+
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 */;
|
|
60703
60702
|
if (remove) {
|
|
60704
60703
|
orderedRemoveItemAt(types, i);
|
|
60705
60704
|
}
|
|
@@ -60714,7 +60713,7 @@ function createTypeChecker(host) {
|
|
|
60714
60713
|
if (type === undefinedType) {
|
|
60715
60714
|
return containsType(u.types, missingType);
|
|
60716
60715
|
}
|
|
60717
|
-
const primitive = type.flags &
|
|
60716
|
+
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;
|
|
60718
60717
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
60719
60718
|
return false;
|
|
60720
60719
|
}
|
|
@@ -60724,7 +60723,7 @@ function createTypeChecker(host) {
|
|
|
60724
60723
|
}
|
|
60725
60724
|
function extractRedundantTemplateLiterals(types) {
|
|
60726
60725
|
let i = types.length;
|
|
60727
|
-
const literals = filter(types, (t) => !!(t.flags &
|
|
60726
|
+
const literals = filter(types, (t) => !!(t.flags & 1024 /* StringLiteral */));
|
|
60728
60727
|
while (i > 0) {
|
|
60729
60728
|
i--;
|
|
60730
60729
|
const t = types[i];
|
|
@@ -60790,7 +60789,7 @@ function createTypeChecker(host) {
|
|
|
60790
60789
|
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
60791
60790
|
types,
|
|
60792
60791
|
/*excludeKinds*/
|
|
60793
|
-
|
|
60792
|
+
12 /* Nullable */
|
|
60794
60793
|
);
|
|
60795
60794
|
result.types = types;
|
|
60796
60795
|
result.aliasSymbol = aliasSymbol;
|
|
@@ -60805,19 +60804,19 @@ function createTypeChecker(host) {
|
|
|
60805
60804
|
if (includes & 131072 /* Never */) {
|
|
60806
60805
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
60807
60806
|
}
|
|
60808
|
-
if (strictNullChecks && includes &
|
|
60807
|
+
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 */)) {
|
|
60809
60808
|
return neverType;
|
|
60810
60809
|
}
|
|
60811
|
-
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes &
|
|
60810
|
+
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 1024 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) {
|
|
60812
60811
|
return neverType;
|
|
60813
60812
|
}
|
|
60814
60813
|
if (includes & 1 /* Any */) {
|
|
60815
60814
|
return includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType;
|
|
60816
60815
|
}
|
|
60817
|
-
if (!strictNullChecks && includes &
|
|
60818
|
-
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes &
|
|
60816
|
+
if (!strictNullChecks && includes & 12 /* Nullable */) {
|
|
60817
|
+
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes & 4 /* Undefined */ ? undefinedType : nullType;
|
|
60819
60818
|
}
|
|
60820
|
-
if (includes &
|
|
60819
|
+
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 */) {
|
|
60821
60820
|
if (!(flags & 1 /* NoSupertypeReduction */)) removeRedundantSupertypes(typeSet, includes);
|
|
60822
60821
|
}
|
|
60823
60822
|
if (includes & 262144 /* IncludesMissingType */) {
|
|
@@ -60854,12 +60853,12 @@ function createTypeChecker(host) {
|
|
|
60854
60853
|
if (includes & 1048576 /* Union */) {
|
|
60855
60854
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
60856
60855
|
result = getIntersectionType(typeSet, flags, aliasSymbol, aliasTypeArguments);
|
|
60857
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags &
|
|
60856
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 4 /* Undefined */))) {
|
|
60858
60857
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
60859
|
-
removeFromEach(typeSet,
|
|
60858
|
+
removeFromEach(typeSet, 4 /* Undefined */);
|
|
60860
60859
|
result = getUnionType([getIntersectionType(typeSet, flags), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60861
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags &
|
|
60862
|
-
removeFromEach(typeSet,
|
|
60860
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 8 /* Null */ || t.types[1].flags & 8 /* Null */)))) {
|
|
60861
|
+
removeFromEach(typeSet, 8 /* Null */);
|
|
60863
60862
|
result = getUnionType([getIntersectionType(typeSet, flags), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60864
60863
|
} else if (typeSet.length >= 3 && types.length > 2) {
|
|
60865
60864
|
const middle = Math.floor(typeSet.length / 2);
|
|
@@ -60924,7 +60923,7 @@ function createTypeChecker(host) {
|
|
|
60924
60923
|
const types = map(node.types, getTypeFromTypeNode);
|
|
60925
60924
|
const emptyIndex = types.length === 2 ? types.indexOf(emptyTypeLiteralType) : -1;
|
|
60926
60925
|
const t = emptyIndex >= 0 ? types[1 - emptyIndex] : unknownType;
|
|
60927
|
-
const noSupertypeReduction = !!(t.flags & (
|
|
60926
|
+
const noSupertypeReduction = !!(t.flags & (32 /* String */ | 64 /* Number */ | 128 /* BigInt */) || t.flags & 134217728 /* TemplateLiteral */ && isPatternLiteralType(t));
|
|
60928
60927
|
links.resolvedType = getIntersectionType(types, noSupertypeReduction ? 1 /* NoSupertypeReduction */ : 0, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
60929
60928
|
}
|
|
60930
60929
|
return links.resolvedType;
|
|
@@ -60958,11 +60957,11 @@ function createTypeChecker(host) {
|
|
|
60958
60957
|
forEachType(constraintType, addMemberForKeyType);
|
|
60959
60958
|
} else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
60960
60959
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
60961
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType,
|
|
60960
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 19456 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
|
|
60962
60961
|
} else {
|
|
60963
60962
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
60964
60963
|
}
|
|
60965
|
-
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ |
|
|
60964
|
+
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ | 32 /* String */))) : getUnionType(keyTypes);
|
|
60966
60965
|
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
60967
60966
|
return constraintType;
|
|
60968
60967
|
}
|
|
@@ -61017,7 +61016,7 @@ function createTypeChecker(host) {
|
|
|
61017
61016
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
61018
61017
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
61019
61018
|
const propertyTypes = map(getPropertiesOfType(type), (prop) => getLiteralTypeFromProperty(prop, include));
|
|
61020
|
-
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include &
|
|
61019
|
+
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 64 /* Number */ ? stringOrNumberType : info.keyType : neverType);
|
|
61021
61020
|
return getUnionType(
|
|
61022
61021
|
concatenate(propertyTypes, indexKeyTypes),
|
|
61023
61022
|
1 /* Literal */,
|
|
@@ -61033,7 +61032,7 @@ function createTypeChecker(host) {
|
|
|
61033
61032
|
}
|
|
61034
61033
|
function getIndexType(type, indexFlags = 0 /* None */) {
|
|
61035
61034
|
type = getReducedType(type);
|
|
61036
|
-
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 */ ?
|
|
61035
|
+
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 */);
|
|
61037
61036
|
}
|
|
61038
61037
|
function getExtractStringType(type) {
|
|
61039
61038
|
const extractTypeAlias = getGlobalExtractSymbol();
|
|
@@ -61091,7 +61090,7 @@ function createTypeChecker(host) {
|
|
|
61091
61090
|
}
|
|
61092
61091
|
newTexts.push(text);
|
|
61093
61092
|
if (every(newTexts, (t) => t === "")) {
|
|
61094
|
-
if (every(newTypes, (t) => !!(t.flags &
|
|
61093
|
+
if (every(newTypes, (t) => !!(t.flags & 32 /* String */))) {
|
|
61095
61094
|
return stringType;
|
|
61096
61095
|
}
|
|
61097
61096
|
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
@@ -61107,7 +61106,7 @@ function createTypeChecker(host) {
|
|
|
61107
61106
|
function addSpans(texts2, types2) {
|
|
61108
61107
|
for (let i = 0; i < types2.length; i++) {
|
|
61109
61108
|
const t = types2[i];
|
|
61110
|
-
if (t.flags & (
|
|
61109
|
+
if (t.flags & (15360 /* Literal */ | 8 /* Null */ | 4 /* Undefined */)) {
|
|
61111
61110
|
text += getTemplateStringForType(t) || "";
|
|
61112
61111
|
text += texts2[i + 1];
|
|
61113
61112
|
} else if (t.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -61126,7 +61125,7 @@ function createTypeChecker(host) {
|
|
|
61126
61125
|
}
|
|
61127
61126
|
}
|
|
61128
61127
|
function getTemplateStringForType(type) {
|
|
61129
|
-
return type.flags &
|
|
61128
|
+
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;
|
|
61130
61129
|
}
|
|
61131
61130
|
function createTemplateLiteralType(texts, types) {
|
|
61132
61131
|
const type = createType(134217728 /* TemplateLiteral */);
|
|
@@ -61135,9 +61134,9 @@ function createTypeChecker(host) {
|
|
|
61135
61134
|
return type;
|
|
61136
61135
|
}
|
|
61137
61136
|
function getStringMappingType(symbol, type) {
|
|
61138
|
-
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags &
|
|
61137
|
+
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)) : (
|
|
61139
61138
|
// Mapping<Mapping<T>> === Mapping<T>
|
|
61140
|
-
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ |
|
|
61139
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ | 32 /* String */ | 268435456 /* StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : (
|
|
61141
61140
|
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
61142
61141
|
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) : type
|
|
61143
61142
|
)
|
|
@@ -61275,7 +61274,7 @@ function createTypeChecker(host) {
|
|
|
61275
61274
|
}
|
|
61276
61275
|
}
|
|
61277
61276
|
}
|
|
61278
|
-
if (!(indexType.flags &
|
|
61277
|
+
if (!(indexType.flags & 12 /* Nullable */) && isTypeAssignableToKind(indexType, 402654240 /* StringLike */ | 67648 /* NumberLike */ | 16896 /* ESSymbolLike */)) {
|
|
61279
61278
|
if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
|
|
61280
61279
|
return objectType;
|
|
61281
61280
|
}
|
|
@@ -61291,13 +61290,13 @@ function createTypeChecker(host) {
|
|
|
61291
61290
|
}
|
|
61292
61291
|
return void 0;
|
|
61293
61292
|
}
|
|
61294
|
-
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType,
|
|
61293
|
+
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 32 /* String */ | 64 /* Number */)) {
|
|
61295
61294
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
61296
61295
|
error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
|
|
61297
61296
|
return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
|
|
61298
61297
|
}
|
|
61299
61298
|
errorIfWritingToReadonlyIndex(indexInfo);
|
|
61300
|
-
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags &
|
|
61299
|
+
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags & 32768 /* EnumLiteral */ && getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
|
|
61301
61300
|
return getUnionType([indexInfo.type, missingType]);
|
|
61302
61301
|
}
|
|
61303
61302
|
return indexInfo.type;
|
|
@@ -61310,10 +61309,10 @@ function createTypeChecker(host) {
|
|
|
61310
61309
|
}
|
|
61311
61310
|
if (accessExpression && !isConstEnumObjectType(objectType)) {
|
|
61312
61311
|
if (isObjectLiteralType(objectType)) {
|
|
61313
|
-
if (noImplicitAny && indexType.flags & (
|
|
61312
|
+
if (noImplicitAny && indexType.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */)) {
|
|
61314
61313
|
diagnostics.add(createDiagnosticForNode(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)));
|
|
61315
61314
|
return undefinedType;
|
|
61316
|
-
} else if (indexType.flags & (
|
|
61315
|
+
} else if (indexType.flags & (64 /* Number */ | 32 /* String */)) {
|
|
61317
61316
|
const types = map(objectType.properties, (property) => {
|
|
61318
61317
|
return getTypeOfSymbol(property);
|
|
61319
61318
|
});
|
|
@@ -61340,7 +61339,7 @@ function createTypeChecker(host) {
|
|
|
61340
61339
|
error(accessExpression, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion2);
|
|
61341
61340
|
} else {
|
|
61342
61341
|
let errorInfo;
|
|
61343
|
-
if (indexType.flags &
|
|
61342
|
+
if (indexType.flags & 32768 /* EnumLiteral */) {
|
|
61344
61343
|
errorInfo = chainDiagnosticMessages(
|
|
61345
61344
|
/*details*/
|
|
61346
61345
|
void 0,
|
|
@@ -61348,7 +61347,7 @@ function createTypeChecker(host) {
|
|
|
61348
61347
|
"[" + typeToString(indexType) + "]",
|
|
61349
61348
|
typeToString(objectType)
|
|
61350
61349
|
);
|
|
61351
|
-
} else if (indexType.flags &
|
|
61350
|
+
} else if (indexType.flags & 16384 /* UniqueESSymbol */) {
|
|
61352
61351
|
const symbolName2 = getFullyQualifiedName(indexType.symbol, accessExpression);
|
|
61353
61352
|
errorInfo = chainDiagnosticMessages(
|
|
61354
61353
|
/*details*/
|
|
@@ -61357,7 +61356,7 @@ function createTypeChecker(host) {
|
|
|
61357
61356
|
"[" + symbolName2 + "]",
|
|
61358
61357
|
typeToString(objectType)
|
|
61359
61358
|
);
|
|
61360
|
-
} else if (indexType.flags &
|
|
61359
|
+
} else if (indexType.flags & 1024 /* StringLiteral */) {
|
|
61361
61360
|
errorInfo = chainDiagnosticMessages(
|
|
61362
61361
|
/*details*/
|
|
61363
61362
|
void 0,
|
|
@@ -61365,7 +61364,7 @@ function createTypeChecker(host) {
|
|
|
61365
61364
|
indexType.value,
|
|
61366
61365
|
typeToString(objectType)
|
|
61367
61366
|
);
|
|
61368
|
-
} else if (indexType.flags &
|
|
61367
|
+
} else if (indexType.flags & 2048 /* NumberLiteral */) {
|
|
61369
61368
|
errorInfo = chainDiagnosticMessages(
|
|
61370
61369
|
/*details*/
|
|
61371
61370
|
void 0,
|
|
@@ -61373,7 +61372,7 @@ function createTypeChecker(host) {
|
|
|
61373
61372
|
indexType.value,
|
|
61374
61373
|
typeToString(objectType)
|
|
61375
61374
|
);
|
|
61376
|
-
} else if (indexType.flags & (
|
|
61375
|
+
} else if (indexType.flags & (64 /* Number */ | 32 /* String */)) {
|
|
61377
61376
|
errorInfo = chainDiagnosticMessages(
|
|
61378
61377
|
/*details*/
|
|
61379
61378
|
void 0,
|
|
@@ -61404,9 +61403,9 @@ function createTypeChecker(host) {
|
|
|
61404
61403
|
}
|
|
61405
61404
|
if (accessNode) {
|
|
61406
61405
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
61407
|
-
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (
|
|
61406
|
+
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */)) {
|
|
61408
61407
|
error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
|
|
61409
|
-
} else if (indexType.flags & (
|
|
61408
|
+
} else if (indexType.flags & (32 /* String */ | 64 /* Number */)) {
|
|
61410
61409
|
error(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
|
|
61411
61410
|
} else {
|
|
61412
61411
|
const typeString = indexNode.kind === 10 /* BigIntLiteral */ ? "bigint" : typeToString(indexType);
|
|
@@ -61430,7 +61429,7 @@ function createTypeChecker(host) {
|
|
|
61430
61429
|
if (type.flags & 2097152 /* Intersection */) {
|
|
61431
61430
|
let seenPlaceholder = false;
|
|
61432
61431
|
for (const t of type.types) {
|
|
61433
|
-
if (t.flags & (
|
|
61432
|
+
if (t.flags & (15360 /* Literal */ | 12 /* Nullable */) || isPatternLiteralPlaceholderType(t)) {
|
|
61434
61433
|
seenPlaceholder = true;
|
|
61435
61434
|
} else if (!(t.flags & 524288 /* Object */)) {
|
|
61436
61435
|
return false;
|
|
@@ -61438,7 +61437,7 @@ function createTypeChecker(host) {
|
|
|
61438
61437
|
}
|
|
61439
61438
|
return seenPlaceholder;
|
|
61440
61439
|
}
|
|
61441
|
-
return !!(type.flags & (1 /* Any */ |
|
|
61440
|
+
return !!(type.flags & (1 /* Any */ | 32 /* String */ | 64 /* Number */ | 128 /* BigInt */)) || isPatternLiteralType(type);
|
|
61442
61441
|
}
|
|
61443
61442
|
function isPatternLiteralType(type) {
|
|
61444
61443
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
@@ -61503,10 +61502,10 @@ function createTypeChecker(host) {
|
|
|
61503
61502
|
return type[cache] = distributedOverObject;
|
|
61504
61503
|
}
|
|
61505
61504
|
}
|
|
61506
|
-
if (isGenericTupleType(objectType) && indexType.flags &
|
|
61505
|
+
if (isGenericTupleType(objectType) && indexType.flags & 67648 /* NumberLike */) {
|
|
61507
61506
|
const elementType = getElementTypeOfSliceOfTupleType(
|
|
61508
61507
|
objectType,
|
|
61509
|
-
indexType.flags &
|
|
61508
|
+
indexType.flags & 64 /* Number */ ? 0 : objectType.target.fixedLength,
|
|
61510
61509
|
/*endSkipCount*/
|
|
61511
61510
|
0,
|
|
61512
61511
|
writing
|
|
@@ -61559,14 +61558,14 @@ function createTypeChecker(host) {
|
|
|
61559
61558
|
}
|
|
61560
61559
|
function couldAccessOptionalProperty(objectType, indexType) {
|
|
61561
61560
|
const indexConstraint = getBaseConstraintOfType(indexType);
|
|
61562
|
-
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p,
|
|
61561
|
+
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p, 19456 /* StringOrNumberLiteralOrUnique */), indexConstraint));
|
|
61563
61562
|
}
|
|
61564
61563
|
function getIndexedAccessType(objectType, indexType, accessFlags = 0 /* None */, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
61565
61564
|
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
61566
61565
|
}
|
|
61567
61566
|
function indexTypeLessThan(indexType, limit) {
|
|
61568
61567
|
return everyType(indexType, (t) => {
|
|
61569
|
-
if (t.flags &
|
|
61568
|
+
if (t.flags & 3072 /* StringOrNumberLiteral */) {
|
|
61570
61569
|
const propName = getPropertyNameFromType(t);
|
|
61571
61570
|
if (isNumericLiteralName(propName)) {
|
|
61572
61571
|
const index = +propName;
|
|
@@ -61581,7 +61580,7 @@ function createTypeChecker(host) {
|
|
|
61581
61580
|
return wildcardType;
|
|
61582
61581
|
}
|
|
61583
61582
|
objectType = getReducedType(objectType);
|
|
61584
|
-
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags &
|
|
61583
|
+
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 12 /* Nullable */) && isTypeAssignableToKind(indexType, 32 /* String */ | 64 /* Number */)) {
|
|
61585
61584
|
indexType = stringType;
|
|
61586
61585
|
}
|
|
61587
61586
|
if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) accessFlags |= 1 /* IncludeUndefined */;
|
|
@@ -61598,7 +61597,7 @@ function createTypeChecker(host) {
|
|
|
61598
61597
|
return type;
|
|
61599
61598
|
}
|
|
61600
61599
|
const apparentObjectType = getReducedApparentType(objectType);
|
|
61601
|
-
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags &
|
|
61600
|
+
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 256 /* Boolean */)) {
|
|
61602
61601
|
const propTypes = [];
|
|
61603
61602
|
let wasMissingProp = false;
|
|
61604
61603
|
for (const t of indexType.types) {
|
|
@@ -61931,7 +61930,7 @@ function createTypeChecker(host) {
|
|
|
61931
61930
|
return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type);
|
|
61932
61931
|
}
|
|
61933
61932
|
function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
|
|
61934
|
-
return isEmptyObjectType(type) || !!(type.flags & (
|
|
61933
|
+
return isEmptyObjectType(type) || !!(type.flags & (8 /* Null */ | 4 /* Undefined */ | 4352 /* BooleanLike */ | 67648 /* NumberLike */ | 8320 /* BigIntLike */ | 402654240 /* StringLike */ | 98304 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */));
|
|
61935
61934
|
}
|
|
61936
61935
|
function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
|
|
61937
61936
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
@@ -61994,7 +61993,7 @@ function createTypeChecker(host) {
|
|
|
61994
61993
|
if (right.flags & 1048576 /* Union */) {
|
|
61995
61994
|
return checkCrossProductUnion([left, right]) ? mapType(right, (t) => getSpreadType(left, t, symbol, objectFlags, readonly)) : errorType;
|
|
61996
61995
|
}
|
|
61997
|
-
if (right.flags & (
|
|
61996
|
+
if (right.flags & (4352 /* BooleanLike */ | 67648 /* NumberLike */ | 8320 /* BigIntLike */ | 402654240 /* StringLike */ | 98304 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) {
|
|
61998
61997
|
return left;
|
|
61999
61998
|
}
|
|
62000
61999
|
if (isGenericObjectType(left) || isGenericObjectType(right)) {
|
|
@@ -62076,7 +62075,7 @@ function createTypeChecker(host) {
|
|
|
62076
62075
|
return type;
|
|
62077
62076
|
}
|
|
62078
62077
|
function getFreshTypeOfLiteralType(type) {
|
|
62079
|
-
if (type.flags &
|
|
62078
|
+
if (type.flags & 80896 /* Freshable */) {
|
|
62080
62079
|
if (!type.freshType) {
|
|
62081
62080
|
const freshType = createLiteralType(type.flags, type.value, type.symbol, type);
|
|
62082
62081
|
freshType.freshType = freshType;
|
|
@@ -62087,28 +62086,28 @@ function createTypeChecker(host) {
|
|
|
62087
62086
|
return type;
|
|
62088
62087
|
}
|
|
62089
62088
|
function getRegularTypeOfLiteralType(type) {
|
|
62090
|
-
return type.flags &
|
|
62089
|
+
return type.flags & 80896 /* Freshable */ ? type.regularType : type.flags & 1048576 /* Union */ ? type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType)) : type;
|
|
62091
62090
|
}
|
|
62092
62091
|
function isFreshLiteralType(type) {
|
|
62093
|
-
return !!(type.flags &
|
|
62092
|
+
return !!(type.flags & 80896 /* Freshable */) && type.freshType === type;
|
|
62094
62093
|
}
|
|
62095
62094
|
function getStringLiteralType(value) {
|
|
62096
62095
|
let type;
|
|
62097
|
-
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(
|
|
62096
|
+
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(1024 /* StringLiteral */, value)), type);
|
|
62098
62097
|
}
|
|
62099
62098
|
function getNumberLiteralType(value) {
|
|
62100
62099
|
let type;
|
|
62101
|
-
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(
|
|
62100
|
+
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(2048 /* NumberLiteral */, value)), type);
|
|
62102
62101
|
}
|
|
62103
62102
|
function getBigIntLiteralType(value) {
|
|
62104
62103
|
let type;
|
|
62105
62104
|
const key = pseudoBigIntToString(value);
|
|
62106
|
-
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(
|
|
62105
|
+
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(8192 /* BigIntLiteral */, value)), type);
|
|
62107
62106
|
}
|
|
62108
62107
|
function getEnumLiteralType(value, enumId, symbol) {
|
|
62109
62108
|
let type;
|
|
62110
62109
|
const key = `${enumId}${typeof value === "string" ? "@" : "#"}${value}`;
|
|
62111
|
-
const flags =
|
|
62110
|
+
const flags = 32768 /* EnumLiteral */ | (typeof value === "string" ? 1024 /* StringLiteral */ : 2048 /* NumberLiteral */);
|
|
62112
62111
|
return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type);
|
|
62113
62112
|
}
|
|
62114
62113
|
function getTypeFromLiteralTypeNode(node) {
|
|
@@ -62122,7 +62121,7 @@ function createTypeChecker(host) {
|
|
|
62122
62121
|
return links.resolvedType;
|
|
62123
62122
|
}
|
|
62124
62123
|
function createUniqueESSymbolType(symbol) {
|
|
62125
|
-
const type = createTypeWithSymbol(
|
|
62124
|
+
const type = createTypeWithSymbol(16384 /* UniqueESSymbol */, symbol);
|
|
62126
62125
|
type.escapedName = `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}`;
|
|
62127
62126
|
return type;
|
|
62128
62127
|
}
|
|
@@ -62510,7 +62509,7 @@ function createTypeChecker(host) {
|
|
|
62510
62509
|
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);
|
|
62511
62510
|
target.instantiations.set(id, result);
|
|
62512
62511
|
const resultObjectFlags = getObjectFlags(result);
|
|
62513
|
-
if (result.flags &
|
|
62512
|
+
if (result.flags & 3801101 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62514
62513
|
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
62515
62514
|
if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62516
62515
|
if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
|
|
@@ -62639,7 +62638,7 @@ function createTypeChecker(host) {
|
|
|
62639
62638
|
const templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
|
|
62640
62639
|
const propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
|
|
62641
62640
|
const modifiers = getMappedTypeModifiers(type);
|
|
62642
|
-
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType,
|
|
62641
|
+
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 4 /* Undefined */ | 16 /* Void */) ? getOptionalType(
|
|
62643
62642
|
propType,
|
|
62644
62643
|
/*isProperty*/
|
|
62645
62644
|
true
|
|
@@ -63186,7 +63185,7 @@ function createTypeChecker(host) {
|
|
|
63186
63185
|
createDiagnosticForNode(
|
|
63187
63186
|
targetNode,
|
|
63188
63187
|
Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1,
|
|
63189
|
-
propertyName && !(nameType.flags &
|
|
63188
|
+
propertyName && !(nameType.flags & 16384 /* UniqueESSymbol */) ? unescapeLeadingUnderscores(propertyName) : typeToString(nameType),
|
|
63190
63189
|
typeToString(target)
|
|
63191
63190
|
)
|
|
63192
63191
|
);
|
|
@@ -63429,7 +63428,7 @@ function createTypeChecker(host) {
|
|
|
63429
63428
|
if (!length(node.properties)) return;
|
|
63430
63429
|
for (const prop of node.properties) {
|
|
63431
63430
|
if (isSpreadAssignment(prop)) continue;
|
|
63432
|
-
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop),
|
|
63431
|
+
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop), 19456 /* StringOrNumberLiteralOrUnique */);
|
|
63433
63432
|
if (!type || type.flags & 131072 /* Never */) {
|
|
63434
63433
|
continue;
|
|
63435
63434
|
}
|
|
@@ -63479,7 +63478,7 @@ function createTypeChecker(host) {
|
|
|
63479
63478
|
}
|
|
63480
63479
|
return false;
|
|
63481
63480
|
}
|
|
63482
|
-
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
63481
|
+
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes2, reportUnreliableMarkers) {
|
|
63483
63482
|
if (source === target) {
|
|
63484
63483
|
return -1 /* True */;
|
|
63485
63484
|
}
|
|
@@ -63504,7 +63503,7 @@ function createTypeChecker(host) {
|
|
|
63504
63503
|
target,
|
|
63505
63504
|
/*inferenceContext*/
|
|
63506
63505
|
void 0,
|
|
63507
|
-
|
|
63506
|
+
compareTypes2
|
|
63508
63507
|
);
|
|
63509
63508
|
}
|
|
63510
63509
|
const sourceCount = getParameterCount(source);
|
|
@@ -63520,12 +63519,12 @@ function createTypeChecker(host) {
|
|
|
63520
63519
|
if (sourceThisType && sourceThisType !== voidType) {
|
|
63521
63520
|
const targetThisType = getThisTypeOfSignature(target);
|
|
63522
63521
|
if (targetThisType) {
|
|
63523
|
-
const related = !strictVariance &&
|
|
63522
|
+
const related = !strictVariance && compareTypes2(
|
|
63524
63523
|
sourceThisType,
|
|
63525
63524
|
targetThisType,
|
|
63526
63525
|
/*reportErrors*/
|
|
63527
63526
|
false
|
|
63528
|
-
) ||
|
|
63527
|
+
) || compareTypes2(targetThisType, sourceThisType, reportErrors2);
|
|
63529
63528
|
if (!related) {
|
|
63530
63529
|
if (reportErrors2) {
|
|
63531
63530
|
errorReporter(Diagnostics.The_this_types_of_each_signature_are_incompatible);
|
|
@@ -63544,13 +63543,13 @@ function createTypeChecker(host) {
|
|
|
63544
63543
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
63545
63544
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
63546
63545
|
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
63547
|
-
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
63546
|
+
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes2, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes2(
|
|
63548
63547
|
sourceType,
|
|
63549
63548
|
targetType,
|
|
63550
63549
|
/*reportErrors*/
|
|
63551
63550
|
false
|
|
63552
|
-
) ||
|
|
63553
|
-
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) &&
|
|
63551
|
+
) || compareTypes2(targetType, sourceType, reportErrors2);
|
|
63552
|
+
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes2(
|
|
63554
63553
|
sourceType,
|
|
63555
63554
|
targetType,
|
|
63556
63555
|
/*reportErrors*/
|
|
@@ -63577,7 +63576,7 @@ function createTypeChecker(host) {
|
|
|
63577
63576
|
if (targetTypePredicate) {
|
|
63578
63577
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
63579
63578
|
if (sourceTypePredicate) {
|
|
63580
|
-
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter,
|
|
63579
|
+
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter, compareTypes2);
|
|
63581
63580
|
} else if (isIdentifierTypePredicate(targetTypePredicate) || isThisTypePredicate(targetTypePredicate)) {
|
|
63582
63581
|
if (reportErrors2) {
|
|
63583
63582
|
errorReporter(Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
|
|
@@ -63585,12 +63584,12 @@ function createTypeChecker(host) {
|
|
|
63585
63584
|
return 0 /* False */;
|
|
63586
63585
|
}
|
|
63587
63586
|
} else {
|
|
63588
|
-
result &= checkMode & 1 /* BivariantCallback */ &&
|
|
63587
|
+
result &= checkMode & 1 /* BivariantCallback */ && compareTypes2(
|
|
63589
63588
|
targetReturnType,
|
|
63590
63589
|
sourceReturnType,
|
|
63591
63590
|
/*reportErrors*/
|
|
63592
63591
|
false
|
|
63593
|
-
) ||
|
|
63592
|
+
) || compareTypes2(sourceReturnType, targetReturnType, reportErrors2);
|
|
63594
63593
|
if (!result && reportErrors2 && incompatibleErrorReporter) {
|
|
63595
63594
|
incompatibleErrorReporter(sourceReturnType, targetReturnType);
|
|
63596
63595
|
}
|
|
@@ -63598,7 +63597,7 @@ function createTypeChecker(host) {
|
|
|
63598
63597
|
}
|
|
63599
63598
|
return result;
|
|
63600
63599
|
}
|
|
63601
|
-
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter,
|
|
63600
|
+
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter, compareTypes2) {
|
|
63602
63601
|
if (source.kind !== target.kind) {
|
|
63603
63602
|
if (reportErrors2) {
|
|
63604
63603
|
errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
|
|
@@ -63615,7 +63614,7 @@ function createTypeChecker(host) {
|
|
|
63615
63614
|
return 0 /* False */;
|
|
63616
63615
|
}
|
|
63617
63616
|
}
|
|
63618
|
-
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
63617
|
+
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ? compareTypes2(source.type, target.type, reportErrors2) : 0 /* False */;
|
|
63619
63618
|
if (related === 0 /* False */ && reportErrors2) {
|
|
63620
63619
|
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
|
|
63621
63620
|
}
|
|
@@ -63649,18 +63648,18 @@ function createTypeChecker(host) {
|
|
|
63649
63648
|
if (strictNullChecks && type.flags & 1048576 /* Union */) {
|
|
63650
63649
|
if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
|
|
63651
63650
|
const types = type.types;
|
|
63652
|
-
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags &
|
|
63651
|
+
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 4 /* Undefined */ && types[1].flags & 8 /* Null */ && some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
|
|
63653
63652
|
}
|
|
63654
63653
|
return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
|
|
63655
63654
|
}
|
|
63656
63655
|
return false;
|
|
63657
63656
|
}
|
|
63658
63657
|
function containsUndefinedType(type) {
|
|
63659
|
-
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags &
|
|
63658
|
+
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 4 /* Undefined */);
|
|
63660
63659
|
}
|
|
63661
63660
|
function containsNonMissingUndefinedType(type) {
|
|
63662
63661
|
const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
|
|
63663
|
-
return !!(candidate.flags &
|
|
63662
|
+
return !!(candidate.flags & 4 /* Undefined */) && candidate !== missingType;
|
|
63664
63663
|
}
|
|
63665
63664
|
function isStringIndexSignatureOnlyType(type) {
|
|
63666
63665
|
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;
|
|
@@ -63731,25 +63730,25 @@ function createTypeChecker(host) {
|
|
|
63731
63730
|
if (t & 1 /* Any */ || s & 131072 /* Never */ || source === wildcardType) return true;
|
|
63732
63731
|
if (t & 2 /* Unknown */ && !(relation === strictSubtypeRelation && s & 1 /* Any */)) return true;
|
|
63733
63732
|
if (t & 131072 /* Never */) return false;
|
|
63734
|
-
if (s &
|
|
63735
|
-
if (s &
|
|
63736
|
-
if (s &
|
|
63737
|
-
if (s &
|
|
63738
|
-
if (s &
|
|
63739
|
-
if (s &
|
|
63740
|
-
if (s &
|
|
63741
|
-
if (s &
|
|
63742
|
-
if (s &
|
|
63733
|
+
if (s & 402654240 /* StringLike */ && t & 32 /* String */) return true;
|
|
63734
|
+
if (s & 1024 /* StringLiteral */ && s & 32768 /* EnumLiteral */ && t & 1024 /* StringLiteral */ && !(t & 32768 /* EnumLiteral */) && source.value === target.value) return true;
|
|
63735
|
+
if (s & 67648 /* NumberLike */ && t & 64 /* Number */) return true;
|
|
63736
|
+
if (s & 2048 /* NumberLiteral */ && s & 32768 /* EnumLiteral */ && t & 2048 /* NumberLiteral */ && !(t & 32768 /* EnumLiteral */) && source.value === target.value) return true;
|
|
63737
|
+
if (s & 8320 /* BigIntLike */ && t & 128 /* BigInt */) return true;
|
|
63738
|
+
if (s & 4352 /* BooleanLike */ && t & 256 /* Boolean */) return true;
|
|
63739
|
+
if (s & 16896 /* ESSymbolLike */ && t & 512 /* ESSymbol */) return true;
|
|
63740
|
+
if (s & 65536 /* Enum */ && t & 65536 /* Enum */ && source.symbol.escapedName === target.symbol.escapedName && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
63741
|
+
if (s & 32768 /* EnumLiteral */ && t & 32768 /* EnumLiteral */) {
|
|
63743
63742
|
if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
63744
|
-
if (s &
|
|
63743
|
+
if (s & 15360 /* Literal */ && t & 15360 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
63745
63744
|
}
|
|
63746
|
-
if (s &
|
|
63747
|
-
if (s &
|
|
63745
|
+
if (s & 4 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (4 /* Undefined */ | 16 /* Void */))) return true;
|
|
63746
|
+
if (s & 8 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 8 /* Null */)) return true;
|
|
63748
63747
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(getObjectFlags(source) & 8192 /* FreshLiteral */))) return true;
|
|
63749
63748
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
63750
63749
|
if (s & 1 /* Any */) return true;
|
|
63751
|
-
if (s &
|
|
63752
|
-
if (s &
|
|
63750
|
+
if (s & 64 /* Number */ && (t & 65536 /* Enum */ || t & 2048 /* NumberLiteral */ && t & 32768 /* EnumLiteral */)) return true;
|
|
63751
|
+
if (s & 2048 /* NumberLiteral */ && !(s & 32768 /* EnumLiteral */) && (t & 65536 /* Enum */ || t & 2048 /* NumberLiteral */ && t & 32768 /* EnumLiteral */ && source.value === target.value)) return true;
|
|
63753
63752
|
if (isUnknownLikeUnionType(target)) return true;
|
|
63754
63753
|
}
|
|
63755
63754
|
return false;
|
|
@@ -63770,7 +63769,7 @@ function createTypeChecker(host) {
|
|
|
63770
63769
|
}
|
|
63771
63770
|
} else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
|
|
63772
63771
|
if (source.flags !== target.flags) return false;
|
|
63773
|
-
if (source.flags &
|
|
63772
|
+
if (source.flags & 67240959 /* Singleton */) return true;
|
|
63774
63773
|
}
|
|
63775
63774
|
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63776
63775
|
const related = relation.get(getRelationKey(
|
|
@@ -63824,7 +63823,7 @@ function createTypeChecker(host) {
|
|
|
63824
63823
|
let hasNullableOrEmpty = false;
|
|
63825
63824
|
for (const t of type.types) {
|
|
63826
63825
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
63827
|
-
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags &
|
|
63826
|
+
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 12 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
63828
63827
|
if (hasInstantiable && hasNullableOrEmpty) return true;
|
|
63829
63828
|
}
|
|
63830
63829
|
return false;
|
|
@@ -64094,7 +64093,7 @@ function createTypeChecker(host) {
|
|
|
64094
64093
|
} else if (exactOptionalPropertyTypes && getExactOptionalUnassignableProperties(source2, target2).length) {
|
|
64095
64094
|
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;
|
|
64096
64095
|
} else {
|
|
64097
|
-
if (source2.flags &
|
|
64096
|
+
if (source2.flags & 1024 /* StringLiteral */ && target2.flags & 1048576 /* Union */) {
|
|
64098
64097
|
const suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source2, target2);
|
|
64099
64098
|
if (suggestedType) {
|
|
64100
64099
|
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType));
|
|
@@ -64163,7 +64162,7 @@ function createTypeChecker(host) {
|
|
|
64163
64162
|
if (source2 === target2) return -1 /* True */;
|
|
64164
64163
|
if (relation === identityRelation) {
|
|
64165
64164
|
if (source2.flags !== target2.flags) return 0 /* False */;
|
|
64166
|
-
if (source2.flags &
|
|
64165
|
+
if (source2.flags & 67240959 /* Singleton */) return -1 /* True */;
|
|
64167
64166
|
traceUnionsOrIntersectionsTooLarge(source2, target2);
|
|
64168
64167
|
return recursiveTypeRelatedTo(
|
|
64169
64168
|
source2,
|
|
@@ -64177,10 +64176,10 @@ function createTypeChecker(host) {
|
|
|
64177
64176
|
if (source2.flags & 262144 /* TypeParameter */ && getConstraintOfType(source2) === target2) {
|
|
64178
64177
|
return -1 /* True */;
|
|
64179
64178
|
}
|
|
64180
|
-
if (source2.flags &
|
|
64179
|
+
if (source2.flags & 470417376 /* DefinitelyNonNullable */ && target2.flags & 1048576 /* Union */) {
|
|
64181
64180
|
const types = target2.types;
|
|
64182
|
-
const candidate = types.length === 2 && types[0].flags &
|
|
64183
|
-
if (candidate && !(candidate.flags &
|
|
64181
|
+
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;
|
|
64182
|
+
if (candidate && !(candidate.flags & 12 /* Nullable */)) {
|
|
64184
64183
|
target2 = getNormalizedType(
|
|
64185
64184
|
candidate,
|
|
64186
64185
|
/*writing*/
|
|
@@ -64482,9 +64481,9 @@ function createTypeChecker(host) {
|
|
|
64482
64481
|
if (containsType(targetTypes, source2)) {
|
|
64483
64482
|
return -1 /* True */;
|
|
64484
64483
|
}
|
|
64485
|
-
if (relation !== comparableRelation && getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags &
|
|
64484
|
+
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 */)) {
|
|
64486
64485
|
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
64487
|
-
const primitive = source2.flags &
|
|
64486
|
+
const primitive = source2.flags & 1024 /* StringLiteral */ ? stringType : source2.flags & 2048 /* NumberLiteral */ ? numberType : source2.flags & 8192 /* BigIntLiteral */ ? bigintType : void 0;
|
|
64488
64487
|
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
64489
64488
|
}
|
|
64490
64489
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
@@ -64579,8 +64578,8 @@ function createTypeChecker(host) {
|
|
|
64579
64578
|
return 0 /* False */;
|
|
64580
64579
|
}
|
|
64581
64580
|
function getUndefinedStrippedTargetIfNeeded(source2, target2) {
|
|
64582
|
-
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags &
|
|
64583
|
-
return extractTypesOfKind(target2, ~
|
|
64581
|
+
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags & 4 /* Undefined */) && target2.types[0].flags & 4 /* Undefined */) {
|
|
64582
|
+
return extractTypesOfKind(target2, ~4 /* Undefined */);
|
|
64584
64583
|
}
|
|
64585
64584
|
return target2;
|
|
64586
64585
|
}
|
|
@@ -64922,7 +64921,7 @@ function createTypeChecker(host) {
|
|
|
64922
64921
|
const mappedKeys = [];
|
|
64923
64922
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
64924
64923
|
modifiersType,
|
|
64925
|
-
|
|
64924
|
+
19456 /* StringOrNumberLiteralOrUnique */,
|
|
64926
64925
|
/*stringsOnly*/
|
|
64927
64926
|
false,
|
|
64928
64927
|
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
@@ -65181,7 +65180,7 @@ function createTypeChecker(host) {
|
|
|
65181
65180
|
if (includeOptional ? !(filteredByApplicability.flags & 131072 /* Never */) : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
|
|
65182
65181
|
const templateType2 = getTemplateTypeFromMappedType(target2);
|
|
65183
65182
|
const typeParameter = getTypeParameterFromMappedType(target2);
|
|
65184
|
-
const nonNullComponent = extractTypesOfKind(templateType2, ~
|
|
65183
|
+
const nonNullComponent = extractTypesOfKind(templateType2, ~12 /* Nullable */);
|
|
65185
65184
|
if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
|
|
65186
65185
|
if (result2 = isRelatedTo(source2, nonNullComponent.objectType, 2 /* Target */, reportErrors2)) {
|
|
65187
65186
|
return result2;
|
|
@@ -65842,7 +65841,7 @@ function createTypeChecker(host) {
|
|
|
65842
65841
|
for (const sourceProp of excludeProperties(getPropertiesOfType(source2), excludedProperties)) {
|
|
65843
65842
|
if (!getPropertyOfObjectType(target2, sourceProp.escapedName)) {
|
|
65844
65843
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
65845
|
-
if (!(sourceType.flags &
|
|
65844
|
+
if (!(sourceType.flags & 4 /* Undefined */)) {
|
|
65846
65845
|
if (reportErrors2) {
|
|
65847
65846
|
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target2));
|
|
65848
65847
|
}
|
|
@@ -66070,9 +66069,9 @@ function createTypeChecker(host) {
|
|
|
66070
66069
|
if (isIgnoredJsxProperty(source2, prop)) {
|
|
66071
66070
|
continue;
|
|
66072
66071
|
}
|
|
66073
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
66072
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */), keyType)) {
|
|
66074
66073
|
const propType = getNonMissingTypeOfSymbol(prop);
|
|
66075
|
-
const type = exactOptionalPropertyTypes || propType.flags &
|
|
66074
|
+
const type = exactOptionalPropertyTypes || propType.flags & 4 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) ? propType : getTypeWithFacts(propType, 524288 /* NEUndefined */);
|
|
66076
66075
|
const related = isRelatedTo(
|
|
66077
66076
|
type,
|
|
66078
66077
|
targetInfo.type,
|
|
@@ -66186,7 +66185,7 @@ function createTypeChecker(host) {
|
|
|
66186
66185
|
}
|
|
66187
66186
|
}
|
|
66188
66187
|
function typeCouldHaveTopLevelSingletonTypes(type) {
|
|
66189
|
-
if (type.flags &
|
|
66188
|
+
if (type.flags & 256 /* Boolean */) {
|
|
66190
66189
|
return false;
|
|
66191
66190
|
}
|
|
66192
66191
|
if (type.flags & 3145728 /* UnionOrIntersection */) {
|
|
@@ -66205,7 +66204,7 @@ function createTypeChecker(host) {
|
|
|
66205
66204
|
return getPropertiesOfType(target).filter((targetProp) => isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)));
|
|
66206
66205
|
}
|
|
66207
66206
|
function isExactOptionalPropertyMismatch(source, target) {
|
|
66208
|
-
return !!source && !!target && maybeTypeOfKind(source,
|
|
66207
|
+
return !!source && !!target && maybeTypeOfKind(source, 4 /* Undefined */) && !!containsMissingType(target);
|
|
66209
66208
|
}
|
|
66210
66209
|
function getExactOptionalProperties(type) {
|
|
66211
66210
|
return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
|
|
@@ -66331,7 +66330,7 @@ function createTypeChecker(host) {
|
|
|
66331
66330
|
}
|
|
66332
66331
|
function hasCovariantVoidArgument(typeArguments, variances) {
|
|
66333
66332
|
for (let i = 0; i < variances.length; i++) {
|
|
66334
|
-
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags &
|
|
66333
|
+
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16 /* Void */) {
|
|
66335
66334
|
return true;
|
|
66336
66335
|
}
|
|
66337
66336
|
}
|
|
@@ -66488,7 +66487,7 @@ function createTypeChecker(host) {
|
|
|
66488
66487
|
function isPropertyIdenticalTo(sourceProp, targetProp) {
|
|
66489
66488
|
return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
|
|
66490
66489
|
}
|
|
66491
|
-
function compareProperties(sourceProp, targetProp,
|
|
66490
|
+
function compareProperties(sourceProp, targetProp, compareTypes2) {
|
|
66492
66491
|
if (sourceProp === targetProp) {
|
|
66493
66492
|
return -1 /* True */;
|
|
66494
66493
|
}
|
|
@@ -66509,7 +66508,7 @@ function createTypeChecker(host) {
|
|
|
66509
66508
|
if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
|
|
66510
66509
|
return 0 /* False */;
|
|
66511
66510
|
}
|
|
66512
|
-
return
|
|
66511
|
+
return compareTypes2(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
66513
66512
|
}
|
|
66514
66513
|
function isMatchingSignature(source, target, partialMatch) {
|
|
66515
66514
|
const sourceParameterCount = getParameterCount(source);
|
|
@@ -66526,7 +66525,7 @@ function createTypeChecker(host) {
|
|
|
66526
66525
|
}
|
|
66527
66526
|
return false;
|
|
66528
66527
|
}
|
|
66529
|
-
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes,
|
|
66528
|
+
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes2) {
|
|
66530
66529
|
if (source === target) {
|
|
66531
66530
|
return -1 /* True */;
|
|
66532
66531
|
}
|
|
@@ -66541,7 +66540,7 @@ function createTypeChecker(host) {
|
|
|
66541
66540
|
for (let i = 0; i < target.typeParameters.length; i++) {
|
|
66542
66541
|
const s = source.typeParameters[i];
|
|
66543
66542
|
const t = target.typeParameters[i];
|
|
66544
|
-
if (!(s === t ||
|
|
66543
|
+
if (!(s === t || compareTypes2(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes2(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
|
|
66545
66544
|
return 0 /* False */;
|
|
66546
66545
|
}
|
|
66547
66546
|
}
|
|
@@ -66558,7 +66557,7 @@ function createTypeChecker(host) {
|
|
|
66558
66557
|
if (sourceThisType) {
|
|
66559
66558
|
const targetThisType = getThisTypeOfSignature(target);
|
|
66560
66559
|
if (targetThisType) {
|
|
66561
|
-
const related =
|
|
66560
|
+
const related = compareTypes2(sourceThisType, targetThisType);
|
|
66562
66561
|
if (!related) {
|
|
66563
66562
|
return 0 /* False */;
|
|
66564
66563
|
}
|
|
@@ -66570,7 +66569,7 @@ function createTypeChecker(host) {
|
|
|
66570
66569
|
for (let i = 0; i < targetLen; i++) {
|
|
66571
66570
|
const s = getTypeAtPosition(source, i);
|
|
66572
66571
|
const t = getTypeAtPosition(target, i);
|
|
66573
|
-
const related =
|
|
66572
|
+
const related = compareTypes2(t, s);
|
|
66574
66573
|
if (!related) {
|
|
66575
66574
|
return 0 /* False */;
|
|
66576
66575
|
}
|
|
@@ -66579,12 +66578,12 @@ function createTypeChecker(host) {
|
|
|
66579
66578
|
if (!ignoreReturnTypes) {
|
|
66580
66579
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
66581
66580
|
const targetTypePredicate = getTypePredicateOfSignature(target);
|
|
66582
|
-
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate,
|
|
66581
|
+
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes2) : compareTypes2(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
|
66583
66582
|
}
|
|
66584
66583
|
return result;
|
|
66585
66584
|
}
|
|
66586
|
-
function compareTypePredicatesIdentical(source, target,
|
|
66587
|
-
return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
66585
|
+
function compareTypePredicatesIdentical(source, target, compareTypes2) {
|
|
66586
|
+
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 */;
|
|
66588
66587
|
}
|
|
66589
66588
|
function literalTypesWithSameBaseType(types) {
|
|
66590
66589
|
let commonBaseType;
|
|
@@ -66606,9 +66605,9 @@ function createTypeChecker(host) {
|
|
|
66606
66605
|
if (types.length === 1) {
|
|
66607
66606
|
return types[0];
|
|
66608
66607
|
}
|
|
66609
|
-
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags &
|
|
66608
|
+
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags & 12 /* Nullable */))) : types;
|
|
66610
66609
|
const superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? getUnionType(primaryTypes) : reduceLeft(primaryTypes, (s, t) => isTypeSubtypeOf(s, t) ? t : s);
|
|
66611
|
-
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) &
|
|
66610
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 12 /* Nullable */);
|
|
66612
66611
|
}
|
|
66613
66612
|
function getCommonSubtype(types) {
|
|
66614
66613
|
return reduceLeft(types, (s, t) => isTypeSubtypeOf(t, s) ? t : s);
|
|
@@ -66629,10 +66628,10 @@ function createTypeChecker(host) {
|
|
|
66629
66628
|
return isArrayType(type) ? getTypeArguments(type)[0] : void 0;
|
|
66630
66629
|
}
|
|
66631
66630
|
function isArrayLikeType(type) {
|
|
66632
|
-
return isArrayType(type) || !(type.flags &
|
|
66631
|
+
return isArrayType(type) || !(type.flags & 12 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType);
|
|
66633
66632
|
}
|
|
66634
66633
|
function isMutableArrayLikeType(type) {
|
|
66635
|
-
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ |
|
|
66634
|
+
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ | 12 /* Nullable */)) && isTypeAssignableTo(type, anyArrayType);
|
|
66636
66635
|
}
|
|
66637
66636
|
function getSingleBaseForNonAugmentingSubtype(type) {
|
|
66638
66637
|
if (!(getObjectFlags(type) & 4 /* Reference */) || !(getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
@@ -66672,7 +66671,7 @@ function createTypeChecker(host) {
|
|
|
66672
66671
|
}
|
|
66673
66672
|
function isTupleLikeType(type) {
|
|
66674
66673
|
let lengthType;
|
|
66675
|
-
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags &
|
|
66674
|
+
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags & 2048 /* NumberLiteral */));
|
|
66676
66675
|
}
|
|
66677
66676
|
function isArrayOrTupleLikeType(type) {
|
|
66678
66677
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
@@ -66688,10 +66687,10 @@ function createTypeChecker(host) {
|
|
|
66688
66687
|
return void 0;
|
|
66689
66688
|
}
|
|
66690
66689
|
function isNeitherUnitTypeNorNever(type) {
|
|
66691
|
-
return !(type.flags & (
|
|
66690
|
+
return !(type.flags & (97292 /* Unit */ | 131072 /* Never */));
|
|
66692
66691
|
}
|
|
66693
66692
|
function isUnitType(type) {
|
|
66694
|
-
return !!(type.flags &
|
|
66693
|
+
return !!(type.flags & 97292 /* Unit */);
|
|
66695
66694
|
}
|
|
66696
66695
|
function isUnitLikeType(type) {
|
|
66697
66696
|
const t = getBaseConstraintOrType(type);
|
|
@@ -66701,23 +66700,23 @@ function createTypeChecker(host) {
|
|
|
66701
66700
|
return type.flags & 2097152 /* Intersection */ ? find(type.types, isUnitType) || type : type;
|
|
66702
66701
|
}
|
|
66703
66702
|
function isLiteralType(type) {
|
|
66704
|
-
return type.flags &
|
|
66703
|
+
return type.flags & 256 /* Boolean */ ? true : type.flags & 1048576 /* Union */ ? type.flags & 32768 /* EnumLiteral */ ? true : every(type.types, isUnitType) : isUnitType(type);
|
|
66705
66704
|
}
|
|
66706
66705
|
function getBaseTypeOfLiteralType(type) {
|
|
66707
|
-
return type.flags &
|
|
66706
|
+
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;
|
|
66708
66707
|
}
|
|
66709
66708
|
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
66710
66709
|
const key = `B${getTypeId(type)}`;
|
|
66711
66710
|
return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
66712
66711
|
}
|
|
66713
66712
|
function getBaseTypeOfLiteralTypeForComparison(type) {
|
|
66714
|
-
return type.flags & (
|
|
66713
|
+
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;
|
|
66715
66714
|
}
|
|
66716
66715
|
function getWidenedLiteralType(type) {
|
|
66717
|
-
return type.flags &
|
|
66716
|
+
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;
|
|
66718
66717
|
}
|
|
66719
66718
|
function getWidenedUniqueESSymbolType(type) {
|
|
66720
|
-
return type.flags &
|
|
66719
|
+
return type.flags & 16384 /* UniqueESSymbol */ ? esSymbolType : type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type;
|
|
66721
66720
|
}
|
|
66722
66721
|
function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
|
|
66723
66722
|
if (!isLiteralOfContextualType(type, contextualType)) {
|
|
@@ -66794,11 +66793,11 @@ function createTypeChecker(host) {
|
|
|
66794
66793
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
66795
66794
|
}
|
|
66796
66795
|
function getDefinitelyFalsyPartOfType(type) {
|
|
66797
|
-
return type.flags &
|
|
66796
|
+
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;
|
|
66798
66797
|
}
|
|
66799
66798
|
function getNullableType(type, flags) {
|
|
66800
|
-
const missing = flags & ~type.flags & (
|
|
66801
|
-
return missing === 0 ? type : missing ===
|
|
66799
|
+
const missing = flags & ~type.flags & (4 /* Undefined */ | 8 /* Null */);
|
|
66800
|
+
return missing === 0 ? type : missing === 4 /* Undefined */ ? getUnionType([type, undefinedType]) : missing === 8 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]);
|
|
66802
66801
|
}
|
|
66803
66802
|
function getOptionalType(type, isProperty = false) {
|
|
66804
66803
|
Debug.assert(strictNullChecks);
|
|
@@ -66841,7 +66840,7 @@ function createTypeChecker(host) {
|
|
|
66841
66840
|
return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */);
|
|
66842
66841
|
}
|
|
66843
66842
|
function isCoercibleUnderDoubleEquals(source, target) {
|
|
66844
|
-
return (source.flags & (
|
|
66843
|
+
return (source.flags & (64 /* Number */ | 32 /* String */ | 4096 /* BooleanLiteral */)) !== 0 && (target.flags & (64 /* Number */ | 32 /* String */ | 256 /* Boolean */)) !== 0;
|
|
66845
66844
|
}
|
|
66846
66845
|
function isObjectTypeWithInferableIndex(type) {
|
|
66847
66846
|
const objectFlags = getObjectFlags(type);
|
|
@@ -66974,7 +66973,7 @@ function createTypeChecker(host) {
|
|
|
66974
66973
|
return type.widened;
|
|
66975
66974
|
}
|
|
66976
66975
|
let result;
|
|
66977
|
-
if (type.flags & (1 /* Any */ |
|
|
66976
|
+
if (type.flags & (1 /* Any */ | 12 /* Nullable */)) {
|
|
66978
66977
|
result = anyType;
|
|
66979
66978
|
} else if (isObjectLiteralType(type)) {
|
|
66980
66979
|
result = getWidenedTypeOfObjectLiteral(type, context);
|
|
@@ -66986,7 +66985,7 @@ function createTypeChecker(host) {
|
|
|
66986
66985
|
void 0,
|
|
66987
66986
|
type.types
|
|
66988
66987
|
);
|
|
66989
|
-
const widenedTypes = sameMap(type.types, (t) => t.flags &
|
|
66988
|
+
const widenedTypes = sameMap(type.types, (t) => t.flags & 12 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext));
|
|
66990
66989
|
result = getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */);
|
|
66991
66990
|
} else if (type.flags & 2097152 /* Intersection */) {
|
|
66992
66991
|
result = getIntersectionType(sameMap(type.types, getWidenedType));
|
|
@@ -67186,18 +67185,18 @@ function createTypeChecker(host) {
|
|
|
67186
67185
|
callback(getReturnTypeOfSignature(source), targetReturnType);
|
|
67187
67186
|
}
|
|
67188
67187
|
}
|
|
67189
|
-
function createInferenceContext(typeParameters, signature, flags,
|
|
67190
|
-
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags,
|
|
67188
|
+
function createInferenceContext(typeParameters, signature, flags, compareTypes2) {
|
|
67189
|
+
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes2 || compareTypesAssignable);
|
|
67191
67190
|
}
|
|
67192
67191
|
function cloneInferenceContext(context, extraFlags = 0) {
|
|
67193
67192
|
return context && createInferenceContextWorker(map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
|
|
67194
67193
|
}
|
|
67195
|
-
function createInferenceContextWorker(inferences, signature, flags,
|
|
67194
|
+
function createInferenceContextWorker(inferences, signature, flags, compareTypes2) {
|
|
67196
67195
|
const context = {
|
|
67197
67196
|
inferences,
|
|
67198
67197
|
signature,
|
|
67199
67198
|
flags,
|
|
67200
|
-
compareTypes,
|
|
67199
|
+
compareTypes: compareTypes2,
|
|
67201
67200
|
mapper: reportUnmeasurableMapper,
|
|
67202
67201
|
// initialize to a noop mapper so the context object is available, but the underlying object shape is right upon construction
|
|
67203
67202
|
nonFixingMapper: reportUnmeasurableMapper
|
|
@@ -67284,8 +67283,8 @@ function createTypeChecker(host) {
|
|
|
67284
67283
|
if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
|
|
67285
67284
|
return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
|
|
67286
67285
|
}
|
|
67287
|
-
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 &
|
|
67288
|
-
if (type.flags &
|
|
67286
|
+
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));
|
|
67287
|
+
if (type.flags & 3801101 /* ObjectFlagsType */) {
|
|
67289
67288
|
type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
67290
67289
|
}
|
|
67291
67290
|
return result;
|
|
@@ -67307,7 +67306,7 @@ function createTypeChecker(host) {
|
|
|
67307
67306
|
function createEmptyObjectTypeFromStringLiteral(type) {
|
|
67308
67307
|
const members = createSymbolTable();
|
|
67309
67308
|
forEachType(type, (t) => {
|
|
67310
|
-
if (!(t.flags &
|
|
67309
|
+
if (!(t.flags & 1024 /* StringLiteral */)) {
|
|
67311
67310
|
return;
|
|
67312
67311
|
}
|
|
67313
67312
|
const name = escapeLeadingUnderscores(t.value);
|
|
@@ -67319,7 +67318,7 @@ function createTypeChecker(host) {
|
|
|
67319
67318
|
}
|
|
67320
67319
|
members.set(name, literalProp);
|
|
67321
67320
|
});
|
|
67322
|
-
const indexInfos = type.flags &
|
|
67321
|
+
const indexInfos = type.flags & 32 /* String */ ? [createIndexInfo(
|
|
67323
67322
|
stringType,
|
|
67324
67323
|
emptyObjectType,
|
|
67325
67324
|
/*isReadonly*/
|
|
@@ -67421,7 +67420,7 @@ function createTypeChecker(host) {
|
|
|
67421
67420
|
yield targetProp;
|
|
67422
67421
|
} else if (matchDiscriminantProperties) {
|
|
67423
67422
|
const targetType = getTypeOfSymbol(targetProp);
|
|
67424
|
-
if (targetType.flags &
|
|
67423
|
+
if (targetType.flags & 97292 /* Unit */) {
|
|
67425
67424
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
67426
67425
|
if (!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) {
|
|
67427
67426
|
yield targetProp;
|
|
@@ -67484,7 +67483,7 @@ function createTypeChecker(host) {
|
|
|
67484
67483
|
if (target.flags & 1 /* Any */) {
|
|
67485
67484
|
return true;
|
|
67486
67485
|
}
|
|
67487
|
-
if (target.flags & (
|
|
67486
|
+
if (target.flags & (32 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
67488
67487
|
return isTypeAssignableTo(source, target);
|
|
67489
67488
|
}
|
|
67490
67489
|
if (target.flags & 268435456 /* StringMapping */) {
|
|
@@ -67502,20 +67501,20 @@ function createTypeChecker(host) {
|
|
|
67502
67501
|
if (target.flags & 2097152 /* Intersection */) {
|
|
67503
67502
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
67504
67503
|
}
|
|
67505
|
-
if (target.flags &
|
|
67504
|
+
if (target.flags & 32 /* String */ || isTypeAssignableTo(source, target)) {
|
|
67506
67505
|
return true;
|
|
67507
67506
|
}
|
|
67508
|
-
if (source.flags &
|
|
67507
|
+
if (source.flags & 1024 /* StringLiteral */) {
|
|
67509
67508
|
const value = source.value;
|
|
67510
|
-
return !!(target.flags &
|
|
67509
|
+
return !!(target.flags & 64 /* Number */ && isValidNumberString(
|
|
67511
67510
|
value,
|
|
67512
67511
|
/*roundTripOnly*/
|
|
67513
67512
|
false
|
|
67514
|
-
) || target.flags &
|
|
67513
|
+
) || target.flags & 128 /* BigInt */ && isValidBigIntString(
|
|
67515
67514
|
value,
|
|
67516
67515
|
/*roundTripOnly*/
|
|
67517
67516
|
false
|
|
67518
|
-
) || target.flags & (
|
|
67517
|
+
) || target.flags & (4096 /* BooleanLiteral */ | 12 /* Nullable */) && value === target.intrinsicName || target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(source, target) || target.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source, target));
|
|
67519
67518
|
}
|
|
67520
67519
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
67521
67520
|
const texts = source.texts;
|
|
@@ -67524,7 +67523,7 @@ function createTypeChecker(host) {
|
|
|
67524
67523
|
return false;
|
|
67525
67524
|
}
|
|
67526
67525
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
67527
|
-
return source.flags &
|
|
67526
|
+
return source.flags & 1024 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arrayIsEqualTo(source.texts, target.texts) ? map(source.types, (s, i) => {
|
|
67528
67527
|
return isTypeAssignableTo(getBaseConstraintOrType(s), getBaseConstraintOrType(target.types[i])) ? s : getStringLikeTypeForType(s);
|
|
67529
67528
|
}) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
|
|
67530
67529
|
}
|
|
@@ -67533,7 +67532,7 @@ function createTypeChecker(host) {
|
|
|
67533
67532
|
return !!inferences && every(inferences, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]));
|
|
67534
67533
|
}
|
|
67535
67534
|
function getStringLikeTypeForType(type) {
|
|
67536
|
-
return type.flags & (1 /* Any */ |
|
|
67535
|
+
return type.flags & (1 /* Any */ | 402654240 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
|
|
67537
67536
|
}
|
|
67538
67537
|
function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) {
|
|
67539
67538
|
const lastSourceIndex = sourceTexts.length - 1;
|
|
@@ -67728,7 +67727,7 @@ function createTypeChecker(host) {
|
|
|
67728
67727
|
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
|
|
67729
67728
|
} else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
|
|
67730
67729
|
inferFromContravariantTypes(source.type, target.type);
|
|
67731
|
-
} else if ((isLiteralType(source) || source.flags &
|
|
67730
|
+
} else if ((isLiteralType(source) || source.flags & 32 /* String */) && target.flags & 4194304 /* Index */) {
|
|
67732
67731
|
const empty = createEmptyObjectTypeFromStringLiteral(source);
|
|
67733
67732
|
inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
67734
67733
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
@@ -67983,29 +67982,29 @@ function createTypeChecker(host) {
|
|
|
67983
67982
|
for (let i = 0; i < types.length; i++) {
|
|
67984
67983
|
const source2 = matches ? matches[i] : neverType;
|
|
67985
67984
|
const target2 = types[i];
|
|
67986
|
-
if (source2.flags &
|
|
67985
|
+
if (source2.flags & 1024 /* StringLiteral */ && target2.flags & 8650752 /* TypeVariable */) {
|
|
67987
67986
|
const inferenceContext = getInferenceInfoForType(target2);
|
|
67988
67987
|
const constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : void 0;
|
|
67989
67988
|
if (constraint && !isTypeAny(constraint)) {
|
|
67990
67989
|
const constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
|
|
67991
67990
|
let allTypeFlags = reduceLeft(constraintTypes, (flags, t) => flags | t.flags, 0);
|
|
67992
|
-
if (!(allTypeFlags &
|
|
67991
|
+
if (!(allTypeFlags & 32 /* String */)) {
|
|
67993
67992
|
const str = source2.value;
|
|
67994
|
-
if (allTypeFlags &
|
|
67993
|
+
if (allTypeFlags & 67648 /* NumberLike */ && !isValidNumberString(
|
|
67995
67994
|
str,
|
|
67996
67995
|
/*roundTripOnly*/
|
|
67997
67996
|
true
|
|
67998
67997
|
)) {
|
|
67999
|
-
allTypeFlags &= ~
|
|
67998
|
+
allTypeFlags &= ~67648 /* NumberLike */;
|
|
68000
67999
|
}
|
|
68001
|
-
if (allTypeFlags &
|
|
68000
|
+
if (allTypeFlags & 8320 /* BigIntLike */ && !isValidBigIntString(
|
|
68002
68001
|
str,
|
|
68003
68002
|
/*roundTripOnly*/
|
|
68004
68003
|
true
|
|
68005
68004
|
)) {
|
|
68006
|
-
allTypeFlags &= ~
|
|
68005
|
+
allTypeFlags &= ~8320 /* BigIntLike */;
|
|
68007
68006
|
}
|
|
68008
|
-
const matchingType = reduceLeft(constraintTypes, (left, right) => !(right.flags & allTypeFlags) ? left : left.flags &
|
|
68007
|
+
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);
|
|
68009
68008
|
if (!(matchingType.flags & 131072 /* Never */)) {
|
|
68010
68009
|
inferFromTypes(matchingType, target2);
|
|
68011
68010
|
continue;
|
|
@@ -68165,7 +68164,7 @@ function createTypeChecker(host) {
|
|
|
68165
68164
|
for (const targetInfo of indexInfos) {
|
|
68166
68165
|
const propTypes = [];
|
|
68167
68166
|
for (const prop of getPropertiesOfType(source)) {
|
|
68168
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
68167
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) {
|
|
68169
68168
|
const propType = getTypeOfSymbol(prop);
|
|
68170
68169
|
propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType);
|
|
68171
68170
|
}
|
|
@@ -68189,7 +68188,7 @@ function createTypeChecker(host) {
|
|
|
68189
68188
|
}
|
|
68190
68189
|
}
|
|
68191
68190
|
function isTypeOrBaseIdenticalTo(s, t) {
|
|
68192
|
-
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags &
|
|
68191
|
+
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags & 32 /* String */ && s.flags & 1024 /* StringLiteral */ || t.flags & 64 /* Number */ && s.flags & 2048 /* NumberLiteral */);
|
|
68193
68192
|
}
|
|
68194
68193
|
function isTypeCloselyMatchedBy(s, t) {
|
|
68195
68194
|
return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
|
|
@@ -68441,7 +68440,7 @@ function createTypeChecker(host) {
|
|
|
68441
68440
|
return void 0;
|
|
68442
68441
|
}
|
|
68443
68442
|
function tryGetNameFromType(type) {
|
|
68444
|
-
return type.flags &
|
|
68443
|
+
return type.flags & 16384 /* UniqueESSymbol */ ? type.escapedName : type.flags & 3072 /* StringOrNumberLiteral */ ? escapeLeadingUnderscores("" + type.value) : void 0;
|
|
68445
68444
|
}
|
|
68446
68445
|
function tryGetElementAccessExpressionName(node) {
|
|
68447
68446
|
return isStringOrNumericLiteralLike(node.argumentExpression) ? escapeLeadingUnderscores(node.argumentExpression.text) : isEntityNameExpression(node.argumentExpression) ? tryGetNameFromEntityNameExpression(node.argumentExpression) : void 0;
|
|
@@ -68620,7 +68619,7 @@ function createTypeChecker(host) {
|
|
|
68620
68619
|
}
|
|
68621
68620
|
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
68622
68621
|
const filteredType = filterType(declaredType, (t) => typeMaybeAssignableTo(assignedType, t));
|
|
68623
|
-
const reducedType = assignedType.flags &
|
|
68622
|
+
const reducedType = assignedType.flags & 4096 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
68624
68623
|
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
68625
68624
|
}
|
|
68626
68625
|
function isFunctionObjectType(type) {
|
|
@@ -68641,31 +68640,31 @@ function createTypeChecker(host) {
|
|
|
68641
68640
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
68642
68641
|
}
|
|
68643
68642
|
const flags = type.flags;
|
|
68644
|
-
if (flags & (
|
|
68643
|
+
if (flags & (32 /* String */ | 268435456 /* StringMapping */)) {
|
|
68645
68644
|
return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
|
|
68646
68645
|
}
|
|
68647
|
-
if (flags & (
|
|
68648
|
-
const isEmpty = flags &
|
|
68646
|
+
if (flags & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) {
|
|
68647
|
+
const isEmpty = flags & 1024 /* StringLiteral */ && type.value === "";
|
|
68649
68648
|
return strictNullChecks ? isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
|
|
68650
68649
|
}
|
|
68651
|
-
if (flags & (
|
|
68650
|
+
if (flags & (64 /* Number */ | 65536 /* Enum */)) {
|
|
68652
68651
|
return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */;
|
|
68653
68652
|
}
|
|
68654
|
-
if (flags &
|
|
68653
|
+
if (flags & 2048 /* NumberLiteral */) {
|
|
68655
68654
|
const isZero = type.value === 0;
|
|
68656
68655
|
return strictNullChecks ? isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */;
|
|
68657
68656
|
}
|
|
68658
|
-
if (flags &
|
|
68657
|
+
if (flags & 128 /* BigInt */) {
|
|
68659
68658
|
return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */;
|
|
68660
68659
|
}
|
|
68661
|
-
if (flags &
|
|
68660
|
+
if (flags & 8192 /* BigIntLiteral */) {
|
|
68662
68661
|
const isZero = isZeroBigInt(type);
|
|
68663
68662
|
return strictNullChecks ? isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */;
|
|
68664
68663
|
}
|
|
68665
|
-
if (flags &
|
|
68664
|
+
if (flags & 256 /* Boolean */) {
|
|
68666
68665
|
return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */;
|
|
68667
68666
|
}
|
|
68668
|
-
if (flags &
|
|
68667
|
+
if (flags & 4352 /* BooleanLike */) {
|
|
68669
68668
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
68670
68669
|
}
|
|
68671
68670
|
if (flags & 524288 /* Object */) {
|
|
@@ -68675,16 +68674,16 @@ function createTypeChecker(host) {
|
|
|
68675
68674
|
}
|
|
68676
68675
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
68677
68676
|
}
|
|
68678
|
-
if (flags &
|
|
68677
|
+
if (flags & 16 /* Void */) {
|
|
68679
68678
|
return 9830144 /* VoidFacts */;
|
|
68680
68679
|
}
|
|
68681
|
-
if (flags &
|
|
68680
|
+
if (flags & 4 /* Undefined */) {
|
|
68682
68681
|
return 26607360 /* UndefinedFacts */;
|
|
68683
68682
|
}
|
|
68684
|
-
if (flags &
|
|
68683
|
+
if (flags & 8 /* Null */) {
|
|
68685
68684
|
return 42917664 /* NullFacts */;
|
|
68686
68685
|
}
|
|
68687
|
-
if (flags &
|
|
68686
|
+
if (flags & 16896 /* ESSymbolLike */) {
|
|
68688
68687
|
return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
|
|
68689
68688
|
}
|
|
68690
68689
|
if (flags & 67108864 /* NonPrimitive */) {
|
|
@@ -68907,7 +68906,7 @@ function createTypeChecker(host) {
|
|
|
68907
68906
|
}
|
|
68908
68907
|
return true;
|
|
68909
68908
|
}
|
|
68910
|
-
if (source.flags &
|
|
68909
|
+
if (source.flags & 98304 /* EnumLike */ && getBaseTypeOfEnumLikeType(source) === target) {
|
|
68911
68910
|
return true;
|
|
68912
68911
|
}
|
|
68913
68912
|
return containsType(target.types, source);
|
|
@@ -68992,8 +68991,8 @@ function createTypeChecker(host) {
|
|
|
68992
68991
|
return filterType(type, (t) => (t.flags & kind) !== 0);
|
|
68993
68992
|
}
|
|
68994
68993
|
function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
|
|
68995
|
-
if (maybeTypeOfKind(typeWithPrimitives,
|
|
68996
|
-
return mapType(typeWithPrimitives, (t) => t.flags &
|
|
68994
|
+
if (maybeTypeOfKind(typeWithPrimitives, 32 /* String */ | 134217728 /* TemplateLiteral */ | 64 /* Number */ | 128 /* BigInt */) && maybeTypeOfKind(typeWithLiterals, 1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 2048 /* NumberLiteral */ | 8192 /* BigIntLiteral */)) {
|
|
68995
|
+
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);
|
|
68997
68996
|
}
|
|
68998
68997
|
return typeWithPrimitives;
|
|
68999
68998
|
}
|
|
@@ -69048,7 +69047,7 @@ function createTypeChecker(host) {
|
|
|
69048
69047
|
const root = getReferenceRoot(node);
|
|
69049
69048
|
const parent = root.parent;
|
|
69050
69049
|
const isLengthPushOrUnshift = isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || parent.parent.kind === 213 /* CallExpression */ && isIdentifier(parent.name) && isPushOrUnshiftIdentifier(parent.name));
|
|
69051
|
-
const isElementAssignment = parent.kind === 212 /* ElementAccessExpression */ && parent.expression === root && parent.parent.kind === 226 /* BinaryExpression */ && parent.parent.operatorToken.kind === 64 /* EqualsToken */ && parent.parent.left === parent && !isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression),
|
|
69050
|
+
const isElementAssignment = parent.kind === 212 /* ElementAccessExpression */ && parent.expression === root && parent.parent.kind === 226 /* BinaryExpression */ && parent.parent.operatorToken.kind === 64 /* EqualsToken */ && parent.parent.left === parent && !isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 67648 /* NumberLike */);
|
|
69052
69051
|
return isLengthPushOrUnshift || isElementAssignment;
|
|
69053
69052
|
}
|
|
69054
69053
|
function isDeclarationWithExplicitTypeAnnotation(node) {
|
|
@@ -69536,7 +69535,7 @@ function createTypeChecker(host) {
|
|
|
69536
69535
|
}
|
|
69537
69536
|
} else {
|
|
69538
69537
|
const indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
|
|
69539
|
-
if (isTypeAssignableToKind(indexType,
|
|
69538
|
+
if (isTypeAssignableToKind(indexType, 67648 /* NumberLike */)) {
|
|
69540
69539
|
evolvedType2 = addEvolvingArrayElementType(evolvedType2, node.right);
|
|
69541
69540
|
}
|
|
69542
69541
|
}
|
|
@@ -69574,9 +69573,9 @@ function createTypeChecker(host) {
|
|
|
69574
69573
|
} else {
|
|
69575
69574
|
if (strictNullChecks) {
|
|
69576
69575
|
if (optionalChainContainsReference(expr, reference)) {
|
|
69577
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (
|
|
69576
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (4 /* Undefined */ | 131072 /* Never */)));
|
|
69578
69577
|
} else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
|
|
69579
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags &
|
|
69578
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags & 1024 /* StringLiteral */ && t.value === "undefined"));
|
|
69580
69579
|
}
|
|
69581
69580
|
}
|
|
69582
69581
|
const access = getDiscriminantPropertyAccess(expr, type);
|
|
@@ -69750,7 +69749,7 @@ function createTypeChecker(host) {
|
|
|
69750
69749
|
return type;
|
|
69751
69750
|
}
|
|
69752
69751
|
const optionalChain = isOptionalChain(access);
|
|
69753
|
-
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type,
|
|
69752
|
+
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type, 12 /* Nullable */);
|
|
69754
69753
|
let propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName);
|
|
69755
69754
|
if (!propType) {
|
|
69756
69755
|
return type;
|
|
@@ -69972,7 +69971,7 @@ function createTypeChecker(host) {
|
|
|
69972
69971
|
}
|
|
69973
69972
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
69974
69973
|
const equalsOperator = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
69975
|
-
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ?
|
|
69974
|
+
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ? 12 /* Nullable */ : 4 /* Undefined */;
|
|
69976
69975
|
const valueType = getTypeOfExpression(value);
|
|
69977
69976
|
const removeNullable = equalsOperator !== assumeTrue && everyType(valueType, (t) => !!(t.flags & nullableFlags)) || equalsOperator === assumeTrue && everyType(valueType, (t) => !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)));
|
|
69978
69977
|
return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
|
|
@@ -69986,11 +69985,11 @@ function createTypeChecker(host) {
|
|
|
69986
69985
|
}
|
|
69987
69986
|
const valueType = getTypeOfExpression(value);
|
|
69988
69987
|
const doubleEquals = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */;
|
|
69989
|
-
if (valueType.flags &
|
|
69988
|
+
if (valueType.flags & 12 /* Nullable */) {
|
|
69990
69989
|
if (!strictNullChecks) {
|
|
69991
69990
|
return type;
|
|
69992
69991
|
}
|
|
69993
|
-
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags &
|
|
69992
|
+
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 8 /* Null */ ? assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
|
|
69994
69993
|
return getAdjustedTypeWithFacts(type, facts);
|
|
69995
69994
|
}
|
|
69996
69995
|
if (assumeTrue) {
|
|
@@ -70065,7 +70064,7 @@ function createTypeChecker(host) {
|
|
|
70065
70064
|
if (!hasDefaultClause) {
|
|
70066
70065
|
return caseType;
|
|
70067
70066
|
}
|
|
70068
|
-
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags &
|
|
70067
|
+
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags & 4 /* Undefined */ ? undefinedType : getRegularTypeOfLiteralType(extractUnitType(t)))));
|
|
70069
70068
|
return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
|
|
70070
70069
|
}
|
|
70071
70070
|
function narrowTypeByTypeName(type, typeName) {
|
|
@@ -70556,10 +70555,10 @@ function createTypeChecker(host) {
|
|
|
70556
70555
|
return parent.kind === 211 /* PropertyAccessExpression */ || parent.kind === 166 /* QualifiedName */ || parent.kind === 213 /* CallExpression */ && parent.expression === node || parent.kind === 214 /* NewExpression */ && parent.expression === node || parent.kind === 212 /* ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
70557
70556
|
}
|
|
70558
70557
|
function isGenericTypeWithUnionConstraint(type) {
|
|
70559
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (
|
|
70558
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (12 /* Nullable */ | 1048576 /* Union */));
|
|
70560
70559
|
}
|
|
70561
70560
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
70562
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type),
|
|
70561
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 12 /* Nullable */));
|
|
70563
70562
|
}
|
|
70564
70563
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
70565
70564
|
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 32 /* RestBindingElement */ ? getContextualType(node, 8 /* SkipBindingPatterns */) : getContextualType(
|
|
@@ -71118,7 +71117,7 @@ function createTypeChecker(host) {
|
|
|
71118
71117
|
flowContainer = getControlFlowContainer(flowContainer);
|
|
71119
71118
|
}
|
|
71120
71119
|
const isNeverInitialized = immediateDeclaration && isVariableDeclaration(immediateDeclaration) && !immediateDeclaration.initializer && !immediateDeclaration.exclamationToken && isMutableLocalVariableDeclaration(immediateDeclaration) && !isSymbolAssignedDefinitely(symbol);
|
|
71121
|
-
const assumeInitialized = isParameter2 || isAlias || isOuterVariable && !isNeverInitialized || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ |
|
|
71120
|
+
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 */;
|
|
71122
71121
|
const initialType = isAutomaticTypeInNonNull ? undefinedType : assumeInitialized ? isParameter2 ? removeOptionalityFromDeclaredType(type, declaration) : type : typeIsAutomatic ? undefinedType : getOptionalType(type);
|
|
71123
71122
|
const flowType = isAutomaticTypeInNonNull ? getNonNullableType(getFlowTypeOfReference(node, type, initialType, flowContainer)) : getFlowTypeOfReference(node, type, initialType, flowContainer);
|
|
71124
71123
|
if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
|
|
@@ -71806,7 +71805,7 @@ function createTypeChecker(host) {
|
|
|
71806
71805
|
const functionFlags = getFunctionFlags(functionDecl);
|
|
71807
71806
|
if (functionFlags & 1 /* Generator */) {
|
|
71808
71807
|
return filterType(returnType2, (t) => {
|
|
71809
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
71808
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || checkGeneratorInstantiationAssignabilityToReturnType(
|
|
71810
71809
|
t,
|
|
71811
71810
|
functionFlags,
|
|
71812
71811
|
/*errorNode*/
|
|
@@ -71816,7 +71815,7 @@ function createTypeChecker(host) {
|
|
|
71816
71815
|
}
|
|
71817
71816
|
if (functionFlags & 2 /* Async */) {
|
|
71818
71817
|
return filterType(returnType2, (t) => {
|
|
71819
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
71818
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || !!getAwaitedTypeOfPromise(t);
|
|
71820
71819
|
});
|
|
71821
71820
|
}
|
|
71822
71821
|
return returnType2;
|
|
@@ -72575,7 +72574,7 @@ function createTypeChecker(host) {
|
|
|
72575
72574
|
return getOrCreateTypeFromSignature(fakeSignature);
|
|
72576
72575
|
}
|
|
72577
72576
|
const tagType = checkExpressionCached(context.tagName);
|
|
72578
|
-
if (tagType.flags &
|
|
72577
|
+
if (tagType.flags & 1024 /* StringLiteral */) {
|
|
72579
72578
|
const result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
|
|
72580
72579
|
if (!result) {
|
|
72581
72580
|
return errorType;
|
|
@@ -72947,7 +72946,7 @@ function createTypeChecker(host) {
|
|
|
72947
72946
|
}
|
|
72948
72947
|
}
|
|
72949
72948
|
function isNumericComputedName(name) {
|
|
72950
|
-
return isTypeAssignableToKind(checkComputedPropertyName(name),
|
|
72949
|
+
return isTypeAssignableToKind(checkComputedPropertyName(name), 67648 /* NumberLike */);
|
|
72951
72950
|
}
|
|
72952
72951
|
function checkComputedPropertyName(node) {
|
|
72953
72952
|
const links = getNodeLinks(node.expression);
|
|
@@ -72965,7 +72964,7 @@ function createTypeChecker(host) {
|
|
|
72965
72964
|
getNodeLinks(node.parent.parent).flags |= 32768 /* BlockScopedBindingInLoop */;
|
|
72966
72965
|
}
|
|
72967
72966
|
}
|
|
72968
|
-
if (links.resolvedType.flags &
|
|
72967
|
+
if (links.resolvedType.flags & 12 /* Nullable */ || !isTypeAssignableToKind(links.resolvedType, 402654240 /* StringLike */ | 67648 /* NumberLike */ | 16896 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
|
|
72969
72968
|
error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
|
|
72970
72969
|
}
|
|
72971
72970
|
}
|
|
@@ -72979,7 +72978,7 @@ function createTypeChecker(host) {
|
|
|
72979
72978
|
function isSymbolWithSymbolName(symbol) {
|
|
72980
72979
|
var _a;
|
|
72981
72980
|
const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
|
|
72982
|
-
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name),
|
|
72981
|
+
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 512 /* ESSymbol */);
|
|
72983
72982
|
}
|
|
72984
72983
|
function isSymbolWithComputedName(symbol) {
|
|
72985
72984
|
var _a;
|
|
@@ -73135,7 +73134,7 @@ function createTypeChecker(host) {
|
|
|
73135
73134
|
Debug.assert(memberDecl.kind === 177 /* GetAccessor */ || memberDecl.kind === 178 /* SetAccessor */);
|
|
73136
73135
|
checkNodeDeferred(memberDecl);
|
|
73137
73136
|
}
|
|
73138
|
-
if (computedNameType && !(computedNameType.flags &
|
|
73137
|
+
if (computedNameType && !(computedNameType.flags & 19456 /* StringOrNumberLiteralOrUnique */)) {
|
|
73139
73138
|
if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
|
|
73140
73139
|
if (isTypeAssignableTo(computedNameType, numberType)) {
|
|
73141
73140
|
hasComputedNumberProperty = true;
|
|
@@ -73548,9 +73547,9 @@ function createTypeChecker(host) {
|
|
|
73548
73547
|
return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
|
|
73549
73548
|
}
|
|
73550
73549
|
function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
|
|
73551
|
-
if (elementType.flags &
|
|
73550
|
+
if (elementType.flags & 32 /* String */) {
|
|
73552
73551
|
return [anySignature];
|
|
73553
|
-
} else if (elementType.flags &
|
|
73552
|
+
} else if (elementType.flags & 1024 /* StringLiteral */) {
|
|
73554
73553
|
const intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
|
|
73555
73554
|
if (!intrinsicType) {
|
|
73556
73555
|
error(caller, Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
|
|
@@ -73932,7 +73931,7 @@ function createTypeChecker(host) {
|
|
|
73932
73931
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
73933
73932
|
reportError(node, facts);
|
|
73934
73933
|
const t = getNonNullableType(type);
|
|
73935
|
-
return t.flags & (
|
|
73934
|
+
return t.flags & (12 /* Nullable */ | 131072 /* Never */) ? errorType : t;
|
|
73936
73935
|
}
|
|
73937
73936
|
return type;
|
|
73938
73937
|
}
|
|
@@ -73941,7 +73940,7 @@ function createTypeChecker(host) {
|
|
|
73941
73940
|
}
|
|
73942
73941
|
function checkNonNullNonVoidType(type, node) {
|
|
73943
73942
|
const nonNullType = checkNonNullType(type, node);
|
|
73944
|
-
if (nonNullType.flags &
|
|
73943
|
+
if (nonNullType.flags & 16 /* Void */) {
|
|
73945
73944
|
if (isEntityNameExpression(node)) {
|
|
73946
73945
|
const nodeText = entityNameToString(node);
|
|
73947
73946
|
if (isIdentifier(node) && nodeText === "undefined") {
|
|
@@ -74488,7 +74487,7 @@ function createTypeChecker(host) {
|
|
|
74488
74487
|
return suggestion;
|
|
74489
74488
|
}
|
|
74490
74489
|
function getSuggestedTypeForNonexistentStringLiteralType(source, target) {
|
|
74491
|
-
const candidates = target.types.filter((type) => !!(type.flags &
|
|
74490
|
+
const candidates = target.types.filter((type) => !!(type.flags & 1024 /* StringLiteral */));
|
|
74492
74491
|
return getSpellingSuggestion(source.value, candidates, (type) => type.value);
|
|
74493
74492
|
}
|
|
74494
74493
|
function getSpellingSuggestionForName(name, symbols, meaning) {
|
|
@@ -74720,10 +74719,10 @@ function createTypeChecker(host) {
|
|
|
74720
74719
|
return findIndex(args, isSpreadArgument);
|
|
74721
74720
|
}
|
|
74722
74721
|
function acceptsVoid(t) {
|
|
74723
|
-
return !!(t.flags &
|
|
74722
|
+
return !!(t.flags & 16 /* Void */);
|
|
74724
74723
|
}
|
|
74725
74724
|
function acceptsVoidUndefinedUnknownOrAny(t) {
|
|
74726
|
-
return !!(t.flags & (
|
|
74725
|
+
return !!(t.flags & (16 /* Void */ | 4 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */));
|
|
74727
74726
|
}
|
|
74728
74727
|
function hasCorrectArity(node, args, signature, signatureHelpTrailingComma = false) {
|
|
74729
74728
|
if (isJsxOpeningFragment(node)) return true;
|
|
@@ -74822,8 +74821,8 @@ function createTypeChecker(host) {
|
|
|
74822
74821
|
}
|
|
74823
74822
|
return void 0;
|
|
74824
74823
|
}
|
|
74825
|
-
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext,
|
|
74826
|
-
const context = createInferenceContext(getTypeParametersForMapper(signature), signature, 0 /* None */,
|
|
74824
|
+
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes2) {
|
|
74825
|
+
const context = createInferenceContext(getTypeParametersForMapper(signature), signature, 0 /* None */, compareTypes2);
|
|
74827
74826
|
const restType = getEffectiveRestType(contextualSignature);
|
|
74828
74827
|
const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
|
|
74829
74828
|
const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
|
|
@@ -76558,10 +76557,10 @@ function createTypeChecker(host) {
|
|
|
76558
76557
|
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
|
|
76559
76558
|
}
|
|
76560
76559
|
const returnType = getReturnTypeOfSignature(signature);
|
|
76561
|
-
if (returnType.flags &
|
|
76560
|
+
if (returnType.flags & 16896 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) {
|
|
76562
76561
|
return getESSymbolLikeTypeForNode(walkUpParenthesizedExpressions(node.parent));
|
|
76563
76562
|
}
|
|
76564
|
-
if (node.kind === 213 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 244 /* ExpressionStatement */ && returnType.flags &
|
|
76563
|
+
if (node.kind === 213 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 244 /* ExpressionStatement */ && returnType.flags & 16 /* Void */ && getTypePredicateOfSignature(signature)) {
|
|
76565
76564
|
if (!isDottedName(node.expression)) {
|
|
76566
76565
|
error(node.expression, Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
|
|
76567
76566
|
} else if (!getEffectsSignature(node)) {
|
|
@@ -76651,7 +76650,7 @@ function createTypeChecker(host) {
|
|
|
76651
76650
|
for (let i = 2; i < node.arguments.length; ++i) {
|
|
76652
76651
|
checkExpressionCached(node.arguments[i]);
|
|
76653
76652
|
}
|
|
76654
|
-
if (specifierType.flags &
|
|
76653
|
+
if (specifierType.flags & 4 /* Undefined */ || specifierType.flags & 8 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) {
|
|
76655
76654
|
error(specifier, Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
|
|
76656
76655
|
}
|
|
76657
76656
|
if (optionsType) {
|
|
@@ -76660,7 +76659,7 @@ function createTypeChecker(host) {
|
|
|
76660
76659
|
true
|
|
76661
76660
|
);
|
|
76662
76661
|
if (importCallOptionsType !== emptyObjectType) {
|
|
76663
|
-
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType,
|
|
76662
|
+
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 4 /* Undefined */), node.arguments[1]);
|
|
76664
76663
|
}
|
|
76665
76664
|
}
|
|
76666
76665
|
const moduleSymbol = resolveExternalModuleName(node, specifier);
|
|
@@ -76783,6 +76782,11 @@ function createTypeChecker(host) {
|
|
|
76783
76782
|
if (file && fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) {
|
|
76784
76783
|
grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
|
|
76785
76784
|
}
|
|
76785
|
+
if (compilerOptions.erasableSyntaxOnly) {
|
|
76786
|
+
const start = node.type.pos - "<".length;
|
|
76787
|
+
const end = skipTrivia(file.text, node.type.end) + ">".length;
|
|
76788
|
+
diagnostics.add(createFileDiagnostic(file, start, end - start, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled));
|
|
76789
|
+
}
|
|
76786
76790
|
}
|
|
76787
76791
|
return checkAssertionWorker(node, checkMode);
|
|
76788
76792
|
}
|
|
@@ -77701,7 +77705,7 @@ function createTypeChecker(host) {
|
|
|
77701
77705
|
/*contextFlags*/
|
|
77702
77706
|
void 0
|
|
77703
77707
|
);
|
|
77704
|
-
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags &
|
|
77708
|
+
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 4 /* Undefined */ ? undefinedType : voidType;
|
|
77705
77709
|
return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
|
|
77706
77710
|
// Async function
|
|
77707
77711
|
returnType2
|
|
@@ -77947,10 +77951,10 @@ function createTypeChecker(host) {
|
|
|
77947
77951
|
true
|
|
77948
77952
|
);
|
|
77949
77953
|
const returnType = checkExpressionCached(expr);
|
|
77950
|
-
if (!(returnType.flags &
|
|
77954
|
+
if (!(returnType.flags & 256 /* Boolean */)) return void 0;
|
|
77951
77955
|
return forEach(func.parameters, (param, i) => {
|
|
77952
77956
|
const initType = getTypeOfSymbol(param.symbol);
|
|
77953
|
-
if (!initType || initType.flags &
|
|
77957
|
+
if (!initType || initType.flags & 256 /* Boolean */ || !isIdentifier(param.name) || isSymbolAssigned(param.symbol) || isRestParameter(param)) {
|
|
77954
77958
|
return;
|
|
77955
77959
|
}
|
|
77956
77960
|
const trueType2 = checkIfExpressionRefinesParameter(func, expr, param, initType);
|
|
@@ -77980,7 +77984,7 @@ function createTypeChecker(host) {
|
|
|
77980
77984
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
77981
77985
|
const functionFlags = getFunctionFlags(func);
|
|
77982
77986
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
77983
|
-
if (type && (maybeTypeOfKind(type,
|
|
77987
|
+
if (type && (maybeTypeOfKind(type, 16 /* Void */) || type.flags & (1 /* Any */ | 4 /* Undefined */))) {
|
|
77984
77988
|
return;
|
|
77985
77989
|
}
|
|
77986
77990
|
if (func.kind === 173 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 241 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -78352,11 +78356,11 @@ function createTypeChecker(host) {
|
|
|
78352
78356
|
case 41 /* MinusToken */:
|
|
78353
78357
|
case 55 /* TildeToken */:
|
|
78354
78358
|
checkNonNullType(operandType, node.operand);
|
|
78355
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
78359
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 16896 /* ESSymbolLike */)) {
|
|
78356
78360
|
error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator));
|
|
78357
78361
|
}
|
|
78358
78362
|
if (node.operator === 40 /* PlusToken */) {
|
|
78359
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
78363
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 8320 /* BigIntLike */)) {
|
|
78360
78364
|
error(node.operand, Diagnostics.Operator_0_cannot_be_applied_to_type_1, tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
|
|
78361
78365
|
}
|
|
78362
78366
|
return numberType;
|
|
@@ -78400,8 +78404,8 @@ function createTypeChecker(host) {
|
|
|
78400
78404
|
return getUnaryResultType(operandType);
|
|
78401
78405
|
}
|
|
78402
78406
|
function getUnaryResultType(operandType) {
|
|
78403
|
-
if (maybeTypeOfKind(operandType,
|
|
78404
|
-
return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType,
|
|
78407
|
+
if (maybeTypeOfKind(operandType, 8320 /* BigIntLike */)) {
|
|
78408
|
+
return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 67648 /* NumberLike */) ? numberOrBigIntType : bigintType;
|
|
78405
78409
|
}
|
|
78406
78410
|
return numberType;
|
|
78407
78411
|
}
|
|
@@ -78430,10 +78434,10 @@ function createTypeChecker(host) {
|
|
|
78430
78434
|
if (source.flags & kind) {
|
|
78431
78435
|
return true;
|
|
78432
78436
|
}
|
|
78433
|
-
if (strict && source.flags & (3 /* AnyOrUnknown */ |
|
|
78437
|
+
if (strict && source.flags & (3 /* AnyOrUnknown */ | 16 /* Void */ | 4 /* Undefined */ | 8 /* Null */)) {
|
|
78434
78438
|
return false;
|
|
78435
78439
|
}
|
|
78436
|
-
return !!(kind &
|
|
78440
|
+
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);
|
|
78437
78441
|
}
|
|
78438
78442
|
function allTypesAssignableToKind(source, kind, strict) {
|
|
78439
78443
|
return source.flags & 1048576 /* Union */ ? every(source.types, (subType) => allTypesAssignableToKind(subType, kind, strict)) : isTypeAssignableToKind(source, kind, strict);
|
|
@@ -78706,7 +78710,7 @@ function createTypeChecker(host) {
|
|
|
78706
78710
|
}
|
|
78707
78711
|
}
|
|
78708
78712
|
function isTypeEqualityComparableTo(source, target) {
|
|
78709
|
-
return (target.flags &
|
|
78713
|
+
return (target.flags & 12 /* Nullable */) !== 0 || isTypeComparableTo(source, target);
|
|
78710
78714
|
}
|
|
78711
78715
|
function createCheckBinaryExpression() {
|
|
78712
78716
|
const trampoline = createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState);
|
|
@@ -78957,7 +78961,7 @@ function createTypeChecker(host) {
|
|
|
78957
78961
|
leftType = checkNonNullType(leftType, left);
|
|
78958
78962
|
rightType = checkNonNullType(rightType, right);
|
|
78959
78963
|
let suggestedOperator;
|
|
78960
|
-
if (leftType.flags &
|
|
78964
|
+
if (leftType.flags & 4352 /* BooleanLike */ && rightType.flags & 4352 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
|
|
78961
78965
|
error(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
|
|
78962
78966
|
return numberType;
|
|
78963
78967
|
} else {
|
|
@@ -78977,7 +78981,7 @@ function createTypeChecker(host) {
|
|
|
78977
78981
|
);
|
|
78978
78982
|
let resultType2;
|
|
78979
78983
|
if (isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */) || // Or, if neither could be bigint, implicit coercion results in a number result
|
|
78980
|
-
!(maybeTypeOfKind(leftType,
|
|
78984
|
+
!(maybeTypeOfKind(leftType, 8320 /* BigIntLike */) || maybeTypeOfKind(rightType, 8320 /* BigIntLike */))) {
|
|
78981
78985
|
resultType2 = numberType;
|
|
78982
78986
|
} else if (bothAreBigIntLike(leftType, rightType)) {
|
|
78983
78987
|
switch (operator) {
|
|
@@ -79029,43 +79033,43 @@ function createTypeChecker(host) {
|
|
|
79029
79033
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
79030
79034
|
return silentNeverType;
|
|
79031
79035
|
}
|
|
79032
|
-
if (!isTypeAssignableToKind(leftType,
|
|
79036
|
+
if (!isTypeAssignableToKind(leftType, 402654240 /* StringLike */) && !isTypeAssignableToKind(rightType, 402654240 /* StringLike */)) {
|
|
79033
79037
|
leftType = checkNonNullType(leftType, left);
|
|
79034
79038
|
rightType = checkNonNullType(rightType, right);
|
|
79035
79039
|
}
|
|
79036
79040
|
let resultType;
|
|
79037
79041
|
if (isTypeAssignableToKind(
|
|
79038
79042
|
leftType,
|
|
79039
|
-
|
|
79043
|
+
67648 /* NumberLike */,
|
|
79040
79044
|
/*strict*/
|
|
79041
79045
|
true
|
|
79042
79046
|
) && isTypeAssignableToKind(
|
|
79043
79047
|
rightType,
|
|
79044
|
-
|
|
79048
|
+
67648 /* NumberLike */,
|
|
79045
79049
|
/*strict*/
|
|
79046
79050
|
true
|
|
79047
79051
|
)) {
|
|
79048
79052
|
resultType = numberType;
|
|
79049
79053
|
} else if (isTypeAssignableToKind(
|
|
79050
79054
|
leftType,
|
|
79051
|
-
|
|
79055
|
+
8320 /* BigIntLike */,
|
|
79052
79056
|
/*strict*/
|
|
79053
79057
|
true
|
|
79054
79058
|
) && isTypeAssignableToKind(
|
|
79055
79059
|
rightType,
|
|
79056
|
-
|
|
79060
|
+
8320 /* BigIntLike */,
|
|
79057
79061
|
/*strict*/
|
|
79058
79062
|
true
|
|
79059
79063
|
)) {
|
|
79060
79064
|
resultType = bigintType;
|
|
79061
79065
|
} else if (isTypeAssignableToKind(
|
|
79062
79066
|
leftType,
|
|
79063
|
-
|
|
79067
|
+
402654240 /* StringLike */,
|
|
79064
79068
|
/*strict*/
|
|
79065
79069
|
true
|
|
79066
79070
|
) || isTypeAssignableToKind(
|
|
79067
79071
|
rightType,
|
|
79068
|
-
|
|
79072
|
+
402654240 /* StringLike */,
|
|
79069
79073
|
/*strict*/
|
|
79070
79074
|
true
|
|
79071
79075
|
)) {
|
|
@@ -79077,7 +79081,7 @@ function createTypeChecker(host) {
|
|
|
79077
79081
|
return resultType;
|
|
79078
79082
|
}
|
|
79079
79083
|
if (!resultType) {
|
|
79080
|
-
const closeEnoughKind =
|
|
79084
|
+
const closeEnoughKind = 67648 /* NumberLike */ | 8320 /* BigIntLike */ | 402654240 /* StringLike */ | 3 /* AnyOrUnknown */;
|
|
79081
79085
|
reportOperatorError(
|
|
79082
79086
|
(left2, right2) => isTypeAssignableToKind(left2, closeEnoughKind) && isTypeAssignableToKind(right2, closeEnoughKind)
|
|
79083
79087
|
);
|
|
@@ -79174,7 +79178,7 @@ function createTypeChecker(host) {
|
|
|
79174
79178
|
return Debug.fail();
|
|
79175
79179
|
}
|
|
79176
79180
|
function bothAreBigIntLike(left2, right2) {
|
|
79177
|
-
return isTypeAssignableToKind(left2,
|
|
79181
|
+
return isTypeAssignableToKind(left2, 8320 /* BigIntLike */) && isTypeAssignableToKind(right2, 8320 /* BigIntLike */);
|
|
79178
79182
|
}
|
|
79179
79183
|
function checkAssignmentDeclaration(kind, rightType2) {
|
|
79180
79184
|
if (kind === 2 /* ModuleExports */) {
|
|
@@ -79204,7 +79208,7 @@ function createTypeChecker(host) {
|
|
|
79204
79208
|
(isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
|
|
79205
79209
|
}
|
|
79206
79210
|
function checkForDisallowedESSymbolOperand(operator2) {
|
|
79207
|
-
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType,
|
|
79211
|
+
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 16896 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 16896 /* ESSymbolLike */) ? right : void 0;
|
|
79208
79212
|
if (offendingSymbolOperand) {
|
|
79209
79213
|
error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator2));
|
|
79210
79214
|
return false;
|
|
@@ -79243,7 +79247,7 @@ function createTypeChecker(host) {
|
|
|
79243
79247
|
}
|
|
79244
79248
|
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)) {
|
|
79245
79249
|
let headMessage;
|
|
79246
|
-
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType,
|
|
79250
|
+
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 4 /* Undefined */)) {
|
|
79247
79251
|
const target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText);
|
|
79248
79252
|
if (isExactOptionalPropertyMismatch(valueType, target)) {
|
|
79249
79253
|
headMessage = Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target;
|
|
@@ -79432,7 +79436,7 @@ function createTypeChecker(host) {
|
|
|
79432
79436
|
const types = [];
|
|
79433
79437
|
for (const span of node.templateSpans) {
|
|
79434
79438
|
const type = checkExpression(span.expression);
|
|
79435
|
-
if (maybeTypeOfKindConsideringBaseConstraint(type,
|
|
79439
|
+
if (maybeTypeOfKindConsideringBaseConstraint(type, 16896 /* ESSymbolLike */)) {
|
|
79436
79440
|
error(span.expression, Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
|
|
79437
79441
|
}
|
|
79438
79442
|
texts.push(span.literal.text);
|
|
@@ -79452,7 +79456,7 @@ function createTypeChecker(host) {
|
|
|
79452
79456
|
return stringType;
|
|
79453
79457
|
}
|
|
79454
79458
|
function isTemplateLiteralContextualType(type) {
|
|
79455
|
-
return !!(type.flags & (
|
|
79459
|
+
return !!(type.flags & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402654240 /* StringLike */));
|
|
79456
79460
|
}
|
|
79457
79461
|
function getContextNode(node) {
|
|
79458
79462
|
if (isJsxAttributes(node) && !isJsxSelfClosingElement(node.parent)) {
|
|
@@ -79473,7 +79477,7 @@ function createTypeChecker(host) {
|
|
|
79473
79477
|
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
79474
79478
|
inferenceContext.intraExpressionInferenceSites = void 0;
|
|
79475
79479
|
}
|
|
79476
|
-
const result = maybeTypeOfKind(type,
|
|
79480
|
+
const result = maybeTypeOfKind(type, 15360 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(
|
|
79477
79481
|
contextualType,
|
|
79478
79482
|
node,
|
|
79479
79483
|
/*contextFlags*/
|
|
@@ -79617,9 +79621,9 @@ function createTypeChecker(host) {
|
|
|
79617
79621
|
}
|
|
79618
79622
|
if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
79619
79623
|
const constraint = getBaseConstraintOfType(contextualType) || unknownType;
|
|
79620
|
-
return maybeTypeOfKind(constraint,
|
|
79624
|
+
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);
|
|
79621
79625
|
}
|
|
79622
|
-
return !!(contextualType.flags & (
|
|
79626
|
+
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 */));
|
|
79623
79627
|
}
|
|
79624
79628
|
return false;
|
|
79625
79629
|
}
|
|
@@ -80720,18 +80724,6 @@ function createTypeChecker(host) {
|
|
|
80720
80724
|
}
|
|
80721
80725
|
function checkIndexedAccessIndexType(type, accessNode) {
|
|
80722
80726
|
if (!(type.flags & 8388608 /* IndexedAccess */)) {
|
|
80723
|
-
if (isIndexedAccessTypeNode(accessNode)) {
|
|
80724
|
-
const indexType2 = getTypeFromTypeNode(accessNode.indexType);
|
|
80725
|
-
const objectType2 = getTypeFromTypeNode(accessNode.objectType);
|
|
80726
|
-
const propertyName2 = getPropertyNameFromIndex(indexType2, accessNode);
|
|
80727
|
-
if (propertyName2) {
|
|
80728
|
-
const propertySymbol = forEachType(getApparentType(objectType2), (t) => getPropertyOfType(t, propertyName2));
|
|
80729
|
-
if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 6 /* NonPublicAccessibilityModifier */) {
|
|
80730
|
-
error(accessNode, Diagnostics.Private_or_protected_member_0_cannot_be_accessed_via_indexed_access, unescapeLeadingUnderscores(propertyName2));
|
|
80731
|
-
return errorType;
|
|
80732
|
-
}
|
|
80733
|
-
}
|
|
80734
|
-
}
|
|
80735
80727
|
return type;
|
|
80736
80728
|
}
|
|
80737
80729
|
const objectType = type.objectType;
|
|
@@ -80744,12 +80736,14 @@ function createTypeChecker(host) {
|
|
|
80744
80736
|
}
|
|
80745
80737
|
return type;
|
|
80746
80738
|
}
|
|
80747
|
-
|
|
80748
|
-
|
|
80749
|
-
|
|
80750
|
-
|
|
80751
|
-
|
|
80752
|
-
|
|
80739
|
+
if (isGenericObjectType(objectType)) {
|
|
80740
|
+
const propertyName = getPropertyNameFromIndex(indexType, accessNode);
|
|
80741
|
+
if (propertyName) {
|
|
80742
|
+
const propertySymbol = forEachType(getApparentType(objectType), (t) => getPropertyOfType(t, propertyName));
|
|
80743
|
+
if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 6 /* NonPublicAccessibilityModifier */) {
|
|
80744
|
+
error(accessNode, Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, unescapeLeadingUnderscores(propertyName));
|
|
80745
|
+
return errorType;
|
|
80746
|
+
}
|
|
80753
80747
|
}
|
|
80754
80748
|
}
|
|
80755
80749
|
error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
|
@@ -82490,7 +82484,7 @@ function createTypeChecker(host) {
|
|
|
82490
82484
|
return;
|
|
82491
82485
|
}
|
|
82492
82486
|
const type = location === condExpr2 ? condType : checkExpression(location);
|
|
82493
|
-
if (type.flags &
|
|
82487
|
+
if (type.flags & 32768 /* EnumLiteral */ && isPropertyAccessExpression(location) && (getNodeLinks(location.expression).resolvedSymbol ?? unknownSymbol).flags & 384 /* Enum */) {
|
|
82494
82488
|
error(location, Diagnostics.This_condition_will_always_return_0, !!type.value ? "true" : "false");
|
|
82495
82489
|
return;
|
|
82496
82490
|
}
|
|
@@ -82582,7 +82576,7 @@ function createTypeChecker(host) {
|
|
|
82582
82576
|
checkSourceElement(node.statement);
|
|
82583
82577
|
}
|
|
82584
82578
|
function checkTruthinessOfType(type, node) {
|
|
82585
|
-
if (type.flags &
|
|
82579
|
+
if (type.flags & 16 /* Void */) {
|
|
82586
82580
|
error(node, Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
|
|
82587
82581
|
} else {
|
|
82588
82582
|
const semantics = getSyntacticTruthySemantics(node);
|
|
@@ -82770,11 +82764,11 @@ function createTypeChecker(host) {
|
|
|
82770
82764
|
if (use & 4 /* AllowsStringInputFlag */) {
|
|
82771
82765
|
if (arrayType.flags & 1048576 /* Union */) {
|
|
82772
82766
|
const arrayTypes = inputType.types;
|
|
82773
|
-
const filteredTypes = filter(arrayTypes, (t) => !(t.flags &
|
|
82767
|
+
const filteredTypes = filter(arrayTypes, (t) => !(t.flags & 402654240 /* StringLike */));
|
|
82774
82768
|
if (filteredTypes !== arrayTypes) {
|
|
82775
82769
|
arrayType = getUnionType(filteredTypes, 2 /* Subtype */);
|
|
82776
82770
|
}
|
|
82777
|
-
} else if (arrayType.flags &
|
|
82771
|
+
} else if (arrayType.flags & 402654240 /* StringLike */) {
|
|
82778
82772
|
arrayType = neverType;
|
|
82779
82773
|
}
|
|
82780
82774
|
hasStringConstituent = arrayType !== inputType;
|
|
@@ -82799,7 +82793,7 @@ function createTypeChecker(host) {
|
|
|
82799
82793
|
}
|
|
82800
82794
|
const arrayElementType = getIndexTypeOfType(arrayType, numberType);
|
|
82801
82795
|
if (hasStringConstituent && arrayElementType) {
|
|
82802
|
-
if (arrayElementType.flags &
|
|
82796
|
+
if (arrayElementType.flags & 402654240 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) {
|
|
82803
82797
|
return stringType;
|
|
82804
82798
|
}
|
|
82805
82799
|
return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */);
|
|
@@ -82850,7 +82844,7 @@ function createTypeChecker(host) {
|
|
|
82850
82844
|
return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
|
|
82851
82845
|
}
|
|
82852
82846
|
function createIterationTypes(yieldType = neverType, returnType = neverType, nextType = unknownType) {
|
|
82853
|
-
if (yieldType.flags &
|
|
82847
|
+
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 */)) {
|
|
82854
82848
|
const id = getTypeListId([yieldType, returnType, nextType]);
|
|
82855
82849
|
let iterationTypes = iterationTypesCache.get(id);
|
|
82856
82850
|
if (!iterationTypes) {
|
|
@@ -83346,7 +83340,7 @@ function createTypeChecker(host) {
|
|
|
83346
83340
|
}
|
|
83347
83341
|
function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
|
|
83348
83342
|
const type = unwrapReturnType(returnType, getFunctionFlags(func));
|
|
83349
|
-
return !!(type && (maybeTypeOfKind(type,
|
|
83343
|
+
return !!(type && (maybeTypeOfKind(type, 16 /* Void */) || type.flags & (1 /* Any */ | 4 /* Undefined */)));
|
|
83350
83344
|
}
|
|
83351
83345
|
function checkReturnStatement(node) {
|
|
83352
83346
|
if (checkGrammarStatementInAmbientContext(node)) {
|
|
@@ -83543,7 +83537,7 @@ function createTypeChecker(host) {
|
|
|
83543
83537
|
if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) {
|
|
83544
83538
|
checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(
|
|
83545
83539
|
prop,
|
|
83546
|
-
|
|
83540
|
+
19456 /* StringOrNumberLiteralOrUnique */,
|
|
83547
83541
|
/*includeNonPublic*/
|
|
83548
83542
|
true
|
|
83549
83543
|
), getNonMissingTypeOfSymbol(prop));
|
|
@@ -85014,7 +85008,7 @@ function createTypeChecker(host) {
|
|
|
85014
85008
|
true
|
|
85015
85009
|
);
|
|
85016
85010
|
if (importAttributesType !== emptyObjectType) {
|
|
85017
|
-
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType,
|
|
85011
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 4 /* Undefined */), node);
|
|
85018
85012
|
}
|
|
85019
85013
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
85020
85014
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
@@ -86566,7 +86560,7 @@ function createTypeChecker(host) {
|
|
|
86566
86560
|
return getStringLiteralType(name.text);
|
|
86567
86561
|
case 167 /* ComputedPropertyName */:
|
|
86568
86562
|
const nameType = checkComputedPropertyName(name);
|
|
86569
|
-
return isTypeAssignableToKind(nameType,
|
|
86563
|
+
return isTypeAssignableToKind(nameType, 16896 /* ESSymbolLike */) ? nameType : stringType;
|
|
86570
86564
|
default:
|
|
86571
86565
|
return Debug.fail("Unsupported property name.");
|
|
86572
86566
|
}
|
|
@@ -87087,19 +87081,19 @@ function createTypeChecker(host) {
|
|
|
87087
87081
|
return isTypeOnly ? 11 /* ObjectType */ : 0 /* Unknown */;
|
|
87088
87082
|
} else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
87089
87083
|
return 11 /* ObjectType */;
|
|
87090
|
-
} else if (isTypeAssignableToKind(type,
|
|
87084
|
+
} else if (isTypeAssignableToKind(type, 16 /* Void */ | 12 /* Nullable */ | 131072 /* Never */)) {
|
|
87091
87085
|
return 2 /* VoidNullableOrNeverType */;
|
|
87092
|
-
} else if (isTypeAssignableToKind(type,
|
|
87086
|
+
} else if (isTypeAssignableToKind(type, 4352 /* BooleanLike */)) {
|
|
87093
87087
|
return 6 /* BooleanType */;
|
|
87094
|
-
} else if (isTypeAssignableToKind(type,
|
|
87088
|
+
} else if (isTypeAssignableToKind(type, 67648 /* NumberLike */)) {
|
|
87095
87089
|
return 3 /* NumberLikeType */;
|
|
87096
|
-
} else if (isTypeAssignableToKind(type,
|
|
87090
|
+
} else if (isTypeAssignableToKind(type, 8320 /* BigIntLike */)) {
|
|
87097
87091
|
return 4 /* BigIntLikeType */;
|
|
87098
|
-
} else if (isTypeAssignableToKind(type,
|
|
87092
|
+
} else if (isTypeAssignableToKind(type, 402654240 /* StringLike */)) {
|
|
87099
87093
|
return 5 /* StringLikeType */;
|
|
87100
87094
|
} else if (isTupleType(type)) {
|
|
87101
87095
|
return 7 /* ArrayLikeType */;
|
|
87102
|
-
} else if (isTypeAssignableToKind(type,
|
|
87096
|
+
} else if (isTypeAssignableToKind(type, 16896 /* ESSymbolLike */)) {
|
|
87103
87097
|
return 8 /* ESSymbolType */;
|
|
87104
87098
|
} else if (isFunctionType(type)) {
|
|
87105
87099
|
return 10 /* TypeWithCallSignature */;
|
|
@@ -87242,7 +87236,7 @@ function createTypeChecker(host) {
|
|
|
87242
87236
|
return false;
|
|
87243
87237
|
}
|
|
87244
87238
|
function literalTypeToNode(type, enclosing, tracker) {
|
|
87245
|
-
const enumResult = type.flags &
|
|
87239
|
+
const enumResult = type.flags & 98304 /* EnumLike */ ? nodeBuilder.symbolToExpression(
|
|
87246
87240
|
type.symbol,
|
|
87247
87241
|
111551 /* Value */,
|
|
87248
87242
|
enclosing,
|
|
@@ -88261,7 +88255,7 @@ function createTypeChecker(host) {
|
|
|
88261
88255
|
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
|
|
88262
88256
|
}
|
|
88263
88257
|
const type = getTypeFromTypeNode(parameter.type);
|
|
88264
|
-
if (someType(type, (t) => !!(t.flags &
|
|
88258
|
+
if (someType(type, (t) => !!(t.flags & 19456 /* StringOrNumberLiteralOrUnique */)) || isGenericType(type)) {
|
|
88265
88259
|
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);
|
|
88266
88260
|
}
|
|
88267
88261
|
if (!everyType(type, isValidIndexKeyType)) {
|
|
@@ -88792,7 +88786,7 @@ function createTypeChecker(host) {
|
|
|
88792
88786
|
}
|
|
88793
88787
|
function isSimpleLiteralEnumReference(expr) {
|
|
88794
88788
|
if ((isPropertyAccessExpression(expr) || isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression)) && isEntityNameExpression(expr.expression)) {
|
|
88795
|
-
return !!(checkExpressionCached(expr).flags &
|
|
88789
|
+
return !!(checkExpressionCached(expr).flags & 98304 /* EnumLike */);
|
|
88796
88790
|
}
|
|
88797
88791
|
}
|
|
88798
88792
|
function checkAmbientInitializer(node) {
|
|
@@ -89282,6 +89276,319 @@ function createTypeChecker(host) {
|
|
|
89282
89276
|
Debug.assert(specifier && nodeIsSynthesized(specifier) && specifier.text === "tslib", `Expected sourceFile.imports[0] to be the synthesized tslib import`);
|
|
89283
89277
|
return specifier;
|
|
89284
89278
|
}
|
|
89279
|
+
function compareSymbols(s1, s2) {
|
|
89280
|
+
if (s1 === s2) return 0;
|
|
89281
|
+
if (s1 === void 0) return 1;
|
|
89282
|
+
if (s2 === void 0) return -1;
|
|
89283
|
+
if (length(s1.declarations) !== 0 && length(s2.declarations) !== 0) {
|
|
89284
|
+
const r2 = compareNodes(s1.declarations[0], s2.declarations[0]);
|
|
89285
|
+
if (r2 !== 0) return r2;
|
|
89286
|
+
} else if (length(s1.declarations) !== 0) {
|
|
89287
|
+
return -1;
|
|
89288
|
+
} else if (length(s2.declarations) !== 0) {
|
|
89289
|
+
return 1;
|
|
89290
|
+
}
|
|
89291
|
+
const r = compareComparableValues(s1.escapedName, s2.escapedName);
|
|
89292
|
+
if (r !== 0) return r;
|
|
89293
|
+
return getSymbolId(s1) - getSymbolId(s2);
|
|
89294
|
+
}
|
|
89295
|
+
function compareNodes(n1, n2) {
|
|
89296
|
+
if (n1 === n2) return 0;
|
|
89297
|
+
if (n1 === void 0) return 1;
|
|
89298
|
+
if (n2 === void 0) return -1;
|
|
89299
|
+
const f1 = fileIndexMap.get(getSourceFileOfNode(n1));
|
|
89300
|
+
const f2 = fileIndexMap.get(getSourceFileOfNode(n2));
|
|
89301
|
+
if (f1 !== f2) {
|
|
89302
|
+
return f1 - f2;
|
|
89303
|
+
}
|
|
89304
|
+
return n1.pos - n2.pos;
|
|
89305
|
+
}
|
|
89306
|
+
function compareTypes(t1, t2) {
|
|
89307
|
+
if (t1 === t2) return 0;
|
|
89308
|
+
if (t1 === void 0) return 1;
|
|
89309
|
+
if (t2 === void 0) return -1;
|
|
89310
|
+
let c = getSortOrderFlags(t1) - getSortOrderFlags(t2);
|
|
89311
|
+
if (c !== 0) return c;
|
|
89312
|
+
c = compareTypeNames(t1, t2);
|
|
89313
|
+
if (c !== 0) return c;
|
|
89314
|
+
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 */)) {
|
|
89315
|
+
} else if (t1.flags & 524288 /* Object */) {
|
|
89316
|
+
const c2 = compareSymbols(t1.symbol, t2.symbol);
|
|
89317
|
+
if (c2 !== 0) return c2;
|
|
89318
|
+
if (getObjectFlags(t1) & 4 /* Reference */ && getObjectFlags(t2) & 4 /* Reference */) {
|
|
89319
|
+
const r1 = t1;
|
|
89320
|
+
const r2 = t2;
|
|
89321
|
+
if (getObjectFlags(r1.target) & 8 /* Tuple */ && getObjectFlags(r2.target) & 8 /* Tuple */) {
|
|
89322
|
+
const c3 = compareTupleTypes(r1.target, r2.target);
|
|
89323
|
+
if (c3 !== 0) {
|
|
89324
|
+
return c3;
|
|
89325
|
+
}
|
|
89326
|
+
}
|
|
89327
|
+
if (r1.node === void 0 && r2.node === void 0) {
|
|
89328
|
+
const c3 = compareTypeLists(t1.resolvedTypeArguments, t2.resolvedTypeArguments);
|
|
89329
|
+
if (c3 !== 0) {
|
|
89330
|
+
return c3;
|
|
89331
|
+
}
|
|
89332
|
+
} else {
|
|
89333
|
+
let c3 = compareNodes(r1.node, r2.node);
|
|
89334
|
+
if (c3 !== 0) {
|
|
89335
|
+
return c3;
|
|
89336
|
+
}
|
|
89337
|
+
c3 = compareTypeMappers(t1.mapper, t2.mapper);
|
|
89338
|
+
if (c3 !== 0) {
|
|
89339
|
+
return c3;
|
|
89340
|
+
}
|
|
89341
|
+
}
|
|
89342
|
+
} else if (getObjectFlags(t1) & 4 /* Reference */) {
|
|
89343
|
+
return -1;
|
|
89344
|
+
} else if (getObjectFlags(t2) & 4 /* Reference */) {
|
|
89345
|
+
return 1;
|
|
89346
|
+
} else {
|
|
89347
|
+
let c3 = getObjectFlags(t1) & 142607679 /* ObjectTypeKindMask */ - getObjectFlags(t2) & 142607679 /* ObjectTypeKindMask */;
|
|
89348
|
+
if (c3 !== 0) {
|
|
89349
|
+
return c3;
|
|
89350
|
+
}
|
|
89351
|
+
c3 = compareTypeMappers(t1.mapper, t2.mapper);
|
|
89352
|
+
if (c3 !== 0) {
|
|
89353
|
+
return c3;
|
|
89354
|
+
}
|
|
89355
|
+
}
|
|
89356
|
+
} else if (t1.flags & 1048576 /* Union */) {
|
|
89357
|
+
const o1 = t1.origin;
|
|
89358
|
+
const o2 = t2.origin;
|
|
89359
|
+
if (o1 === void 0 && o2 === void 0) {
|
|
89360
|
+
const c2 = compareTypeLists(t1.types, t2.types);
|
|
89361
|
+
if (c2 !== 0) {
|
|
89362
|
+
return c2;
|
|
89363
|
+
}
|
|
89364
|
+
} else if (o1 === void 0) {
|
|
89365
|
+
return 1;
|
|
89366
|
+
} else if (o2 === void 0) {
|
|
89367
|
+
return -1;
|
|
89368
|
+
} else {
|
|
89369
|
+
const c2 = compareTypes(o1, o2);
|
|
89370
|
+
if (c2 !== 0) {
|
|
89371
|
+
return c2;
|
|
89372
|
+
}
|
|
89373
|
+
}
|
|
89374
|
+
} else if (t1.flags & 2097152 /* Intersection */) {
|
|
89375
|
+
const c2 = compareTypeLists(t1.types, t2.types);
|
|
89376
|
+
if (c2 !== 0) {
|
|
89377
|
+
return c2;
|
|
89378
|
+
}
|
|
89379
|
+
} else if (t1.flags & (32768 /* EnumLiteral */ | 16384 /* UniqueESSymbol */)) {
|
|
89380
|
+
const c2 = compareSymbols(t1.symbol, t2.symbol);
|
|
89381
|
+
if (c2 !== 0) {
|
|
89382
|
+
return c2;
|
|
89383
|
+
}
|
|
89384
|
+
} else if (t1.flags & 1024 /* StringLiteral */) {
|
|
89385
|
+
const c2 = compareComparableValues(t1.value, t2.value);
|
|
89386
|
+
if (c2 !== 0) {
|
|
89387
|
+
return c2;
|
|
89388
|
+
}
|
|
89389
|
+
} else if (t1.flags & 2048 /* NumberLiteral */) {
|
|
89390
|
+
const c2 = compareComparableValues(t1.value, t2.value);
|
|
89391
|
+
if (c2 !== 0) {
|
|
89392
|
+
return c2;
|
|
89393
|
+
}
|
|
89394
|
+
} else if (t1.flags & 4096 /* BooleanLiteral */) {
|
|
89395
|
+
const b1 = t1.intrinsicName === "true";
|
|
89396
|
+
const b2 = t2.intrinsicName === "true";
|
|
89397
|
+
if (b1 !== b2) {
|
|
89398
|
+
if (b1) {
|
|
89399
|
+
return 1;
|
|
89400
|
+
}
|
|
89401
|
+
return -1;
|
|
89402
|
+
}
|
|
89403
|
+
} else if (t1.flags & 262144 /* TypeParameter */) {
|
|
89404
|
+
const c2 = compareSymbols(t1.symbol, t2.symbol);
|
|
89405
|
+
if (c2 !== 0) {
|
|
89406
|
+
return c2;
|
|
89407
|
+
}
|
|
89408
|
+
} else if (t1.flags & 4194304 /* Index */) {
|
|
89409
|
+
let c2 = compareTypes(t1.type, t2.type);
|
|
89410
|
+
if (c2 !== 0) {
|
|
89411
|
+
return c2;
|
|
89412
|
+
}
|
|
89413
|
+
c2 = t1.flags - t2.flags;
|
|
89414
|
+
if (c2 !== 0) {
|
|
89415
|
+
return c2;
|
|
89416
|
+
}
|
|
89417
|
+
} else if (t1.flags & 8388608 /* IndexedAccess */) {
|
|
89418
|
+
let c2 = compareTypes(t1.objectType, t2.objectType);
|
|
89419
|
+
if (c2 !== 0) {
|
|
89420
|
+
return c2;
|
|
89421
|
+
}
|
|
89422
|
+
c2 = compareTypes(t1.indexType, t2.indexType);
|
|
89423
|
+
if (c2 !== 0) {
|
|
89424
|
+
return c2;
|
|
89425
|
+
}
|
|
89426
|
+
} else if (t1.flags & 16777216 /* Conditional */) {
|
|
89427
|
+
let c2 = compareNodes(t1.root.node, t2.root.node);
|
|
89428
|
+
if (c2 !== 0) {
|
|
89429
|
+
return c2;
|
|
89430
|
+
}
|
|
89431
|
+
c2 = compareTypeMappers(t1.mapper, t2.mapper);
|
|
89432
|
+
if (c2 !== 0) {
|
|
89433
|
+
return c2;
|
|
89434
|
+
}
|
|
89435
|
+
} else if (t1.flags & 33554432 /* Substitution */) {
|
|
89436
|
+
let c2 = compareTypes(t1.baseType, t2.baseType);
|
|
89437
|
+
if (c2 !== 0) {
|
|
89438
|
+
return c2;
|
|
89439
|
+
}
|
|
89440
|
+
c2 = compareTypes(t1.constraint, t2.constraint);
|
|
89441
|
+
if (c2 !== 0) {
|
|
89442
|
+
return c2;
|
|
89443
|
+
}
|
|
89444
|
+
} else if (t1.flags & 134217728 /* TemplateLiteral */) {
|
|
89445
|
+
let c2 = slicesCompareString(t1.texts, t2.texts);
|
|
89446
|
+
if (c2 !== 0) {
|
|
89447
|
+
return c2;
|
|
89448
|
+
}
|
|
89449
|
+
c2 = compareTypeLists(t1.types, t2.types);
|
|
89450
|
+
if (c2 !== 0) {
|
|
89451
|
+
return c2;
|
|
89452
|
+
}
|
|
89453
|
+
} else if (t1.flags & 268435456 /* StringMapping */) {
|
|
89454
|
+
const c2 = compareTypes(t1.type, t2.type);
|
|
89455
|
+
if (c2 !== 0) {
|
|
89456
|
+
return c2;
|
|
89457
|
+
}
|
|
89458
|
+
}
|
|
89459
|
+
return t1.id - t2.id;
|
|
89460
|
+
function slicesCompareString(s1, s2) {
|
|
89461
|
+
for (let i = 0; i < s1.length; i++) {
|
|
89462
|
+
if (i > s2.length) {
|
|
89463
|
+
return 1;
|
|
89464
|
+
}
|
|
89465
|
+
const v1 = s1[i];
|
|
89466
|
+
const v2 = s2[i];
|
|
89467
|
+
const c2 = compareComparableValues(v1, v2);
|
|
89468
|
+
if (c2 !== 0) return c2;
|
|
89469
|
+
}
|
|
89470
|
+
if (s1.length < s2.length) {
|
|
89471
|
+
return -1;
|
|
89472
|
+
}
|
|
89473
|
+
return 0;
|
|
89474
|
+
}
|
|
89475
|
+
}
|
|
89476
|
+
function getSortOrderFlags(t) {
|
|
89477
|
+
return (t.flags & 65536 /* Enum */) >> 1 | t.flags & ~65536 /* Enum */;
|
|
89478
|
+
}
|
|
89479
|
+
function compareTypeNames(t1, t2) {
|
|
89480
|
+
const s1 = getTypeNameSymbol(t1);
|
|
89481
|
+
const s2 = getTypeNameSymbol(t2);
|
|
89482
|
+
if (s1 === s2) {
|
|
89483
|
+
if (t1.aliasTypeArguments !== void 0) {
|
|
89484
|
+
return compareTypeLists(t1.aliasTypeArguments, t2.aliasTypeArguments);
|
|
89485
|
+
}
|
|
89486
|
+
return 0;
|
|
89487
|
+
}
|
|
89488
|
+
if (s1 === void 0) {
|
|
89489
|
+
return 1;
|
|
89490
|
+
}
|
|
89491
|
+
if (s2 === void 0) {
|
|
89492
|
+
return -1;
|
|
89493
|
+
}
|
|
89494
|
+
return compareComparableValues(s1.escapedName, s2.escapedName);
|
|
89495
|
+
}
|
|
89496
|
+
function getTypeNameSymbol(t) {
|
|
89497
|
+
if (t.aliasSymbol !== void 0) {
|
|
89498
|
+
return t.aliasSymbol;
|
|
89499
|
+
}
|
|
89500
|
+
if (t.flags & (262144 /* TypeParameter */ | 268435456 /* StringMapping */) || getObjectFlags(t) & (3 /* ClassOrInterface */ | 4 /* Reference */)) {
|
|
89501
|
+
return t.symbol;
|
|
89502
|
+
}
|
|
89503
|
+
return void 0;
|
|
89504
|
+
}
|
|
89505
|
+
function compareTupleTypes(t1, t2) {
|
|
89506
|
+
var _a;
|
|
89507
|
+
if (t1 === t2) {
|
|
89508
|
+
return 0;
|
|
89509
|
+
}
|
|
89510
|
+
if (t1.readonly === t2.readonly) {
|
|
89511
|
+
return t1.readonly ? 1 : -1;
|
|
89512
|
+
}
|
|
89513
|
+
if (t1.elementFlags.length !== t2.elementFlags.length) {
|
|
89514
|
+
return t1.elementFlags.length - t2.elementFlags.length;
|
|
89515
|
+
}
|
|
89516
|
+
for (let i = 0; i < t1.elementFlags.length; i++) {
|
|
89517
|
+
const c = t1.elementFlags[i] - t2.elementFlags[i];
|
|
89518
|
+
if (c !== 0) {
|
|
89519
|
+
return c;
|
|
89520
|
+
}
|
|
89521
|
+
}
|
|
89522
|
+
for (let i = 0; i < (((_a = t1.labeledElementDeclarations) == null ? void 0 : _a.length) ?? 0); i++) {
|
|
89523
|
+
const c = compareElementLabels(t1.labeledElementDeclarations[i], t2.labeledElementDeclarations[i]);
|
|
89524
|
+
if (c !== 0) {
|
|
89525
|
+
return c;
|
|
89526
|
+
}
|
|
89527
|
+
}
|
|
89528
|
+
return 0;
|
|
89529
|
+
}
|
|
89530
|
+
function compareElementLabels(n1, n2) {
|
|
89531
|
+
if (n1 === n2) {
|
|
89532
|
+
return 0;
|
|
89533
|
+
}
|
|
89534
|
+
if (n1 === void 0) {
|
|
89535
|
+
return -1;
|
|
89536
|
+
}
|
|
89537
|
+
if (n2 === void 0) {
|
|
89538
|
+
return 1;
|
|
89539
|
+
}
|
|
89540
|
+
return compareComparableValues(n1.name.escapedText, n2.name.escapedText);
|
|
89541
|
+
}
|
|
89542
|
+
function compareTypeLists(s1, s2) {
|
|
89543
|
+
if (length(s1) !== length(s2)) {
|
|
89544
|
+
return length(s1) - length(s2);
|
|
89545
|
+
}
|
|
89546
|
+
for (let i = 0; i < length(s1); i++) {
|
|
89547
|
+
const c = compareTypes(s1[i], s2 == null ? void 0 : s2[i]);
|
|
89548
|
+
if (c !== 0) return c;
|
|
89549
|
+
}
|
|
89550
|
+
return 0;
|
|
89551
|
+
}
|
|
89552
|
+
function compareTypeMappers(m1, m2) {
|
|
89553
|
+
if (m1 === m2) {
|
|
89554
|
+
return 0;
|
|
89555
|
+
}
|
|
89556
|
+
if (m1 === void 0) {
|
|
89557
|
+
return 1;
|
|
89558
|
+
}
|
|
89559
|
+
if (m2 === void 0) {
|
|
89560
|
+
return -1;
|
|
89561
|
+
}
|
|
89562
|
+
const kind1 = m1.kind;
|
|
89563
|
+
const kind2 = m2.kind;
|
|
89564
|
+
if (kind1 !== kind2) {
|
|
89565
|
+
return kind1 - kind2;
|
|
89566
|
+
}
|
|
89567
|
+
switch (kind1) {
|
|
89568
|
+
case 0 /* Simple */: {
|
|
89569
|
+
const c = compareTypes(m1.source, m2.source);
|
|
89570
|
+
if (c !== 0) {
|
|
89571
|
+
return c;
|
|
89572
|
+
}
|
|
89573
|
+
return compareTypes(m1.target, m2.target);
|
|
89574
|
+
}
|
|
89575
|
+
case 1 /* Array */: {
|
|
89576
|
+
const c = compareTypeLists(m1.sources, m2.sources);
|
|
89577
|
+
if (c !== 0) {
|
|
89578
|
+
return c;
|
|
89579
|
+
}
|
|
89580
|
+
return compareTypeLists(m1.targets, m2.targets);
|
|
89581
|
+
}
|
|
89582
|
+
case 5 /* Merged */: {
|
|
89583
|
+
const c = compareTypeMappers(m1.mapper1, m2.mapper1);
|
|
89584
|
+
if (c !== 0) {
|
|
89585
|
+
return c;
|
|
89586
|
+
}
|
|
89587
|
+
return compareTypeMappers(m1.mapper2, m2.mapper2);
|
|
89588
|
+
}
|
|
89589
|
+
}
|
|
89590
|
+
return 0;
|
|
89591
|
+
}
|
|
89285
89592
|
}
|
|
89286
89593
|
function isNotAccessor(declaration) {
|
|
89287
89594
|
return !isAccessor(declaration);
|
|
@@ -132635,18 +132942,17 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
132635
132942
|
);
|
|
132636
132943
|
}
|
|
132637
132944
|
function reuseTypeParameters(typeParameters, context) {
|
|
132638
|
-
return typeParameters == null ? void 0 : typeParameters.map(
|
|
132639
|
-
|
|
132640
|
-
|
|
132641
|
-
|
|
132642
|
-
|
|
132643
|
-
|
|
132644
|
-
|
|
132645
|
-
|
|
132646
|
-
|
|
132647
|
-
|
|
132648
|
-
|
|
132649
|
-
);
|
|
132945
|
+
return typeParameters == null ? void 0 : typeParameters.map((tp) => {
|
|
132946
|
+
var _a;
|
|
132947
|
+
const { node: tpName } = resolver.trackExistingEntityName(context, tp.name);
|
|
132948
|
+
return factory.updateTypeParameterDeclaration(
|
|
132949
|
+
tp,
|
|
132950
|
+
(_a = tp.modifiers) == null ? void 0 : _a.map((m) => reuseNode(context, m)),
|
|
132951
|
+
tpName,
|
|
132952
|
+
serializeExistingTypeNodeWithFallback(tp.constraint, context),
|
|
132953
|
+
serializeExistingTypeNodeWithFallback(tp.default, context)
|
|
132954
|
+
);
|
|
132955
|
+
});
|
|
132650
132956
|
}
|
|
132651
132957
|
function typeFromObjectLiteralMethod(method, name, context, isConstContext) {
|
|
132652
132958
|
const returnType = createReturnFromSignature(
|