@typescript-deploys/pr-build 5.9.0-pr-61342-2 → 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 +709 -396
- 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 +751 -435
- 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";
|
|
@@ -17456,7 +17456,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
|
|
|
17456
17456
|
return (_a = symbol.declarations) == null ? void 0 : _a.find(isClassLike);
|
|
17457
17457
|
}
|
|
17458
17458
|
function getObjectFlags(type) {
|
|
17459
|
-
return type.flags &
|
|
17459
|
+
return type.flags & 3801101 /* ObjectFlagsType */ ? type.objectFlags : 0;
|
|
17460
17460
|
}
|
|
17461
17461
|
function isUMDExportSymbol(symbol) {
|
|
17462
17462
|
return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
|
|
@@ -19248,13 +19248,13 @@ function intrinsicTagNameToString(node) {
|
|
|
19248
19248
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
19249
19249
|
}
|
|
19250
19250
|
function isTypeUsableAsPropertyName(type) {
|
|
19251
|
-
return !!(type.flags &
|
|
19251
|
+
return !!(type.flags & 19456 /* StringOrNumberLiteralOrUnique */);
|
|
19252
19252
|
}
|
|
19253
19253
|
function getPropertyNameFromType(type) {
|
|
19254
|
-
if (type.flags &
|
|
19254
|
+
if (type.flags & 16384 /* UniqueESSymbol */) {
|
|
19255
19255
|
return type.escapedName;
|
|
19256
19256
|
}
|
|
19257
|
-
if (type.flags & (
|
|
19257
|
+
if (type.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */)) {
|
|
19258
19258
|
return escapeLeadingUnderscores("" + type.value);
|
|
19259
19259
|
}
|
|
19260
19260
|
return Debug.fail();
|
|
@@ -46163,6 +46163,7 @@ function createTypeChecker(host) {
|
|
|
46163
46163
|
};
|
|
46164
46164
|
var cancellationToken;
|
|
46165
46165
|
var scanner;
|
|
46166
|
+
var fileIndexMap = new Map(host.getSourceFiles().map((file, i) => [file, i]));
|
|
46166
46167
|
var Symbol13 = objectAllocator.getSymbolConstructor();
|
|
46167
46168
|
var Type7 = objectAllocator.getTypeConstructor();
|
|
46168
46169
|
var Signature5 = objectAllocator.getSignatureConstructor();
|
|
@@ -46744,10 +46745,10 @@ function createTypeChecker(host) {
|
|
|
46744
46745
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */, "non-inferrable");
|
|
46745
46746
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
46746
46747
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
46747
|
-
var undefinedType = createIntrinsicType(
|
|
46748
|
-
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(
|
|
46748
|
+
var undefinedType = createIntrinsicType(4 /* Undefined */, "undefined");
|
|
46749
|
+
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(4 /* Undefined */, "undefined", 65536 /* ContainsWideningType */, "widening");
|
|
46749
46750
|
var missingType = createIntrinsicType(
|
|
46750
|
-
|
|
46751
|
+
4 /* Undefined */,
|
|
46751
46752
|
"undefined",
|
|
46752
46753
|
/*objectFlags*/
|
|
46753
46754
|
void 0,
|
|
@@ -46755,33 +46756,33 @@ function createTypeChecker(host) {
|
|
|
46755
46756
|
);
|
|
46756
46757
|
var undefinedOrMissingType = exactOptionalPropertyTypes ? missingType : undefinedType;
|
|
46757
46758
|
var optionalType = createIntrinsicType(
|
|
46758
|
-
|
|
46759
|
+
4 /* Undefined */,
|
|
46759
46760
|
"undefined",
|
|
46760
46761
|
/*objectFlags*/
|
|
46761
46762
|
void 0,
|
|
46762
46763
|
"optional"
|
|
46763
46764
|
);
|
|
46764
|
-
var nullType = createIntrinsicType(
|
|
46765
|
-
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(
|
|
46766
|
-
var stringType = createIntrinsicType(
|
|
46767
|
-
var numberType = createIntrinsicType(
|
|
46768
|
-
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");
|
|
46769
46770
|
var falseType = createIntrinsicType(
|
|
46770
|
-
|
|
46771
|
+
4096 /* BooleanLiteral */,
|
|
46771
46772
|
"false",
|
|
46772
46773
|
/*objectFlags*/
|
|
46773
46774
|
void 0,
|
|
46774
46775
|
"fresh"
|
|
46775
46776
|
);
|
|
46776
|
-
var regularFalseType = createIntrinsicType(
|
|
46777
|
+
var regularFalseType = createIntrinsicType(4096 /* BooleanLiteral */, "false");
|
|
46777
46778
|
var trueType = createIntrinsicType(
|
|
46778
|
-
|
|
46779
|
+
4096 /* BooleanLiteral */,
|
|
46779
46780
|
"true",
|
|
46780
46781
|
/*objectFlags*/
|
|
46781
46782
|
void 0,
|
|
46782
46783
|
"fresh"
|
|
46783
46784
|
);
|
|
46784
|
-
var regularTrueType = createIntrinsicType(
|
|
46785
|
+
var regularTrueType = createIntrinsicType(4096 /* BooleanLiteral */, "true");
|
|
46785
46786
|
trueType.regularType = regularTrueType;
|
|
46786
46787
|
trueType.freshType = trueType;
|
|
46787
46788
|
regularTrueType.regularType = regularTrueType;
|
|
@@ -46791,8 +46792,8 @@ function createTypeChecker(host) {
|
|
|
46791
46792
|
regularFalseType.regularType = regularFalseType;
|
|
46792
46793
|
regularFalseType.freshType = falseType;
|
|
46793
46794
|
var booleanType = getUnionType([regularFalseType, regularTrueType]);
|
|
46794
|
-
var esSymbolType = createIntrinsicType(
|
|
46795
|
-
var voidType = createIntrinsicType(
|
|
46795
|
+
var esSymbolType = createIntrinsicType(512 /* ESSymbol */, "symbol");
|
|
46796
|
+
var voidType = createIntrinsicType(16 /* Void */, "void");
|
|
46796
46797
|
var neverType = createIntrinsicType(131072 /* Never */, "never");
|
|
46797
46798
|
var silentNeverType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */, "silent");
|
|
46798
46799
|
var implicitNeverType = createIntrinsicType(
|
|
@@ -48079,7 +48080,7 @@ function createTypeChecker(host) {
|
|
|
48079
48080
|
const type = getDeclaredTypeOfSymbol(symbol);
|
|
48080
48081
|
return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(
|
|
48081
48082
|
type,
|
|
48082
|
-
|
|
48083
|
+
3072 /* StringOrNumberLiteral */,
|
|
48083
48084
|
/*strict*/
|
|
48084
48085
|
true
|
|
48085
48086
|
);
|
|
@@ -49786,7 +49787,7 @@ function createTypeChecker(host) {
|
|
|
49786
49787
|
return type;
|
|
49787
49788
|
}
|
|
49788
49789
|
function createTypeofType() {
|
|
49789
|
-
return getUnionType(
|
|
49790
|
+
return getUnionType(map([...typeofNEFacts.keys()].sort(), getStringLiteralType));
|
|
49790
49791
|
}
|
|
49791
49792
|
function createTypeParameter(symbol) {
|
|
49792
49793
|
return createTypeWithSymbol(262144 /* TypeParameter */, symbol);
|
|
@@ -50607,7 +50608,7 @@ function createTypeChecker(host) {
|
|
|
50607
50608
|
if (name && isComputedPropertyName(name)) return name;
|
|
50608
50609
|
}
|
|
50609
50610
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
50610
|
-
if (nameType && nameType.flags & (
|
|
50611
|
+
if (nameType && nameType.flags & (32768 /* EnumLiteral */ | 16384 /* UniqueESSymbol */)) {
|
|
50611
50612
|
context.enclosingDeclaration = nameType.symbol.valueDeclaration;
|
|
50612
50613
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, meaning));
|
|
50613
50614
|
}
|
|
@@ -50715,23 +50716,23 @@ function createTypeChecker(host) {
|
|
|
50715
50716
|
if (type.flags & 2 /* Unknown */) {
|
|
50716
50717
|
return factory.createKeywordTypeNode(159 /* UnknownKeyword */);
|
|
50717
50718
|
}
|
|
50718
|
-
if (type.flags &
|
|
50719
|
+
if (type.flags & 32 /* String */) {
|
|
50719
50720
|
context.approximateLength += 6;
|
|
50720
50721
|
return factory.createKeywordTypeNode(154 /* StringKeyword */);
|
|
50721
50722
|
}
|
|
50722
|
-
if (type.flags &
|
|
50723
|
+
if (type.flags & 64 /* Number */) {
|
|
50723
50724
|
context.approximateLength += 6;
|
|
50724
50725
|
return factory.createKeywordTypeNode(150 /* NumberKeyword */);
|
|
50725
50726
|
}
|
|
50726
|
-
if (type.flags &
|
|
50727
|
+
if (type.flags & 128 /* BigInt */) {
|
|
50727
50728
|
context.approximateLength += 6;
|
|
50728
50729
|
return factory.createKeywordTypeNode(163 /* BigIntKeyword */);
|
|
50729
50730
|
}
|
|
50730
|
-
if (type.flags &
|
|
50731
|
+
if (type.flags & 256 /* Boolean */ && !type.aliasSymbol) {
|
|
50731
50732
|
context.approximateLength += 7;
|
|
50732
50733
|
return factory.createKeywordTypeNode(136 /* BooleanKeyword */);
|
|
50733
50734
|
}
|
|
50734
|
-
if (type.flags &
|
|
50735
|
+
if (type.flags & 98304 /* EnumLike */) {
|
|
50735
50736
|
if (type.symbol.flags & 8 /* EnumMember */) {
|
|
50736
50737
|
const parentSymbol = getParentOfSymbol(type.symbol);
|
|
50737
50738
|
const parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */);
|
|
@@ -50760,24 +50761,24 @@ function createTypeChecker(host) {
|
|
|
50760
50761
|
}
|
|
50761
50762
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
50762
50763
|
}
|
|
50763
|
-
if (type.flags &
|
|
50764
|
+
if (type.flags & 1024 /* StringLiteral */) {
|
|
50764
50765
|
context.approximateLength += type.value.length + 2;
|
|
50765
50766
|
return factory.createLiteralTypeNode(setEmitFlags(factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */));
|
|
50766
50767
|
}
|
|
50767
|
-
if (type.flags &
|
|
50768
|
+
if (type.flags & 2048 /* NumberLiteral */) {
|
|
50768
50769
|
const value = type.value;
|
|
50769
50770
|
context.approximateLength += ("" + value).length;
|
|
50770
50771
|
return factory.createLiteralTypeNode(value < 0 ? factory.createPrefixUnaryExpression(41 /* MinusToken */, factory.createNumericLiteral(-value)) : factory.createNumericLiteral(value));
|
|
50771
50772
|
}
|
|
50772
|
-
if (type.flags &
|
|
50773
|
+
if (type.flags & 8192 /* BigIntLiteral */) {
|
|
50773
50774
|
context.approximateLength += pseudoBigIntToString(type.value).length + 1;
|
|
50774
50775
|
return factory.createLiteralTypeNode(factory.createBigIntLiteral(type.value));
|
|
50775
50776
|
}
|
|
50776
|
-
if (type.flags &
|
|
50777
|
+
if (type.flags & 4096 /* BooleanLiteral */) {
|
|
50777
50778
|
context.approximateLength += type.intrinsicName.length;
|
|
50778
50779
|
return factory.createLiteralTypeNode(type.intrinsicName === "true" ? factory.createTrue() : factory.createFalse());
|
|
50779
50780
|
}
|
|
50780
|
-
if (type.flags &
|
|
50781
|
+
if (type.flags & 16384 /* UniqueESSymbol */) {
|
|
50781
50782
|
if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) {
|
|
50782
50783
|
if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
|
|
50783
50784
|
context.approximateLength += 6;
|
|
@@ -50790,15 +50791,15 @@ function createTypeChecker(host) {
|
|
|
50790
50791
|
context.approximateLength += 13;
|
|
50791
50792
|
return factory.createTypeOperatorNode(158 /* UniqueKeyword */, factory.createKeywordTypeNode(155 /* SymbolKeyword */));
|
|
50792
50793
|
}
|
|
50793
|
-
if (type.flags &
|
|
50794
|
+
if (type.flags & 16 /* Void */) {
|
|
50794
50795
|
context.approximateLength += 4;
|
|
50795
50796
|
return factory.createKeywordTypeNode(116 /* VoidKeyword */);
|
|
50796
50797
|
}
|
|
50797
|
-
if (type.flags &
|
|
50798
|
+
if (type.flags & 4 /* Undefined */) {
|
|
50798
50799
|
context.approximateLength += 9;
|
|
50799
50800
|
return factory.createKeywordTypeNode(157 /* UndefinedKeyword */);
|
|
50800
50801
|
}
|
|
50801
|
-
if (type.flags &
|
|
50802
|
+
if (type.flags & 8 /* Null */) {
|
|
50802
50803
|
context.approximateLength += 4;
|
|
50803
50804
|
return factory.createLiteralTypeNode(factory.createNull());
|
|
50804
50805
|
}
|
|
@@ -50806,7 +50807,7 @@ function createTypeChecker(host) {
|
|
|
50806
50807
|
context.approximateLength += 5;
|
|
50807
50808
|
return factory.createKeywordTypeNode(146 /* NeverKeyword */);
|
|
50808
50809
|
}
|
|
50809
|
-
if (type.flags &
|
|
50810
|
+
if (type.flags & 512 /* ESSymbol */) {
|
|
50810
50811
|
context.approximateLength += 6;
|
|
50811
50812
|
return factory.createKeywordTypeNode(155 /* SymbolKeyword */);
|
|
50812
50813
|
}
|
|
@@ -51595,7 +51596,7 @@ function createTypeChecker(host) {
|
|
|
51595
51596
|
}
|
|
51596
51597
|
const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
51597
51598
|
if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
|
|
51598
|
-
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags &
|
|
51599
|
+
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 4 /* Undefined */)), 0 /* Call */);
|
|
51599
51600
|
for (const signature of signatures) {
|
|
51600
51601
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 173 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
51601
51602
|
typeElements.push(preserveCommentsOn(methodDeclaration, signature.declaration || propertySymbol.valueDeclaration));
|
|
@@ -52635,11 +52636,11 @@ function createTypeChecker(host) {
|
|
|
52635
52636
|
}
|
|
52636
52637
|
if (isComputedPropertyName(name)) {
|
|
52637
52638
|
const type = checkExpression(name.expression);
|
|
52638
|
-
return !!(type.flags &
|
|
52639
|
+
return !!(type.flags & 402654240 /* StringLike */);
|
|
52639
52640
|
}
|
|
52640
52641
|
if (isElementAccessExpression(name)) {
|
|
52641
52642
|
const type = checkExpression(name.argumentExpression);
|
|
52642
|
-
return !!(type.flags &
|
|
52643
|
+
return !!(type.flags & 402654240 /* StringLike */);
|
|
52643
52644
|
}
|
|
52644
52645
|
return isStringLiteral(name);
|
|
52645
52646
|
}
|
|
@@ -52665,7 +52666,7 @@ function createTypeChecker(host) {
|
|
|
52665
52666
|
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote, stringNamed, isMethod) {
|
|
52666
52667
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
52667
52668
|
if (nameType) {
|
|
52668
|
-
if (nameType.flags &
|
|
52669
|
+
if (nameType.flags & 3072 /* StringOrNumberLiteral */) {
|
|
52669
52670
|
const name = "" + nameType.value;
|
|
52670
52671
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && (stringNamed || !isNumericLiteralName(name))) {
|
|
52671
52672
|
return factory.createStringLiteral(name, !!singleQuote);
|
|
@@ -52675,7 +52676,7 @@ function createTypeChecker(host) {
|
|
|
52675
52676
|
}
|
|
52676
52677
|
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
|
|
52677
52678
|
}
|
|
52678
|
-
if (nameType.flags &
|
|
52679
|
+
if (nameType.flags & 16384 /* UniqueESSymbol */) {
|
|
52679
52680
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
|
|
52680
52681
|
}
|
|
52681
52682
|
}
|
|
@@ -52717,7 +52718,7 @@ function createTypeChecker(host) {
|
|
|
52717
52718
|
return enclosingDeclaration;
|
|
52718
52719
|
}
|
|
52719
52720
|
function serializeInferredTypeForDeclaration(symbol, context, type) {
|
|
52720
|
-
if (type.flags &
|
|
52721
|
+
if (type.flags & 16384 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === context.enclosingFile))) {
|
|
52721
52722
|
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
52722
52723
|
}
|
|
52723
52724
|
const result = typeToTypeNodeHelper(type, context);
|
|
@@ -52950,7 +52951,7 @@ function createTypeChecker(host) {
|
|
|
52950
52951
|
}
|
|
52951
52952
|
function serializeExistingTypeNode(context, typeNode, addUndefined) {
|
|
52952
52953
|
const type = getTypeFromTypeNode2(context, typeNode);
|
|
52953
|
-
if (addUndefined && !someType(type, (t) => !!(t.flags &
|
|
52954
|
+
if (addUndefined && !someType(type, (t) => !!(t.flags & 4 /* Undefined */)) && canReuseTypeNode(context, typeNode)) {
|
|
52954
52955
|
const clone = syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode);
|
|
52955
52956
|
if (clone) {
|
|
52956
52957
|
return factory.createUnionTypeNode([clone, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
@@ -54489,9 +54490,9 @@ function createTypeChecker(host) {
|
|
|
54489
54490
|
for (let i = 0; i < types.length; i++) {
|
|
54490
54491
|
const t = types[i];
|
|
54491
54492
|
flags |= t.flags;
|
|
54492
|
-
if (!(t.flags &
|
|
54493
|
-
if (t.flags & (
|
|
54494
|
-
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);
|
|
54495
54496
|
if (baseType.flags & 1048576 /* Union */) {
|
|
54496
54497
|
const count = baseType.types.length;
|
|
54497
54498
|
if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
|
|
@@ -54504,8 +54505,8 @@ function createTypeChecker(host) {
|
|
|
54504
54505
|
result.push(t);
|
|
54505
54506
|
}
|
|
54506
54507
|
}
|
|
54507
|
-
if (flags &
|
|
54508
|
-
if (flags &
|
|
54508
|
+
if (flags & 8 /* Null */) result.push(nullType);
|
|
54509
|
+
if (flags & 4 /* Undefined */) result.push(undefinedType);
|
|
54509
54510
|
return result || types;
|
|
54510
54511
|
}
|
|
54511
54512
|
function visibilityToString(flags) {
|
|
@@ -54535,7 +54536,7 @@ function createTypeChecker(host) {
|
|
|
54535
54536
|
function getNameOfSymbolFromNameType(symbol, context) {
|
|
54536
54537
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
54537
54538
|
if (nameType) {
|
|
54538
|
-
if (nameType.flags &
|
|
54539
|
+
if (nameType.flags & 3072 /* StringOrNumberLiteral */) {
|
|
54539
54540
|
const name = "" + nameType.value;
|
|
54540
54541
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
54541
54542
|
return `"${escapeString(name, 34 /* doubleQuote */)}"`;
|
|
@@ -54545,7 +54546,7 @@ function createTypeChecker(host) {
|
|
|
54545
54546
|
}
|
|
54546
54547
|
return name;
|
|
54547
54548
|
}
|
|
54548
|
-
if (nameType.flags &
|
|
54549
|
+
if (nameType.flags & 16384 /* UniqueESSymbol */) {
|
|
54549
54550
|
return `[${getNameOfSymbolAsWritten(nameType.symbol, context)}]`;
|
|
54550
54551
|
}
|
|
54551
54552
|
}
|
|
@@ -54570,7 +54571,7 @@ function createTypeChecker(host) {
|
|
|
54570
54571
|
}
|
|
54571
54572
|
if (isComputedPropertyName(name2) && !(getCheckFlags(symbol) & 4096 /* Late */)) {
|
|
54572
54573
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
54573
|
-
if (nameType && nameType.flags &
|
|
54574
|
+
if (nameType && nameType.flags & 3072 /* StringOrNumberLiteral */) {
|
|
54574
54575
|
const result = getNameOfSymbolFromNameType(symbol, context);
|
|
54575
54576
|
if (result !== void 0) {
|
|
54576
54577
|
return result;
|
|
@@ -54851,7 +54852,7 @@ function createTypeChecker(host) {
|
|
|
54851
54852
|
);
|
|
54852
54853
|
}
|
|
54853
54854
|
function getRestType(source, properties, symbol) {
|
|
54854
|
-
source = filterType(source, (t) => !(t.flags &
|
|
54855
|
+
source = filterType(source, (t) => !(t.flags & 12 /* Nullable */));
|
|
54855
54856
|
if (source.flags & 131072 /* Never */) {
|
|
54856
54857
|
return emptyObjectType;
|
|
54857
54858
|
}
|
|
@@ -54862,7 +54863,7 @@ function createTypeChecker(host) {
|
|
|
54862
54863
|
const spreadableProperties = [];
|
|
54863
54864
|
const unspreadableToRestKeys = [];
|
|
54864
54865
|
for (const prop of getPropertiesOfType(source)) {
|
|
54865
|
-
const literalTypeFromProperty = getLiteralTypeFromProperty(prop,
|
|
54866
|
+
const literalTypeFromProperty = getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */);
|
|
54866
54867
|
if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) && isSpreadableProperty(prop)) {
|
|
54867
54868
|
spreadableProperties.push(prop);
|
|
54868
54869
|
} else {
|
|
@@ -54895,7 +54896,7 @@ function createTypeChecker(host) {
|
|
|
54895
54896
|
return result;
|
|
54896
54897
|
}
|
|
54897
54898
|
function isGenericTypeWithUndefinedConstraint(type) {
|
|
54898
|
-
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType,
|
|
54899
|
+
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 4 /* Undefined */);
|
|
54899
54900
|
}
|
|
54900
54901
|
function getNonUndefinedType(type) {
|
|
54901
54902
|
const typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, (t) => t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t) : type;
|
|
@@ -54949,7 +54950,7 @@ function createTypeChecker(host) {
|
|
|
54949
54950
|
}
|
|
54950
54951
|
function getLiteralPropertyNameText(name) {
|
|
54951
54952
|
const type = getLiteralTypeFromPropertyName(name);
|
|
54952
|
-
return type.flags & (
|
|
54953
|
+
return type.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
54953
54954
|
}
|
|
54954
54955
|
function getTypeForBindingElement(declaration) {
|
|
54955
54956
|
const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
@@ -55289,7 +55290,7 @@ function createTypeChecker(host) {
|
|
|
55289
55290
|
definedInConstructor = true;
|
|
55290
55291
|
}
|
|
55291
55292
|
}
|
|
55292
|
-
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~
|
|
55293
|
+
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~12 /* Nullable */)) ? constructorTypes : types;
|
|
55293
55294
|
type = getUnionType(sourceTypes);
|
|
55294
55295
|
}
|
|
55295
55296
|
}
|
|
@@ -55299,7 +55300,7 @@ function createTypeChecker(host) {
|
|
|
55299
55300
|
false,
|
|
55300
55301
|
definedInMethod && !definedInConstructor
|
|
55301
55302
|
));
|
|
55302
|
-
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) {
|
|
55303
55304
|
reportImplicitAny(symbol.valueDeclaration, anyType);
|
|
55304
55305
|
return anyType;
|
|
55305
55306
|
}
|
|
@@ -55597,13 +55598,13 @@ function createTypeChecker(host) {
|
|
|
55597
55598
|
}
|
|
55598
55599
|
function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors2) {
|
|
55599
55600
|
if (type) {
|
|
55600
|
-
if (type.flags &
|
|
55601
|
+
if (type.flags & 512 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) {
|
|
55601
55602
|
type = getESSymbolLikeTypeForNode(declaration);
|
|
55602
55603
|
}
|
|
55603
55604
|
if (reportErrors2) {
|
|
55604
55605
|
reportErrorsFromWidening(declaration, type);
|
|
55605
55606
|
}
|
|
55606
|
-
if (type.flags &
|
|
55607
|
+
if (type.flags & 16384 /* UniqueESSymbol */ && (isBindingElement(declaration) || !tryGetTypeFromEffectiveTypeNode(declaration)) && type.symbol !== getSymbolOfDeclaration(declaration)) {
|
|
55607
55608
|
type = esSymbolType;
|
|
55608
55609
|
}
|
|
55609
55610
|
return getWidenedType(type);
|
|
@@ -56440,7 +56441,7 @@ function createTypeChecker(host) {
|
|
|
56440
56441
|
return links.declaredType;
|
|
56441
56442
|
}
|
|
56442
56443
|
function getBaseTypeOfEnumLikeType(type) {
|
|
56443
|
-
return type.flags &
|
|
56444
|
+
return type.flags & 98304 /* EnumLike */ && type.symbol.flags & 8 /* EnumMember */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
|
|
56444
56445
|
}
|
|
56445
56446
|
function getDeclaredTypeOfEnum(symbol) {
|
|
56446
56447
|
const links = getSymbolLinks(symbol);
|
|
@@ -56471,7 +56472,7 @@ function createTypeChecker(host) {
|
|
|
56471
56472
|
void 0
|
|
56472
56473
|
) : createComputedEnumType(symbol);
|
|
56473
56474
|
if (enumType.flags & 1048576 /* Union */) {
|
|
56474
|
-
enumType.flags |=
|
|
56475
|
+
enumType.flags |= 32768 /* EnumLiteral */;
|
|
56475
56476
|
enumType.symbol = symbol;
|
|
56476
56477
|
}
|
|
56477
56478
|
links.declaredType = enumType;
|
|
@@ -56479,8 +56480,8 @@ function createTypeChecker(host) {
|
|
|
56479
56480
|
return links.declaredType;
|
|
56480
56481
|
}
|
|
56481
56482
|
function createComputedEnumType(symbol) {
|
|
56482
|
-
const regularType = createTypeWithSymbol(
|
|
56483
|
-
const freshType = createTypeWithSymbol(
|
|
56483
|
+
const regularType = createTypeWithSymbol(65536 /* Enum */, symbol);
|
|
56484
|
+
const freshType = createTypeWithSymbol(65536 /* Enum */, symbol);
|
|
56484
56485
|
regularType.regularType = regularType;
|
|
56485
56486
|
regularType.freshType = freshType;
|
|
56486
56487
|
freshType.regularType = regularType;
|
|
@@ -56682,7 +56683,7 @@ function createTypeChecker(host) {
|
|
|
56682
56683
|
const earlySymbol = earlySymbols && earlySymbols.get(memberName);
|
|
56683
56684
|
if (!(parent.flags & 32 /* Class */) && lateSymbol.flags & getExcludedSymbolFlags(symbolFlags)) {
|
|
56684
56685
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
56685
|
-
const name = !(type.flags &
|
|
56686
|
+
const name = !(type.flags & 16384 /* UniqueESSymbol */) && unescapeLeadingUnderscores(memberName) || declarationNameToString(declName);
|
|
56686
56687
|
forEach(declarations, (declaration) => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
56687
56688
|
error(declName || decl, Diagnostics.Duplicate_property_0, name);
|
|
56688
56689
|
lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
|
|
@@ -57377,7 +57378,7 @@ function createTypeChecker(host) {
|
|
|
57377
57378
|
if (baseConstructorIndexInfo) {
|
|
57378
57379
|
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
|
57379
57380
|
}
|
|
57380
|
-
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 */)))) {
|
|
57381
57382
|
indexInfos = append(indexInfos, enumNumberIndexInfo);
|
|
57382
57383
|
}
|
|
57383
57384
|
}
|
|
@@ -57438,7 +57439,7 @@ function createTypeChecker(host) {
|
|
|
57438
57439
|
const limitedConstraint = getLimitedConstraint(type);
|
|
57439
57440
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
57440
57441
|
if (limitedConstraint) {
|
|
57441
|
-
const propertyNameType = getLiteralTypeFromProperty(prop,
|
|
57442
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */);
|
|
57442
57443
|
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
57443
57444
|
continue;
|
|
57444
57445
|
}
|
|
@@ -57491,7 +57492,7 @@ function createTypeChecker(host) {
|
|
|
57491
57492
|
}
|
|
57492
57493
|
if (type.flags & 2097152 /* Intersection */) {
|
|
57493
57494
|
const types = type.types;
|
|
57494
|
-
if (types.length === 2 && !!(types[0].flags & (
|
|
57495
|
+
if (types.length === 2 && !!(types[0].flags & (32 /* String */ | 64 /* Number */ | 128 /* BigInt */)) && types[1] === emptyTypeLiteralType) {
|
|
57495
57496
|
return type;
|
|
57496
57497
|
}
|
|
57497
57498
|
return getIntersectionType(sameMap(type.types, getLowerBoundOfKeyType));
|
|
@@ -57509,7 +57510,7 @@ function createTypeChecker(host) {
|
|
|
57509
57510
|
cb(stringType);
|
|
57510
57511
|
} else {
|
|
57511
57512
|
for (const info of getIndexInfosOfType(type)) {
|
|
57512
|
-
if (!stringsOnly || info.keyType.flags & (
|
|
57513
|
+
if (!stringsOnly || info.keyType.flags & (32 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
57513
57514
|
cb(info.keyType);
|
|
57514
57515
|
}
|
|
57515
57516
|
}
|
|
@@ -57527,7 +57528,7 @@ function createTypeChecker(host) {
|
|
|
57527
57528
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
57528
57529
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
57529
57530
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
57530
|
-
const include =
|
|
57531
|
+
const include = 19456 /* StringOrNumberLiteralOrUnique */;
|
|
57531
57532
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
57532
57533
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
57533
57534
|
modifiersType,
|
|
@@ -57567,8 +57568,8 @@ function createTypeChecker(host) {
|
|
|
57567
57568
|
}
|
|
57568
57569
|
members.set(propName, prop);
|
|
57569
57570
|
}
|
|
57570
|
-
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ |
|
|
57571
|
-
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;
|
|
57572
57573
|
const propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType));
|
|
57573
57574
|
const modifiersIndexInfo = getApplicableIndexInfo(modifiersType, propNameType);
|
|
57574
57575
|
const isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || !(templateModifiers & 2 /* ExcludeReadonly */) && (modifiersIndexInfo == null ? void 0 : modifiersIndexInfo.isReadonly));
|
|
@@ -57593,7 +57594,7 @@ function createTypeChecker(host) {
|
|
|
57593
57594
|
const templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType);
|
|
57594
57595
|
const mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.links.keyType);
|
|
57595
57596
|
const propType = instantiateType(templateType, mapper);
|
|
57596
|
-
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType,
|
|
57597
|
+
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 4 /* Undefined */ | 16 /* Void */) ? getOptionalType(
|
|
57597
57598
|
propType,
|
|
57598
57599
|
/*isProperty*/
|
|
57599
57600
|
true
|
|
@@ -57887,14 +57888,14 @@ function createTypeChecker(host) {
|
|
|
57887
57888
|
constraints = append(constraints, t);
|
|
57888
57889
|
}
|
|
57889
57890
|
}
|
|
57890
|
-
} else if (t.flags &
|
|
57891
|
+
} else if (t.flags & 469860348 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
57891
57892
|
hasDisjointDomainType = true;
|
|
57892
57893
|
}
|
|
57893
57894
|
}
|
|
57894
57895
|
if (constraints && (targetIsUnion || hasDisjointDomainType)) {
|
|
57895
57896
|
if (hasDisjointDomainType) {
|
|
57896
57897
|
for (const t of types) {
|
|
57897
|
-
if (t.flags &
|
|
57898
|
+
if (t.flags & 469860348 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
57898
57899
|
constraints = append(constraints, t);
|
|
57899
57900
|
}
|
|
57900
57901
|
}
|
|
@@ -58095,7 +58096,7 @@ function createTypeChecker(host) {
|
|
|
58095
58096
|
function getApparentType(type) {
|
|
58096
58097
|
const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
|
|
58097
58098
|
const objectFlags = getObjectFlags(t);
|
|
58098
|
-
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;
|
|
58099
58100
|
}
|
|
58100
58101
|
function getReducedApparentType(type) {
|
|
58101
58102
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
@@ -58447,7 +58448,7 @@ function createTypeChecker(host) {
|
|
|
58447
58448
|
)) : applicableInfo ? applicableInfo : stringIndexInfo && isApplicableIndexType(keyType, stringType) ? stringIndexInfo : void 0;
|
|
58448
58449
|
}
|
|
58449
58450
|
function isApplicableIndexType(source, target) {
|
|
58450
|
-
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));
|
|
58451
58452
|
}
|
|
58452
58453
|
function getIndexInfosOfStructuredType(type) {
|
|
58453
58454
|
if (type.flags & 3670016 /* StructuredType */) {
|
|
@@ -58776,7 +58777,7 @@ function createTypeChecker(host) {
|
|
|
58776
58777
|
}
|
|
58777
58778
|
if (type || jsdocPredicate) {
|
|
58778
58779
|
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
58779
|
-
} 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) {
|
|
58780
58781
|
const { declaration } = signature;
|
|
58781
58782
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
58782
58783
|
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
@@ -59061,7 +59062,7 @@ function createTypeChecker(host) {
|
|
|
59061
59062
|
return emptyArray;
|
|
59062
59063
|
}
|
|
59063
59064
|
function isValidIndexKeyType(type) {
|
|
59064
|
-
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);
|
|
59065
59066
|
}
|
|
59066
59067
|
function getConstraintDeclaration(type) {
|
|
59067
59068
|
return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
|
|
@@ -59562,7 +59563,7 @@ function createTypeChecker(host) {
|
|
|
59562
59563
|
}
|
|
59563
59564
|
function getTypeFromJSDocNullableTypeNode(node) {
|
|
59564
59565
|
const type = getTypeFromTypeNode(node.type);
|
|
59565
|
-
return strictNullChecks ? getNullableType(type,
|
|
59566
|
+
return strictNullChecks ? getNullableType(type, 8 /* Null */) : type;
|
|
59566
59567
|
}
|
|
59567
59568
|
function getTypeFromTypeReference(node) {
|
|
59568
59569
|
const links = getNodeLinks(node);
|
|
@@ -60335,10 +60336,10 @@ function createTypeChecker(host) {
|
|
|
60335
60336
|
return type.id;
|
|
60336
60337
|
}
|
|
60337
60338
|
function containsType(types, type) {
|
|
60338
|
-
return binarySearch(types, type,
|
|
60339
|
+
return binarySearch(types, type, identity, compareTypes) >= 0;
|
|
60339
60340
|
}
|
|
60340
60341
|
function insertType(types, type) {
|
|
60341
|
-
const index = binarySearch(types, type,
|
|
60342
|
+
const index = binarySearch(types, type, identity, compareTypes);
|
|
60342
60343
|
if (index < 0) {
|
|
60343
60344
|
types.splice(~index, 0, type);
|
|
60344
60345
|
return true;
|
|
@@ -60353,11 +60354,10 @@ function createTypeChecker(host) {
|
|
|
60353
60354
|
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) includes |= 536870912 /* IncludesConstrainedTypeVariable */;
|
|
60354
60355
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
60355
60356
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
60356
|
-
if (!strictNullChecks && flags &
|
|
60357
|
+
if (!strictNullChecks && flags & 12 /* Nullable */) {
|
|
60357
60358
|
if (!(getObjectFlags(type) & 65536 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */;
|
|
60358
60359
|
} else {
|
|
60359
|
-
const
|
|
60360
|
-
const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues);
|
|
60360
|
+
const index = binarySearch(typeSet, type, identity, compareTypes);
|
|
60361
60361
|
if (index < 0) {
|
|
60362
60362
|
typeSet.splice(~index, 0, type);
|
|
60363
60363
|
}
|
|
@@ -60435,7 +60435,7 @@ function createTypeChecker(host) {
|
|
|
60435
60435
|
i--;
|
|
60436
60436
|
const t = types[i];
|
|
60437
60437
|
const flags = t.flags;
|
|
60438
|
-
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);
|
|
60439
60439
|
if (remove) {
|
|
60440
60440
|
orderedRemoveItemAt(types, i);
|
|
60441
60441
|
}
|
|
@@ -60448,7 +60448,7 @@ function createTypeChecker(host) {
|
|
|
60448
60448
|
while (i > 0) {
|
|
60449
60449
|
i--;
|
|
60450
60450
|
const t = types[i];
|
|
60451
|
-
if (t.flags &
|
|
60451
|
+
if (t.flags & 1024 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
|
|
60452
60452
|
orderedRemoveItemAt(types, i);
|
|
60453
60453
|
}
|
|
60454
60454
|
}
|
|
@@ -60546,15 +60546,15 @@ function createTypeChecker(host) {
|
|
|
60546
60546
|
if (includes & 3 /* AnyOrUnknown */) {
|
|
60547
60547
|
return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType : unknownType;
|
|
60548
60548
|
}
|
|
60549
|
-
if (includes &
|
|
60549
|
+
if (includes & 4 /* Undefined */) {
|
|
60550
60550
|
if (typeSet.length >= 2 && typeSet[0] === undefinedType && typeSet[1] === missingType) {
|
|
60551
60551
|
orderedRemoveItemAt(typeSet, 1);
|
|
60552
60552
|
}
|
|
60553
60553
|
}
|
|
60554
|
-
if (includes & (
|
|
60554
|
+
if (includes & (65536 /* Enum */ | 15360 /* Literal */ | 16384 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16 /* Void */ && includes & 4 /* Undefined */) {
|
|
60555
60555
|
removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */));
|
|
60556
60556
|
}
|
|
60557
|
-
if (includes &
|
|
60557
|
+
if (includes & 1024 /* StringLiteral */ && includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
60558
60558
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
60559
60559
|
}
|
|
60560
60560
|
if (includes & 536870912 /* IncludesConstrainedTypeVariable */) {
|
|
@@ -60567,7 +60567,7 @@ function createTypeChecker(host) {
|
|
|
60567
60567
|
}
|
|
60568
60568
|
}
|
|
60569
60569
|
if (typeSet.length === 0) {
|
|
60570
|
-
return includes &
|
|
60570
|
+
return includes & 8 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : includes & 4 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType;
|
|
60571
60571
|
}
|
|
60572
60572
|
}
|
|
60573
60573
|
if (!origin && includes & 1048576 /* Union */) {
|
|
@@ -60590,7 +60590,7 @@ function createTypeChecker(host) {
|
|
|
60590
60590
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
60591
60591
|
}
|
|
60592
60592
|
}
|
|
60593
|
-
const objectFlags = (includes &
|
|
60593
|
+
const objectFlags = (includes & 36306963 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
60594
60594
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
60595
60595
|
}
|
|
60596
60596
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -60635,14 +60635,14 @@ function createTypeChecker(host) {
|
|
|
60635
60635
|
type.objectFlags = precomputedObjectFlags | getPropagatingFlagsOfTypes(
|
|
60636
60636
|
types,
|
|
60637
60637
|
/*excludeKinds*/
|
|
60638
|
-
|
|
60638
|
+
12 /* Nullable */
|
|
60639
60639
|
);
|
|
60640
60640
|
type.types = types;
|
|
60641
60641
|
type.origin = origin;
|
|
60642
60642
|
type.aliasSymbol = aliasSymbol;
|
|
60643
60643
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
60644
|
-
if (types.length === 2 && types[0].flags &
|
|
60645
|
-
type.flags |=
|
|
60644
|
+
if (types.length === 2 && types[0].flags & 4096 /* BooleanLiteral */ && types[1].flags & 4096 /* BooleanLiteral */) {
|
|
60645
|
+
type.flags |= 256 /* Boolean */;
|
|
60646
60646
|
type.intrinsicName = "boolean";
|
|
60647
60647
|
}
|
|
60648
60648
|
unionTypes.set(id, type);
|
|
@@ -60671,13 +60671,13 @@ function createTypeChecker(host) {
|
|
|
60671
60671
|
if (flags & 3 /* AnyOrUnknown */) {
|
|
60672
60672
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
60673
60673
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
60674
|
-
} else if (strictNullChecks || !(flags &
|
|
60674
|
+
} else if (strictNullChecks || !(flags & 12 /* Nullable */)) {
|
|
60675
60675
|
if (type === missingType) {
|
|
60676
60676
|
includes |= 262144 /* IncludesMissingType */;
|
|
60677
60677
|
type = undefinedType;
|
|
60678
60678
|
}
|
|
60679
60679
|
if (!typeSet.has(type.id.toString())) {
|
|
60680
|
-
if (type.flags &
|
|
60680
|
+
if (type.flags & 97292 /* Unit */ && includes & 97292 /* Unit */) {
|
|
60681
60681
|
includes |= 67108864 /* NonPrimitive */;
|
|
60682
60682
|
}
|
|
60683
60683
|
typeSet.set(type.id.toString(), type);
|
|
@@ -60698,7 +60698,7 @@ function createTypeChecker(host) {
|
|
|
60698
60698
|
while (i > 0) {
|
|
60699
60699
|
i--;
|
|
60700
60700
|
const t = types[i];
|
|
60701
|
-
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 */;
|
|
60702
60702
|
if (remove) {
|
|
60703
60703
|
orderedRemoveItemAt(types, i);
|
|
60704
60704
|
}
|
|
@@ -60713,7 +60713,7 @@ function createTypeChecker(host) {
|
|
|
60713
60713
|
if (type === undefinedType) {
|
|
60714
60714
|
return containsType(u.types, missingType);
|
|
60715
60715
|
}
|
|
60716
|
-
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;
|
|
60717
60717
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
60718
60718
|
return false;
|
|
60719
60719
|
}
|
|
@@ -60723,7 +60723,7 @@ function createTypeChecker(host) {
|
|
|
60723
60723
|
}
|
|
60724
60724
|
function extractRedundantTemplateLiterals(types) {
|
|
60725
60725
|
let i = types.length;
|
|
60726
|
-
const literals = filter(types, (t) => !!(t.flags &
|
|
60726
|
+
const literals = filter(types, (t) => !!(t.flags & 1024 /* StringLiteral */));
|
|
60727
60727
|
while (i > 0) {
|
|
60728
60728
|
i--;
|
|
60729
60729
|
const t = types[i];
|
|
@@ -60789,7 +60789,7 @@ function createTypeChecker(host) {
|
|
|
60789
60789
|
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
60790
60790
|
types,
|
|
60791
60791
|
/*excludeKinds*/
|
|
60792
|
-
|
|
60792
|
+
12 /* Nullable */
|
|
60793
60793
|
);
|
|
60794
60794
|
result.types = types;
|
|
60795
60795
|
result.aliasSymbol = aliasSymbol;
|
|
@@ -60804,19 +60804,19 @@ function createTypeChecker(host) {
|
|
|
60804
60804
|
if (includes & 131072 /* Never */) {
|
|
60805
60805
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
60806
60806
|
}
|
|
60807
|
-
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 */)) {
|
|
60808
60808
|
return neverType;
|
|
60809
60809
|
}
|
|
60810
|
-
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes &
|
|
60810
|
+
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 1024 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) {
|
|
60811
60811
|
return neverType;
|
|
60812
60812
|
}
|
|
60813
60813
|
if (includes & 1 /* Any */) {
|
|
60814
60814
|
return includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType;
|
|
60815
60815
|
}
|
|
60816
|
-
if (!strictNullChecks && includes &
|
|
60817
|
-
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes &
|
|
60816
|
+
if (!strictNullChecks && includes & 12 /* Nullable */) {
|
|
60817
|
+
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes & 4 /* Undefined */ ? undefinedType : nullType;
|
|
60818
60818
|
}
|
|
60819
|
-
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 */) {
|
|
60820
60820
|
if (!(flags & 1 /* NoSupertypeReduction */)) removeRedundantSupertypes(typeSet, includes);
|
|
60821
60821
|
}
|
|
60822
60822
|
if (includes & 262144 /* IncludesMissingType */) {
|
|
@@ -60853,12 +60853,12 @@ function createTypeChecker(host) {
|
|
|
60853
60853
|
if (includes & 1048576 /* Union */) {
|
|
60854
60854
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
60855
60855
|
result = getIntersectionType(typeSet, flags, aliasSymbol, aliasTypeArguments);
|
|
60856
|
-
} 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 */))) {
|
|
60857
60857
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
60858
|
-
removeFromEach(typeSet,
|
|
60858
|
+
removeFromEach(typeSet, 4 /* Undefined */);
|
|
60859
60859
|
result = getUnionType([getIntersectionType(typeSet, flags), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60860
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags &
|
|
60861
|
-
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 */);
|
|
60862
60862
|
result = getUnionType([getIntersectionType(typeSet, flags), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60863
60863
|
} else if (typeSet.length >= 3 && types.length > 2) {
|
|
60864
60864
|
const middle = Math.floor(typeSet.length / 2);
|
|
@@ -60923,7 +60923,7 @@ function createTypeChecker(host) {
|
|
|
60923
60923
|
const types = map(node.types, getTypeFromTypeNode);
|
|
60924
60924
|
const emptyIndex = types.length === 2 ? types.indexOf(emptyTypeLiteralType) : -1;
|
|
60925
60925
|
const t = emptyIndex >= 0 ? types[1 - emptyIndex] : unknownType;
|
|
60926
|
-
const noSupertypeReduction = !!(t.flags & (
|
|
60926
|
+
const noSupertypeReduction = !!(t.flags & (32 /* String */ | 64 /* Number */ | 128 /* BigInt */) || t.flags & 134217728 /* TemplateLiteral */ && isPatternLiteralType(t));
|
|
60927
60927
|
links.resolvedType = getIntersectionType(types, noSupertypeReduction ? 1 /* NoSupertypeReduction */ : 0, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
60928
60928
|
}
|
|
60929
60929
|
return links.resolvedType;
|
|
@@ -60957,11 +60957,11 @@ function createTypeChecker(host) {
|
|
|
60957
60957
|
forEachType(constraintType, addMemberForKeyType);
|
|
60958
60958
|
} else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
60959
60959
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
60960
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType,
|
|
60960
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 19456 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
|
|
60961
60961
|
} else {
|
|
60962
60962
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
60963
60963
|
}
|
|
60964
|
-
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);
|
|
60965
60965
|
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
60966
60966
|
return constraintType;
|
|
60967
60967
|
}
|
|
@@ -61016,7 +61016,7 @@ function createTypeChecker(host) {
|
|
|
61016
61016
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
61017
61017
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
61018
61018
|
const propertyTypes = map(getPropertiesOfType(type), (prop) => getLiteralTypeFromProperty(prop, include));
|
|
61019
|
-
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);
|
|
61020
61020
|
return getUnionType(
|
|
61021
61021
|
concatenate(propertyTypes, indexKeyTypes),
|
|
61022
61022
|
1 /* Literal */,
|
|
@@ -61032,7 +61032,7 @@ function createTypeChecker(host) {
|
|
|
61032
61032
|
}
|
|
61033
61033
|
function getIndexType(type, indexFlags = 0 /* None */) {
|
|
61034
61034
|
type = getReducedType(type);
|
|
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 */ ?
|
|
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 */);
|
|
61036
61036
|
}
|
|
61037
61037
|
function getExtractStringType(type) {
|
|
61038
61038
|
const extractTypeAlias = getGlobalExtractSymbol();
|
|
@@ -61090,7 +61090,7 @@ function createTypeChecker(host) {
|
|
|
61090
61090
|
}
|
|
61091
61091
|
newTexts.push(text);
|
|
61092
61092
|
if (every(newTexts, (t) => t === "")) {
|
|
61093
|
-
if (every(newTypes, (t) => !!(t.flags &
|
|
61093
|
+
if (every(newTypes, (t) => !!(t.flags & 32 /* String */))) {
|
|
61094
61094
|
return stringType;
|
|
61095
61095
|
}
|
|
61096
61096
|
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
@@ -61106,7 +61106,7 @@ function createTypeChecker(host) {
|
|
|
61106
61106
|
function addSpans(texts2, types2) {
|
|
61107
61107
|
for (let i = 0; i < types2.length; i++) {
|
|
61108
61108
|
const t = types2[i];
|
|
61109
|
-
if (t.flags & (
|
|
61109
|
+
if (t.flags & (15360 /* Literal */ | 8 /* Null */ | 4 /* Undefined */)) {
|
|
61110
61110
|
text += getTemplateStringForType(t) || "";
|
|
61111
61111
|
text += texts2[i + 1];
|
|
61112
61112
|
} else if (t.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -61125,7 +61125,7 @@ function createTypeChecker(host) {
|
|
|
61125
61125
|
}
|
|
61126
61126
|
}
|
|
61127
61127
|
function getTemplateStringForType(type) {
|
|
61128
|
-
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;
|
|
61129
61129
|
}
|
|
61130
61130
|
function createTemplateLiteralType(texts, types) {
|
|
61131
61131
|
const type = createType(134217728 /* TemplateLiteral */);
|
|
@@ -61134,9 +61134,9 @@ function createTypeChecker(host) {
|
|
|
61134
61134
|
return type;
|
|
61135
61135
|
}
|
|
61136
61136
|
function getStringMappingType(symbol, type) {
|
|
61137
|
-
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)) : (
|
|
61138
61138
|
// Mapping<Mapping<T>> === Mapping<T>
|
|
61139
|
-
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) : (
|
|
61140
61140
|
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
61141
61141
|
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) : type
|
|
61142
61142
|
)
|
|
@@ -61274,7 +61274,7 @@ function createTypeChecker(host) {
|
|
|
61274
61274
|
}
|
|
61275
61275
|
}
|
|
61276
61276
|
}
|
|
61277
|
-
if (!(indexType.flags &
|
|
61277
|
+
if (!(indexType.flags & 12 /* Nullable */) && isTypeAssignableToKind(indexType, 402654240 /* StringLike */ | 67648 /* NumberLike */ | 16896 /* ESSymbolLike */)) {
|
|
61278
61278
|
if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
|
|
61279
61279
|
return objectType;
|
|
61280
61280
|
}
|
|
@@ -61290,13 +61290,13 @@ function createTypeChecker(host) {
|
|
|
61290
61290
|
}
|
|
61291
61291
|
return void 0;
|
|
61292
61292
|
}
|
|
61293
|
-
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType,
|
|
61293
|
+
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 32 /* String */ | 64 /* Number */)) {
|
|
61294
61294
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
61295
61295
|
error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
|
|
61296
61296
|
return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
|
|
61297
61297
|
}
|
|
61298
61298
|
errorIfWritingToReadonlyIndex(indexInfo);
|
|
61299
|
-
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))) {
|
|
61300
61300
|
return getUnionType([indexInfo.type, missingType]);
|
|
61301
61301
|
}
|
|
61302
61302
|
return indexInfo.type;
|
|
@@ -61309,10 +61309,10 @@ function createTypeChecker(host) {
|
|
|
61309
61309
|
}
|
|
61310
61310
|
if (accessExpression && !isConstEnumObjectType(objectType)) {
|
|
61311
61311
|
if (isObjectLiteralType(objectType)) {
|
|
61312
|
-
if (noImplicitAny && indexType.flags & (
|
|
61312
|
+
if (noImplicitAny && indexType.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */)) {
|
|
61313
61313
|
diagnostics.add(createDiagnosticForNode(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)));
|
|
61314
61314
|
return undefinedType;
|
|
61315
|
-
} else if (indexType.flags & (
|
|
61315
|
+
} else if (indexType.flags & (64 /* Number */ | 32 /* String */)) {
|
|
61316
61316
|
const types = map(objectType.properties, (property) => {
|
|
61317
61317
|
return getTypeOfSymbol(property);
|
|
61318
61318
|
});
|
|
@@ -61339,7 +61339,7 @@ function createTypeChecker(host) {
|
|
|
61339
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);
|
|
61340
61340
|
} else {
|
|
61341
61341
|
let errorInfo;
|
|
61342
|
-
if (indexType.flags &
|
|
61342
|
+
if (indexType.flags & 32768 /* EnumLiteral */) {
|
|
61343
61343
|
errorInfo = chainDiagnosticMessages(
|
|
61344
61344
|
/*details*/
|
|
61345
61345
|
void 0,
|
|
@@ -61347,7 +61347,7 @@ function createTypeChecker(host) {
|
|
|
61347
61347
|
"[" + typeToString(indexType) + "]",
|
|
61348
61348
|
typeToString(objectType)
|
|
61349
61349
|
);
|
|
61350
|
-
} else if (indexType.flags &
|
|
61350
|
+
} else if (indexType.flags & 16384 /* UniqueESSymbol */) {
|
|
61351
61351
|
const symbolName2 = getFullyQualifiedName(indexType.symbol, accessExpression);
|
|
61352
61352
|
errorInfo = chainDiagnosticMessages(
|
|
61353
61353
|
/*details*/
|
|
@@ -61356,7 +61356,7 @@ function createTypeChecker(host) {
|
|
|
61356
61356
|
"[" + symbolName2 + "]",
|
|
61357
61357
|
typeToString(objectType)
|
|
61358
61358
|
);
|
|
61359
|
-
} else if (indexType.flags &
|
|
61359
|
+
} else if (indexType.flags & 1024 /* StringLiteral */) {
|
|
61360
61360
|
errorInfo = chainDiagnosticMessages(
|
|
61361
61361
|
/*details*/
|
|
61362
61362
|
void 0,
|
|
@@ -61364,7 +61364,7 @@ function createTypeChecker(host) {
|
|
|
61364
61364
|
indexType.value,
|
|
61365
61365
|
typeToString(objectType)
|
|
61366
61366
|
);
|
|
61367
|
-
} else if (indexType.flags &
|
|
61367
|
+
} else if (indexType.flags & 2048 /* NumberLiteral */) {
|
|
61368
61368
|
errorInfo = chainDiagnosticMessages(
|
|
61369
61369
|
/*details*/
|
|
61370
61370
|
void 0,
|
|
@@ -61372,7 +61372,7 @@ function createTypeChecker(host) {
|
|
|
61372
61372
|
indexType.value,
|
|
61373
61373
|
typeToString(objectType)
|
|
61374
61374
|
);
|
|
61375
|
-
} else if (indexType.flags & (
|
|
61375
|
+
} else if (indexType.flags & (64 /* Number */ | 32 /* String */)) {
|
|
61376
61376
|
errorInfo = chainDiagnosticMessages(
|
|
61377
61377
|
/*details*/
|
|
61378
61378
|
void 0,
|
|
@@ -61403,9 +61403,9 @@ function createTypeChecker(host) {
|
|
|
61403
61403
|
}
|
|
61404
61404
|
if (accessNode) {
|
|
61405
61405
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
61406
|
-
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (
|
|
61406
|
+
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (1024 /* StringLiteral */ | 2048 /* NumberLiteral */)) {
|
|
61407
61407
|
error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
|
|
61408
|
-
} else if (indexType.flags & (
|
|
61408
|
+
} else if (indexType.flags & (32 /* String */ | 64 /* Number */)) {
|
|
61409
61409
|
error(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
|
|
61410
61410
|
} else {
|
|
61411
61411
|
const typeString = indexNode.kind === 10 /* BigIntLiteral */ ? "bigint" : typeToString(indexType);
|
|
@@ -61429,7 +61429,7 @@ function createTypeChecker(host) {
|
|
|
61429
61429
|
if (type.flags & 2097152 /* Intersection */) {
|
|
61430
61430
|
let seenPlaceholder = false;
|
|
61431
61431
|
for (const t of type.types) {
|
|
61432
|
-
if (t.flags & (
|
|
61432
|
+
if (t.flags & (15360 /* Literal */ | 12 /* Nullable */) || isPatternLiteralPlaceholderType(t)) {
|
|
61433
61433
|
seenPlaceholder = true;
|
|
61434
61434
|
} else if (!(t.flags & 524288 /* Object */)) {
|
|
61435
61435
|
return false;
|
|
@@ -61437,7 +61437,7 @@ function createTypeChecker(host) {
|
|
|
61437
61437
|
}
|
|
61438
61438
|
return seenPlaceholder;
|
|
61439
61439
|
}
|
|
61440
|
-
return !!(type.flags & (1 /* Any */ |
|
|
61440
|
+
return !!(type.flags & (1 /* Any */ | 32 /* String */ | 64 /* Number */ | 128 /* BigInt */)) || isPatternLiteralType(type);
|
|
61441
61441
|
}
|
|
61442
61442
|
function isPatternLiteralType(type) {
|
|
61443
61443
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
@@ -61502,10 +61502,10 @@ function createTypeChecker(host) {
|
|
|
61502
61502
|
return type[cache] = distributedOverObject;
|
|
61503
61503
|
}
|
|
61504
61504
|
}
|
|
61505
|
-
if (isGenericTupleType(objectType) && indexType.flags &
|
|
61505
|
+
if (isGenericTupleType(objectType) && indexType.flags & 67648 /* NumberLike */) {
|
|
61506
61506
|
const elementType = getElementTypeOfSliceOfTupleType(
|
|
61507
61507
|
objectType,
|
|
61508
|
-
indexType.flags &
|
|
61508
|
+
indexType.flags & 64 /* Number */ ? 0 : objectType.target.fixedLength,
|
|
61509
61509
|
/*endSkipCount*/
|
|
61510
61510
|
0,
|
|
61511
61511
|
writing
|
|
@@ -61558,14 +61558,14 @@ function createTypeChecker(host) {
|
|
|
61558
61558
|
}
|
|
61559
61559
|
function couldAccessOptionalProperty(objectType, indexType) {
|
|
61560
61560
|
const indexConstraint = getBaseConstraintOfType(indexType);
|
|
61561
|
-
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));
|
|
61562
61562
|
}
|
|
61563
61563
|
function getIndexedAccessType(objectType, indexType, accessFlags = 0 /* None */, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
61564
61564
|
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
61565
61565
|
}
|
|
61566
61566
|
function indexTypeLessThan(indexType, limit) {
|
|
61567
61567
|
return everyType(indexType, (t) => {
|
|
61568
|
-
if (t.flags &
|
|
61568
|
+
if (t.flags & 3072 /* StringOrNumberLiteral */) {
|
|
61569
61569
|
const propName = getPropertyNameFromType(t);
|
|
61570
61570
|
if (isNumericLiteralName(propName)) {
|
|
61571
61571
|
const index = +propName;
|
|
@@ -61580,7 +61580,7 @@ function createTypeChecker(host) {
|
|
|
61580
61580
|
return wildcardType;
|
|
61581
61581
|
}
|
|
61582
61582
|
objectType = getReducedType(objectType);
|
|
61583
|
-
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags &
|
|
61583
|
+
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 12 /* Nullable */) && isTypeAssignableToKind(indexType, 32 /* String */ | 64 /* Number */)) {
|
|
61584
61584
|
indexType = stringType;
|
|
61585
61585
|
}
|
|
61586
61586
|
if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) accessFlags |= 1 /* IncludeUndefined */;
|
|
@@ -61597,7 +61597,7 @@ function createTypeChecker(host) {
|
|
|
61597
61597
|
return type;
|
|
61598
61598
|
}
|
|
61599
61599
|
const apparentObjectType = getReducedApparentType(objectType);
|
|
61600
|
-
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags &
|
|
61600
|
+
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 256 /* Boolean */)) {
|
|
61601
61601
|
const propTypes = [];
|
|
61602
61602
|
let wasMissingProp = false;
|
|
61603
61603
|
for (const t of indexType.types) {
|
|
@@ -61930,7 +61930,7 @@ function createTypeChecker(host) {
|
|
|
61930
61930
|
return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type);
|
|
61931
61931
|
}
|
|
61932
61932
|
function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
|
|
61933
|
-
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 */));
|
|
61934
61934
|
}
|
|
61935
61935
|
function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
|
|
61936
61936
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
@@ -61993,7 +61993,7 @@ function createTypeChecker(host) {
|
|
|
61993
61993
|
if (right.flags & 1048576 /* Union */) {
|
|
61994
61994
|
return checkCrossProductUnion([left, right]) ? mapType(right, (t) => getSpreadType(left, t, symbol, objectFlags, readonly)) : errorType;
|
|
61995
61995
|
}
|
|
61996
|
-
if (right.flags & (
|
|
61996
|
+
if (right.flags & (4352 /* BooleanLike */ | 67648 /* NumberLike */ | 8320 /* BigIntLike */ | 402654240 /* StringLike */ | 98304 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) {
|
|
61997
61997
|
return left;
|
|
61998
61998
|
}
|
|
61999
61999
|
if (isGenericObjectType(left) || isGenericObjectType(right)) {
|
|
@@ -62075,7 +62075,7 @@ function createTypeChecker(host) {
|
|
|
62075
62075
|
return type;
|
|
62076
62076
|
}
|
|
62077
62077
|
function getFreshTypeOfLiteralType(type) {
|
|
62078
|
-
if (type.flags &
|
|
62078
|
+
if (type.flags & 80896 /* Freshable */) {
|
|
62079
62079
|
if (!type.freshType) {
|
|
62080
62080
|
const freshType = createLiteralType(type.flags, type.value, type.symbol, type);
|
|
62081
62081
|
freshType.freshType = freshType;
|
|
@@ -62086,28 +62086,28 @@ function createTypeChecker(host) {
|
|
|
62086
62086
|
return type;
|
|
62087
62087
|
}
|
|
62088
62088
|
function getRegularTypeOfLiteralType(type) {
|
|
62089
|
-
return type.flags &
|
|
62089
|
+
return type.flags & 80896 /* Freshable */ ? type.regularType : type.flags & 1048576 /* Union */ ? type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType)) : type;
|
|
62090
62090
|
}
|
|
62091
62091
|
function isFreshLiteralType(type) {
|
|
62092
|
-
return !!(type.flags &
|
|
62092
|
+
return !!(type.flags & 80896 /* Freshable */) && type.freshType === type;
|
|
62093
62093
|
}
|
|
62094
62094
|
function getStringLiteralType(value) {
|
|
62095
62095
|
let type;
|
|
62096
|
-
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(
|
|
62096
|
+
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(1024 /* StringLiteral */, value)), type);
|
|
62097
62097
|
}
|
|
62098
62098
|
function getNumberLiteralType(value) {
|
|
62099
62099
|
let type;
|
|
62100
|
-
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(
|
|
62100
|
+
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(2048 /* NumberLiteral */, value)), type);
|
|
62101
62101
|
}
|
|
62102
62102
|
function getBigIntLiteralType(value) {
|
|
62103
62103
|
let type;
|
|
62104
62104
|
const key = pseudoBigIntToString(value);
|
|
62105
|
-
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(
|
|
62105
|
+
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(8192 /* BigIntLiteral */, value)), type);
|
|
62106
62106
|
}
|
|
62107
62107
|
function getEnumLiteralType(value, enumId, symbol) {
|
|
62108
62108
|
let type;
|
|
62109
62109
|
const key = `${enumId}${typeof value === "string" ? "@" : "#"}${value}`;
|
|
62110
|
-
const flags =
|
|
62110
|
+
const flags = 32768 /* EnumLiteral */ | (typeof value === "string" ? 1024 /* StringLiteral */ : 2048 /* NumberLiteral */);
|
|
62111
62111
|
return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type);
|
|
62112
62112
|
}
|
|
62113
62113
|
function getTypeFromLiteralTypeNode(node) {
|
|
@@ -62121,7 +62121,7 @@ function createTypeChecker(host) {
|
|
|
62121
62121
|
return links.resolvedType;
|
|
62122
62122
|
}
|
|
62123
62123
|
function createUniqueESSymbolType(symbol) {
|
|
62124
|
-
const type = createTypeWithSymbol(
|
|
62124
|
+
const type = createTypeWithSymbol(16384 /* UniqueESSymbol */, symbol);
|
|
62125
62125
|
type.escapedName = `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}`;
|
|
62126
62126
|
return type;
|
|
62127
62127
|
}
|
|
@@ -62509,7 +62509,7 @@ function createTypeChecker(host) {
|
|
|
62509
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);
|
|
62510
62510
|
target.instantiations.set(id, result);
|
|
62511
62511
|
const resultObjectFlags = getObjectFlags(result);
|
|
62512
|
-
if (result.flags &
|
|
62512
|
+
if (result.flags & 3801101 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62513
62513
|
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
62514
62514
|
if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62515
62515
|
if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
|
|
@@ -62638,7 +62638,7 @@ function createTypeChecker(host) {
|
|
|
62638
62638
|
const templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
|
|
62639
62639
|
const propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
|
|
62640
62640
|
const modifiers = getMappedTypeModifiers(type);
|
|
62641
|
-
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType,
|
|
62641
|
+
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 4 /* Undefined */ | 16 /* Void */) ? getOptionalType(
|
|
62642
62642
|
propType,
|
|
62643
62643
|
/*isProperty*/
|
|
62644
62644
|
true
|
|
@@ -63185,7 +63185,7 @@ function createTypeChecker(host) {
|
|
|
63185
63185
|
createDiagnosticForNode(
|
|
63186
63186
|
targetNode,
|
|
63187
63187
|
Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1,
|
|
63188
|
-
propertyName && !(nameType.flags &
|
|
63188
|
+
propertyName && !(nameType.flags & 16384 /* UniqueESSymbol */) ? unescapeLeadingUnderscores(propertyName) : typeToString(nameType),
|
|
63189
63189
|
typeToString(target)
|
|
63190
63190
|
)
|
|
63191
63191
|
);
|
|
@@ -63428,7 +63428,7 @@ function createTypeChecker(host) {
|
|
|
63428
63428
|
if (!length(node.properties)) return;
|
|
63429
63429
|
for (const prop of node.properties) {
|
|
63430
63430
|
if (isSpreadAssignment(prop)) continue;
|
|
63431
|
-
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop),
|
|
63431
|
+
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop), 19456 /* StringOrNumberLiteralOrUnique */);
|
|
63432
63432
|
if (!type || type.flags & 131072 /* Never */) {
|
|
63433
63433
|
continue;
|
|
63434
63434
|
}
|
|
@@ -63478,7 +63478,7 @@ function createTypeChecker(host) {
|
|
|
63478
63478
|
}
|
|
63479
63479
|
return false;
|
|
63480
63480
|
}
|
|
63481
|
-
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
63481
|
+
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes2, reportUnreliableMarkers) {
|
|
63482
63482
|
if (source === target) {
|
|
63483
63483
|
return -1 /* True */;
|
|
63484
63484
|
}
|
|
@@ -63503,7 +63503,7 @@ function createTypeChecker(host) {
|
|
|
63503
63503
|
target,
|
|
63504
63504
|
/*inferenceContext*/
|
|
63505
63505
|
void 0,
|
|
63506
|
-
|
|
63506
|
+
compareTypes2
|
|
63507
63507
|
);
|
|
63508
63508
|
}
|
|
63509
63509
|
const sourceCount = getParameterCount(source);
|
|
@@ -63519,12 +63519,12 @@ function createTypeChecker(host) {
|
|
|
63519
63519
|
if (sourceThisType && sourceThisType !== voidType) {
|
|
63520
63520
|
const targetThisType = getThisTypeOfSignature(target);
|
|
63521
63521
|
if (targetThisType) {
|
|
63522
|
-
const related = !strictVariance &&
|
|
63522
|
+
const related = !strictVariance && compareTypes2(
|
|
63523
63523
|
sourceThisType,
|
|
63524
63524
|
targetThisType,
|
|
63525
63525
|
/*reportErrors*/
|
|
63526
63526
|
false
|
|
63527
|
-
) ||
|
|
63527
|
+
) || compareTypes2(targetThisType, sourceThisType, reportErrors2);
|
|
63528
63528
|
if (!related) {
|
|
63529
63529
|
if (reportErrors2) {
|
|
63530
63530
|
errorReporter(Diagnostics.The_this_types_of_each_signature_are_incompatible);
|
|
@@ -63543,13 +63543,13 @@ function createTypeChecker(host) {
|
|
|
63543
63543
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
63544
63544
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
63545
63545
|
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
63546
|
-
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(
|
|
63547
63547
|
sourceType,
|
|
63548
63548
|
targetType,
|
|
63549
63549
|
/*reportErrors*/
|
|
63550
63550
|
false
|
|
63551
|
-
) ||
|
|
63552
|
-
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(
|
|
63553
63553
|
sourceType,
|
|
63554
63554
|
targetType,
|
|
63555
63555
|
/*reportErrors*/
|
|
@@ -63576,7 +63576,7 @@ function createTypeChecker(host) {
|
|
|
63576
63576
|
if (targetTypePredicate) {
|
|
63577
63577
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
63578
63578
|
if (sourceTypePredicate) {
|
|
63579
|
-
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter,
|
|
63579
|
+
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter, compareTypes2);
|
|
63580
63580
|
} else if (isIdentifierTypePredicate(targetTypePredicate) || isThisTypePredicate(targetTypePredicate)) {
|
|
63581
63581
|
if (reportErrors2) {
|
|
63582
63582
|
errorReporter(Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
|
|
@@ -63584,12 +63584,12 @@ function createTypeChecker(host) {
|
|
|
63584
63584
|
return 0 /* False */;
|
|
63585
63585
|
}
|
|
63586
63586
|
} else {
|
|
63587
|
-
result &= checkMode & 1 /* BivariantCallback */ &&
|
|
63587
|
+
result &= checkMode & 1 /* BivariantCallback */ && compareTypes2(
|
|
63588
63588
|
targetReturnType,
|
|
63589
63589
|
sourceReturnType,
|
|
63590
63590
|
/*reportErrors*/
|
|
63591
63591
|
false
|
|
63592
|
-
) ||
|
|
63592
|
+
) || compareTypes2(sourceReturnType, targetReturnType, reportErrors2);
|
|
63593
63593
|
if (!result && reportErrors2 && incompatibleErrorReporter) {
|
|
63594
63594
|
incompatibleErrorReporter(sourceReturnType, targetReturnType);
|
|
63595
63595
|
}
|
|
@@ -63597,7 +63597,7 @@ function createTypeChecker(host) {
|
|
|
63597
63597
|
}
|
|
63598
63598
|
return result;
|
|
63599
63599
|
}
|
|
63600
|
-
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter,
|
|
63600
|
+
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter, compareTypes2) {
|
|
63601
63601
|
if (source.kind !== target.kind) {
|
|
63602
63602
|
if (reportErrors2) {
|
|
63603
63603
|
errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
|
|
@@ -63614,7 +63614,7 @@ function createTypeChecker(host) {
|
|
|
63614
63614
|
return 0 /* False */;
|
|
63615
63615
|
}
|
|
63616
63616
|
}
|
|
63617
|
-
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 */;
|
|
63618
63618
|
if (related === 0 /* False */ && reportErrors2) {
|
|
63619
63619
|
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
|
|
63620
63620
|
}
|
|
@@ -63648,18 +63648,18 @@ function createTypeChecker(host) {
|
|
|
63648
63648
|
if (strictNullChecks && type.flags & 1048576 /* Union */) {
|
|
63649
63649
|
if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
|
|
63650
63650
|
const types = type.types;
|
|
63651
|
-
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);
|
|
63652
63652
|
}
|
|
63653
63653
|
return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
|
|
63654
63654
|
}
|
|
63655
63655
|
return false;
|
|
63656
63656
|
}
|
|
63657
63657
|
function containsUndefinedType(type) {
|
|
63658
|
-
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags &
|
|
63658
|
+
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 4 /* Undefined */);
|
|
63659
63659
|
}
|
|
63660
63660
|
function containsNonMissingUndefinedType(type) {
|
|
63661
63661
|
const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
|
|
63662
|
-
return !!(candidate.flags &
|
|
63662
|
+
return !!(candidate.flags & 4 /* Undefined */) && candidate !== missingType;
|
|
63663
63663
|
}
|
|
63664
63664
|
function isStringIndexSignatureOnlyType(type) {
|
|
63665
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;
|
|
@@ -63730,25 +63730,25 @@ function createTypeChecker(host) {
|
|
|
63730
63730
|
if (t & 1 /* Any */ || s & 131072 /* Never */ || source === wildcardType) return true;
|
|
63731
63731
|
if (t & 2 /* Unknown */ && !(relation === strictSubtypeRelation && s & 1 /* Any */)) return true;
|
|
63732
63732
|
if (t & 131072 /* Never */) return false;
|
|
63733
|
-
if (s &
|
|
63734
|
-
if (s &
|
|
63735
|
-
if (s &
|
|
63736
|
-
if (s &
|
|
63737
|
-
if (s &
|
|
63738
|
-
if (s &
|
|
63739
|
-
if (s &
|
|
63740
|
-
if (s &
|
|
63741
|
-
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 */) {
|
|
63742
63742
|
if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
63743
|
-
if (s &
|
|
63743
|
+
if (s & 15360 /* Literal */ && t & 15360 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
63744
63744
|
}
|
|
63745
|
-
if (s &
|
|
63746
|
-
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;
|
|
63747
63747
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(getObjectFlags(source) & 8192 /* FreshLiteral */))) return true;
|
|
63748
63748
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
63749
63749
|
if (s & 1 /* Any */) return true;
|
|
63750
|
-
if (s &
|
|
63751
|
-
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;
|
|
63752
63752
|
if (isUnknownLikeUnionType(target)) return true;
|
|
63753
63753
|
}
|
|
63754
63754
|
return false;
|
|
@@ -63769,7 +63769,7 @@ function createTypeChecker(host) {
|
|
|
63769
63769
|
}
|
|
63770
63770
|
} else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
|
|
63771
63771
|
if (source.flags !== target.flags) return false;
|
|
63772
|
-
if (source.flags &
|
|
63772
|
+
if (source.flags & 67240959 /* Singleton */) return true;
|
|
63773
63773
|
}
|
|
63774
63774
|
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63775
63775
|
const related = relation.get(getRelationKey(
|
|
@@ -63823,7 +63823,7 @@ function createTypeChecker(host) {
|
|
|
63823
63823
|
let hasNullableOrEmpty = false;
|
|
63824
63824
|
for (const t of type.types) {
|
|
63825
63825
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
63826
|
-
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags &
|
|
63826
|
+
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 12 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
63827
63827
|
if (hasInstantiable && hasNullableOrEmpty) return true;
|
|
63828
63828
|
}
|
|
63829
63829
|
return false;
|
|
@@ -64093,7 +64093,7 @@ function createTypeChecker(host) {
|
|
|
64093
64093
|
} else if (exactOptionalPropertyTypes && getExactOptionalUnassignableProperties(source2, target2).length) {
|
|
64094
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;
|
|
64095
64095
|
} else {
|
|
64096
|
-
if (source2.flags &
|
|
64096
|
+
if (source2.flags & 1024 /* StringLiteral */ && target2.flags & 1048576 /* Union */) {
|
|
64097
64097
|
const suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source2, target2);
|
|
64098
64098
|
if (suggestedType) {
|
|
64099
64099
|
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType));
|
|
@@ -64162,7 +64162,7 @@ function createTypeChecker(host) {
|
|
|
64162
64162
|
if (source2 === target2) return -1 /* True */;
|
|
64163
64163
|
if (relation === identityRelation) {
|
|
64164
64164
|
if (source2.flags !== target2.flags) return 0 /* False */;
|
|
64165
|
-
if (source2.flags &
|
|
64165
|
+
if (source2.flags & 67240959 /* Singleton */) return -1 /* True */;
|
|
64166
64166
|
traceUnionsOrIntersectionsTooLarge(source2, target2);
|
|
64167
64167
|
return recursiveTypeRelatedTo(
|
|
64168
64168
|
source2,
|
|
@@ -64176,10 +64176,10 @@ function createTypeChecker(host) {
|
|
|
64176
64176
|
if (source2.flags & 262144 /* TypeParameter */ && getConstraintOfType(source2) === target2) {
|
|
64177
64177
|
return -1 /* True */;
|
|
64178
64178
|
}
|
|
64179
|
-
if (source2.flags &
|
|
64179
|
+
if (source2.flags & 470417376 /* DefinitelyNonNullable */ && target2.flags & 1048576 /* Union */) {
|
|
64180
64180
|
const types = target2.types;
|
|
64181
|
-
const candidate = types.length === 2 && types[0].flags &
|
|
64182
|
-
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 */)) {
|
|
64183
64183
|
target2 = getNormalizedType(
|
|
64184
64184
|
candidate,
|
|
64185
64185
|
/*writing*/
|
|
@@ -64481,9 +64481,9 @@ function createTypeChecker(host) {
|
|
|
64481
64481
|
if (containsType(targetTypes, source2)) {
|
|
64482
64482
|
return -1 /* True */;
|
|
64483
64483
|
}
|
|
64484
|
-
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 */)) {
|
|
64485
64485
|
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
64486
|
-
const primitive = source2.flags &
|
|
64486
|
+
const primitive = source2.flags & 1024 /* StringLiteral */ ? stringType : source2.flags & 2048 /* NumberLiteral */ ? numberType : source2.flags & 8192 /* BigIntLiteral */ ? bigintType : void 0;
|
|
64487
64487
|
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
64488
64488
|
}
|
|
64489
64489
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
@@ -64578,8 +64578,8 @@ function createTypeChecker(host) {
|
|
|
64578
64578
|
return 0 /* False */;
|
|
64579
64579
|
}
|
|
64580
64580
|
function getUndefinedStrippedTargetIfNeeded(source2, target2) {
|
|
64581
|
-
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags &
|
|
64582
|
-
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 */);
|
|
64583
64583
|
}
|
|
64584
64584
|
return target2;
|
|
64585
64585
|
}
|
|
@@ -64921,7 +64921,7 @@ function createTypeChecker(host) {
|
|
|
64921
64921
|
const mappedKeys = [];
|
|
64922
64922
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
64923
64923
|
modifiersType,
|
|
64924
|
-
|
|
64924
|
+
19456 /* StringOrNumberLiteralOrUnique */,
|
|
64925
64925
|
/*stringsOnly*/
|
|
64926
64926
|
false,
|
|
64927
64927
|
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
@@ -65180,7 +65180,7 @@ function createTypeChecker(host) {
|
|
|
65180
65180
|
if (includeOptional ? !(filteredByApplicability.flags & 131072 /* Never */) : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
|
|
65181
65181
|
const templateType2 = getTemplateTypeFromMappedType(target2);
|
|
65182
65182
|
const typeParameter = getTypeParameterFromMappedType(target2);
|
|
65183
|
-
const nonNullComponent = extractTypesOfKind(templateType2, ~
|
|
65183
|
+
const nonNullComponent = extractTypesOfKind(templateType2, ~12 /* Nullable */);
|
|
65184
65184
|
if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
|
|
65185
65185
|
if (result2 = isRelatedTo(source2, nonNullComponent.objectType, 2 /* Target */, reportErrors2)) {
|
|
65186
65186
|
return result2;
|
|
@@ -65841,7 +65841,7 @@ function createTypeChecker(host) {
|
|
|
65841
65841
|
for (const sourceProp of excludeProperties(getPropertiesOfType(source2), excludedProperties)) {
|
|
65842
65842
|
if (!getPropertyOfObjectType(target2, sourceProp.escapedName)) {
|
|
65843
65843
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
65844
|
-
if (!(sourceType.flags &
|
|
65844
|
+
if (!(sourceType.flags & 4 /* Undefined */)) {
|
|
65845
65845
|
if (reportErrors2) {
|
|
65846
65846
|
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target2));
|
|
65847
65847
|
}
|
|
@@ -66069,9 +66069,9 @@ function createTypeChecker(host) {
|
|
|
66069
66069
|
if (isIgnoredJsxProperty(source2, prop)) {
|
|
66070
66070
|
continue;
|
|
66071
66071
|
}
|
|
66072
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
66072
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */), keyType)) {
|
|
66073
66073
|
const propType = getNonMissingTypeOfSymbol(prop);
|
|
66074
|
-
const type = exactOptionalPropertyTypes || propType.flags &
|
|
66074
|
+
const type = exactOptionalPropertyTypes || propType.flags & 4 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) ? propType : getTypeWithFacts(propType, 524288 /* NEUndefined */);
|
|
66075
66075
|
const related = isRelatedTo(
|
|
66076
66076
|
type,
|
|
66077
66077
|
targetInfo.type,
|
|
@@ -66185,7 +66185,7 @@ function createTypeChecker(host) {
|
|
|
66185
66185
|
}
|
|
66186
66186
|
}
|
|
66187
66187
|
function typeCouldHaveTopLevelSingletonTypes(type) {
|
|
66188
|
-
if (type.flags &
|
|
66188
|
+
if (type.flags & 256 /* Boolean */) {
|
|
66189
66189
|
return false;
|
|
66190
66190
|
}
|
|
66191
66191
|
if (type.flags & 3145728 /* UnionOrIntersection */) {
|
|
@@ -66204,7 +66204,7 @@ function createTypeChecker(host) {
|
|
|
66204
66204
|
return getPropertiesOfType(target).filter((targetProp) => isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)));
|
|
66205
66205
|
}
|
|
66206
66206
|
function isExactOptionalPropertyMismatch(source, target) {
|
|
66207
|
-
return !!source && !!target && maybeTypeOfKind(source,
|
|
66207
|
+
return !!source && !!target && maybeTypeOfKind(source, 4 /* Undefined */) && !!containsMissingType(target);
|
|
66208
66208
|
}
|
|
66209
66209
|
function getExactOptionalProperties(type) {
|
|
66210
66210
|
return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
|
|
@@ -66330,7 +66330,7 @@ function createTypeChecker(host) {
|
|
|
66330
66330
|
}
|
|
66331
66331
|
function hasCovariantVoidArgument(typeArguments, variances) {
|
|
66332
66332
|
for (let i = 0; i < variances.length; i++) {
|
|
66333
|
-
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags &
|
|
66333
|
+
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16 /* Void */) {
|
|
66334
66334
|
return true;
|
|
66335
66335
|
}
|
|
66336
66336
|
}
|
|
@@ -66487,7 +66487,7 @@ function createTypeChecker(host) {
|
|
|
66487
66487
|
function isPropertyIdenticalTo(sourceProp, targetProp) {
|
|
66488
66488
|
return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
|
|
66489
66489
|
}
|
|
66490
|
-
function compareProperties(sourceProp, targetProp,
|
|
66490
|
+
function compareProperties(sourceProp, targetProp, compareTypes2) {
|
|
66491
66491
|
if (sourceProp === targetProp) {
|
|
66492
66492
|
return -1 /* True */;
|
|
66493
66493
|
}
|
|
@@ -66508,7 +66508,7 @@ function createTypeChecker(host) {
|
|
|
66508
66508
|
if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
|
|
66509
66509
|
return 0 /* False */;
|
|
66510
66510
|
}
|
|
66511
|
-
return
|
|
66511
|
+
return compareTypes2(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
66512
66512
|
}
|
|
66513
66513
|
function isMatchingSignature(source, target, partialMatch) {
|
|
66514
66514
|
const sourceParameterCount = getParameterCount(source);
|
|
@@ -66525,7 +66525,7 @@ function createTypeChecker(host) {
|
|
|
66525
66525
|
}
|
|
66526
66526
|
return false;
|
|
66527
66527
|
}
|
|
66528
|
-
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes,
|
|
66528
|
+
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes2) {
|
|
66529
66529
|
if (source === target) {
|
|
66530
66530
|
return -1 /* True */;
|
|
66531
66531
|
}
|
|
@@ -66540,7 +66540,7 @@ function createTypeChecker(host) {
|
|
|
66540
66540
|
for (let i = 0; i < target.typeParameters.length; i++) {
|
|
66541
66541
|
const s = source.typeParameters[i];
|
|
66542
66542
|
const t = target.typeParameters[i];
|
|
66543
|
-
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))) {
|
|
66544
66544
|
return 0 /* False */;
|
|
66545
66545
|
}
|
|
66546
66546
|
}
|
|
@@ -66557,7 +66557,7 @@ function createTypeChecker(host) {
|
|
|
66557
66557
|
if (sourceThisType) {
|
|
66558
66558
|
const targetThisType = getThisTypeOfSignature(target);
|
|
66559
66559
|
if (targetThisType) {
|
|
66560
|
-
const related =
|
|
66560
|
+
const related = compareTypes2(sourceThisType, targetThisType);
|
|
66561
66561
|
if (!related) {
|
|
66562
66562
|
return 0 /* False */;
|
|
66563
66563
|
}
|
|
@@ -66569,7 +66569,7 @@ function createTypeChecker(host) {
|
|
|
66569
66569
|
for (let i = 0; i < targetLen; i++) {
|
|
66570
66570
|
const s = getTypeAtPosition(source, i);
|
|
66571
66571
|
const t = getTypeAtPosition(target, i);
|
|
66572
|
-
const related =
|
|
66572
|
+
const related = compareTypes2(t, s);
|
|
66573
66573
|
if (!related) {
|
|
66574
66574
|
return 0 /* False */;
|
|
66575
66575
|
}
|
|
@@ -66578,12 +66578,12 @@ function createTypeChecker(host) {
|
|
|
66578
66578
|
if (!ignoreReturnTypes) {
|
|
66579
66579
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
66580
66580
|
const targetTypePredicate = getTypePredicateOfSignature(target);
|
|
66581
|
-
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate,
|
|
66581
|
+
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes2) : compareTypes2(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
|
66582
66582
|
}
|
|
66583
66583
|
return result;
|
|
66584
66584
|
}
|
|
66585
|
-
function compareTypePredicatesIdentical(source, target,
|
|
66586
|
-
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 */;
|
|
66587
66587
|
}
|
|
66588
66588
|
function literalTypesWithSameBaseType(types) {
|
|
66589
66589
|
let commonBaseType;
|
|
@@ -66605,9 +66605,9 @@ function createTypeChecker(host) {
|
|
|
66605
66605
|
if (types.length === 1) {
|
|
66606
66606
|
return types[0];
|
|
66607
66607
|
}
|
|
66608
|
-
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;
|
|
66609
66609
|
const superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? getUnionType(primaryTypes) : reduceLeft(primaryTypes, (s, t) => isTypeSubtypeOf(s, t) ? t : s);
|
|
66610
|
-
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) &
|
|
66610
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 12 /* Nullable */);
|
|
66611
66611
|
}
|
|
66612
66612
|
function getCommonSubtype(types) {
|
|
66613
66613
|
return reduceLeft(types, (s, t) => isTypeSubtypeOf(t, s) ? t : s);
|
|
@@ -66628,10 +66628,10 @@ function createTypeChecker(host) {
|
|
|
66628
66628
|
return isArrayType(type) ? getTypeArguments(type)[0] : void 0;
|
|
66629
66629
|
}
|
|
66630
66630
|
function isArrayLikeType(type) {
|
|
66631
|
-
return isArrayType(type) || !(type.flags &
|
|
66631
|
+
return isArrayType(type) || !(type.flags & 12 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType);
|
|
66632
66632
|
}
|
|
66633
66633
|
function isMutableArrayLikeType(type) {
|
|
66634
|
-
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ |
|
|
66634
|
+
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ | 12 /* Nullable */)) && isTypeAssignableTo(type, anyArrayType);
|
|
66635
66635
|
}
|
|
66636
66636
|
function getSingleBaseForNonAugmentingSubtype(type) {
|
|
66637
66637
|
if (!(getObjectFlags(type) & 4 /* Reference */) || !(getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
@@ -66671,7 +66671,7 @@ function createTypeChecker(host) {
|
|
|
66671
66671
|
}
|
|
66672
66672
|
function isTupleLikeType(type) {
|
|
66673
66673
|
let lengthType;
|
|
66674
|
-
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 */));
|
|
66675
66675
|
}
|
|
66676
66676
|
function isArrayOrTupleLikeType(type) {
|
|
66677
66677
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
@@ -66687,10 +66687,10 @@ function createTypeChecker(host) {
|
|
|
66687
66687
|
return void 0;
|
|
66688
66688
|
}
|
|
66689
66689
|
function isNeitherUnitTypeNorNever(type) {
|
|
66690
|
-
return !(type.flags & (
|
|
66690
|
+
return !(type.flags & (97292 /* Unit */ | 131072 /* Never */));
|
|
66691
66691
|
}
|
|
66692
66692
|
function isUnitType(type) {
|
|
66693
|
-
return !!(type.flags &
|
|
66693
|
+
return !!(type.flags & 97292 /* Unit */);
|
|
66694
66694
|
}
|
|
66695
66695
|
function isUnitLikeType(type) {
|
|
66696
66696
|
const t = getBaseConstraintOrType(type);
|
|
@@ -66700,23 +66700,23 @@ function createTypeChecker(host) {
|
|
|
66700
66700
|
return type.flags & 2097152 /* Intersection */ ? find(type.types, isUnitType) || type : type;
|
|
66701
66701
|
}
|
|
66702
66702
|
function isLiteralType(type) {
|
|
66703
|
-
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);
|
|
66704
66704
|
}
|
|
66705
66705
|
function getBaseTypeOfLiteralType(type) {
|
|
66706
|
-
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;
|
|
66707
66707
|
}
|
|
66708
66708
|
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
66709
66709
|
const key = `B${getTypeId(type)}`;
|
|
66710
66710
|
return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
66711
66711
|
}
|
|
66712
66712
|
function getBaseTypeOfLiteralTypeForComparison(type) {
|
|
66713
|
-
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;
|
|
66714
66714
|
}
|
|
66715
66715
|
function getWidenedLiteralType(type) {
|
|
66716
|
-
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;
|
|
66717
66717
|
}
|
|
66718
66718
|
function getWidenedUniqueESSymbolType(type) {
|
|
66719
|
-
return type.flags &
|
|
66719
|
+
return type.flags & 16384 /* UniqueESSymbol */ ? esSymbolType : type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type;
|
|
66720
66720
|
}
|
|
66721
66721
|
function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
|
|
66722
66722
|
if (!isLiteralOfContextualType(type, contextualType)) {
|
|
@@ -66793,11 +66793,11 @@ function createTypeChecker(host) {
|
|
|
66793
66793
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
66794
66794
|
}
|
|
66795
66795
|
function getDefinitelyFalsyPartOfType(type) {
|
|
66796
|
-
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;
|
|
66797
66797
|
}
|
|
66798
66798
|
function getNullableType(type, flags) {
|
|
66799
|
-
const missing = flags & ~type.flags & (
|
|
66800
|
-
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]);
|
|
66801
66801
|
}
|
|
66802
66802
|
function getOptionalType(type, isProperty = false) {
|
|
66803
66803
|
Debug.assert(strictNullChecks);
|
|
@@ -66840,7 +66840,7 @@ function createTypeChecker(host) {
|
|
|
66840
66840
|
return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */);
|
|
66841
66841
|
}
|
|
66842
66842
|
function isCoercibleUnderDoubleEquals(source, target) {
|
|
66843
|
-
return (source.flags & (
|
|
66843
|
+
return (source.flags & (64 /* Number */ | 32 /* String */ | 4096 /* BooleanLiteral */)) !== 0 && (target.flags & (64 /* Number */ | 32 /* String */ | 256 /* Boolean */)) !== 0;
|
|
66844
66844
|
}
|
|
66845
66845
|
function isObjectTypeWithInferableIndex(type) {
|
|
66846
66846
|
const objectFlags = getObjectFlags(type);
|
|
@@ -66973,7 +66973,7 @@ function createTypeChecker(host) {
|
|
|
66973
66973
|
return type.widened;
|
|
66974
66974
|
}
|
|
66975
66975
|
let result;
|
|
66976
|
-
if (type.flags & (1 /* Any */ |
|
|
66976
|
+
if (type.flags & (1 /* Any */ | 12 /* Nullable */)) {
|
|
66977
66977
|
result = anyType;
|
|
66978
66978
|
} else if (isObjectLiteralType(type)) {
|
|
66979
66979
|
result = getWidenedTypeOfObjectLiteral(type, context);
|
|
@@ -66985,7 +66985,7 @@ function createTypeChecker(host) {
|
|
|
66985
66985
|
void 0,
|
|
66986
66986
|
type.types
|
|
66987
66987
|
);
|
|
66988
|
-
const widenedTypes = sameMap(type.types, (t) => t.flags &
|
|
66988
|
+
const widenedTypes = sameMap(type.types, (t) => t.flags & 12 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext));
|
|
66989
66989
|
result = getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */);
|
|
66990
66990
|
} else if (type.flags & 2097152 /* Intersection */) {
|
|
66991
66991
|
result = getIntersectionType(sameMap(type.types, getWidenedType));
|
|
@@ -67185,18 +67185,18 @@ function createTypeChecker(host) {
|
|
|
67185
67185
|
callback(getReturnTypeOfSignature(source), targetReturnType);
|
|
67186
67186
|
}
|
|
67187
67187
|
}
|
|
67188
|
-
function createInferenceContext(typeParameters, signature, flags,
|
|
67189
|
-
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags,
|
|
67188
|
+
function createInferenceContext(typeParameters, signature, flags, compareTypes2) {
|
|
67189
|
+
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes2 || compareTypesAssignable);
|
|
67190
67190
|
}
|
|
67191
67191
|
function cloneInferenceContext(context, extraFlags = 0) {
|
|
67192
67192
|
return context && createInferenceContextWorker(map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
|
|
67193
67193
|
}
|
|
67194
|
-
function createInferenceContextWorker(inferences, signature, flags,
|
|
67194
|
+
function createInferenceContextWorker(inferences, signature, flags, compareTypes2) {
|
|
67195
67195
|
const context = {
|
|
67196
67196
|
inferences,
|
|
67197
67197
|
signature,
|
|
67198
67198
|
flags,
|
|
67199
|
-
compareTypes,
|
|
67199
|
+
compareTypes: compareTypes2,
|
|
67200
67200
|
mapper: reportUnmeasurableMapper,
|
|
67201
67201
|
// initialize to a noop mapper so the context object is available, but the underlying object shape is right upon construction
|
|
67202
67202
|
nonFixingMapper: reportUnmeasurableMapper
|
|
@@ -67283,8 +67283,8 @@ function createTypeChecker(host) {
|
|
|
67283
67283
|
if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
|
|
67284
67284
|
return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
|
|
67285
67285
|
}
|
|
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 &
|
|
67287
|
-
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 */) {
|
|
67288
67288
|
type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
67289
67289
|
}
|
|
67290
67290
|
return result;
|
|
@@ -67306,7 +67306,7 @@ function createTypeChecker(host) {
|
|
|
67306
67306
|
function createEmptyObjectTypeFromStringLiteral(type) {
|
|
67307
67307
|
const members = createSymbolTable();
|
|
67308
67308
|
forEachType(type, (t) => {
|
|
67309
|
-
if (!(t.flags &
|
|
67309
|
+
if (!(t.flags & 1024 /* StringLiteral */)) {
|
|
67310
67310
|
return;
|
|
67311
67311
|
}
|
|
67312
67312
|
const name = escapeLeadingUnderscores(t.value);
|
|
@@ -67318,7 +67318,7 @@ function createTypeChecker(host) {
|
|
|
67318
67318
|
}
|
|
67319
67319
|
members.set(name, literalProp);
|
|
67320
67320
|
});
|
|
67321
|
-
const indexInfos = type.flags &
|
|
67321
|
+
const indexInfos = type.flags & 32 /* String */ ? [createIndexInfo(
|
|
67322
67322
|
stringType,
|
|
67323
67323
|
emptyObjectType,
|
|
67324
67324
|
/*isReadonly*/
|
|
@@ -67420,7 +67420,7 @@ function createTypeChecker(host) {
|
|
|
67420
67420
|
yield targetProp;
|
|
67421
67421
|
} else if (matchDiscriminantProperties) {
|
|
67422
67422
|
const targetType = getTypeOfSymbol(targetProp);
|
|
67423
|
-
if (targetType.flags &
|
|
67423
|
+
if (targetType.flags & 97292 /* Unit */) {
|
|
67424
67424
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
67425
67425
|
if (!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) {
|
|
67426
67426
|
yield targetProp;
|
|
@@ -67483,7 +67483,7 @@ function createTypeChecker(host) {
|
|
|
67483
67483
|
if (target.flags & 1 /* Any */) {
|
|
67484
67484
|
return true;
|
|
67485
67485
|
}
|
|
67486
|
-
if (target.flags & (
|
|
67486
|
+
if (target.flags & (32 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
67487
67487
|
return isTypeAssignableTo(source, target);
|
|
67488
67488
|
}
|
|
67489
67489
|
if (target.flags & 268435456 /* StringMapping */) {
|
|
@@ -67501,20 +67501,20 @@ function createTypeChecker(host) {
|
|
|
67501
67501
|
if (target.flags & 2097152 /* Intersection */) {
|
|
67502
67502
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
67503
67503
|
}
|
|
67504
|
-
if (target.flags &
|
|
67504
|
+
if (target.flags & 32 /* String */ || isTypeAssignableTo(source, target)) {
|
|
67505
67505
|
return true;
|
|
67506
67506
|
}
|
|
67507
|
-
if (source.flags &
|
|
67507
|
+
if (source.flags & 1024 /* StringLiteral */) {
|
|
67508
67508
|
const value = source.value;
|
|
67509
|
-
return !!(target.flags &
|
|
67509
|
+
return !!(target.flags & 64 /* Number */ && isValidNumberString(
|
|
67510
67510
|
value,
|
|
67511
67511
|
/*roundTripOnly*/
|
|
67512
67512
|
false
|
|
67513
|
-
) || target.flags &
|
|
67513
|
+
) || target.flags & 128 /* BigInt */ && isValidBigIntString(
|
|
67514
67514
|
value,
|
|
67515
67515
|
/*roundTripOnly*/
|
|
67516
67516
|
false
|
|
67517
|
-
) || 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));
|
|
67518
67518
|
}
|
|
67519
67519
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
67520
67520
|
const texts = source.texts;
|
|
@@ -67523,7 +67523,7 @@ function createTypeChecker(host) {
|
|
|
67523
67523
|
return false;
|
|
67524
67524
|
}
|
|
67525
67525
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
67526
|
-
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) => {
|
|
67527
67527
|
return isTypeAssignableTo(getBaseConstraintOrType(s), getBaseConstraintOrType(target.types[i])) ? s : getStringLikeTypeForType(s);
|
|
67528
67528
|
}) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
|
|
67529
67529
|
}
|
|
@@ -67532,7 +67532,7 @@ function createTypeChecker(host) {
|
|
|
67532
67532
|
return !!inferences && every(inferences, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]));
|
|
67533
67533
|
}
|
|
67534
67534
|
function getStringLikeTypeForType(type) {
|
|
67535
|
-
return type.flags & (1 /* Any */ |
|
|
67535
|
+
return type.flags & (1 /* Any */ | 402654240 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
|
|
67536
67536
|
}
|
|
67537
67537
|
function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) {
|
|
67538
67538
|
const lastSourceIndex = sourceTexts.length - 1;
|
|
@@ -67727,7 +67727,7 @@ function createTypeChecker(host) {
|
|
|
67727
67727
|
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
|
|
67728
67728
|
} else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
|
|
67729
67729
|
inferFromContravariantTypes(source.type, target.type);
|
|
67730
|
-
} else if ((isLiteralType(source) || source.flags &
|
|
67730
|
+
} else if ((isLiteralType(source) || source.flags & 32 /* String */) && target.flags & 4194304 /* Index */) {
|
|
67731
67731
|
const empty = createEmptyObjectTypeFromStringLiteral(source);
|
|
67732
67732
|
inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
67733
67733
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
@@ -67982,29 +67982,29 @@ function createTypeChecker(host) {
|
|
|
67982
67982
|
for (let i = 0; i < types.length; i++) {
|
|
67983
67983
|
const source2 = matches ? matches[i] : neverType;
|
|
67984
67984
|
const target2 = types[i];
|
|
67985
|
-
if (source2.flags &
|
|
67985
|
+
if (source2.flags & 1024 /* StringLiteral */ && target2.flags & 8650752 /* TypeVariable */) {
|
|
67986
67986
|
const inferenceContext = getInferenceInfoForType(target2);
|
|
67987
67987
|
const constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : void 0;
|
|
67988
67988
|
if (constraint && !isTypeAny(constraint)) {
|
|
67989
67989
|
const constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
|
|
67990
67990
|
let allTypeFlags = reduceLeft(constraintTypes, (flags, t) => flags | t.flags, 0);
|
|
67991
|
-
if (!(allTypeFlags &
|
|
67991
|
+
if (!(allTypeFlags & 32 /* String */)) {
|
|
67992
67992
|
const str = source2.value;
|
|
67993
|
-
if (allTypeFlags &
|
|
67993
|
+
if (allTypeFlags & 67648 /* NumberLike */ && !isValidNumberString(
|
|
67994
67994
|
str,
|
|
67995
67995
|
/*roundTripOnly*/
|
|
67996
67996
|
true
|
|
67997
67997
|
)) {
|
|
67998
|
-
allTypeFlags &= ~
|
|
67998
|
+
allTypeFlags &= ~67648 /* NumberLike */;
|
|
67999
67999
|
}
|
|
68000
|
-
if (allTypeFlags &
|
|
68000
|
+
if (allTypeFlags & 8320 /* BigIntLike */ && !isValidBigIntString(
|
|
68001
68001
|
str,
|
|
68002
68002
|
/*roundTripOnly*/
|
|
68003
68003
|
true
|
|
68004
68004
|
)) {
|
|
68005
|
-
allTypeFlags &= ~
|
|
68005
|
+
allTypeFlags &= ~8320 /* BigIntLike */;
|
|
68006
68006
|
}
|
|
68007
|
-
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);
|
|
68008
68008
|
if (!(matchingType.flags & 131072 /* Never */)) {
|
|
68009
68009
|
inferFromTypes(matchingType, target2);
|
|
68010
68010
|
continue;
|
|
@@ -68164,7 +68164,7 @@ function createTypeChecker(host) {
|
|
|
68164
68164
|
for (const targetInfo of indexInfos) {
|
|
68165
68165
|
const propTypes = [];
|
|
68166
68166
|
for (const prop of getPropertiesOfType(source)) {
|
|
68167
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
68167
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 19456 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) {
|
|
68168
68168
|
const propType = getTypeOfSymbol(prop);
|
|
68169
68169
|
propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType);
|
|
68170
68170
|
}
|
|
@@ -68188,7 +68188,7 @@ function createTypeChecker(host) {
|
|
|
68188
68188
|
}
|
|
68189
68189
|
}
|
|
68190
68190
|
function isTypeOrBaseIdenticalTo(s, t) {
|
|
68191
|
-
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 */);
|
|
68192
68192
|
}
|
|
68193
68193
|
function isTypeCloselyMatchedBy(s, t) {
|
|
68194
68194
|
return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
|
|
@@ -68440,7 +68440,7 @@ function createTypeChecker(host) {
|
|
|
68440
68440
|
return void 0;
|
|
68441
68441
|
}
|
|
68442
68442
|
function tryGetNameFromType(type) {
|
|
68443
|
-
return type.flags &
|
|
68443
|
+
return type.flags & 16384 /* UniqueESSymbol */ ? type.escapedName : type.flags & 3072 /* StringOrNumberLiteral */ ? escapeLeadingUnderscores("" + type.value) : void 0;
|
|
68444
68444
|
}
|
|
68445
68445
|
function tryGetElementAccessExpressionName(node) {
|
|
68446
68446
|
return isStringOrNumericLiteralLike(node.argumentExpression) ? escapeLeadingUnderscores(node.argumentExpression.text) : isEntityNameExpression(node.argumentExpression) ? tryGetNameFromEntityNameExpression(node.argumentExpression) : void 0;
|
|
@@ -68619,7 +68619,7 @@ function createTypeChecker(host) {
|
|
|
68619
68619
|
}
|
|
68620
68620
|
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
68621
68621
|
const filteredType = filterType(declaredType, (t) => typeMaybeAssignableTo(assignedType, t));
|
|
68622
|
-
const reducedType = assignedType.flags &
|
|
68622
|
+
const reducedType = assignedType.flags & 4096 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
68623
68623
|
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
68624
68624
|
}
|
|
68625
68625
|
function isFunctionObjectType(type) {
|
|
@@ -68640,31 +68640,31 @@ function createTypeChecker(host) {
|
|
|
68640
68640
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
68641
68641
|
}
|
|
68642
68642
|
const flags = type.flags;
|
|
68643
|
-
if (flags & (
|
|
68643
|
+
if (flags & (32 /* String */ | 268435456 /* StringMapping */)) {
|
|
68644
68644
|
return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
|
|
68645
68645
|
}
|
|
68646
|
-
if (flags & (
|
|
68647
|
-
const isEmpty = flags &
|
|
68646
|
+
if (flags & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) {
|
|
68647
|
+
const isEmpty = flags & 1024 /* StringLiteral */ && type.value === "";
|
|
68648
68648
|
return strictNullChecks ? isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
|
|
68649
68649
|
}
|
|
68650
|
-
if (flags & (
|
|
68650
|
+
if (flags & (64 /* Number */ | 65536 /* Enum */)) {
|
|
68651
68651
|
return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */;
|
|
68652
68652
|
}
|
|
68653
|
-
if (flags &
|
|
68653
|
+
if (flags & 2048 /* NumberLiteral */) {
|
|
68654
68654
|
const isZero = type.value === 0;
|
|
68655
68655
|
return strictNullChecks ? isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */;
|
|
68656
68656
|
}
|
|
68657
|
-
if (flags &
|
|
68657
|
+
if (flags & 128 /* BigInt */) {
|
|
68658
68658
|
return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */;
|
|
68659
68659
|
}
|
|
68660
|
-
if (flags &
|
|
68660
|
+
if (flags & 8192 /* BigIntLiteral */) {
|
|
68661
68661
|
const isZero = isZeroBigInt(type);
|
|
68662
68662
|
return strictNullChecks ? isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */;
|
|
68663
68663
|
}
|
|
68664
|
-
if (flags &
|
|
68664
|
+
if (flags & 256 /* Boolean */) {
|
|
68665
68665
|
return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */;
|
|
68666
68666
|
}
|
|
68667
|
-
if (flags &
|
|
68667
|
+
if (flags & 4352 /* BooleanLike */) {
|
|
68668
68668
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
68669
68669
|
}
|
|
68670
68670
|
if (flags & 524288 /* Object */) {
|
|
@@ -68674,16 +68674,16 @@ function createTypeChecker(host) {
|
|
|
68674
68674
|
}
|
|
68675
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 */;
|
|
68676
68676
|
}
|
|
68677
|
-
if (flags &
|
|
68677
|
+
if (flags & 16 /* Void */) {
|
|
68678
68678
|
return 9830144 /* VoidFacts */;
|
|
68679
68679
|
}
|
|
68680
|
-
if (flags &
|
|
68680
|
+
if (flags & 4 /* Undefined */) {
|
|
68681
68681
|
return 26607360 /* UndefinedFacts */;
|
|
68682
68682
|
}
|
|
68683
|
-
if (flags &
|
|
68683
|
+
if (flags & 8 /* Null */) {
|
|
68684
68684
|
return 42917664 /* NullFacts */;
|
|
68685
68685
|
}
|
|
68686
|
-
if (flags &
|
|
68686
|
+
if (flags & 16896 /* ESSymbolLike */) {
|
|
68687
68687
|
return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
|
|
68688
68688
|
}
|
|
68689
68689
|
if (flags & 67108864 /* NonPrimitive */) {
|
|
@@ -68906,7 +68906,7 @@ function createTypeChecker(host) {
|
|
|
68906
68906
|
}
|
|
68907
68907
|
return true;
|
|
68908
68908
|
}
|
|
68909
|
-
if (source.flags &
|
|
68909
|
+
if (source.flags & 98304 /* EnumLike */ && getBaseTypeOfEnumLikeType(source) === target) {
|
|
68910
68910
|
return true;
|
|
68911
68911
|
}
|
|
68912
68912
|
return containsType(target.types, source);
|
|
@@ -68991,8 +68991,8 @@ function createTypeChecker(host) {
|
|
|
68991
68991
|
return filterType(type, (t) => (t.flags & kind) !== 0);
|
|
68992
68992
|
}
|
|
68993
68993
|
function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
|
|
68994
|
-
if (maybeTypeOfKind(typeWithPrimitives,
|
|
68995
|
-
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);
|
|
68996
68996
|
}
|
|
68997
68997
|
return typeWithPrimitives;
|
|
68998
68998
|
}
|
|
@@ -69047,7 +69047,7 @@ function createTypeChecker(host) {
|
|
|
69047
69047
|
const root = getReferenceRoot(node);
|
|
69048
69048
|
const parent = root.parent;
|
|
69049
69049
|
const isLengthPushOrUnshift = isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || parent.parent.kind === 213 /* CallExpression */ && isIdentifier(parent.name) && isPushOrUnshiftIdentifier(parent.name));
|
|
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),
|
|
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 */);
|
|
69051
69051
|
return isLengthPushOrUnshift || isElementAssignment;
|
|
69052
69052
|
}
|
|
69053
69053
|
function isDeclarationWithExplicitTypeAnnotation(node) {
|
|
@@ -69535,7 +69535,7 @@ function createTypeChecker(host) {
|
|
|
69535
69535
|
}
|
|
69536
69536
|
} else {
|
|
69537
69537
|
const indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
|
|
69538
|
-
if (isTypeAssignableToKind(indexType,
|
|
69538
|
+
if (isTypeAssignableToKind(indexType, 67648 /* NumberLike */)) {
|
|
69539
69539
|
evolvedType2 = addEvolvingArrayElementType(evolvedType2, node.right);
|
|
69540
69540
|
}
|
|
69541
69541
|
}
|
|
@@ -69573,9 +69573,9 @@ function createTypeChecker(host) {
|
|
|
69573
69573
|
} else {
|
|
69574
69574
|
if (strictNullChecks) {
|
|
69575
69575
|
if (optionalChainContainsReference(expr, reference)) {
|
|
69576
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (
|
|
69576
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (4 /* Undefined */ | 131072 /* Never */)));
|
|
69577
69577
|
} else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
|
|
69578
|
-
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"));
|
|
69579
69579
|
}
|
|
69580
69580
|
}
|
|
69581
69581
|
const access = getDiscriminantPropertyAccess(expr, type);
|
|
@@ -69749,7 +69749,7 @@ function createTypeChecker(host) {
|
|
|
69749
69749
|
return type;
|
|
69750
69750
|
}
|
|
69751
69751
|
const optionalChain = isOptionalChain(access);
|
|
69752
|
-
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type,
|
|
69752
|
+
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type, 12 /* Nullable */);
|
|
69753
69753
|
let propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName);
|
|
69754
69754
|
if (!propType) {
|
|
69755
69755
|
return type;
|
|
@@ -69971,7 +69971,7 @@ function createTypeChecker(host) {
|
|
|
69971
69971
|
}
|
|
69972
69972
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
69973
69973
|
const equalsOperator = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
69974
|
-
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ?
|
|
69974
|
+
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ? 12 /* Nullable */ : 4 /* Undefined */;
|
|
69975
69975
|
const valueType = getTypeOfExpression(value);
|
|
69976
69976
|
const removeNullable = equalsOperator !== assumeTrue && everyType(valueType, (t) => !!(t.flags & nullableFlags)) || equalsOperator === assumeTrue && everyType(valueType, (t) => !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)));
|
|
69977
69977
|
return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
|
|
@@ -69985,11 +69985,11 @@ function createTypeChecker(host) {
|
|
|
69985
69985
|
}
|
|
69986
69986
|
const valueType = getTypeOfExpression(value);
|
|
69987
69987
|
const doubleEquals = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */;
|
|
69988
|
-
if (valueType.flags &
|
|
69988
|
+
if (valueType.flags & 12 /* Nullable */) {
|
|
69989
69989
|
if (!strictNullChecks) {
|
|
69990
69990
|
return type;
|
|
69991
69991
|
}
|
|
69992
|
-
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 */;
|
|
69993
69993
|
return getAdjustedTypeWithFacts(type, facts);
|
|
69994
69994
|
}
|
|
69995
69995
|
if (assumeTrue) {
|
|
@@ -70064,7 +70064,7 @@ function createTypeChecker(host) {
|
|
|
70064
70064
|
if (!hasDefaultClause) {
|
|
70065
70065
|
return caseType;
|
|
70066
70066
|
}
|
|
70067
|
-
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)))));
|
|
70068
70068
|
return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
|
|
70069
70069
|
}
|
|
70070
70070
|
function narrowTypeByTypeName(type, typeName) {
|
|
@@ -70555,10 +70555,10 @@ function createTypeChecker(host) {
|
|
|
70555
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)));
|
|
70556
70556
|
}
|
|
70557
70557
|
function isGenericTypeWithUnionConstraint(type) {
|
|
70558
|
-
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 */));
|
|
70559
70559
|
}
|
|
70560
70560
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
70561
|
-
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 */));
|
|
70562
70562
|
}
|
|
70563
70563
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
70564
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(
|
|
@@ -71117,7 +71117,7 @@ function createTypeChecker(host) {
|
|
|
71117
71117
|
flowContainer = getControlFlowContainer(flowContainer);
|
|
71118
71118
|
}
|
|
71119
71119
|
const isNeverInitialized = immediateDeclaration && isVariableDeclaration(immediateDeclaration) && !immediateDeclaration.initializer && !immediateDeclaration.exclamationToken && isMutableLocalVariableDeclaration(immediateDeclaration) && !isSymbolAssignedDefinitely(symbol);
|
|
71120
|
-
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 */;
|
|
71121
71121
|
const initialType = isAutomaticTypeInNonNull ? undefinedType : assumeInitialized ? isParameter2 ? removeOptionalityFromDeclaredType(type, declaration) : type : typeIsAutomatic ? undefinedType : getOptionalType(type);
|
|
71122
71122
|
const flowType = isAutomaticTypeInNonNull ? getNonNullableType(getFlowTypeOfReference(node, type, initialType, flowContainer)) : getFlowTypeOfReference(node, type, initialType, flowContainer);
|
|
71123
71123
|
if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
|
|
@@ -71805,7 +71805,7 @@ function createTypeChecker(host) {
|
|
|
71805
71805
|
const functionFlags = getFunctionFlags(functionDecl);
|
|
71806
71806
|
if (functionFlags & 1 /* Generator */) {
|
|
71807
71807
|
return filterType(returnType2, (t) => {
|
|
71808
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
71808
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || checkGeneratorInstantiationAssignabilityToReturnType(
|
|
71809
71809
|
t,
|
|
71810
71810
|
functionFlags,
|
|
71811
71811
|
/*errorNode*/
|
|
@@ -71815,7 +71815,7 @@ function createTypeChecker(host) {
|
|
|
71815
71815
|
}
|
|
71816
71816
|
if (functionFlags & 2 /* Async */) {
|
|
71817
71817
|
return filterType(returnType2, (t) => {
|
|
71818
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
71818
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || !!getAwaitedTypeOfPromise(t);
|
|
71819
71819
|
});
|
|
71820
71820
|
}
|
|
71821
71821
|
return returnType2;
|
|
@@ -72574,7 +72574,7 @@ function createTypeChecker(host) {
|
|
|
72574
72574
|
return getOrCreateTypeFromSignature(fakeSignature);
|
|
72575
72575
|
}
|
|
72576
72576
|
const tagType = checkExpressionCached(context.tagName);
|
|
72577
|
-
if (tagType.flags &
|
|
72577
|
+
if (tagType.flags & 1024 /* StringLiteral */) {
|
|
72578
72578
|
const result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
|
|
72579
72579
|
if (!result) {
|
|
72580
72580
|
return errorType;
|
|
@@ -72946,7 +72946,7 @@ function createTypeChecker(host) {
|
|
|
72946
72946
|
}
|
|
72947
72947
|
}
|
|
72948
72948
|
function isNumericComputedName(name) {
|
|
72949
|
-
return isTypeAssignableToKind(checkComputedPropertyName(name),
|
|
72949
|
+
return isTypeAssignableToKind(checkComputedPropertyName(name), 67648 /* NumberLike */);
|
|
72950
72950
|
}
|
|
72951
72951
|
function checkComputedPropertyName(node) {
|
|
72952
72952
|
const links = getNodeLinks(node.expression);
|
|
@@ -72964,7 +72964,7 @@ function createTypeChecker(host) {
|
|
|
72964
72964
|
getNodeLinks(node.parent.parent).flags |= 32768 /* BlockScopedBindingInLoop */;
|
|
72965
72965
|
}
|
|
72966
72966
|
}
|
|
72967
|
-
if (links.resolvedType.flags &
|
|
72967
|
+
if (links.resolvedType.flags & 12 /* Nullable */ || !isTypeAssignableToKind(links.resolvedType, 402654240 /* StringLike */ | 67648 /* NumberLike */ | 16896 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
|
|
72968
72968
|
error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
|
|
72969
72969
|
}
|
|
72970
72970
|
}
|
|
@@ -72978,7 +72978,7 @@ function createTypeChecker(host) {
|
|
|
72978
72978
|
function isSymbolWithSymbolName(symbol) {
|
|
72979
72979
|
var _a;
|
|
72980
72980
|
const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
|
|
72981
|
-
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 */);
|
|
72982
72982
|
}
|
|
72983
72983
|
function isSymbolWithComputedName(symbol) {
|
|
72984
72984
|
var _a;
|
|
@@ -73134,7 +73134,7 @@ function createTypeChecker(host) {
|
|
|
73134
73134
|
Debug.assert(memberDecl.kind === 177 /* GetAccessor */ || memberDecl.kind === 178 /* SetAccessor */);
|
|
73135
73135
|
checkNodeDeferred(memberDecl);
|
|
73136
73136
|
}
|
|
73137
|
-
if (computedNameType && !(computedNameType.flags &
|
|
73137
|
+
if (computedNameType && !(computedNameType.flags & 19456 /* StringOrNumberLiteralOrUnique */)) {
|
|
73138
73138
|
if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
|
|
73139
73139
|
if (isTypeAssignableTo(computedNameType, numberType)) {
|
|
73140
73140
|
hasComputedNumberProperty = true;
|
|
@@ -73547,9 +73547,9 @@ function createTypeChecker(host) {
|
|
|
73547
73547
|
return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
|
|
73548
73548
|
}
|
|
73549
73549
|
function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
|
|
73550
|
-
if (elementType.flags &
|
|
73550
|
+
if (elementType.flags & 32 /* String */) {
|
|
73551
73551
|
return [anySignature];
|
|
73552
|
-
} else if (elementType.flags &
|
|
73552
|
+
} else if (elementType.flags & 1024 /* StringLiteral */) {
|
|
73553
73553
|
const intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
|
|
73554
73554
|
if (!intrinsicType) {
|
|
73555
73555
|
error(caller, Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
|
|
@@ -73931,7 +73931,7 @@ function createTypeChecker(host) {
|
|
|
73931
73931
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
73932
73932
|
reportError(node, facts);
|
|
73933
73933
|
const t = getNonNullableType(type);
|
|
73934
|
-
return t.flags & (
|
|
73934
|
+
return t.flags & (12 /* Nullable */ | 131072 /* Never */) ? errorType : t;
|
|
73935
73935
|
}
|
|
73936
73936
|
return type;
|
|
73937
73937
|
}
|
|
@@ -73940,7 +73940,7 @@ function createTypeChecker(host) {
|
|
|
73940
73940
|
}
|
|
73941
73941
|
function checkNonNullNonVoidType(type, node) {
|
|
73942
73942
|
const nonNullType = checkNonNullType(type, node);
|
|
73943
|
-
if (nonNullType.flags &
|
|
73943
|
+
if (nonNullType.flags & 16 /* Void */) {
|
|
73944
73944
|
if (isEntityNameExpression(node)) {
|
|
73945
73945
|
const nodeText = entityNameToString(node);
|
|
73946
73946
|
if (isIdentifier(node) && nodeText === "undefined") {
|
|
@@ -74487,7 +74487,7 @@ function createTypeChecker(host) {
|
|
|
74487
74487
|
return suggestion;
|
|
74488
74488
|
}
|
|
74489
74489
|
function getSuggestedTypeForNonexistentStringLiteralType(source, target) {
|
|
74490
|
-
const candidates = target.types.filter((type) => !!(type.flags &
|
|
74490
|
+
const candidates = target.types.filter((type) => !!(type.flags & 1024 /* StringLiteral */));
|
|
74491
74491
|
return getSpellingSuggestion(source.value, candidates, (type) => type.value);
|
|
74492
74492
|
}
|
|
74493
74493
|
function getSpellingSuggestionForName(name, symbols, meaning) {
|
|
@@ -74719,10 +74719,10 @@ function createTypeChecker(host) {
|
|
|
74719
74719
|
return findIndex(args, isSpreadArgument);
|
|
74720
74720
|
}
|
|
74721
74721
|
function acceptsVoid(t) {
|
|
74722
|
-
return !!(t.flags &
|
|
74722
|
+
return !!(t.flags & 16 /* Void */);
|
|
74723
74723
|
}
|
|
74724
74724
|
function acceptsVoidUndefinedUnknownOrAny(t) {
|
|
74725
|
-
return !!(t.flags & (
|
|
74725
|
+
return !!(t.flags & (16 /* Void */ | 4 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */));
|
|
74726
74726
|
}
|
|
74727
74727
|
function hasCorrectArity(node, args, signature, signatureHelpTrailingComma = false) {
|
|
74728
74728
|
if (isJsxOpeningFragment(node)) return true;
|
|
@@ -74821,8 +74821,8 @@ function createTypeChecker(host) {
|
|
|
74821
74821
|
}
|
|
74822
74822
|
return void 0;
|
|
74823
74823
|
}
|
|
74824
|
-
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext,
|
|
74825
|
-
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);
|
|
74826
74826
|
const restType = getEffectiveRestType(contextualSignature);
|
|
74827
74827
|
const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
|
|
74828
74828
|
const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
|
|
@@ -76557,10 +76557,10 @@ function createTypeChecker(host) {
|
|
|
76557
76557
|
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
|
|
76558
76558
|
}
|
|
76559
76559
|
const returnType = getReturnTypeOfSignature(signature);
|
|
76560
|
-
if (returnType.flags &
|
|
76560
|
+
if (returnType.flags & 16896 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) {
|
|
76561
76561
|
return getESSymbolLikeTypeForNode(walkUpParenthesizedExpressions(node.parent));
|
|
76562
76562
|
}
|
|
76563
|
-
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)) {
|
|
76564
76564
|
if (!isDottedName(node.expression)) {
|
|
76565
76565
|
error(node.expression, Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
|
|
76566
76566
|
} else if (!getEffectsSignature(node)) {
|
|
@@ -76650,7 +76650,7 @@ function createTypeChecker(host) {
|
|
|
76650
76650
|
for (let i = 2; i < node.arguments.length; ++i) {
|
|
76651
76651
|
checkExpressionCached(node.arguments[i]);
|
|
76652
76652
|
}
|
|
76653
|
-
if (specifierType.flags &
|
|
76653
|
+
if (specifierType.flags & 4 /* Undefined */ || specifierType.flags & 8 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) {
|
|
76654
76654
|
error(specifier, Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
|
|
76655
76655
|
}
|
|
76656
76656
|
if (optionsType) {
|
|
@@ -76659,7 +76659,7 @@ function createTypeChecker(host) {
|
|
|
76659
76659
|
true
|
|
76660
76660
|
);
|
|
76661
76661
|
if (importCallOptionsType !== emptyObjectType) {
|
|
76662
|
-
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType,
|
|
76662
|
+
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 4 /* Undefined */), node.arguments[1]);
|
|
76663
76663
|
}
|
|
76664
76664
|
}
|
|
76665
76665
|
const moduleSymbol = resolveExternalModuleName(node, specifier);
|
|
@@ -77705,7 +77705,7 @@ function createTypeChecker(host) {
|
|
|
77705
77705
|
/*contextFlags*/
|
|
77706
77706
|
void 0
|
|
77707
77707
|
);
|
|
77708
|
-
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags &
|
|
77708
|
+
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 4 /* Undefined */ ? undefinedType : voidType;
|
|
77709
77709
|
return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
|
|
77710
77710
|
// Async function
|
|
77711
77711
|
returnType2
|
|
@@ -77951,10 +77951,10 @@ function createTypeChecker(host) {
|
|
|
77951
77951
|
true
|
|
77952
77952
|
);
|
|
77953
77953
|
const returnType = checkExpressionCached(expr);
|
|
77954
|
-
if (!(returnType.flags &
|
|
77954
|
+
if (!(returnType.flags & 256 /* Boolean */)) return void 0;
|
|
77955
77955
|
return forEach(func.parameters, (param, i) => {
|
|
77956
77956
|
const initType = getTypeOfSymbol(param.symbol);
|
|
77957
|
-
if (!initType || initType.flags &
|
|
77957
|
+
if (!initType || initType.flags & 256 /* Boolean */ || !isIdentifier(param.name) || isSymbolAssigned(param.symbol) || isRestParameter(param)) {
|
|
77958
77958
|
return;
|
|
77959
77959
|
}
|
|
77960
77960
|
const trueType2 = checkIfExpressionRefinesParameter(func, expr, param, initType);
|
|
@@ -77984,7 +77984,7 @@ function createTypeChecker(host) {
|
|
|
77984
77984
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
77985
77985
|
const functionFlags = getFunctionFlags(func);
|
|
77986
77986
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
77987
|
-
if (type && (maybeTypeOfKind(type,
|
|
77987
|
+
if (type && (maybeTypeOfKind(type, 16 /* Void */) || type.flags & (1 /* Any */ | 4 /* Undefined */))) {
|
|
77988
77988
|
return;
|
|
77989
77989
|
}
|
|
77990
77990
|
if (func.kind === 173 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 241 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -78356,11 +78356,11 @@ function createTypeChecker(host) {
|
|
|
78356
78356
|
case 41 /* MinusToken */:
|
|
78357
78357
|
case 55 /* TildeToken */:
|
|
78358
78358
|
checkNonNullType(operandType, node.operand);
|
|
78359
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
78359
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 16896 /* ESSymbolLike */)) {
|
|
78360
78360
|
error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator));
|
|
78361
78361
|
}
|
|
78362
78362
|
if (node.operator === 40 /* PlusToken */) {
|
|
78363
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
78363
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 8320 /* BigIntLike */)) {
|
|
78364
78364
|
error(node.operand, Diagnostics.Operator_0_cannot_be_applied_to_type_1, tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
|
|
78365
78365
|
}
|
|
78366
78366
|
return numberType;
|
|
@@ -78404,8 +78404,8 @@ function createTypeChecker(host) {
|
|
|
78404
78404
|
return getUnaryResultType(operandType);
|
|
78405
78405
|
}
|
|
78406
78406
|
function getUnaryResultType(operandType) {
|
|
78407
|
-
if (maybeTypeOfKind(operandType,
|
|
78408
|
-
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;
|
|
78409
78409
|
}
|
|
78410
78410
|
return numberType;
|
|
78411
78411
|
}
|
|
@@ -78434,10 +78434,10 @@ function createTypeChecker(host) {
|
|
|
78434
78434
|
if (source.flags & kind) {
|
|
78435
78435
|
return true;
|
|
78436
78436
|
}
|
|
78437
|
-
if (strict && source.flags & (3 /* AnyOrUnknown */ |
|
|
78437
|
+
if (strict && source.flags & (3 /* AnyOrUnknown */ | 16 /* Void */ | 4 /* Undefined */ | 8 /* Null */)) {
|
|
78438
78438
|
return false;
|
|
78439
78439
|
}
|
|
78440
|
-
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);
|
|
78441
78441
|
}
|
|
78442
78442
|
function allTypesAssignableToKind(source, kind, strict) {
|
|
78443
78443
|
return source.flags & 1048576 /* Union */ ? every(source.types, (subType) => allTypesAssignableToKind(subType, kind, strict)) : isTypeAssignableToKind(source, kind, strict);
|
|
@@ -78710,7 +78710,7 @@ function createTypeChecker(host) {
|
|
|
78710
78710
|
}
|
|
78711
78711
|
}
|
|
78712
78712
|
function isTypeEqualityComparableTo(source, target) {
|
|
78713
|
-
return (target.flags &
|
|
78713
|
+
return (target.flags & 12 /* Nullable */) !== 0 || isTypeComparableTo(source, target);
|
|
78714
78714
|
}
|
|
78715
78715
|
function createCheckBinaryExpression() {
|
|
78716
78716
|
const trampoline = createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState);
|
|
@@ -78961,7 +78961,7 @@ function createTypeChecker(host) {
|
|
|
78961
78961
|
leftType = checkNonNullType(leftType, left);
|
|
78962
78962
|
rightType = checkNonNullType(rightType, right);
|
|
78963
78963
|
let suggestedOperator;
|
|
78964
|
-
if (leftType.flags &
|
|
78964
|
+
if (leftType.flags & 4352 /* BooleanLike */ && rightType.flags & 4352 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
|
|
78965
78965
|
error(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
|
|
78966
78966
|
return numberType;
|
|
78967
78967
|
} else {
|
|
@@ -78981,7 +78981,7 @@ function createTypeChecker(host) {
|
|
|
78981
78981
|
);
|
|
78982
78982
|
let resultType2;
|
|
78983
78983
|
if (isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */) || // Or, if neither could be bigint, implicit coercion results in a number result
|
|
78984
|
-
!(maybeTypeOfKind(leftType,
|
|
78984
|
+
!(maybeTypeOfKind(leftType, 8320 /* BigIntLike */) || maybeTypeOfKind(rightType, 8320 /* BigIntLike */))) {
|
|
78985
78985
|
resultType2 = numberType;
|
|
78986
78986
|
} else if (bothAreBigIntLike(leftType, rightType)) {
|
|
78987
78987
|
switch (operator) {
|
|
@@ -79033,43 +79033,43 @@ function createTypeChecker(host) {
|
|
|
79033
79033
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
79034
79034
|
return silentNeverType;
|
|
79035
79035
|
}
|
|
79036
|
-
if (!isTypeAssignableToKind(leftType,
|
|
79036
|
+
if (!isTypeAssignableToKind(leftType, 402654240 /* StringLike */) && !isTypeAssignableToKind(rightType, 402654240 /* StringLike */)) {
|
|
79037
79037
|
leftType = checkNonNullType(leftType, left);
|
|
79038
79038
|
rightType = checkNonNullType(rightType, right);
|
|
79039
79039
|
}
|
|
79040
79040
|
let resultType;
|
|
79041
79041
|
if (isTypeAssignableToKind(
|
|
79042
79042
|
leftType,
|
|
79043
|
-
|
|
79043
|
+
67648 /* NumberLike */,
|
|
79044
79044
|
/*strict*/
|
|
79045
79045
|
true
|
|
79046
79046
|
) && isTypeAssignableToKind(
|
|
79047
79047
|
rightType,
|
|
79048
|
-
|
|
79048
|
+
67648 /* NumberLike */,
|
|
79049
79049
|
/*strict*/
|
|
79050
79050
|
true
|
|
79051
79051
|
)) {
|
|
79052
79052
|
resultType = numberType;
|
|
79053
79053
|
} else if (isTypeAssignableToKind(
|
|
79054
79054
|
leftType,
|
|
79055
|
-
|
|
79055
|
+
8320 /* BigIntLike */,
|
|
79056
79056
|
/*strict*/
|
|
79057
79057
|
true
|
|
79058
79058
|
) && isTypeAssignableToKind(
|
|
79059
79059
|
rightType,
|
|
79060
|
-
|
|
79060
|
+
8320 /* BigIntLike */,
|
|
79061
79061
|
/*strict*/
|
|
79062
79062
|
true
|
|
79063
79063
|
)) {
|
|
79064
79064
|
resultType = bigintType;
|
|
79065
79065
|
} else if (isTypeAssignableToKind(
|
|
79066
79066
|
leftType,
|
|
79067
|
-
|
|
79067
|
+
402654240 /* StringLike */,
|
|
79068
79068
|
/*strict*/
|
|
79069
79069
|
true
|
|
79070
79070
|
) || isTypeAssignableToKind(
|
|
79071
79071
|
rightType,
|
|
79072
|
-
|
|
79072
|
+
402654240 /* StringLike */,
|
|
79073
79073
|
/*strict*/
|
|
79074
79074
|
true
|
|
79075
79075
|
)) {
|
|
@@ -79081,7 +79081,7 @@ function createTypeChecker(host) {
|
|
|
79081
79081
|
return resultType;
|
|
79082
79082
|
}
|
|
79083
79083
|
if (!resultType) {
|
|
79084
|
-
const closeEnoughKind =
|
|
79084
|
+
const closeEnoughKind = 67648 /* NumberLike */ | 8320 /* BigIntLike */ | 402654240 /* StringLike */ | 3 /* AnyOrUnknown */;
|
|
79085
79085
|
reportOperatorError(
|
|
79086
79086
|
(left2, right2) => isTypeAssignableToKind(left2, closeEnoughKind) && isTypeAssignableToKind(right2, closeEnoughKind)
|
|
79087
79087
|
);
|
|
@@ -79178,7 +79178,7 @@ function createTypeChecker(host) {
|
|
|
79178
79178
|
return Debug.fail();
|
|
79179
79179
|
}
|
|
79180
79180
|
function bothAreBigIntLike(left2, right2) {
|
|
79181
|
-
return isTypeAssignableToKind(left2,
|
|
79181
|
+
return isTypeAssignableToKind(left2, 8320 /* BigIntLike */) && isTypeAssignableToKind(right2, 8320 /* BigIntLike */);
|
|
79182
79182
|
}
|
|
79183
79183
|
function checkAssignmentDeclaration(kind, rightType2) {
|
|
79184
79184
|
if (kind === 2 /* ModuleExports */) {
|
|
@@ -79208,7 +79208,7 @@ function createTypeChecker(host) {
|
|
|
79208
79208
|
(isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
|
|
79209
79209
|
}
|
|
79210
79210
|
function checkForDisallowedESSymbolOperand(operator2) {
|
|
79211
|
-
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType,
|
|
79211
|
+
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 16896 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 16896 /* ESSymbolLike */) ? right : void 0;
|
|
79212
79212
|
if (offendingSymbolOperand) {
|
|
79213
79213
|
error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator2));
|
|
79214
79214
|
return false;
|
|
@@ -79247,7 +79247,7 @@ function createTypeChecker(host) {
|
|
|
79247
79247
|
}
|
|
79248
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)) {
|
|
79249
79249
|
let headMessage;
|
|
79250
|
-
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType,
|
|
79250
|
+
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 4 /* Undefined */)) {
|
|
79251
79251
|
const target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText);
|
|
79252
79252
|
if (isExactOptionalPropertyMismatch(valueType, target)) {
|
|
79253
79253
|
headMessage = Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target;
|
|
@@ -79436,7 +79436,7 @@ function createTypeChecker(host) {
|
|
|
79436
79436
|
const types = [];
|
|
79437
79437
|
for (const span of node.templateSpans) {
|
|
79438
79438
|
const type = checkExpression(span.expression);
|
|
79439
|
-
if (maybeTypeOfKindConsideringBaseConstraint(type,
|
|
79439
|
+
if (maybeTypeOfKindConsideringBaseConstraint(type, 16896 /* ESSymbolLike */)) {
|
|
79440
79440
|
error(span.expression, Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
|
|
79441
79441
|
}
|
|
79442
79442
|
texts.push(span.literal.text);
|
|
@@ -79456,7 +79456,7 @@ function createTypeChecker(host) {
|
|
|
79456
79456
|
return stringType;
|
|
79457
79457
|
}
|
|
79458
79458
|
function isTemplateLiteralContextualType(type) {
|
|
79459
|
-
return !!(type.flags & (
|
|
79459
|
+
return !!(type.flags & (1024 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402654240 /* StringLike */));
|
|
79460
79460
|
}
|
|
79461
79461
|
function getContextNode(node) {
|
|
79462
79462
|
if (isJsxAttributes(node) && !isJsxSelfClosingElement(node.parent)) {
|
|
@@ -79477,7 +79477,7 @@ function createTypeChecker(host) {
|
|
|
79477
79477
|
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
79478
79478
|
inferenceContext.intraExpressionInferenceSites = void 0;
|
|
79479
79479
|
}
|
|
79480
|
-
const result = maybeTypeOfKind(type,
|
|
79480
|
+
const result = maybeTypeOfKind(type, 15360 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(
|
|
79481
79481
|
contextualType,
|
|
79482
79482
|
node,
|
|
79483
79483
|
/*contextFlags*/
|
|
@@ -79621,9 +79621,9 @@ function createTypeChecker(host) {
|
|
|
79621
79621
|
}
|
|
79622
79622
|
if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
79623
79623
|
const constraint = getBaseConstraintOfType(contextualType) || unknownType;
|
|
79624
|
-
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);
|
|
79625
79625
|
}
|
|
79626
|
-
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 */));
|
|
79627
79627
|
}
|
|
79628
79628
|
return false;
|
|
79629
79629
|
}
|
|
@@ -82484,7 +82484,7 @@ function createTypeChecker(host) {
|
|
|
82484
82484
|
return;
|
|
82485
82485
|
}
|
|
82486
82486
|
const type = location === condExpr2 ? condType : checkExpression(location);
|
|
82487
|
-
if (type.flags &
|
|
82487
|
+
if (type.flags & 32768 /* EnumLiteral */ && isPropertyAccessExpression(location) && (getNodeLinks(location.expression).resolvedSymbol ?? unknownSymbol).flags & 384 /* Enum */) {
|
|
82488
82488
|
error(location, Diagnostics.This_condition_will_always_return_0, !!type.value ? "true" : "false");
|
|
82489
82489
|
return;
|
|
82490
82490
|
}
|
|
@@ -82576,7 +82576,7 @@ function createTypeChecker(host) {
|
|
|
82576
82576
|
checkSourceElement(node.statement);
|
|
82577
82577
|
}
|
|
82578
82578
|
function checkTruthinessOfType(type, node) {
|
|
82579
|
-
if (type.flags &
|
|
82579
|
+
if (type.flags & 16 /* Void */) {
|
|
82580
82580
|
error(node, Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
|
|
82581
82581
|
} else {
|
|
82582
82582
|
const semantics = getSyntacticTruthySemantics(node);
|
|
@@ -82764,11 +82764,11 @@ function createTypeChecker(host) {
|
|
|
82764
82764
|
if (use & 4 /* AllowsStringInputFlag */) {
|
|
82765
82765
|
if (arrayType.flags & 1048576 /* Union */) {
|
|
82766
82766
|
const arrayTypes = inputType.types;
|
|
82767
|
-
const filteredTypes = filter(arrayTypes, (t) => !(t.flags &
|
|
82767
|
+
const filteredTypes = filter(arrayTypes, (t) => !(t.flags & 402654240 /* StringLike */));
|
|
82768
82768
|
if (filteredTypes !== arrayTypes) {
|
|
82769
82769
|
arrayType = getUnionType(filteredTypes, 2 /* Subtype */);
|
|
82770
82770
|
}
|
|
82771
|
-
} else if (arrayType.flags &
|
|
82771
|
+
} else if (arrayType.flags & 402654240 /* StringLike */) {
|
|
82772
82772
|
arrayType = neverType;
|
|
82773
82773
|
}
|
|
82774
82774
|
hasStringConstituent = arrayType !== inputType;
|
|
@@ -82793,7 +82793,7 @@ function createTypeChecker(host) {
|
|
|
82793
82793
|
}
|
|
82794
82794
|
const arrayElementType = getIndexTypeOfType(arrayType, numberType);
|
|
82795
82795
|
if (hasStringConstituent && arrayElementType) {
|
|
82796
|
-
if (arrayElementType.flags &
|
|
82796
|
+
if (arrayElementType.flags & 402654240 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) {
|
|
82797
82797
|
return stringType;
|
|
82798
82798
|
}
|
|
82799
82799
|
return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */);
|
|
@@ -82844,7 +82844,7 @@ function createTypeChecker(host) {
|
|
|
82844
82844
|
return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
|
|
82845
82845
|
}
|
|
82846
82846
|
function createIterationTypes(yieldType = neverType, returnType = neverType, nextType = unknownType) {
|
|
82847
|
-
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 */)) {
|
|
82848
82848
|
const id = getTypeListId([yieldType, returnType, nextType]);
|
|
82849
82849
|
let iterationTypes = iterationTypesCache.get(id);
|
|
82850
82850
|
if (!iterationTypes) {
|
|
@@ -83340,7 +83340,7 @@ function createTypeChecker(host) {
|
|
|
83340
83340
|
}
|
|
83341
83341
|
function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
|
|
83342
83342
|
const type = unwrapReturnType(returnType, getFunctionFlags(func));
|
|
83343
|
-
return !!(type && (maybeTypeOfKind(type,
|
|
83343
|
+
return !!(type && (maybeTypeOfKind(type, 16 /* Void */) || type.flags & (1 /* Any */ | 4 /* Undefined */)));
|
|
83344
83344
|
}
|
|
83345
83345
|
function checkReturnStatement(node) {
|
|
83346
83346
|
if (checkGrammarStatementInAmbientContext(node)) {
|
|
@@ -83537,7 +83537,7 @@ function createTypeChecker(host) {
|
|
|
83537
83537
|
if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) {
|
|
83538
83538
|
checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(
|
|
83539
83539
|
prop,
|
|
83540
|
-
|
|
83540
|
+
19456 /* StringOrNumberLiteralOrUnique */,
|
|
83541
83541
|
/*includeNonPublic*/
|
|
83542
83542
|
true
|
|
83543
83543
|
), getNonMissingTypeOfSymbol(prop));
|
|
@@ -85008,7 +85008,7 @@ function createTypeChecker(host) {
|
|
|
85008
85008
|
true
|
|
85009
85009
|
);
|
|
85010
85010
|
if (importAttributesType !== emptyObjectType) {
|
|
85011
|
-
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType,
|
|
85011
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 4 /* Undefined */), node);
|
|
85012
85012
|
}
|
|
85013
85013
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
85014
85014
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
@@ -86560,7 +86560,7 @@ function createTypeChecker(host) {
|
|
|
86560
86560
|
return getStringLiteralType(name.text);
|
|
86561
86561
|
case 167 /* ComputedPropertyName */:
|
|
86562
86562
|
const nameType = checkComputedPropertyName(name);
|
|
86563
|
-
return isTypeAssignableToKind(nameType,
|
|
86563
|
+
return isTypeAssignableToKind(nameType, 16896 /* ESSymbolLike */) ? nameType : stringType;
|
|
86564
86564
|
default:
|
|
86565
86565
|
return Debug.fail("Unsupported property name.");
|
|
86566
86566
|
}
|
|
@@ -87081,19 +87081,19 @@ function createTypeChecker(host) {
|
|
|
87081
87081
|
return isTypeOnly ? 11 /* ObjectType */ : 0 /* Unknown */;
|
|
87082
87082
|
} else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
87083
87083
|
return 11 /* ObjectType */;
|
|
87084
|
-
} else if (isTypeAssignableToKind(type,
|
|
87084
|
+
} else if (isTypeAssignableToKind(type, 16 /* Void */ | 12 /* Nullable */ | 131072 /* Never */)) {
|
|
87085
87085
|
return 2 /* VoidNullableOrNeverType */;
|
|
87086
|
-
} else if (isTypeAssignableToKind(type,
|
|
87086
|
+
} else if (isTypeAssignableToKind(type, 4352 /* BooleanLike */)) {
|
|
87087
87087
|
return 6 /* BooleanType */;
|
|
87088
|
-
} else if (isTypeAssignableToKind(type,
|
|
87088
|
+
} else if (isTypeAssignableToKind(type, 67648 /* NumberLike */)) {
|
|
87089
87089
|
return 3 /* NumberLikeType */;
|
|
87090
|
-
} else if (isTypeAssignableToKind(type,
|
|
87090
|
+
} else if (isTypeAssignableToKind(type, 8320 /* BigIntLike */)) {
|
|
87091
87091
|
return 4 /* BigIntLikeType */;
|
|
87092
|
-
} else if (isTypeAssignableToKind(type,
|
|
87092
|
+
} else if (isTypeAssignableToKind(type, 402654240 /* StringLike */)) {
|
|
87093
87093
|
return 5 /* StringLikeType */;
|
|
87094
87094
|
} else if (isTupleType(type)) {
|
|
87095
87095
|
return 7 /* ArrayLikeType */;
|
|
87096
|
-
} else if (isTypeAssignableToKind(type,
|
|
87096
|
+
} else if (isTypeAssignableToKind(type, 16896 /* ESSymbolLike */)) {
|
|
87097
87097
|
return 8 /* ESSymbolType */;
|
|
87098
87098
|
} else if (isFunctionType(type)) {
|
|
87099
87099
|
return 10 /* TypeWithCallSignature */;
|
|
@@ -87236,7 +87236,7 @@ function createTypeChecker(host) {
|
|
|
87236
87236
|
return false;
|
|
87237
87237
|
}
|
|
87238
87238
|
function literalTypeToNode(type, enclosing, tracker) {
|
|
87239
|
-
const enumResult = type.flags &
|
|
87239
|
+
const enumResult = type.flags & 98304 /* EnumLike */ ? nodeBuilder.symbolToExpression(
|
|
87240
87240
|
type.symbol,
|
|
87241
87241
|
111551 /* Value */,
|
|
87242
87242
|
enclosing,
|
|
@@ -88255,7 +88255,7 @@ function createTypeChecker(host) {
|
|
|
88255
88255
|
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
|
|
88256
88256
|
}
|
|
88257
88257
|
const type = getTypeFromTypeNode(parameter.type);
|
|
88258
|
-
if (someType(type, (t) => !!(t.flags &
|
|
88258
|
+
if (someType(type, (t) => !!(t.flags & 19456 /* StringOrNumberLiteralOrUnique */)) || isGenericType(type)) {
|
|
88259
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);
|
|
88260
88260
|
}
|
|
88261
88261
|
if (!everyType(type, isValidIndexKeyType)) {
|
|
@@ -88786,7 +88786,7 @@ function createTypeChecker(host) {
|
|
|
88786
88786
|
}
|
|
88787
88787
|
function isSimpleLiteralEnumReference(expr) {
|
|
88788
88788
|
if ((isPropertyAccessExpression(expr) || isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression)) && isEntityNameExpression(expr.expression)) {
|
|
88789
|
-
return !!(checkExpressionCached(expr).flags &
|
|
88789
|
+
return !!(checkExpressionCached(expr).flags & 98304 /* EnumLike */);
|
|
88790
88790
|
}
|
|
88791
88791
|
}
|
|
88792
88792
|
function checkAmbientInitializer(node) {
|
|
@@ -89276,6 +89276,319 @@ function createTypeChecker(host) {
|
|
|
89276
89276
|
Debug.assert(specifier && nodeIsSynthesized(specifier) && specifier.text === "tslib", `Expected sourceFile.imports[0] to be the synthesized tslib import`);
|
|
89277
89277
|
return specifier;
|
|
89278
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
|
+
}
|
|
89279
89592
|
}
|
|
89280
89593
|
function isNotAccessor(declaration) {
|
|
89281
89594
|
return !isAccessor(declaration);
|