@typescript-deploys/pr-build 5.9.0-pr-61399-3 → 5.9.0-pr-61420-2
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 +400 -686
- package/lib/typescript.d.ts +28 -28
- package/lib/typescript.js +439 -725
- 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.20250314`;
|
|
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 (
|
|
638
|
+
switch (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 & 67359327 /* Intrinsic */ ? `IntrinsicType ${this.intrinsicName}${this.debugIntrinsicName ? ` (${this.debugIntrinsicName})` : ""}` : this.flags & 98304 /* Nullable */ ? "NullableType" : this.flags & 384 /* StringOrNumberLiteral */ ? `LiteralType ${JSON.stringify(this.value)}` : this.flags & 2048 /* BigIntLiteral */ ? `LiteralType ${this.value.negative ? "-" : ""}${this.value.base10Value}n` : this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : this.flags & 32 /* 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 & ~1343 /* 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 & 2944 /* 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["String"] = 4] = "String";
|
|
3574
|
+
TypeFlags2[TypeFlags2["Number"] = 8] = "Number";
|
|
3575
|
+
TypeFlags2[TypeFlags2["Boolean"] = 16] = "Boolean";
|
|
3576
|
+
TypeFlags2[TypeFlags2["Enum"] = 32] = "Enum";
|
|
3577
|
+
TypeFlags2[TypeFlags2["BigInt"] = 64] = "BigInt";
|
|
3578
|
+
TypeFlags2[TypeFlags2["StringLiteral"] = 128] = "StringLiteral";
|
|
3579
|
+
TypeFlags2[TypeFlags2["NumberLiteral"] = 256] = "NumberLiteral";
|
|
3580
|
+
TypeFlags2[TypeFlags2["BooleanLiteral"] = 512] = "BooleanLiteral";
|
|
3581
|
+
TypeFlags2[TypeFlags2["EnumLiteral"] = 1024] = "EnumLiteral";
|
|
3582
|
+
TypeFlags2[TypeFlags2["BigIntLiteral"] = 2048] = "BigIntLiteral";
|
|
3583
|
+
TypeFlags2[TypeFlags2["ESSymbol"] = 4096] = "ESSymbol";
|
|
3584
|
+
TypeFlags2[TypeFlags2["UniqueESSymbol"] = 8192] = "UniqueESSymbol";
|
|
3585
|
+
TypeFlags2[TypeFlags2["Void"] = 16384] = "Void";
|
|
3586
|
+
TypeFlags2[TypeFlags2["Undefined"] = 32768] = "Undefined";
|
|
3587
|
+
TypeFlags2[TypeFlags2["Null"] = 65536] = "Null";
|
|
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"] = 98304] = "Nullable";
|
|
3604
|
+
TypeFlags2[TypeFlags2["Literal"] = 2944] = "Literal";
|
|
3605
|
+
TypeFlags2[TypeFlags2["Unit"] = 109472] = "Unit";
|
|
3606
|
+
TypeFlags2[TypeFlags2["Freshable"] = 2976] = "Freshable";
|
|
3607
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral";
|
|
3608
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique";
|
|
3609
|
+
TypeFlags2[TypeFlags2["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy";
|
|
3610
|
+
TypeFlags2[TypeFlags2["PossiblyFalsy"] = 117724] = "PossiblyFalsy";
|
|
3611
|
+
TypeFlags2[TypeFlags2["Intrinsic"] = 67359327] = "Intrinsic";
|
|
3612
|
+
TypeFlags2[TypeFlags2["StringLike"] = 402653316] = "StringLike";
|
|
3613
|
+
TypeFlags2[TypeFlags2["NumberLike"] = 296] = "NumberLike";
|
|
3614
|
+
TypeFlags2[TypeFlags2["BigIntLike"] = 2112] = "BigIntLike";
|
|
3615
|
+
TypeFlags2[TypeFlags2["BooleanLike"] = 528] = "BooleanLike";
|
|
3616
|
+
TypeFlags2[TypeFlags2["EnumLike"] = 1056] = "EnumLike";
|
|
3617
|
+
TypeFlags2[TypeFlags2["ESSymbolLike"] = 12288] = "ESSymbolLike";
|
|
3618
|
+
TypeFlags2[TypeFlags2["VoidLike"] = 49152] = "VoidLike";
|
|
3619
3619
|
TypeFlags2[TypeFlags2["Primitive"] = 402784252] = "Primitive";
|
|
3620
|
-
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] =
|
|
3621
|
-
TypeFlags2[TypeFlags2["DisjointDomains"] =
|
|
3620
|
+
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
|
|
3621
|
+
TypeFlags2[TypeFlags2["DisjointDomains"] = 469892092] = "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"] = 3899393] = "ObjectFlagsType";
|
|
3630
3630
|
TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
|
|
3631
|
-
TypeFlags2[TypeFlags2["Singleton"] =
|
|
3632
|
-
TypeFlags2[TypeFlags2["Narrowable"] =
|
|
3631
|
+
TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
|
|
3632
|
+
TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "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"] = 36323331] = "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";
|
|
3671
3672
|
ObjectFlags3[ObjectFlags3["ContainsSpread"] = 2097152] = "ContainsSpread";
|
|
3672
3673
|
ObjectFlags3[ObjectFlags3["ObjectRestType"] = 4194304] = "ObjectRestType";
|
|
3673
3674
|
ObjectFlags3[ObjectFlags3["InstantiationExpressionType"] = 8388608] = "InstantiationExpressionType";
|
|
3674
3675
|
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 & 3899393 /* 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 & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
19252
19252
|
}
|
|
19253
19253
|
function getPropertyNameFromType(type) {
|
|
19254
|
-
if (type.flags &
|
|
19254
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
19255
19255
|
return type.escapedName;
|
|
19256
19256
|
}
|
|
19257
|
-
if (type.flags & (
|
|
19257
|
+
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
19258
19258
|
return escapeLeadingUnderscores("" + type.value);
|
|
19259
19259
|
}
|
|
19260
19260
|
return Debug.fail();
|
|
@@ -46745,10 +46745,10 @@ function createTypeChecker(host) {
|
|
|
46745
46745
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */, "non-inferrable");
|
|
46746
46746
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
46747
46747
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
46748
|
-
var undefinedType = createIntrinsicType(
|
|
46749
|
-
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(
|
|
46748
|
+
var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined");
|
|
46749
|
+
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */, "widening");
|
|
46750
46750
|
var missingType = createIntrinsicType(
|
|
46751
|
-
|
|
46751
|
+
32768 /* Undefined */,
|
|
46752
46752
|
"undefined",
|
|
46753
46753
|
/*objectFlags*/
|
|
46754
46754
|
void 0,
|
|
@@ -46756,33 +46756,33 @@ function createTypeChecker(host) {
|
|
|
46756
46756
|
);
|
|
46757
46757
|
var undefinedOrMissingType = exactOptionalPropertyTypes ? missingType : undefinedType;
|
|
46758
46758
|
var optionalType = createIntrinsicType(
|
|
46759
|
-
|
|
46759
|
+
32768 /* Undefined */,
|
|
46760
46760
|
"undefined",
|
|
46761
46761
|
/*objectFlags*/
|
|
46762
46762
|
void 0,
|
|
46763
46763
|
"optional"
|
|
46764
46764
|
);
|
|
46765
|
-
var nullType = createIntrinsicType(
|
|
46766
|
-
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(
|
|
46767
|
-
var stringType = createIntrinsicType(
|
|
46768
|
-
var numberType = createIntrinsicType(
|
|
46769
|
-
var bigintType = createIntrinsicType(
|
|
46765
|
+
var nullType = createIntrinsicType(65536 /* Null */, "null");
|
|
46766
|
+
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */, "widening");
|
|
46767
|
+
var stringType = createIntrinsicType(4 /* String */, "string");
|
|
46768
|
+
var numberType = createIntrinsicType(8 /* Number */, "number");
|
|
46769
|
+
var bigintType = createIntrinsicType(64 /* BigInt */, "bigint");
|
|
46770
46770
|
var falseType = createIntrinsicType(
|
|
46771
|
-
|
|
46771
|
+
512 /* BooleanLiteral */,
|
|
46772
46772
|
"false",
|
|
46773
46773
|
/*objectFlags*/
|
|
46774
46774
|
void 0,
|
|
46775
46775
|
"fresh"
|
|
46776
46776
|
);
|
|
46777
|
-
var regularFalseType = createIntrinsicType(
|
|
46777
|
+
var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false");
|
|
46778
46778
|
var trueType = createIntrinsicType(
|
|
46779
|
-
|
|
46779
|
+
512 /* BooleanLiteral */,
|
|
46780
46780
|
"true",
|
|
46781
46781
|
/*objectFlags*/
|
|
46782
46782
|
void 0,
|
|
46783
46783
|
"fresh"
|
|
46784
46784
|
);
|
|
46785
|
-
var regularTrueType = createIntrinsicType(
|
|
46785
|
+
var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true");
|
|
46786
46786
|
trueType.regularType = regularTrueType;
|
|
46787
46787
|
trueType.freshType = trueType;
|
|
46788
46788
|
regularTrueType.regularType = regularTrueType;
|
|
@@ -46792,8 +46792,8 @@ function createTypeChecker(host) {
|
|
|
46792
46792
|
regularFalseType.regularType = regularFalseType;
|
|
46793
46793
|
regularFalseType.freshType = falseType;
|
|
46794
46794
|
var booleanType = getUnionType([regularFalseType, regularTrueType]);
|
|
46795
|
-
var esSymbolType = createIntrinsicType(
|
|
46796
|
-
var voidType = createIntrinsicType(
|
|
46795
|
+
var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol");
|
|
46796
|
+
var voidType = createIntrinsicType(16384 /* Void */, "void");
|
|
46797
46797
|
var neverType = createIntrinsicType(131072 /* Never */, "never");
|
|
46798
46798
|
var silentNeverType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */, "silent");
|
|
46799
46799
|
var implicitNeverType = createIntrinsicType(
|
|
@@ -48080,7 +48080,7 @@ function createTypeChecker(host) {
|
|
|
48080
48080
|
const type = getDeclaredTypeOfSymbol(symbol);
|
|
48081
48081
|
return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(
|
|
48082
48082
|
type,
|
|
48083
|
-
|
|
48083
|
+
384 /* StringOrNumberLiteral */,
|
|
48084
48084
|
/*strict*/
|
|
48085
48085
|
true
|
|
48086
48086
|
);
|
|
@@ -49787,7 +49787,7 @@ function createTypeChecker(host) {
|
|
|
49787
49787
|
return type;
|
|
49788
49788
|
}
|
|
49789
49789
|
function createTypeofType() {
|
|
49790
|
-
return getUnionType(
|
|
49790
|
+
return getUnionType(arrayFrom(typeofNEFacts.keys(), getStringLiteralType));
|
|
49791
49791
|
}
|
|
49792
49792
|
function createTypeParameter(symbol) {
|
|
49793
49793
|
return createTypeWithSymbol(262144 /* TypeParameter */, symbol);
|
|
@@ -49802,6 +49802,7 @@ function createTypeChecker(host) {
|
|
|
49802
49802
|
(result || (result = [])).push(symbol);
|
|
49803
49803
|
}
|
|
49804
49804
|
});
|
|
49805
|
+
result == null ? void 0 : result.sort(compareSymbols);
|
|
49805
49806
|
return result || emptyArray;
|
|
49806
49807
|
}
|
|
49807
49808
|
function isNamedMember(member, escapedName) {
|
|
@@ -50608,7 +50609,7 @@ function createTypeChecker(host) {
|
|
|
50608
50609
|
if (name && isComputedPropertyName(name)) return name;
|
|
50609
50610
|
}
|
|
50610
50611
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
50611
|
-
if (nameType && nameType.flags & (
|
|
50612
|
+
if (nameType && nameType.flags & (1024 /* EnumLiteral */ | 8192 /* UniqueESSymbol */)) {
|
|
50612
50613
|
context.enclosingDeclaration = nameType.symbol.valueDeclaration;
|
|
50613
50614
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, meaning));
|
|
50614
50615
|
}
|
|
@@ -50716,23 +50717,23 @@ function createTypeChecker(host) {
|
|
|
50716
50717
|
if (type.flags & 2 /* Unknown */) {
|
|
50717
50718
|
return factory.createKeywordTypeNode(159 /* UnknownKeyword */);
|
|
50718
50719
|
}
|
|
50719
|
-
if (type.flags &
|
|
50720
|
+
if (type.flags & 4 /* String */) {
|
|
50720
50721
|
context.approximateLength += 6;
|
|
50721
50722
|
return factory.createKeywordTypeNode(154 /* StringKeyword */);
|
|
50722
50723
|
}
|
|
50723
|
-
if (type.flags &
|
|
50724
|
+
if (type.flags & 8 /* Number */) {
|
|
50724
50725
|
context.approximateLength += 6;
|
|
50725
50726
|
return factory.createKeywordTypeNode(150 /* NumberKeyword */);
|
|
50726
50727
|
}
|
|
50727
|
-
if (type.flags &
|
|
50728
|
+
if (type.flags & 64 /* BigInt */) {
|
|
50728
50729
|
context.approximateLength += 6;
|
|
50729
50730
|
return factory.createKeywordTypeNode(163 /* BigIntKeyword */);
|
|
50730
50731
|
}
|
|
50731
|
-
if (type.flags &
|
|
50732
|
+
if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) {
|
|
50732
50733
|
context.approximateLength += 7;
|
|
50733
50734
|
return factory.createKeywordTypeNode(136 /* BooleanKeyword */);
|
|
50734
50735
|
}
|
|
50735
|
-
if (type.flags &
|
|
50736
|
+
if (type.flags & 1056 /* EnumLike */) {
|
|
50736
50737
|
if (type.symbol.flags & 8 /* EnumMember */) {
|
|
50737
50738
|
const parentSymbol = getParentOfSymbol(type.symbol);
|
|
50738
50739
|
const parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */);
|
|
@@ -50761,24 +50762,24 @@ function createTypeChecker(host) {
|
|
|
50761
50762
|
}
|
|
50762
50763
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
50763
50764
|
}
|
|
50764
|
-
if (type.flags &
|
|
50765
|
+
if (type.flags & 128 /* StringLiteral */) {
|
|
50765
50766
|
context.approximateLength += type.value.length + 2;
|
|
50766
50767
|
return factory.createLiteralTypeNode(setEmitFlags(factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */));
|
|
50767
50768
|
}
|
|
50768
|
-
if (type.flags &
|
|
50769
|
+
if (type.flags & 256 /* NumberLiteral */) {
|
|
50769
50770
|
const value = type.value;
|
|
50770
50771
|
context.approximateLength += ("" + value).length;
|
|
50771
50772
|
return factory.createLiteralTypeNode(value < 0 ? factory.createPrefixUnaryExpression(41 /* MinusToken */, factory.createNumericLiteral(-value)) : factory.createNumericLiteral(value));
|
|
50772
50773
|
}
|
|
50773
|
-
if (type.flags &
|
|
50774
|
+
if (type.flags & 2048 /* BigIntLiteral */) {
|
|
50774
50775
|
context.approximateLength += pseudoBigIntToString(type.value).length + 1;
|
|
50775
50776
|
return factory.createLiteralTypeNode(factory.createBigIntLiteral(type.value));
|
|
50776
50777
|
}
|
|
50777
|
-
if (type.flags &
|
|
50778
|
+
if (type.flags & 512 /* BooleanLiteral */) {
|
|
50778
50779
|
context.approximateLength += type.intrinsicName.length;
|
|
50779
50780
|
return factory.createLiteralTypeNode(type.intrinsicName === "true" ? factory.createTrue() : factory.createFalse());
|
|
50780
50781
|
}
|
|
50781
|
-
if (type.flags &
|
|
50782
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
50782
50783
|
if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) {
|
|
50783
50784
|
if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
|
|
50784
50785
|
context.approximateLength += 6;
|
|
@@ -50791,15 +50792,15 @@ function createTypeChecker(host) {
|
|
|
50791
50792
|
context.approximateLength += 13;
|
|
50792
50793
|
return factory.createTypeOperatorNode(158 /* UniqueKeyword */, factory.createKeywordTypeNode(155 /* SymbolKeyword */));
|
|
50793
50794
|
}
|
|
50794
|
-
if (type.flags &
|
|
50795
|
+
if (type.flags & 16384 /* Void */) {
|
|
50795
50796
|
context.approximateLength += 4;
|
|
50796
50797
|
return factory.createKeywordTypeNode(116 /* VoidKeyword */);
|
|
50797
50798
|
}
|
|
50798
|
-
if (type.flags &
|
|
50799
|
+
if (type.flags & 32768 /* Undefined */) {
|
|
50799
50800
|
context.approximateLength += 9;
|
|
50800
50801
|
return factory.createKeywordTypeNode(157 /* UndefinedKeyword */);
|
|
50801
50802
|
}
|
|
50802
|
-
if (type.flags &
|
|
50803
|
+
if (type.flags & 65536 /* Null */) {
|
|
50803
50804
|
context.approximateLength += 4;
|
|
50804
50805
|
return factory.createLiteralTypeNode(factory.createNull());
|
|
50805
50806
|
}
|
|
@@ -50807,7 +50808,7 @@ function createTypeChecker(host) {
|
|
|
50807
50808
|
context.approximateLength += 5;
|
|
50808
50809
|
return factory.createKeywordTypeNode(146 /* NeverKeyword */);
|
|
50809
50810
|
}
|
|
50810
|
-
if (type.flags &
|
|
50811
|
+
if (type.flags & 4096 /* ESSymbol */) {
|
|
50811
50812
|
context.approximateLength += 6;
|
|
50812
50813
|
return factory.createKeywordTypeNode(155 /* SymbolKeyword */);
|
|
50813
50814
|
}
|
|
@@ -51596,7 +51597,7 @@ function createTypeChecker(host) {
|
|
|
51596
51597
|
}
|
|
51597
51598
|
const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
51598
51599
|
if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
|
|
51599
|
-
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags &
|
|
51600
|
+
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */);
|
|
51600
51601
|
for (const signature of signatures) {
|
|
51601
51602
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 173 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
51602
51603
|
typeElements.push(preserveCommentsOn(methodDeclaration, signature.declaration || propertySymbol.valueDeclaration));
|
|
@@ -52636,11 +52637,11 @@ function createTypeChecker(host) {
|
|
|
52636
52637
|
}
|
|
52637
52638
|
if (isComputedPropertyName(name)) {
|
|
52638
52639
|
const type = checkExpression(name.expression);
|
|
52639
|
-
return !!(type.flags &
|
|
52640
|
+
return !!(type.flags & 402653316 /* StringLike */);
|
|
52640
52641
|
}
|
|
52641
52642
|
if (isElementAccessExpression(name)) {
|
|
52642
52643
|
const type = checkExpression(name.argumentExpression);
|
|
52643
|
-
return !!(type.flags &
|
|
52644
|
+
return !!(type.flags & 402653316 /* StringLike */);
|
|
52644
52645
|
}
|
|
52645
52646
|
return isStringLiteral(name);
|
|
52646
52647
|
}
|
|
@@ -52666,7 +52667,7 @@ function createTypeChecker(host) {
|
|
|
52666
52667
|
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote, stringNamed, isMethod) {
|
|
52667
52668
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
52668
52669
|
if (nameType) {
|
|
52669
|
-
if (nameType.flags &
|
|
52670
|
+
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
52670
52671
|
const name = "" + nameType.value;
|
|
52671
52672
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && (stringNamed || !isNumericLiteralName(name))) {
|
|
52672
52673
|
return factory.createStringLiteral(name, !!singleQuote);
|
|
@@ -52676,7 +52677,7 @@ function createTypeChecker(host) {
|
|
|
52676
52677
|
}
|
|
52677
52678
|
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
|
|
52678
52679
|
}
|
|
52679
|
-
if (nameType.flags &
|
|
52680
|
+
if (nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
52680
52681
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
|
|
52681
52682
|
}
|
|
52682
52683
|
}
|
|
@@ -52718,7 +52719,7 @@ function createTypeChecker(host) {
|
|
|
52718
52719
|
return enclosingDeclaration;
|
|
52719
52720
|
}
|
|
52720
52721
|
function serializeInferredTypeForDeclaration(symbol, context, type) {
|
|
52721
|
-
if (type.flags &
|
|
52722
|
+
if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === context.enclosingFile))) {
|
|
52722
52723
|
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
52723
52724
|
}
|
|
52724
52725
|
const result = typeToTypeNodeHelper(type, context);
|
|
@@ -52951,7 +52952,7 @@ function createTypeChecker(host) {
|
|
|
52951
52952
|
}
|
|
52952
52953
|
function serializeExistingTypeNode(context, typeNode, addUndefined) {
|
|
52953
52954
|
const type = getTypeFromTypeNode2(context, typeNode);
|
|
52954
|
-
if (addUndefined && !someType(type, (t) => !!(t.flags &
|
|
52955
|
+
if (addUndefined && !someType(type, (t) => !!(t.flags & 32768 /* Undefined */)) && canReuseTypeNode(context, typeNode)) {
|
|
52955
52956
|
const clone = syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode);
|
|
52956
52957
|
if (clone) {
|
|
52957
52958
|
return factory.createUnionTypeNode([clone, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
@@ -54490,9 +54491,9 @@ function createTypeChecker(host) {
|
|
|
54490
54491
|
for (let i = 0; i < types.length; i++) {
|
|
54491
54492
|
const t = types[i];
|
|
54492
54493
|
flags |= t.flags;
|
|
54493
|
-
if (!(t.flags &
|
|
54494
|
-
if (t.flags & (
|
|
54495
|
-
const baseType = t.flags &
|
|
54494
|
+
if (!(t.flags & 98304 /* Nullable */)) {
|
|
54495
|
+
if (t.flags & (512 /* BooleanLiteral */ | 1056 /* EnumLike */)) {
|
|
54496
|
+
const baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLikeType(t);
|
|
54496
54497
|
if (baseType.flags & 1048576 /* Union */) {
|
|
54497
54498
|
const count = baseType.types.length;
|
|
54498
54499
|
if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
|
|
@@ -54505,8 +54506,8 @@ function createTypeChecker(host) {
|
|
|
54505
54506
|
result.push(t);
|
|
54506
54507
|
}
|
|
54507
54508
|
}
|
|
54508
|
-
if (flags &
|
|
54509
|
-
if (flags &
|
|
54509
|
+
if (flags & 65536 /* Null */) result.push(nullType);
|
|
54510
|
+
if (flags & 32768 /* Undefined */) result.push(undefinedType);
|
|
54510
54511
|
return result || types;
|
|
54511
54512
|
}
|
|
54512
54513
|
function visibilityToString(flags) {
|
|
@@ -54536,7 +54537,7 @@ function createTypeChecker(host) {
|
|
|
54536
54537
|
function getNameOfSymbolFromNameType(symbol, context) {
|
|
54537
54538
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
54538
54539
|
if (nameType) {
|
|
54539
|
-
if (nameType.flags &
|
|
54540
|
+
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
54540
54541
|
const name = "" + nameType.value;
|
|
54541
54542
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
54542
54543
|
return `"${escapeString(name, 34 /* doubleQuote */)}"`;
|
|
@@ -54546,7 +54547,7 @@ function createTypeChecker(host) {
|
|
|
54546
54547
|
}
|
|
54547
54548
|
return name;
|
|
54548
54549
|
}
|
|
54549
|
-
if (nameType.flags &
|
|
54550
|
+
if (nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
54550
54551
|
return `[${getNameOfSymbolAsWritten(nameType.symbol, context)}]`;
|
|
54551
54552
|
}
|
|
54552
54553
|
}
|
|
@@ -54571,7 +54572,7 @@ function createTypeChecker(host) {
|
|
|
54571
54572
|
}
|
|
54572
54573
|
if (isComputedPropertyName(name2) && !(getCheckFlags(symbol) & 4096 /* Late */)) {
|
|
54573
54574
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
54574
|
-
if (nameType && nameType.flags &
|
|
54575
|
+
if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
54575
54576
|
const result = getNameOfSymbolFromNameType(symbol, context);
|
|
54576
54577
|
if (result !== void 0) {
|
|
54577
54578
|
return result;
|
|
@@ -54852,7 +54853,7 @@ function createTypeChecker(host) {
|
|
|
54852
54853
|
);
|
|
54853
54854
|
}
|
|
54854
54855
|
function getRestType(source, properties, symbol) {
|
|
54855
|
-
source = filterType(source, (t) => !(t.flags &
|
|
54856
|
+
source = filterType(source, (t) => !(t.flags & 98304 /* Nullable */));
|
|
54856
54857
|
if (source.flags & 131072 /* Never */) {
|
|
54857
54858
|
return emptyObjectType;
|
|
54858
54859
|
}
|
|
@@ -54863,7 +54864,7 @@ function createTypeChecker(host) {
|
|
|
54863
54864
|
const spreadableProperties = [];
|
|
54864
54865
|
const unspreadableToRestKeys = [];
|
|
54865
54866
|
for (const prop of getPropertiesOfType(source)) {
|
|
54866
|
-
const literalTypeFromProperty = getLiteralTypeFromProperty(prop,
|
|
54867
|
+
const literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
54867
54868
|
if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) && isSpreadableProperty(prop)) {
|
|
54868
54869
|
spreadableProperties.push(prop);
|
|
54869
54870
|
} else {
|
|
@@ -54896,7 +54897,7 @@ function createTypeChecker(host) {
|
|
|
54896
54897
|
return result;
|
|
54897
54898
|
}
|
|
54898
54899
|
function isGenericTypeWithUndefinedConstraint(type) {
|
|
54899
|
-
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType,
|
|
54900
|
+
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */);
|
|
54900
54901
|
}
|
|
54901
54902
|
function getNonUndefinedType(type) {
|
|
54902
54903
|
const typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, (t) => t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t) : type;
|
|
@@ -54950,7 +54951,7 @@ function createTypeChecker(host) {
|
|
|
54950
54951
|
}
|
|
54951
54952
|
function getLiteralPropertyNameText(name) {
|
|
54952
54953
|
const type = getLiteralTypeFromPropertyName(name);
|
|
54953
|
-
return type.flags & (
|
|
54954
|
+
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
54954
54955
|
}
|
|
54955
54956
|
function getTypeForBindingElement(declaration) {
|
|
54956
54957
|
const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
@@ -55290,7 +55291,7 @@ function createTypeChecker(host) {
|
|
|
55290
55291
|
definedInConstructor = true;
|
|
55291
55292
|
}
|
|
55292
55293
|
}
|
|
55293
|
-
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~
|
|
55294
|
+
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~98304 /* Nullable */)) ? constructorTypes : types;
|
|
55294
55295
|
type = getUnionType(sourceTypes);
|
|
55295
55296
|
}
|
|
55296
55297
|
}
|
|
@@ -55300,7 +55301,7 @@ function createTypeChecker(host) {
|
|
|
55300
55301
|
false,
|
|
55301
55302
|
definedInMethod && !definedInConstructor
|
|
55302
55303
|
));
|
|
55303
|
-
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~
|
|
55304
|
+
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~98304 /* Nullable */)) === neverType) {
|
|
55304
55305
|
reportImplicitAny(symbol.valueDeclaration, anyType);
|
|
55305
55306
|
return anyType;
|
|
55306
55307
|
}
|
|
@@ -55598,13 +55599,13 @@ function createTypeChecker(host) {
|
|
|
55598
55599
|
}
|
|
55599
55600
|
function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors2) {
|
|
55600
55601
|
if (type) {
|
|
55601
|
-
if (type.flags &
|
|
55602
|
+
if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) {
|
|
55602
55603
|
type = getESSymbolLikeTypeForNode(declaration);
|
|
55603
55604
|
}
|
|
55604
55605
|
if (reportErrors2) {
|
|
55605
55606
|
reportErrorsFromWidening(declaration, type);
|
|
55606
55607
|
}
|
|
55607
|
-
if (type.flags &
|
|
55608
|
+
if (type.flags & 8192 /* UniqueESSymbol */ && (isBindingElement(declaration) || !tryGetTypeFromEffectiveTypeNode(declaration)) && type.symbol !== getSymbolOfDeclaration(declaration)) {
|
|
55608
55609
|
type = esSymbolType;
|
|
55609
55610
|
}
|
|
55610
55611
|
return getWidenedType(type);
|
|
@@ -56441,7 +56442,7 @@ function createTypeChecker(host) {
|
|
|
56441
56442
|
return links.declaredType;
|
|
56442
56443
|
}
|
|
56443
56444
|
function getBaseTypeOfEnumLikeType(type) {
|
|
56444
|
-
return type.flags &
|
|
56445
|
+
return type.flags & 1056 /* EnumLike */ && type.symbol.flags & 8 /* EnumMember */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
|
|
56445
56446
|
}
|
|
56446
56447
|
function getDeclaredTypeOfEnum(symbol) {
|
|
56447
56448
|
const links = getSymbolLinks(symbol);
|
|
@@ -56472,7 +56473,7 @@ function createTypeChecker(host) {
|
|
|
56472
56473
|
void 0
|
|
56473
56474
|
) : createComputedEnumType(symbol);
|
|
56474
56475
|
if (enumType.flags & 1048576 /* Union */) {
|
|
56475
|
-
enumType.flags |=
|
|
56476
|
+
enumType.flags |= 1024 /* EnumLiteral */;
|
|
56476
56477
|
enumType.symbol = symbol;
|
|
56477
56478
|
}
|
|
56478
56479
|
links.declaredType = enumType;
|
|
@@ -56480,8 +56481,8 @@ function createTypeChecker(host) {
|
|
|
56480
56481
|
return links.declaredType;
|
|
56481
56482
|
}
|
|
56482
56483
|
function createComputedEnumType(symbol) {
|
|
56483
|
-
const regularType = createTypeWithSymbol(
|
|
56484
|
-
const freshType = createTypeWithSymbol(
|
|
56484
|
+
const regularType = createTypeWithSymbol(32 /* Enum */, symbol);
|
|
56485
|
+
const freshType = createTypeWithSymbol(32 /* Enum */, symbol);
|
|
56485
56486
|
regularType.regularType = regularType;
|
|
56486
56487
|
regularType.freshType = freshType;
|
|
56487
56488
|
freshType.regularType = regularType;
|
|
@@ -56683,7 +56684,7 @@ function createTypeChecker(host) {
|
|
|
56683
56684
|
const earlySymbol = earlySymbols && earlySymbols.get(memberName);
|
|
56684
56685
|
if (!(parent.flags & 32 /* Class */) && lateSymbol.flags & getExcludedSymbolFlags(symbolFlags)) {
|
|
56685
56686
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
56686
|
-
const name = !(type.flags &
|
|
56687
|
+
const name = !(type.flags & 8192 /* UniqueESSymbol */) && unescapeLeadingUnderscores(memberName) || declarationNameToString(declName);
|
|
56687
56688
|
forEach(declarations, (declaration) => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
56688
56689
|
error(declName || decl, Diagnostics.Duplicate_property_0, name);
|
|
56689
56690
|
lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
|
|
@@ -57378,7 +57379,7 @@ function createTypeChecker(host) {
|
|
|
57378
57379
|
if (baseConstructorIndexInfo) {
|
|
57379
57380
|
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
|
57380
57381
|
}
|
|
57381
|
-
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags &
|
|
57382
|
+
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || some(type.properties, (prop) => !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */)))) {
|
|
57382
57383
|
indexInfos = append(indexInfos, enumNumberIndexInfo);
|
|
57383
57384
|
}
|
|
57384
57385
|
}
|
|
@@ -57439,7 +57440,7 @@ function createTypeChecker(host) {
|
|
|
57439
57440
|
const limitedConstraint = getLimitedConstraint(type);
|
|
57440
57441
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
57441
57442
|
if (limitedConstraint) {
|
|
57442
|
-
const propertyNameType = getLiteralTypeFromProperty(prop,
|
|
57443
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
57443
57444
|
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
57444
57445
|
continue;
|
|
57445
57446
|
}
|
|
@@ -57492,7 +57493,7 @@ function createTypeChecker(host) {
|
|
|
57492
57493
|
}
|
|
57493
57494
|
if (type.flags & 2097152 /* Intersection */) {
|
|
57494
57495
|
const types = type.types;
|
|
57495
|
-
if (types.length === 2 && !!(types[0].flags & (
|
|
57496
|
+
if (types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType) {
|
|
57496
57497
|
return type;
|
|
57497
57498
|
}
|
|
57498
57499
|
return getIntersectionType(sameMap(type.types, getLowerBoundOfKeyType));
|
|
@@ -57510,7 +57511,7 @@ function createTypeChecker(host) {
|
|
|
57510
57511
|
cb(stringType);
|
|
57511
57512
|
} else {
|
|
57512
57513
|
for (const info of getIndexInfosOfType(type)) {
|
|
57513
|
-
if (!stringsOnly || info.keyType.flags & (
|
|
57514
|
+
if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
57514
57515
|
cb(info.keyType);
|
|
57515
57516
|
}
|
|
57516
57517
|
}
|
|
@@ -57528,7 +57529,7 @@ function createTypeChecker(host) {
|
|
|
57528
57529
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
57529
57530
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
57530
57531
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
57531
|
-
const include =
|
|
57532
|
+
const include = 8576 /* StringOrNumberLiteralOrUnique */;
|
|
57532
57533
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
57533
57534
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
57534
57535
|
modifiersType,
|
|
@@ -57568,8 +57569,8 @@ function createTypeChecker(host) {
|
|
|
57568
57569
|
}
|
|
57569
57570
|
members.set(propName, prop);
|
|
57570
57571
|
}
|
|
57571
|
-
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ |
|
|
57572
|
-
const indexKeyType = propNameType.flags & (1 /* Any */ |
|
|
57572
|
+
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) {
|
|
57573
|
+
const indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : propNameType;
|
|
57573
57574
|
const propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType));
|
|
57574
57575
|
const modifiersIndexInfo = getApplicableIndexInfo(modifiersType, propNameType);
|
|
57575
57576
|
const isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || !(templateModifiers & 2 /* ExcludeReadonly */) && (modifiersIndexInfo == null ? void 0 : modifiersIndexInfo.isReadonly));
|
|
@@ -57594,7 +57595,7 @@ function createTypeChecker(host) {
|
|
|
57594
57595
|
const templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType);
|
|
57595
57596
|
const mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.links.keyType);
|
|
57596
57597
|
const propType = instantiateType(templateType, mapper);
|
|
57597
|
-
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType,
|
|
57598
|
+
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(
|
|
57598
57599
|
propType,
|
|
57599
57600
|
/*isProperty*/
|
|
57600
57601
|
true
|
|
@@ -57888,14 +57889,14 @@ function createTypeChecker(host) {
|
|
|
57888
57889
|
constraints = append(constraints, t);
|
|
57889
57890
|
}
|
|
57890
57891
|
}
|
|
57891
|
-
} else if (t.flags &
|
|
57892
|
+
} else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
57892
57893
|
hasDisjointDomainType = true;
|
|
57893
57894
|
}
|
|
57894
57895
|
}
|
|
57895
57896
|
if (constraints && (targetIsUnion || hasDisjointDomainType)) {
|
|
57896
57897
|
if (hasDisjointDomainType) {
|
|
57897
57898
|
for (const t of types) {
|
|
57898
|
-
if (t.flags &
|
|
57899
|
+
if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
57899
57900
|
constraints = append(constraints, t);
|
|
57900
57901
|
}
|
|
57901
57902
|
}
|
|
@@ -58096,7 +58097,7 @@ function createTypeChecker(host) {
|
|
|
58096
58097
|
function getApparentType(type) {
|
|
58097
58098
|
const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
|
|
58098
58099
|
const objectFlags = getObjectFlags(t);
|
|
58099
|
-
return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags &
|
|
58100
|
+
return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? stringNumberSymbolType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
|
|
58100
58101
|
}
|
|
58101
58102
|
function getReducedApparentType(type) {
|
|
58102
58103
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
@@ -58448,7 +58449,7 @@ function createTypeChecker(host) {
|
|
|
58448
58449
|
)) : applicableInfo ? applicableInfo : stringIndexInfo && isApplicableIndexType(keyType, stringType) ? stringIndexInfo : void 0;
|
|
58449
58450
|
}
|
|
58450
58451
|
function isApplicableIndexType(source, target) {
|
|
58451
|
-
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags &
|
|
58452
|
+
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && isNumericLiteralName(source.value));
|
|
58452
58453
|
}
|
|
58453
58454
|
function getIndexInfosOfStructuredType(type) {
|
|
58454
58455
|
if (type.flags & 3670016 /* StructuredType */) {
|
|
@@ -58777,7 +58778,7 @@ function createTypeChecker(host) {
|
|
|
58777
58778
|
}
|
|
58778
58779
|
if (type || jsdocPredicate) {
|
|
58779
58780
|
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
58780
|
-
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags &
|
|
58781
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 16 /* Boolean */) && getParameterCount(signature) > 0) {
|
|
58781
58782
|
const { declaration } = signature;
|
|
58782
58783
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
58783
58784
|
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
@@ -59062,7 +59063,7 @@ function createTypeChecker(host) {
|
|
|
59062
59063
|
return emptyArray;
|
|
59063
59064
|
}
|
|
59064
59065
|
function isValidIndexKeyType(type) {
|
|
59065
|
-
return !!(type.flags & (
|
|
59066
|
+
return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && some(type.types, isValidIndexKeyType);
|
|
59066
59067
|
}
|
|
59067
59068
|
function getConstraintDeclaration(type) {
|
|
59068
59069
|
return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
|
|
@@ -59563,7 +59564,7 @@ function createTypeChecker(host) {
|
|
|
59563
59564
|
}
|
|
59564
59565
|
function getTypeFromJSDocNullableTypeNode(node) {
|
|
59565
59566
|
const type = getTypeFromTypeNode(node.type);
|
|
59566
|
-
return strictNullChecks ? getNullableType(type,
|
|
59567
|
+
return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type;
|
|
59567
59568
|
}
|
|
59568
59569
|
function getTypeFromTypeReference(node) {
|
|
59569
59570
|
const links = getNodeLinks(node);
|
|
@@ -60336,10 +60337,10 @@ function createTypeChecker(host) {
|
|
|
60336
60337
|
return type.id;
|
|
60337
60338
|
}
|
|
60338
60339
|
function containsType(types, type) {
|
|
60339
|
-
return binarySearch(types, type,
|
|
60340
|
+
return binarySearch(types, type, getTypeId, compareValues) >= 0;
|
|
60340
60341
|
}
|
|
60341
60342
|
function insertType(types, type) {
|
|
60342
|
-
const index = binarySearch(types, type,
|
|
60343
|
+
const index = binarySearch(types, type, getTypeId, compareValues);
|
|
60343
60344
|
if (index < 0) {
|
|
60344
60345
|
types.splice(~index, 0, type);
|
|
60345
60346
|
return true;
|
|
@@ -60354,10 +60355,11 @@ function createTypeChecker(host) {
|
|
|
60354
60355
|
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) includes |= 536870912 /* IncludesConstrainedTypeVariable */;
|
|
60355
60356
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
60356
60357
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
60357
|
-
if (!strictNullChecks && flags &
|
|
60358
|
+
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
60358
60359
|
if (!(getObjectFlags(type) & 65536 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */;
|
|
60359
60360
|
} else {
|
|
60360
|
-
const
|
|
60361
|
+
const len = typeSet.length;
|
|
60362
|
+
const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues);
|
|
60361
60363
|
if (index < 0) {
|
|
60362
60364
|
typeSet.splice(~index, 0, type);
|
|
60363
60365
|
}
|
|
@@ -60435,7 +60437,7 @@ function createTypeChecker(host) {
|
|
|
60435
60437
|
i--;
|
|
60436
60438
|
const t = types[i];
|
|
60437
60439
|
const flags = t.flags;
|
|
60438
|
-
const remove = flags & (
|
|
60440
|
+
const remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || isFreshLiteralType(t) && containsType(types, t.regularType);
|
|
60439
60441
|
if (remove) {
|
|
60440
60442
|
orderedRemoveItemAt(types, i);
|
|
60441
60443
|
}
|
|
@@ -60448,7 +60450,7 @@ function createTypeChecker(host) {
|
|
|
60448
60450
|
while (i > 0) {
|
|
60449
60451
|
i--;
|
|
60450
60452
|
const t = types[i];
|
|
60451
|
-
if (t.flags &
|
|
60453
|
+
if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
|
|
60452
60454
|
orderedRemoveItemAt(types, i);
|
|
60453
60455
|
}
|
|
60454
60456
|
}
|
|
@@ -60546,15 +60548,15 @@ function createTypeChecker(host) {
|
|
|
60546
60548
|
if (includes & 3 /* AnyOrUnknown */) {
|
|
60547
60549
|
return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType : unknownType;
|
|
60548
60550
|
}
|
|
60549
|
-
if (includes &
|
|
60551
|
+
if (includes & 32768 /* Undefined */) {
|
|
60550
60552
|
if (typeSet.length >= 2 && typeSet[0] === undefinedType && typeSet[1] === missingType) {
|
|
60551
60553
|
orderedRemoveItemAt(typeSet, 1);
|
|
60552
60554
|
}
|
|
60553
60555
|
}
|
|
60554
|
-
if (includes & (
|
|
60556
|
+
if (includes & (32 /* Enum */ | 2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) {
|
|
60555
60557
|
removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */));
|
|
60556
60558
|
}
|
|
60557
|
-
if (includes &
|
|
60559
|
+
if (includes & 128 /* StringLiteral */ && includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
60558
60560
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
60559
60561
|
}
|
|
60560
60562
|
if (includes & 536870912 /* IncludesConstrainedTypeVariable */) {
|
|
@@ -60567,7 +60569,7 @@ function createTypeChecker(host) {
|
|
|
60567
60569
|
}
|
|
60568
60570
|
}
|
|
60569
60571
|
if (typeSet.length === 0) {
|
|
60570
|
-
return includes &
|
|
60572
|
+
return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType;
|
|
60571
60573
|
}
|
|
60572
60574
|
}
|
|
60573
60575
|
if (!origin && includes & 1048576 /* Union */) {
|
|
@@ -60590,7 +60592,7 @@ function createTypeChecker(host) {
|
|
|
60590
60592
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
60591
60593
|
}
|
|
60592
60594
|
}
|
|
60593
|
-
const objectFlags = (includes &
|
|
60595
|
+
const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
60594
60596
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
60595
60597
|
}
|
|
60596
60598
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -60635,14 +60637,14 @@ function createTypeChecker(host) {
|
|
|
60635
60637
|
type.objectFlags = precomputedObjectFlags | getPropagatingFlagsOfTypes(
|
|
60636
60638
|
types,
|
|
60637
60639
|
/*excludeKinds*/
|
|
60638
|
-
|
|
60640
|
+
98304 /* Nullable */
|
|
60639
60641
|
);
|
|
60640
60642
|
type.types = types;
|
|
60641
60643
|
type.origin = origin;
|
|
60642
60644
|
type.aliasSymbol = aliasSymbol;
|
|
60643
60645
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
60644
|
-
if (types.length === 2 && types[0].flags &
|
|
60645
|
-
type.flags |=
|
|
60646
|
+
if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
|
|
60647
|
+
type.flags |= 16 /* Boolean */;
|
|
60646
60648
|
type.intrinsicName = "boolean";
|
|
60647
60649
|
}
|
|
60648
60650
|
unionTypes.set(id, type);
|
|
@@ -60671,13 +60673,13 @@ function createTypeChecker(host) {
|
|
|
60671
60673
|
if (flags & 3 /* AnyOrUnknown */) {
|
|
60672
60674
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
60673
60675
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
60674
|
-
} else if (strictNullChecks || !(flags &
|
|
60676
|
+
} else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
|
|
60675
60677
|
if (type === missingType) {
|
|
60676
60678
|
includes |= 262144 /* IncludesMissingType */;
|
|
60677
60679
|
type = undefinedType;
|
|
60678
60680
|
}
|
|
60679
60681
|
if (!typeSet.has(type.id.toString())) {
|
|
60680
|
-
if (type.flags &
|
|
60682
|
+
if (type.flags & 109472 /* Unit */ && includes & 109472 /* Unit */) {
|
|
60681
60683
|
includes |= 67108864 /* NonPrimitive */;
|
|
60682
60684
|
}
|
|
60683
60685
|
typeSet.set(type.id.toString(), type);
|
|
@@ -60698,7 +60700,7 @@ function createTypeChecker(host) {
|
|
|
60698
60700
|
while (i > 0) {
|
|
60699
60701
|
i--;
|
|
60700
60702
|
const t = types[i];
|
|
60701
|
-
const remove = t.flags &
|
|
60703
|
+
const remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ || isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
|
|
60702
60704
|
if (remove) {
|
|
60703
60705
|
orderedRemoveItemAt(types, i);
|
|
60704
60706
|
}
|
|
@@ -60713,7 +60715,7 @@ function createTypeChecker(host) {
|
|
|
60713
60715
|
if (type === undefinedType) {
|
|
60714
60716
|
return containsType(u.types, missingType);
|
|
60715
60717
|
}
|
|
60716
|
-
const primitive = type.flags &
|
|
60718
|
+
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
60717
60719
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
60718
60720
|
return false;
|
|
60719
60721
|
}
|
|
@@ -60723,7 +60725,7 @@ function createTypeChecker(host) {
|
|
|
60723
60725
|
}
|
|
60724
60726
|
function extractRedundantTemplateLiterals(types) {
|
|
60725
60727
|
let i = types.length;
|
|
60726
|
-
const literals = filter(types, (t) => !!(t.flags &
|
|
60728
|
+
const literals = filter(types, (t) => !!(t.flags & 128 /* StringLiteral */));
|
|
60727
60729
|
while (i > 0) {
|
|
60728
60730
|
i--;
|
|
60729
60731
|
const t = types[i];
|
|
@@ -60789,7 +60791,7 @@ function createTypeChecker(host) {
|
|
|
60789
60791
|
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
60790
60792
|
types,
|
|
60791
60793
|
/*excludeKinds*/
|
|
60792
|
-
|
|
60794
|
+
98304 /* Nullable */
|
|
60793
60795
|
);
|
|
60794
60796
|
result.types = types;
|
|
60795
60797
|
result.aliasSymbol = aliasSymbol;
|
|
@@ -60804,19 +60806,19 @@ function createTypeChecker(host) {
|
|
|
60804
60806
|
if (includes & 131072 /* Never */) {
|
|
60805
60807
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
60806
60808
|
}
|
|
60807
|
-
if (strictNullChecks && includes &
|
|
60809
|
+
if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) {
|
|
60808
60810
|
return neverType;
|
|
60809
60811
|
}
|
|
60810
|
-
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes &
|
|
60812
|
+
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) {
|
|
60811
60813
|
return neverType;
|
|
60812
60814
|
}
|
|
60813
60815
|
if (includes & 1 /* Any */) {
|
|
60814
60816
|
return includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType;
|
|
60815
60817
|
}
|
|
60816
|
-
if (!strictNullChecks && includes &
|
|
60817
|
-
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes &
|
|
60818
|
+
if (!strictNullChecks && includes & 98304 /* Nullable */) {
|
|
60819
|
+
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes & 32768 /* Undefined */ ? undefinedType : nullType;
|
|
60818
60820
|
}
|
|
60819
|
-
if (includes &
|
|
60821
|
+
if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || includes & 16384 /* Void */ && includes & 32768 /* Undefined */ || includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
|
|
60820
60822
|
if (!(flags & 1 /* NoSupertypeReduction */)) removeRedundantSupertypes(typeSet, includes);
|
|
60821
60823
|
}
|
|
60822
60824
|
if (includes & 262144 /* IncludesMissingType */) {
|
|
@@ -60853,12 +60855,12 @@ function createTypeChecker(host) {
|
|
|
60853
60855
|
if (includes & 1048576 /* Union */) {
|
|
60854
60856
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
60855
60857
|
result = getIntersectionType(typeSet, flags, aliasSymbol, aliasTypeArguments);
|
|
60856
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags &
|
|
60858
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
|
|
60857
60859
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
60858
|
-
removeFromEach(typeSet,
|
|
60860
|
+
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
60859
60861
|
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,
|
|
60862
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
60863
|
+
removeFromEach(typeSet, 65536 /* Null */);
|
|
60862
60864
|
result = getUnionType([getIntersectionType(typeSet, flags), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60863
60865
|
} else if (typeSet.length >= 3 && types.length > 2) {
|
|
60864
60866
|
const middle = Math.floor(typeSet.length / 2);
|
|
@@ -60923,7 +60925,7 @@ function createTypeChecker(host) {
|
|
|
60923
60925
|
const types = map(node.types, getTypeFromTypeNode);
|
|
60924
60926
|
const emptyIndex = types.length === 2 ? types.indexOf(emptyTypeLiteralType) : -1;
|
|
60925
60927
|
const t = emptyIndex >= 0 ? types[1 - emptyIndex] : unknownType;
|
|
60926
|
-
const noSupertypeReduction = !!(t.flags & (
|
|
60928
|
+
const noSupertypeReduction = !!(t.flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */) || t.flags & 134217728 /* TemplateLiteral */ && isPatternLiteralType(t));
|
|
60927
60929
|
links.resolvedType = getIntersectionType(types, noSupertypeReduction ? 1 /* NoSupertypeReduction */ : 0, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
60928
60930
|
}
|
|
60929
60931
|
return links.resolvedType;
|
|
@@ -60957,11 +60959,11 @@ function createTypeChecker(host) {
|
|
|
60957
60959
|
forEachType(constraintType, addMemberForKeyType);
|
|
60958
60960
|
} else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
60959
60961
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
60960
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType,
|
|
60962
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
|
|
60961
60963
|
} else {
|
|
60962
60964
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
60963
60965
|
}
|
|
60964
|
-
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ |
|
|
60966
|
+
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ | 4 /* String */))) : getUnionType(keyTypes);
|
|
60965
60967
|
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
60966
60968
|
return constraintType;
|
|
60967
60969
|
}
|
|
@@ -61016,7 +61018,7 @@ function createTypeChecker(host) {
|
|
|
61016
61018
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
61017
61019
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
61018
61020
|
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 &
|
|
61021
|
+
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType);
|
|
61020
61022
|
return getUnionType(
|
|
61021
61023
|
concatenate(propertyTypes, indexKeyTypes),
|
|
61022
61024
|
1 /* Literal */,
|
|
@@ -61032,7 +61034,7 @@ function createTypeChecker(host) {
|
|
|
61032
61034
|
}
|
|
61033
61035
|
function getIndexType(type, indexFlags = 0 /* None */) {
|
|
61034
61036
|
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 */ ?
|
|
61037
|
+
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 */ ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (indexFlags & 1 /* StringsOnly */ ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), indexFlags === 0 /* None */);
|
|
61036
61038
|
}
|
|
61037
61039
|
function getExtractStringType(type) {
|
|
61038
61040
|
const extractTypeAlias = getGlobalExtractSymbol();
|
|
@@ -61090,7 +61092,7 @@ function createTypeChecker(host) {
|
|
|
61090
61092
|
}
|
|
61091
61093
|
newTexts.push(text);
|
|
61092
61094
|
if (every(newTexts, (t) => t === "")) {
|
|
61093
|
-
if (every(newTypes, (t) => !!(t.flags &
|
|
61095
|
+
if (every(newTypes, (t) => !!(t.flags & 4 /* String */))) {
|
|
61094
61096
|
return stringType;
|
|
61095
61097
|
}
|
|
61096
61098
|
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
@@ -61106,7 +61108,7 @@ function createTypeChecker(host) {
|
|
|
61106
61108
|
function addSpans(texts2, types2) {
|
|
61107
61109
|
for (let i = 0; i < types2.length; i++) {
|
|
61108
61110
|
const t = types2[i];
|
|
61109
|
-
if (t.flags & (
|
|
61111
|
+
if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) {
|
|
61110
61112
|
text += getTemplateStringForType(t) || "";
|
|
61111
61113
|
text += texts2[i + 1];
|
|
61112
61114
|
} else if (t.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -61125,7 +61127,7 @@ function createTypeChecker(host) {
|
|
|
61125
61127
|
}
|
|
61126
61128
|
}
|
|
61127
61129
|
function getTemplateStringForType(type) {
|
|
61128
|
-
return type.flags &
|
|
61130
|
+
return type.flags & 128 /* StringLiteral */ ? type.value : type.flags & 256 /* NumberLiteral */ ? "" + type.value : type.flags & 2048 /* BigIntLiteral */ ? pseudoBigIntToString(type.value) : type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : void 0;
|
|
61129
61131
|
}
|
|
61130
61132
|
function createTemplateLiteralType(texts, types) {
|
|
61131
61133
|
const type = createType(134217728 /* TemplateLiteral */);
|
|
@@ -61134,9 +61136,9 @@ function createTypeChecker(host) {
|
|
|
61134
61136
|
return type;
|
|
61135
61137
|
}
|
|
61136
61138
|
function getStringMappingType(symbol, type) {
|
|
61137
|
-
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags &
|
|
61139
|
+
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
|
|
61138
61140
|
// Mapping<Mapping<T>> === Mapping<T>
|
|
61139
|
-
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ |
|
|
61141
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ | 4 /* String */ | 268435456 /* StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : (
|
|
61140
61142
|
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
61141
61143
|
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) : type
|
|
61142
61144
|
)
|
|
@@ -61274,7 +61276,7 @@ function createTypeChecker(host) {
|
|
|
61274
61276
|
}
|
|
61275
61277
|
}
|
|
61276
61278
|
}
|
|
61277
|
-
if (!(indexType.flags &
|
|
61279
|
+
if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) {
|
|
61278
61280
|
if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
|
|
61279
61281
|
return objectType;
|
|
61280
61282
|
}
|
|
@@ -61290,13 +61292,13 @@ function createTypeChecker(host) {
|
|
|
61290
61292
|
}
|
|
61291
61293
|
return void 0;
|
|
61292
61294
|
}
|
|
61293
|
-
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType,
|
|
61295
|
+
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
|
|
61294
61296
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
61295
61297
|
error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
|
|
61296
61298
|
return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
|
|
61297
61299
|
}
|
|
61298
61300
|
errorIfWritingToReadonlyIndex(indexInfo);
|
|
61299
|
-
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags &
|
|
61301
|
+
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags & 1024 /* EnumLiteral */ && getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
|
|
61300
61302
|
return getUnionType([indexInfo.type, missingType]);
|
|
61301
61303
|
}
|
|
61302
61304
|
return indexInfo.type;
|
|
@@ -61309,10 +61311,10 @@ function createTypeChecker(host) {
|
|
|
61309
61311
|
}
|
|
61310
61312
|
if (accessExpression && !isConstEnumObjectType(objectType)) {
|
|
61311
61313
|
if (isObjectLiteralType(objectType)) {
|
|
61312
|
-
if (noImplicitAny && indexType.flags & (
|
|
61314
|
+
if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
61313
61315
|
diagnostics.add(createDiagnosticForNode(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)));
|
|
61314
61316
|
return undefinedType;
|
|
61315
|
-
} else if (indexType.flags & (
|
|
61317
|
+
} else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
|
|
61316
61318
|
const types = map(objectType.properties, (property) => {
|
|
61317
61319
|
return getTypeOfSymbol(property);
|
|
61318
61320
|
});
|
|
@@ -61339,7 +61341,7 @@ function createTypeChecker(host) {
|
|
|
61339
61341
|
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
61342
|
} else {
|
|
61341
61343
|
let errorInfo;
|
|
61342
|
-
if (indexType.flags &
|
|
61344
|
+
if (indexType.flags & 1024 /* EnumLiteral */) {
|
|
61343
61345
|
errorInfo = chainDiagnosticMessages(
|
|
61344
61346
|
/*details*/
|
|
61345
61347
|
void 0,
|
|
@@ -61347,7 +61349,7 @@ function createTypeChecker(host) {
|
|
|
61347
61349
|
"[" + typeToString(indexType) + "]",
|
|
61348
61350
|
typeToString(objectType)
|
|
61349
61351
|
);
|
|
61350
|
-
} else if (indexType.flags &
|
|
61352
|
+
} else if (indexType.flags & 8192 /* UniqueESSymbol */) {
|
|
61351
61353
|
const symbolName2 = getFullyQualifiedName(indexType.symbol, accessExpression);
|
|
61352
61354
|
errorInfo = chainDiagnosticMessages(
|
|
61353
61355
|
/*details*/
|
|
@@ -61356,7 +61358,7 @@ function createTypeChecker(host) {
|
|
|
61356
61358
|
"[" + symbolName2 + "]",
|
|
61357
61359
|
typeToString(objectType)
|
|
61358
61360
|
);
|
|
61359
|
-
} else if (indexType.flags &
|
|
61361
|
+
} else if (indexType.flags & 128 /* StringLiteral */) {
|
|
61360
61362
|
errorInfo = chainDiagnosticMessages(
|
|
61361
61363
|
/*details*/
|
|
61362
61364
|
void 0,
|
|
@@ -61364,7 +61366,7 @@ function createTypeChecker(host) {
|
|
|
61364
61366
|
indexType.value,
|
|
61365
61367
|
typeToString(objectType)
|
|
61366
61368
|
);
|
|
61367
|
-
} else if (indexType.flags &
|
|
61369
|
+
} else if (indexType.flags & 256 /* NumberLiteral */) {
|
|
61368
61370
|
errorInfo = chainDiagnosticMessages(
|
|
61369
61371
|
/*details*/
|
|
61370
61372
|
void 0,
|
|
@@ -61372,7 +61374,7 @@ function createTypeChecker(host) {
|
|
|
61372
61374
|
indexType.value,
|
|
61373
61375
|
typeToString(objectType)
|
|
61374
61376
|
);
|
|
61375
|
-
} else if (indexType.flags & (
|
|
61377
|
+
} else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
|
|
61376
61378
|
errorInfo = chainDiagnosticMessages(
|
|
61377
61379
|
/*details*/
|
|
61378
61380
|
void 0,
|
|
@@ -61403,9 +61405,9 @@ function createTypeChecker(host) {
|
|
|
61403
61405
|
}
|
|
61404
61406
|
if (accessNode) {
|
|
61405
61407
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
61406
|
-
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (
|
|
61408
|
+
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
61407
61409
|
error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
|
|
61408
|
-
} else if (indexType.flags & (
|
|
61410
|
+
} else if (indexType.flags & (4 /* String */ | 8 /* Number */)) {
|
|
61409
61411
|
error(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
|
|
61410
61412
|
} else {
|
|
61411
61413
|
const typeString = indexNode.kind === 10 /* BigIntLiteral */ ? "bigint" : typeToString(indexType);
|
|
@@ -61429,7 +61431,7 @@ function createTypeChecker(host) {
|
|
|
61429
61431
|
if (type.flags & 2097152 /* Intersection */) {
|
|
61430
61432
|
let seenPlaceholder = false;
|
|
61431
61433
|
for (const t of type.types) {
|
|
61432
|
-
if (t.flags & (
|
|
61434
|
+
if (t.flags & (2944 /* Literal */ | 98304 /* Nullable */) || isPatternLiteralPlaceholderType(t)) {
|
|
61433
61435
|
seenPlaceholder = true;
|
|
61434
61436
|
} else if (!(t.flags & 524288 /* Object */)) {
|
|
61435
61437
|
return false;
|
|
@@ -61437,7 +61439,7 @@ function createTypeChecker(host) {
|
|
|
61437
61439
|
}
|
|
61438
61440
|
return seenPlaceholder;
|
|
61439
61441
|
}
|
|
61440
|
-
return !!(type.flags & (1 /* Any */ |
|
|
61442
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
|
|
61441
61443
|
}
|
|
61442
61444
|
function isPatternLiteralType(type) {
|
|
61443
61445
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
@@ -61502,10 +61504,10 @@ function createTypeChecker(host) {
|
|
|
61502
61504
|
return type[cache] = distributedOverObject;
|
|
61503
61505
|
}
|
|
61504
61506
|
}
|
|
61505
|
-
if (isGenericTupleType(objectType) && indexType.flags &
|
|
61507
|
+
if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) {
|
|
61506
61508
|
const elementType = getElementTypeOfSliceOfTupleType(
|
|
61507
61509
|
objectType,
|
|
61508
|
-
indexType.flags &
|
|
61510
|
+
indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength,
|
|
61509
61511
|
/*endSkipCount*/
|
|
61510
61512
|
0,
|
|
61511
61513
|
writing
|
|
@@ -61558,14 +61560,14 @@ function createTypeChecker(host) {
|
|
|
61558
61560
|
}
|
|
61559
61561
|
function couldAccessOptionalProperty(objectType, indexType) {
|
|
61560
61562
|
const indexConstraint = getBaseConstraintOfType(indexType);
|
|
61561
|
-
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p,
|
|
61563
|
+
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */), indexConstraint));
|
|
61562
61564
|
}
|
|
61563
61565
|
function getIndexedAccessType(objectType, indexType, accessFlags = 0 /* None */, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
61564
61566
|
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
61565
61567
|
}
|
|
61566
61568
|
function indexTypeLessThan(indexType, limit) {
|
|
61567
61569
|
return everyType(indexType, (t) => {
|
|
61568
|
-
if (t.flags &
|
|
61570
|
+
if (t.flags & 384 /* StringOrNumberLiteral */) {
|
|
61569
61571
|
const propName = getPropertyNameFromType(t);
|
|
61570
61572
|
if (isNumericLiteralName(propName)) {
|
|
61571
61573
|
const index = +propName;
|
|
@@ -61580,7 +61582,7 @@ function createTypeChecker(host) {
|
|
|
61580
61582
|
return wildcardType;
|
|
61581
61583
|
}
|
|
61582
61584
|
objectType = getReducedType(objectType);
|
|
61583
|
-
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags &
|
|
61585
|
+
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
|
|
61584
61586
|
indexType = stringType;
|
|
61585
61587
|
}
|
|
61586
61588
|
if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) accessFlags |= 1 /* IncludeUndefined */;
|
|
@@ -61597,7 +61599,7 @@ function createTypeChecker(host) {
|
|
|
61597
61599
|
return type;
|
|
61598
61600
|
}
|
|
61599
61601
|
const apparentObjectType = getReducedApparentType(objectType);
|
|
61600
|
-
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags &
|
|
61602
|
+
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) {
|
|
61601
61603
|
const propTypes = [];
|
|
61602
61604
|
let wasMissingProp = false;
|
|
61603
61605
|
for (const t of indexType.types) {
|
|
@@ -61930,7 +61932,7 @@ function createTypeChecker(host) {
|
|
|
61930
61932
|
return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type);
|
|
61931
61933
|
}
|
|
61932
61934
|
function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
|
|
61933
|
-
return isEmptyObjectType(type) || !!(type.flags & (
|
|
61935
|
+
return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */));
|
|
61934
61936
|
}
|
|
61935
61937
|
function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
|
|
61936
61938
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
@@ -61993,7 +61995,7 @@ function createTypeChecker(host) {
|
|
|
61993
61995
|
if (right.flags & 1048576 /* Union */) {
|
|
61994
61996
|
return checkCrossProductUnion([left, right]) ? mapType(right, (t) => getSpreadType(left, t, symbol, objectFlags, readonly)) : errorType;
|
|
61995
61997
|
}
|
|
61996
|
-
if (right.flags & (
|
|
61998
|
+
if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) {
|
|
61997
61999
|
return left;
|
|
61998
62000
|
}
|
|
61999
62001
|
if (isGenericObjectType(left) || isGenericObjectType(right)) {
|
|
@@ -62075,7 +62077,7 @@ function createTypeChecker(host) {
|
|
|
62075
62077
|
return type;
|
|
62076
62078
|
}
|
|
62077
62079
|
function getFreshTypeOfLiteralType(type) {
|
|
62078
|
-
if (type.flags &
|
|
62080
|
+
if (type.flags & 2976 /* Freshable */) {
|
|
62079
62081
|
if (!type.freshType) {
|
|
62080
62082
|
const freshType = createLiteralType(type.flags, type.value, type.symbol, type);
|
|
62081
62083
|
freshType.freshType = freshType;
|
|
@@ -62086,28 +62088,28 @@ function createTypeChecker(host) {
|
|
|
62086
62088
|
return type;
|
|
62087
62089
|
}
|
|
62088
62090
|
function getRegularTypeOfLiteralType(type) {
|
|
62089
|
-
return type.flags &
|
|
62091
|
+
return type.flags & 2976 /* Freshable */ ? type.regularType : type.flags & 1048576 /* Union */ ? type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType)) : type;
|
|
62090
62092
|
}
|
|
62091
62093
|
function isFreshLiteralType(type) {
|
|
62092
|
-
return !!(type.flags &
|
|
62094
|
+
return !!(type.flags & 2976 /* Freshable */) && type.freshType === type;
|
|
62093
62095
|
}
|
|
62094
62096
|
function getStringLiteralType(value) {
|
|
62095
62097
|
let type;
|
|
62096
|
-
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(
|
|
62098
|
+
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type);
|
|
62097
62099
|
}
|
|
62098
62100
|
function getNumberLiteralType(value) {
|
|
62099
62101
|
let type;
|
|
62100
|
-
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(
|
|
62102
|
+
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type);
|
|
62101
62103
|
}
|
|
62102
62104
|
function getBigIntLiteralType(value) {
|
|
62103
62105
|
let type;
|
|
62104
62106
|
const key = pseudoBigIntToString(value);
|
|
62105
|
-
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(
|
|
62107
|
+
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type);
|
|
62106
62108
|
}
|
|
62107
62109
|
function getEnumLiteralType(value, enumId, symbol) {
|
|
62108
62110
|
let type;
|
|
62109
62111
|
const key = `${enumId}${typeof value === "string" ? "@" : "#"}${value}`;
|
|
62110
|
-
const flags =
|
|
62112
|
+
const flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */);
|
|
62111
62113
|
return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type);
|
|
62112
62114
|
}
|
|
62113
62115
|
function getTypeFromLiteralTypeNode(node) {
|
|
@@ -62121,7 +62123,7 @@ function createTypeChecker(host) {
|
|
|
62121
62123
|
return links.resolvedType;
|
|
62122
62124
|
}
|
|
62123
62125
|
function createUniqueESSymbolType(symbol) {
|
|
62124
|
-
const type = createTypeWithSymbol(
|
|
62126
|
+
const type = createTypeWithSymbol(8192 /* UniqueESSymbol */, symbol);
|
|
62125
62127
|
type.escapedName = `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}`;
|
|
62126
62128
|
return type;
|
|
62127
62129
|
}
|
|
@@ -62509,7 +62511,7 @@ function createTypeChecker(host) {
|
|
|
62509
62511
|
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
62512
|
target.instantiations.set(id, result);
|
|
62511
62513
|
const resultObjectFlags = getObjectFlags(result);
|
|
62512
|
-
if (result.flags &
|
|
62514
|
+
if (result.flags & 3899393 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62513
62515
|
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
62514
62516
|
if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62515
62517
|
if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
|
|
@@ -62638,7 +62640,7 @@ function createTypeChecker(host) {
|
|
|
62638
62640
|
const templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
|
|
62639
62641
|
const propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
|
|
62640
62642
|
const modifiers = getMappedTypeModifiers(type);
|
|
62641
|
-
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType,
|
|
62643
|
+
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(
|
|
62642
62644
|
propType,
|
|
62643
62645
|
/*isProperty*/
|
|
62644
62646
|
true
|
|
@@ -63185,7 +63187,7 @@ function createTypeChecker(host) {
|
|
|
63185
63187
|
createDiagnosticForNode(
|
|
63186
63188
|
targetNode,
|
|
63187
63189
|
Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1,
|
|
63188
|
-
propertyName && !(nameType.flags &
|
|
63190
|
+
propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? unescapeLeadingUnderscores(propertyName) : typeToString(nameType),
|
|
63189
63191
|
typeToString(target)
|
|
63190
63192
|
)
|
|
63191
63193
|
);
|
|
@@ -63428,7 +63430,7 @@ function createTypeChecker(host) {
|
|
|
63428
63430
|
if (!length(node.properties)) return;
|
|
63429
63431
|
for (const prop of node.properties) {
|
|
63430
63432
|
if (isSpreadAssignment(prop)) continue;
|
|
63431
|
-
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop),
|
|
63433
|
+
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop), 8576 /* StringOrNumberLiteralOrUnique */);
|
|
63432
63434
|
if (!type || type.flags & 131072 /* Never */) {
|
|
63433
63435
|
continue;
|
|
63434
63436
|
}
|
|
@@ -63478,7 +63480,7 @@ function createTypeChecker(host) {
|
|
|
63478
63480
|
}
|
|
63479
63481
|
return false;
|
|
63480
63482
|
}
|
|
63481
|
-
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
63483
|
+
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
|
|
63482
63484
|
if (source === target) {
|
|
63483
63485
|
return -1 /* True */;
|
|
63484
63486
|
}
|
|
@@ -63503,7 +63505,7 @@ function createTypeChecker(host) {
|
|
|
63503
63505
|
target,
|
|
63504
63506
|
/*inferenceContext*/
|
|
63505
63507
|
void 0,
|
|
63506
|
-
|
|
63508
|
+
compareTypes
|
|
63507
63509
|
);
|
|
63508
63510
|
}
|
|
63509
63511
|
const sourceCount = getParameterCount(source);
|
|
@@ -63519,12 +63521,12 @@ function createTypeChecker(host) {
|
|
|
63519
63521
|
if (sourceThisType && sourceThisType !== voidType) {
|
|
63520
63522
|
const targetThisType = getThisTypeOfSignature(target);
|
|
63521
63523
|
if (targetThisType) {
|
|
63522
|
-
const related = !strictVariance &&
|
|
63524
|
+
const related = !strictVariance && compareTypes(
|
|
63523
63525
|
sourceThisType,
|
|
63524
63526
|
targetThisType,
|
|
63525
63527
|
/*reportErrors*/
|
|
63526
63528
|
false
|
|
63527
|
-
) ||
|
|
63529
|
+
) || compareTypes(targetThisType, sourceThisType, reportErrors2);
|
|
63528
63530
|
if (!related) {
|
|
63529
63531
|
if (reportErrors2) {
|
|
63530
63532
|
errorReporter(Diagnostics.The_this_types_of_each_signature_are_incompatible);
|
|
@@ -63543,13 +63545,13 @@ function createTypeChecker(host) {
|
|
|
63543
63545
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
63544
63546
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
63545
63547
|
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,
|
|
63548
|
+
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
63547
63549
|
sourceType,
|
|
63548
63550
|
targetType,
|
|
63549
63551
|
/*reportErrors*/
|
|
63550
63552
|
false
|
|
63551
|
-
) ||
|
|
63552
|
-
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) &&
|
|
63553
|
+
) || compareTypes(targetType, sourceType, reportErrors2);
|
|
63554
|
+
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(
|
|
63553
63555
|
sourceType,
|
|
63554
63556
|
targetType,
|
|
63555
63557
|
/*reportErrors*/
|
|
@@ -63576,7 +63578,7 @@ function createTypeChecker(host) {
|
|
|
63576
63578
|
if (targetTypePredicate) {
|
|
63577
63579
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
63578
63580
|
if (sourceTypePredicate) {
|
|
63579
|
-
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter,
|
|
63581
|
+
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter, compareTypes);
|
|
63580
63582
|
} else if (isIdentifierTypePredicate(targetTypePredicate) || isThisTypePredicate(targetTypePredicate)) {
|
|
63581
63583
|
if (reportErrors2) {
|
|
63582
63584
|
errorReporter(Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
|
|
@@ -63584,12 +63586,12 @@ function createTypeChecker(host) {
|
|
|
63584
63586
|
return 0 /* False */;
|
|
63585
63587
|
}
|
|
63586
63588
|
} else {
|
|
63587
|
-
result &= checkMode & 1 /* BivariantCallback */ &&
|
|
63589
|
+
result &= checkMode & 1 /* BivariantCallback */ && compareTypes(
|
|
63588
63590
|
targetReturnType,
|
|
63589
63591
|
sourceReturnType,
|
|
63590
63592
|
/*reportErrors*/
|
|
63591
63593
|
false
|
|
63592
|
-
) ||
|
|
63594
|
+
) || compareTypes(sourceReturnType, targetReturnType, reportErrors2);
|
|
63593
63595
|
if (!result && reportErrors2 && incompatibleErrorReporter) {
|
|
63594
63596
|
incompatibleErrorReporter(sourceReturnType, targetReturnType);
|
|
63595
63597
|
}
|
|
@@ -63597,7 +63599,7 @@ function createTypeChecker(host) {
|
|
|
63597
63599
|
}
|
|
63598
63600
|
return result;
|
|
63599
63601
|
}
|
|
63600
|
-
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter,
|
|
63602
|
+
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter, compareTypes) {
|
|
63601
63603
|
if (source.kind !== target.kind) {
|
|
63602
63604
|
if (reportErrors2) {
|
|
63603
63605
|
errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
|
|
@@ -63614,7 +63616,7 @@ function createTypeChecker(host) {
|
|
|
63614
63616
|
return 0 /* False */;
|
|
63615
63617
|
}
|
|
63616
63618
|
}
|
|
63617
|
-
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
63619
|
+
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors2) : 0 /* False */;
|
|
63618
63620
|
if (related === 0 /* False */ && reportErrors2) {
|
|
63619
63621
|
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
|
|
63620
63622
|
}
|
|
@@ -63648,18 +63650,18 @@ function createTypeChecker(host) {
|
|
|
63648
63650
|
if (strictNullChecks && type.flags & 1048576 /* Union */) {
|
|
63649
63651
|
if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
|
|
63650
63652
|
const types = type.types;
|
|
63651
|
-
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags &
|
|
63653
|
+
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ && types[1].flags & 65536 /* Null */ && some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
|
|
63652
63654
|
}
|
|
63653
63655
|
return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
|
|
63654
63656
|
}
|
|
63655
63657
|
return false;
|
|
63656
63658
|
}
|
|
63657
63659
|
function containsUndefinedType(type) {
|
|
63658
|
-
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags &
|
|
63660
|
+
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
|
|
63659
63661
|
}
|
|
63660
63662
|
function containsNonMissingUndefinedType(type) {
|
|
63661
63663
|
const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
|
|
63662
|
-
return !!(candidate.flags &
|
|
63664
|
+
return !!(candidate.flags & 32768 /* Undefined */) && candidate !== missingType;
|
|
63663
63665
|
}
|
|
63664
63666
|
function isStringIndexSignatureOnlyType(type) {
|
|
63665
63667
|
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 +63732,25 @@ function createTypeChecker(host) {
|
|
|
63730
63732
|
if (t & 1 /* Any */ || s & 131072 /* Never */ || source === wildcardType) return true;
|
|
63731
63733
|
if (t & 2 /* Unknown */ && !(relation === strictSubtypeRelation && s & 1 /* Any */)) return true;
|
|
63732
63734
|
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 &
|
|
63735
|
+
if (s & 402653316 /* StringLike */ && t & 4 /* String */) return true;
|
|
63736
|
+
if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true;
|
|
63737
|
+
if (s & 296 /* NumberLike */ && t & 8 /* Number */) return true;
|
|
63738
|
+
if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true;
|
|
63739
|
+
if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) return true;
|
|
63740
|
+
if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) return true;
|
|
63741
|
+
if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) return true;
|
|
63742
|
+
if (s & 32 /* Enum */ && t & 32 /* Enum */ && source.symbol.escapedName === target.symbol.escapedName && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
63743
|
+
if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) {
|
|
63742
63744
|
if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
63743
|
-
if (s &
|
|
63745
|
+
if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
63744
63746
|
}
|
|
63745
|
-
if (s &
|
|
63746
|
-
if (s &
|
|
63747
|
+
if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) return true;
|
|
63748
|
+
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) return true;
|
|
63747
63749
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(getObjectFlags(source) & 8192 /* FreshLiteral */))) return true;
|
|
63748
63750
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
63749
63751
|
if (s & 1 /* Any */) return true;
|
|
63750
|
-
if (s &
|
|
63751
|
-
if (s &
|
|
63752
|
+
if (s & 8 /* Number */ && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true;
|
|
63753
|
+
if (s & 256 /* NumberLiteral */ && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */ && source.value === target.value)) return true;
|
|
63752
63754
|
if (isUnknownLikeUnionType(target)) return true;
|
|
63753
63755
|
}
|
|
63754
63756
|
return false;
|
|
@@ -63769,7 +63771,7 @@ function createTypeChecker(host) {
|
|
|
63769
63771
|
}
|
|
63770
63772
|
} else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
|
|
63771
63773
|
if (source.flags !== target.flags) return false;
|
|
63772
|
-
if (source.flags &
|
|
63774
|
+
if (source.flags & 67358815 /* Singleton */) return true;
|
|
63773
63775
|
}
|
|
63774
63776
|
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
63775
63777
|
const related = relation.get(getRelationKey(
|
|
@@ -63823,7 +63825,7 @@ function createTypeChecker(host) {
|
|
|
63823
63825
|
let hasNullableOrEmpty = false;
|
|
63824
63826
|
for (const t of type.types) {
|
|
63825
63827
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
63826
|
-
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags &
|
|
63828
|
+
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
63827
63829
|
if (hasInstantiable && hasNullableOrEmpty) return true;
|
|
63828
63830
|
}
|
|
63829
63831
|
return false;
|
|
@@ -64093,7 +64095,7 @@ function createTypeChecker(host) {
|
|
|
64093
64095
|
} else if (exactOptionalPropertyTypes && getExactOptionalUnassignableProperties(source2, target2).length) {
|
|
64094
64096
|
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
64097
|
} else {
|
|
64096
|
-
if (source2.flags &
|
|
64098
|
+
if (source2.flags & 128 /* StringLiteral */ && target2.flags & 1048576 /* Union */) {
|
|
64097
64099
|
const suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source2, target2);
|
|
64098
64100
|
if (suggestedType) {
|
|
64099
64101
|
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType));
|
|
@@ -64162,7 +64164,7 @@ function createTypeChecker(host) {
|
|
|
64162
64164
|
if (source2 === target2) return -1 /* True */;
|
|
64163
64165
|
if (relation === identityRelation) {
|
|
64164
64166
|
if (source2.flags !== target2.flags) return 0 /* False */;
|
|
64165
|
-
if (source2.flags &
|
|
64167
|
+
if (source2.flags & 67358815 /* Singleton */) return -1 /* True */;
|
|
64166
64168
|
traceUnionsOrIntersectionsTooLarge(source2, target2);
|
|
64167
64169
|
return recursiveTypeRelatedTo(
|
|
64168
64170
|
source2,
|
|
@@ -64176,10 +64178,10 @@ function createTypeChecker(host) {
|
|
|
64176
64178
|
if (source2.flags & 262144 /* TypeParameter */ && getConstraintOfType(source2) === target2) {
|
|
64177
64179
|
return -1 /* True */;
|
|
64178
64180
|
}
|
|
64179
|
-
if (source2.flags &
|
|
64181
|
+
if (source2.flags & 470302716 /* DefinitelyNonNullable */ && target2.flags & 1048576 /* Union */) {
|
|
64180
64182
|
const types = target2.types;
|
|
64181
|
-
const candidate = types.length === 2 && types[0].flags &
|
|
64182
|
-
if (candidate && !(candidate.flags &
|
|
64183
|
+
const candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : void 0;
|
|
64184
|
+
if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
|
|
64183
64185
|
target2 = getNormalizedType(
|
|
64184
64186
|
candidate,
|
|
64185
64187
|
/*writing*/
|
|
@@ -64481,9 +64483,9 @@ function createTypeChecker(host) {
|
|
|
64481
64483
|
if (containsType(targetTypes, source2)) {
|
|
64482
64484
|
return -1 /* True */;
|
|
64483
64485
|
}
|
|
64484
|
-
if (relation !== comparableRelation && getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags &
|
|
64486
|
+
if (relation !== comparableRelation && getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
|
|
64485
64487
|
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
64486
|
-
const primitive = source2.flags &
|
|
64488
|
+
const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
|
|
64487
64489
|
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
64488
64490
|
}
|
|
64489
64491
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
@@ -64578,8 +64580,8 @@ function createTypeChecker(host) {
|
|
|
64578
64580
|
return 0 /* False */;
|
|
64579
64581
|
}
|
|
64580
64582
|
function getUndefinedStrippedTargetIfNeeded(source2, target2) {
|
|
64581
|
-
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags &
|
|
64582
|
-
return extractTypesOfKind(target2, ~
|
|
64583
|
+
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags & 32768 /* Undefined */) && target2.types[0].flags & 32768 /* Undefined */) {
|
|
64584
|
+
return extractTypesOfKind(target2, ~32768 /* Undefined */);
|
|
64583
64585
|
}
|
|
64584
64586
|
return target2;
|
|
64585
64587
|
}
|
|
@@ -64921,7 +64923,7 @@ function createTypeChecker(host) {
|
|
|
64921
64923
|
const mappedKeys = [];
|
|
64922
64924
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
64923
64925
|
modifiersType,
|
|
64924
|
-
|
|
64926
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
64925
64927
|
/*stringsOnly*/
|
|
64926
64928
|
false,
|
|
64927
64929
|
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
@@ -65180,7 +65182,7 @@ function createTypeChecker(host) {
|
|
|
65180
65182
|
if (includeOptional ? !(filteredByApplicability.flags & 131072 /* Never */) : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
|
|
65181
65183
|
const templateType2 = getTemplateTypeFromMappedType(target2);
|
|
65182
65184
|
const typeParameter = getTypeParameterFromMappedType(target2);
|
|
65183
|
-
const nonNullComponent = extractTypesOfKind(templateType2, ~
|
|
65185
|
+
const nonNullComponent = extractTypesOfKind(templateType2, ~98304 /* Nullable */);
|
|
65184
65186
|
if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
|
|
65185
65187
|
if (result2 = isRelatedTo(source2, nonNullComponent.objectType, 2 /* Target */, reportErrors2)) {
|
|
65186
65188
|
return result2;
|
|
@@ -65841,7 +65843,7 @@ function createTypeChecker(host) {
|
|
|
65841
65843
|
for (const sourceProp of excludeProperties(getPropertiesOfType(source2), excludedProperties)) {
|
|
65842
65844
|
if (!getPropertyOfObjectType(target2, sourceProp.escapedName)) {
|
|
65843
65845
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
65844
|
-
if (!(sourceType.flags &
|
|
65846
|
+
if (!(sourceType.flags & 32768 /* Undefined */)) {
|
|
65845
65847
|
if (reportErrors2) {
|
|
65846
65848
|
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target2));
|
|
65847
65849
|
}
|
|
@@ -66069,9 +66071,9 @@ function createTypeChecker(host) {
|
|
|
66069
66071
|
if (isIgnoredJsxProperty(source2, prop)) {
|
|
66070
66072
|
continue;
|
|
66071
66073
|
}
|
|
66072
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
66074
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) {
|
|
66073
66075
|
const propType = getNonMissingTypeOfSymbol(prop);
|
|
66074
|
-
const type = exactOptionalPropertyTypes || propType.flags &
|
|
66076
|
+
const type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) ? propType : getTypeWithFacts(propType, 524288 /* NEUndefined */);
|
|
66075
66077
|
const related = isRelatedTo(
|
|
66076
66078
|
type,
|
|
66077
66079
|
targetInfo.type,
|
|
@@ -66185,7 +66187,7 @@ function createTypeChecker(host) {
|
|
|
66185
66187
|
}
|
|
66186
66188
|
}
|
|
66187
66189
|
function typeCouldHaveTopLevelSingletonTypes(type) {
|
|
66188
|
-
if (type.flags &
|
|
66190
|
+
if (type.flags & 16 /* Boolean */) {
|
|
66189
66191
|
return false;
|
|
66190
66192
|
}
|
|
66191
66193
|
if (type.flags & 3145728 /* UnionOrIntersection */) {
|
|
@@ -66204,7 +66206,7 @@ function createTypeChecker(host) {
|
|
|
66204
66206
|
return getPropertiesOfType(target).filter((targetProp) => isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)));
|
|
66205
66207
|
}
|
|
66206
66208
|
function isExactOptionalPropertyMismatch(source, target) {
|
|
66207
|
-
return !!source && !!target && maybeTypeOfKind(source,
|
|
66209
|
+
return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target);
|
|
66208
66210
|
}
|
|
66209
66211
|
function getExactOptionalProperties(type) {
|
|
66210
66212
|
return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
|
|
@@ -66330,7 +66332,7 @@ function createTypeChecker(host) {
|
|
|
66330
66332
|
}
|
|
66331
66333
|
function hasCovariantVoidArgument(typeArguments, variances) {
|
|
66332
66334
|
for (let i = 0; i < variances.length; i++) {
|
|
66333
|
-
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags &
|
|
66335
|
+
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) {
|
|
66334
66336
|
return true;
|
|
66335
66337
|
}
|
|
66336
66338
|
}
|
|
@@ -66487,7 +66489,7 @@ function createTypeChecker(host) {
|
|
|
66487
66489
|
function isPropertyIdenticalTo(sourceProp, targetProp) {
|
|
66488
66490
|
return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
|
|
66489
66491
|
}
|
|
66490
|
-
function compareProperties(sourceProp, targetProp,
|
|
66492
|
+
function compareProperties(sourceProp, targetProp, compareTypes) {
|
|
66491
66493
|
if (sourceProp === targetProp) {
|
|
66492
66494
|
return -1 /* True */;
|
|
66493
66495
|
}
|
|
@@ -66508,7 +66510,7 @@ function createTypeChecker(host) {
|
|
|
66508
66510
|
if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
|
|
66509
66511
|
return 0 /* False */;
|
|
66510
66512
|
}
|
|
66511
|
-
return
|
|
66513
|
+
return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
66512
66514
|
}
|
|
66513
66515
|
function isMatchingSignature(source, target, partialMatch) {
|
|
66514
66516
|
const sourceParameterCount = getParameterCount(source);
|
|
@@ -66525,7 +66527,7 @@ function createTypeChecker(host) {
|
|
|
66525
66527
|
}
|
|
66526
66528
|
return false;
|
|
66527
66529
|
}
|
|
66528
|
-
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes,
|
|
66530
|
+
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
|
|
66529
66531
|
if (source === target) {
|
|
66530
66532
|
return -1 /* True */;
|
|
66531
66533
|
}
|
|
@@ -66540,7 +66542,7 @@ function createTypeChecker(host) {
|
|
|
66540
66542
|
for (let i = 0; i < target.typeParameters.length; i++) {
|
|
66541
66543
|
const s = source.typeParameters[i];
|
|
66542
66544
|
const t = target.typeParameters[i];
|
|
66543
|
-
if (!(s === t ||
|
|
66545
|
+
if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
|
|
66544
66546
|
return 0 /* False */;
|
|
66545
66547
|
}
|
|
66546
66548
|
}
|
|
@@ -66557,7 +66559,7 @@ function createTypeChecker(host) {
|
|
|
66557
66559
|
if (sourceThisType) {
|
|
66558
66560
|
const targetThisType = getThisTypeOfSignature(target);
|
|
66559
66561
|
if (targetThisType) {
|
|
66560
|
-
const related =
|
|
66562
|
+
const related = compareTypes(sourceThisType, targetThisType);
|
|
66561
66563
|
if (!related) {
|
|
66562
66564
|
return 0 /* False */;
|
|
66563
66565
|
}
|
|
@@ -66569,7 +66571,7 @@ function createTypeChecker(host) {
|
|
|
66569
66571
|
for (let i = 0; i < targetLen; i++) {
|
|
66570
66572
|
const s = getTypeAtPosition(source, i);
|
|
66571
66573
|
const t = getTypeAtPosition(target, i);
|
|
66572
|
-
const related =
|
|
66574
|
+
const related = compareTypes(t, s);
|
|
66573
66575
|
if (!related) {
|
|
66574
66576
|
return 0 /* False */;
|
|
66575
66577
|
}
|
|
@@ -66578,12 +66580,12 @@ function createTypeChecker(host) {
|
|
|
66578
66580
|
if (!ignoreReturnTypes) {
|
|
66579
66581
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
66580
66582
|
const targetTypePredicate = getTypePredicateOfSignature(target);
|
|
66581
|
-
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate,
|
|
66583
|
+
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
|
66582
66584
|
}
|
|
66583
66585
|
return result;
|
|
66584
66586
|
}
|
|
66585
|
-
function compareTypePredicatesIdentical(source, target,
|
|
66586
|
-
return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
66587
|
+
function compareTypePredicatesIdentical(source, target, compareTypes) {
|
|
66588
|
+
return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : source.type && target.type ? compareTypes(source.type, target.type) : 0 /* False */;
|
|
66587
66589
|
}
|
|
66588
66590
|
function literalTypesWithSameBaseType(types) {
|
|
66589
66591
|
let commonBaseType;
|
|
@@ -66605,9 +66607,9 @@ function createTypeChecker(host) {
|
|
|
66605
66607
|
if (types.length === 1) {
|
|
66606
66608
|
return types[0];
|
|
66607
66609
|
}
|
|
66608
|
-
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags &
|
|
66610
|
+
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags & 98304 /* Nullable */))) : types;
|
|
66609
66611
|
const superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? getUnionType(primaryTypes) : reduceLeft(primaryTypes, (s, t) => isTypeSubtypeOf(s, t) ? t : s);
|
|
66610
|
-
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) &
|
|
66612
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* Nullable */);
|
|
66611
66613
|
}
|
|
66612
66614
|
function getCommonSubtype(types) {
|
|
66613
66615
|
return reduceLeft(types, (s, t) => isTypeSubtypeOf(t, s) ? t : s);
|
|
@@ -66628,10 +66630,10 @@ function createTypeChecker(host) {
|
|
|
66628
66630
|
return isArrayType(type) ? getTypeArguments(type)[0] : void 0;
|
|
66629
66631
|
}
|
|
66630
66632
|
function isArrayLikeType(type) {
|
|
66631
|
-
return isArrayType(type) || !(type.flags &
|
|
66633
|
+
return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType);
|
|
66632
66634
|
}
|
|
66633
66635
|
function isMutableArrayLikeType(type) {
|
|
66634
|
-
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ |
|
|
66636
|
+
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ | 98304 /* Nullable */)) && isTypeAssignableTo(type, anyArrayType);
|
|
66635
66637
|
}
|
|
66636
66638
|
function getSingleBaseForNonAugmentingSubtype(type) {
|
|
66637
66639
|
if (!(getObjectFlags(type) & 4 /* Reference */) || !(getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
@@ -66671,7 +66673,7 @@ function createTypeChecker(host) {
|
|
|
66671
66673
|
}
|
|
66672
66674
|
function isTupleLikeType(type) {
|
|
66673
66675
|
let lengthType;
|
|
66674
|
-
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags &
|
|
66676
|
+
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags & 256 /* NumberLiteral */));
|
|
66675
66677
|
}
|
|
66676
66678
|
function isArrayOrTupleLikeType(type) {
|
|
66677
66679
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
@@ -66687,10 +66689,10 @@ function createTypeChecker(host) {
|
|
|
66687
66689
|
return void 0;
|
|
66688
66690
|
}
|
|
66689
66691
|
function isNeitherUnitTypeNorNever(type) {
|
|
66690
|
-
return !(type.flags & (
|
|
66692
|
+
return !(type.flags & (109472 /* Unit */ | 131072 /* Never */));
|
|
66691
66693
|
}
|
|
66692
66694
|
function isUnitType(type) {
|
|
66693
|
-
return !!(type.flags &
|
|
66695
|
+
return !!(type.flags & 109472 /* Unit */);
|
|
66694
66696
|
}
|
|
66695
66697
|
function isUnitLikeType(type) {
|
|
66696
66698
|
const t = getBaseConstraintOrType(type);
|
|
@@ -66700,23 +66702,23 @@ function createTypeChecker(host) {
|
|
|
66700
66702
|
return type.flags & 2097152 /* Intersection */ ? find(type.types, isUnitType) || type : type;
|
|
66701
66703
|
}
|
|
66702
66704
|
function isLiteralType(type) {
|
|
66703
|
-
return type.flags &
|
|
66705
|
+
return type.flags & 16 /* Boolean */ ? true : type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : every(type.types, isUnitType) : isUnitType(type);
|
|
66704
66706
|
}
|
|
66705
66707
|
function getBaseTypeOfLiteralType(type) {
|
|
66706
|
-
return type.flags &
|
|
66708
|
+
return type.flags & 1056 /* EnumLike */ ? getBaseTypeOfEnumLikeType(type) : type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 512 /* BooleanLiteral */ ? booleanType : type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) : type;
|
|
66707
66709
|
}
|
|
66708
66710
|
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
66709
66711
|
const key = `B${getTypeId(type)}`;
|
|
66710
66712
|
return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
66711
66713
|
}
|
|
66712
66714
|
function getBaseTypeOfLiteralTypeForComparison(type) {
|
|
66713
|
-
return type.flags & (
|
|
66715
|
+
return type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : type.flags & (256 /* NumberLiteral */ | 32 /* Enum */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 512 /* BooleanLiteral */ ? booleanType : type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralTypeForComparison) : type;
|
|
66714
66716
|
}
|
|
66715
66717
|
function getWidenedLiteralType(type) {
|
|
66716
|
-
return type.flags &
|
|
66718
|
+
return type.flags & 1056 /* EnumLike */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLikeType(type) : type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : type;
|
|
66717
66719
|
}
|
|
66718
66720
|
function getWidenedUniqueESSymbolType(type) {
|
|
66719
|
-
return type.flags &
|
|
66721
|
+
return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type;
|
|
66720
66722
|
}
|
|
66721
66723
|
function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
|
|
66722
66724
|
if (!isLiteralOfContextualType(type, contextualType)) {
|
|
@@ -66793,11 +66795,11 @@ function createTypeChecker(host) {
|
|
|
66793
66795
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
66794
66796
|
}
|
|
66795
66797
|
function getDefinitelyFalsyPartOfType(type) {
|
|
66796
|
-
return type.flags &
|
|
66798
|
+
return type.flags & 4 /* String */ ? emptyStringType : type.flags & 8 /* Number */ ? zeroType : type.flags & 64 /* BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || type.flags & 128 /* StringLiteral */ && type.value === "" || type.flags & 256 /* NumberLiteral */ && type.value === 0 || type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : neverType;
|
|
66797
66799
|
}
|
|
66798
66800
|
function getNullableType(type, flags) {
|
|
66799
|
-
const missing = flags & ~type.flags & (
|
|
66800
|
-
return missing === 0 ? type : missing ===
|
|
66801
|
+
const missing = flags & ~type.flags & (32768 /* Undefined */ | 65536 /* Null */);
|
|
66802
|
+
return missing === 0 ? type : missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]);
|
|
66801
66803
|
}
|
|
66802
66804
|
function getOptionalType(type, isProperty = false) {
|
|
66803
66805
|
Debug.assert(strictNullChecks);
|
|
@@ -66840,7 +66842,7 @@ function createTypeChecker(host) {
|
|
|
66840
66842
|
return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */);
|
|
66841
66843
|
}
|
|
66842
66844
|
function isCoercibleUnderDoubleEquals(source, target) {
|
|
66843
|
-
return (source.flags & (
|
|
66845
|
+
return (source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0 && (target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0;
|
|
66844
66846
|
}
|
|
66845
66847
|
function isObjectTypeWithInferableIndex(type) {
|
|
66846
66848
|
const objectFlags = getObjectFlags(type);
|
|
@@ -66973,7 +66975,7 @@ function createTypeChecker(host) {
|
|
|
66973
66975
|
return type.widened;
|
|
66974
66976
|
}
|
|
66975
66977
|
let result;
|
|
66976
|
-
if (type.flags & (1 /* Any */ |
|
|
66978
|
+
if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) {
|
|
66977
66979
|
result = anyType;
|
|
66978
66980
|
} else if (isObjectLiteralType(type)) {
|
|
66979
66981
|
result = getWidenedTypeOfObjectLiteral(type, context);
|
|
@@ -66985,7 +66987,7 @@ function createTypeChecker(host) {
|
|
|
66985
66987
|
void 0,
|
|
66986
66988
|
type.types
|
|
66987
66989
|
);
|
|
66988
|
-
const widenedTypes = sameMap(type.types, (t) => t.flags &
|
|
66990
|
+
const widenedTypes = sameMap(type.types, (t) => t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext));
|
|
66989
66991
|
result = getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */);
|
|
66990
66992
|
} else if (type.flags & 2097152 /* Intersection */) {
|
|
66991
66993
|
result = getIntersectionType(sameMap(type.types, getWidenedType));
|
|
@@ -67185,18 +67187,18 @@ function createTypeChecker(host) {
|
|
|
67185
67187
|
callback(getReturnTypeOfSignature(source), targetReturnType);
|
|
67186
67188
|
}
|
|
67187
67189
|
}
|
|
67188
|
-
function createInferenceContext(typeParameters, signature, flags,
|
|
67189
|
-
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags,
|
|
67190
|
+
function createInferenceContext(typeParameters, signature, flags, compareTypes) {
|
|
67191
|
+
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
|
|
67190
67192
|
}
|
|
67191
67193
|
function cloneInferenceContext(context, extraFlags = 0) {
|
|
67192
67194
|
return context && createInferenceContextWorker(map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
|
|
67193
67195
|
}
|
|
67194
|
-
function createInferenceContextWorker(inferences, signature, flags,
|
|
67196
|
+
function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
|
|
67195
67197
|
const context = {
|
|
67196
67198
|
inferences,
|
|
67197
67199
|
signature,
|
|
67198
67200
|
flags,
|
|
67199
|
-
compareTypes
|
|
67201
|
+
compareTypes,
|
|
67200
67202
|
mapper: reportUnmeasurableMapper,
|
|
67201
67203
|
// initialize to a noop mapper so the context object is available, but the underlying object shape is right upon construction
|
|
67202
67204
|
nonFixingMapper: reportUnmeasurableMapper
|
|
@@ -67283,8 +67285,8 @@ function createTypeChecker(host) {
|
|
|
67283
67285
|
if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
|
|
67284
67286
|
return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
|
|
67285
67287
|
}
|
|
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 &
|
|
67288
|
+
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 & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
|
|
67289
|
+
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
67288
67290
|
type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
67289
67291
|
}
|
|
67290
67292
|
return result;
|
|
@@ -67306,7 +67308,7 @@ function createTypeChecker(host) {
|
|
|
67306
67308
|
function createEmptyObjectTypeFromStringLiteral(type) {
|
|
67307
67309
|
const members = createSymbolTable();
|
|
67308
67310
|
forEachType(type, (t) => {
|
|
67309
|
-
if (!(t.flags &
|
|
67311
|
+
if (!(t.flags & 128 /* StringLiteral */)) {
|
|
67310
67312
|
return;
|
|
67311
67313
|
}
|
|
67312
67314
|
const name = escapeLeadingUnderscores(t.value);
|
|
@@ -67318,7 +67320,7 @@ function createTypeChecker(host) {
|
|
|
67318
67320
|
}
|
|
67319
67321
|
members.set(name, literalProp);
|
|
67320
67322
|
});
|
|
67321
|
-
const indexInfos = type.flags &
|
|
67323
|
+
const indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(
|
|
67322
67324
|
stringType,
|
|
67323
67325
|
emptyObjectType,
|
|
67324
67326
|
/*isReadonly*/
|
|
@@ -67420,7 +67422,7 @@ function createTypeChecker(host) {
|
|
|
67420
67422
|
yield targetProp;
|
|
67421
67423
|
} else if (matchDiscriminantProperties) {
|
|
67422
67424
|
const targetType = getTypeOfSymbol(targetProp);
|
|
67423
|
-
if (targetType.flags &
|
|
67425
|
+
if (targetType.flags & 109472 /* Unit */) {
|
|
67424
67426
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
67425
67427
|
if (!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) {
|
|
67426
67428
|
yield targetProp;
|
|
@@ -67483,7 +67485,7 @@ function createTypeChecker(host) {
|
|
|
67483
67485
|
if (target.flags & 1 /* Any */) {
|
|
67484
67486
|
return true;
|
|
67485
67487
|
}
|
|
67486
|
-
if (target.flags & (
|
|
67488
|
+
if (target.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
67487
67489
|
return isTypeAssignableTo(source, target);
|
|
67488
67490
|
}
|
|
67489
67491
|
if (target.flags & 268435456 /* StringMapping */) {
|
|
@@ -67501,20 +67503,20 @@ function createTypeChecker(host) {
|
|
|
67501
67503
|
if (target.flags & 2097152 /* Intersection */) {
|
|
67502
67504
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
67503
67505
|
}
|
|
67504
|
-
if (target.flags &
|
|
67506
|
+
if (target.flags & 4 /* String */ || isTypeAssignableTo(source, target)) {
|
|
67505
67507
|
return true;
|
|
67506
67508
|
}
|
|
67507
|
-
if (source.flags &
|
|
67509
|
+
if (source.flags & 128 /* StringLiteral */) {
|
|
67508
67510
|
const value = source.value;
|
|
67509
|
-
return !!(target.flags &
|
|
67511
|
+
return !!(target.flags & 8 /* Number */ && isValidNumberString(
|
|
67510
67512
|
value,
|
|
67511
67513
|
/*roundTripOnly*/
|
|
67512
67514
|
false
|
|
67513
|
-
) || target.flags &
|
|
67515
|
+
) || target.flags & 64 /* BigInt */ && isValidBigIntString(
|
|
67514
67516
|
value,
|
|
67515
67517
|
/*roundTripOnly*/
|
|
67516
67518
|
false
|
|
67517
|
-
) || target.flags & (
|
|
67519
|
+
) || target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(source, target) || target.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source, target));
|
|
67518
67520
|
}
|
|
67519
67521
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
67520
67522
|
const texts = source.texts;
|
|
@@ -67523,7 +67525,7 @@ function createTypeChecker(host) {
|
|
|
67523
67525
|
return false;
|
|
67524
67526
|
}
|
|
67525
67527
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
67526
|
-
return source.flags &
|
|
67528
|
+
return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arrayIsEqualTo(source.texts, target.texts) ? map(source.types, (s, i) => {
|
|
67527
67529
|
return isTypeAssignableTo(getBaseConstraintOrType(s), getBaseConstraintOrType(target.types[i])) ? s : getStringLikeTypeForType(s);
|
|
67528
67530
|
}) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
|
|
67529
67531
|
}
|
|
@@ -67532,7 +67534,7 @@ function createTypeChecker(host) {
|
|
|
67532
67534
|
return !!inferences && every(inferences, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]));
|
|
67533
67535
|
}
|
|
67534
67536
|
function getStringLikeTypeForType(type) {
|
|
67535
|
-
return type.flags & (1 /* Any */ |
|
|
67537
|
+
return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
|
|
67536
67538
|
}
|
|
67537
67539
|
function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) {
|
|
67538
67540
|
const lastSourceIndex = sourceTexts.length - 1;
|
|
@@ -67727,7 +67729,7 @@ function createTypeChecker(host) {
|
|
|
67727
67729
|
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
|
|
67728
67730
|
} else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
|
|
67729
67731
|
inferFromContravariantTypes(source.type, target.type);
|
|
67730
|
-
} else if ((isLiteralType(source) || source.flags &
|
|
67732
|
+
} else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) {
|
|
67731
67733
|
const empty = createEmptyObjectTypeFromStringLiteral(source);
|
|
67732
67734
|
inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
67733
67735
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
@@ -67982,29 +67984,29 @@ function createTypeChecker(host) {
|
|
|
67982
67984
|
for (let i = 0; i < types.length; i++) {
|
|
67983
67985
|
const source2 = matches ? matches[i] : neverType;
|
|
67984
67986
|
const target2 = types[i];
|
|
67985
|
-
if (source2.flags &
|
|
67987
|
+
if (source2.flags & 128 /* StringLiteral */ && target2.flags & 8650752 /* TypeVariable */) {
|
|
67986
67988
|
const inferenceContext = getInferenceInfoForType(target2);
|
|
67987
67989
|
const constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : void 0;
|
|
67988
67990
|
if (constraint && !isTypeAny(constraint)) {
|
|
67989
67991
|
const constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
|
|
67990
67992
|
let allTypeFlags = reduceLeft(constraintTypes, (flags, t) => flags | t.flags, 0);
|
|
67991
|
-
if (!(allTypeFlags &
|
|
67993
|
+
if (!(allTypeFlags & 4 /* String */)) {
|
|
67992
67994
|
const str = source2.value;
|
|
67993
|
-
if (allTypeFlags &
|
|
67995
|
+
if (allTypeFlags & 296 /* NumberLike */ && !isValidNumberString(
|
|
67994
67996
|
str,
|
|
67995
67997
|
/*roundTripOnly*/
|
|
67996
67998
|
true
|
|
67997
67999
|
)) {
|
|
67998
|
-
allTypeFlags &= ~
|
|
68000
|
+
allTypeFlags &= ~296 /* NumberLike */;
|
|
67999
68001
|
}
|
|
68000
|
-
if (allTypeFlags &
|
|
68002
|
+
if (allTypeFlags & 2112 /* BigIntLike */ && !isValidBigIntString(
|
|
68001
68003
|
str,
|
|
68002
68004
|
/*roundTripOnly*/
|
|
68003
68005
|
true
|
|
68004
68006
|
)) {
|
|
68005
|
-
allTypeFlags &= ~
|
|
68007
|
+
allTypeFlags &= ~2112 /* BigIntLike */;
|
|
68006
68008
|
}
|
|
68007
|
-
const matchingType = reduceLeft(constraintTypes, (left, right) => !(right.flags & allTypeFlags) ? left : left.flags &
|
|
68009
|
+
const matchingType = reduceLeft(constraintTypes, (left, right) => !(right.flags & allTypeFlags) ? left : left.flags & 4 /* String */ ? left : right.flags & 4 /* 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 & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str ? right : left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str) : left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str) : left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str ? right : left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str) : left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && pseudoBigIntToString(right.value) === str ? right : left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str === "true" ? trueType : str === "false" ? falseType : booleanType : left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str ? right : left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str ? right : left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str ? right : left, neverType);
|
|
68008
68010
|
if (!(matchingType.flags & 131072 /* Never */)) {
|
|
68009
68011
|
inferFromTypes(matchingType, target2);
|
|
68010
68012
|
continue;
|
|
@@ -68164,7 +68166,7 @@ function createTypeChecker(host) {
|
|
|
68164
68166
|
for (const targetInfo of indexInfos) {
|
|
68165
68167
|
const propTypes = [];
|
|
68166
68168
|
for (const prop of getPropertiesOfType(source)) {
|
|
68167
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
68169
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) {
|
|
68168
68170
|
const propType = getTypeOfSymbol(prop);
|
|
68169
68171
|
propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType);
|
|
68170
68172
|
}
|
|
@@ -68188,7 +68190,7 @@ function createTypeChecker(host) {
|
|
|
68188
68190
|
}
|
|
68189
68191
|
}
|
|
68190
68192
|
function isTypeOrBaseIdenticalTo(s, t) {
|
|
68191
|
-
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags &
|
|
68193
|
+
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */);
|
|
68192
68194
|
}
|
|
68193
68195
|
function isTypeCloselyMatchedBy(s, t) {
|
|
68194
68196
|
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 +68442,7 @@ function createTypeChecker(host) {
|
|
|
68440
68442
|
return void 0;
|
|
68441
68443
|
}
|
|
68442
68444
|
function tryGetNameFromType(type) {
|
|
68443
|
-
return type.flags &
|
|
68445
|
+
return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : type.flags & 384 /* StringOrNumberLiteral */ ? escapeLeadingUnderscores("" + type.value) : void 0;
|
|
68444
68446
|
}
|
|
68445
68447
|
function tryGetElementAccessExpressionName(node) {
|
|
68446
68448
|
return isStringOrNumericLiteralLike(node.argumentExpression) ? escapeLeadingUnderscores(node.argumentExpression.text) : isEntityNameExpression(node.argumentExpression) ? tryGetNameFromEntityNameExpression(node.argumentExpression) : void 0;
|
|
@@ -68619,7 +68621,7 @@ function createTypeChecker(host) {
|
|
|
68619
68621
|
}
|
|
68620
68622
|
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
68621
68623
|
const filteredType = filterType(declaredType, (t) => typeMaybeAssignableTo(assignedType, t));
|
|
68622
|
-
const reducedType = assignedType.flags &
|
|
68624
|
+
const reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
68623
68625
|
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
68624
68626
|
}
|
|
68625
68627
|
function isFunctionObjectType(type) {
|
|
@@ -68640,31 +68642,31 @@ function createTypeChecker(host) {
|
|
|
68640
68642
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
68641
68643
|
}
|
|
68642
68644
|
const flags = type.flags;
|
|
68643
|
-
if (flags & (
|
|
68645
|
+
if (flags & (4 /* String */ | 268435456 /* StringMapping */)) {
|
|
68644
68646
|
return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
|
|
68645
68647
|
}
|
|
68646
|
-
if (flags & (
|
|
68647
|
-
const isEmpty = flags &
|
|
68648
|
+
if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) {
|
|
68649
|
+
const isEmpty = flags & 128 /* StringLiteral */ && type.value === "";
|
|
68648
68650
|
return strictNullChecks ? isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
|
|
68649
68651
|
}
|
|
68650
|
-
if (flags & (
|
|
68652
|
+
if (flags & (8 /* Number */ | 32 /* Enum */)) {
|
|
68651
68653
|
return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */;
|
|
68652
68654
|
}
|
|
68653
|
-
if (flags &
|
|
68655
|
+
if (flags & 256 /* NumberLiteral */) {
|
|
68654
68656
|
const isZero = type.value === 0;
|
|
68655
68657
|
return strictNullChecks ? isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */;
|
|
68656
68658
|
}
|
|
68657
|
-
if (flags &
|
|
68659
|
+
if (flags & 64 /* BigInt */) {
|
|
68658
68660
|
return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */;
|
|
68659
68661
|
}
|
|
68660
|
-
if (flags &
|
|
68662
|
+
if (flags & 2048 /* BigIntLiteral */) {
|
|
68661
68663
|
const isZero = isZeroBigInt(type);
|
|
68662
68664
|
return strictNullChecks ? isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */;
|
|
68663
68665
|
}
|
|
68664
|
-
if (flags &
|
|
68666
|
+
if (flags & 16 /* Boolean */) {
|
|
68665
68667
|
return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */;
|
|
68666
68668
|
}
|
|
68667
|
-
if (flags &
|
|
68669
|
+
if (flags & 528 /* BooleanLike */) {
|
|
68668
68670
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
68669
68671
|
}
|
|
68670
68672
|
if (flags & 524288 /* Object */) {
|
|
@@ -68674,16 +68676,16 @@ function createTypeChecker(host) {
|
|
|
68674
68676
|
}
|
|
68675
68677
|
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
68678
|
}
|
|
68677
|
-
if (flags &
|
|
68679
|
+
if (flags & 16384 /* Void */) {
|
|
68678
68680
|
return 9830144 /* VoidFacts */;
|
|
68679
68681
|
}
|
|
68680
|
-
if (flags &
|
|
68682
|
+
if (flags & 32768 /* Undefined */) {
|
|
68681
68683
|
return 26607360 /* UndefinedFacts */;
|
|
68682
68684
|
}
|
|
68683
|
-
if (flags &
|
|
68685
|
+
if (flags & 65536 /* Null */) {
|
|
68684
68686
|
return 42917664 /* NullFacts */;
|
|
68685
68687
|
}
|
|
68686
|
-
if (flags &
|
|
68688
|
+
if (flags & 12288 /* ESSymbolLike */) {
|
|
68687
68689
|
return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
|
|
68688
68690
|
}
|
|
68689
68691
|
if (flags & 67108864 /* NonPrimitive */) {
|
|
@@ -68906,7 +68908,7 @@ function createTypeChecker(host) {
|
|
|
68906
68908
|
}
|
|
68907
68909
|
return true;
|
|
68908
68910
|
}
|
|
68909
|
-
if (source.flags &
|
|
68911
|
+
if (source.flags & 1056 /* EnumLike */ && getBaseTypeOfEnumLikeType(source) === target) {
|
|
68910
68912
|
return true;
|
|
68911
68913
|
}
|
|
68912
68914
|
return containsType(target.types, source);
|
|
@@ -68991,8 +68993,8 @@ function createTypeChecker(host) {
|
|
|
68991
68993
|
return filterType(type, (t) => (t.flags & kind) !== 0);
|
|
68992
68994
|
}
|
|
68993
68995
|
function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
|
|
68994
|
-
if (maybeTypeOfKind(typeWithPrimitives,
|
|
68995
|
-
return mapType(typeWithPrimitives, (t) => t.flags &
|
|
68996
|
+
if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) {
|
|
68997
|
+
return mapType(typeWithPrimitives, (t) => t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t);
|
|
68996
68998
|
}
|
|
68997
68999
|
return typeWithPrimitives;
|
|
68998
69000
|
}
|
|
@@ -69047,7 +69049,7 @@ function createTypeChecker(host) {
|
|
|
69047
69049
|
const root = getReferenceRoot(node);
|
|
69048
69050
|
const parent = root.parent;
|
|
69049
69051
|
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),
|
|
69052
|
+
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), 296 /* NumberLike */);
|
|
69051
69053
|
return isLengthPushOrUnshift || isElementAssignment;
|
|
69052
69054
|
}
|
|
69053
69055
|
function isDeclarationWithExplicitTypeAnnotation(node) {
|
|
@@ -69535,7 +69537,7 @@ function createTypeChecker(host) {
|
|
|
69535
69537
|
}
|
|
69536
69538
|
} else {
|
|
69537
69539
|
const indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
|
|
69538
|
-
if (isTypeAssignableToKind(indexType,
|
|
69540
|
+
if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) {
|
|
69539
69541
|
evolvedType2 = addEvolvingArrayElementType(evolvedType2, node.right);
|
|
69540
69542
|
}
|
|
69541
69543
|
}
|
|
@@ -69573,9 +69575,9 @@ function createTypeChecker(host) {
|
|
|
69573
69575
|
} else {
|
|
69574
69576
|
if (strictNullChecks) {
|
|
69575
69577
|
if (optionalChainContainsReference(expr, reference)) {
|
|
69576
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (
|
|
69578
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)));
|
|
69577
69579
|
} else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
|
|
69578
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags &
|
|
69580
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"));
|
|
69579
69581
|
}
|
|
69580
69582
|
}
|
|
69581
69583
|
const access = getDiscriminantPropertyAccess(expr, type);
|
|
@@ -69749,7 +69751,7 @@ function createTypeChecker(host) {
|
|
|
69749
69751
|
return type;
|
|
69750
69752
|
}
|
|
69751
69753
|
const optionalChain = isOptionalChain(access);
|
|
69752
|
-
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type,
|
|
69754
|
+
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type, 98304 /* Nullable */);
|
|
69753
69755
|
let propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName);
|
|
69754
69756
|
if (!propType) {
|
|
69755
69757
|
return type;
|
|
@@ -69971,7 +69973,7 @@ function createTypeChecker(host) {
|
|
|
69971
69973
|
}
|
|
69972
69974
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
69973
69975
|
const equalsOperator = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
69974
|
-
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ?
|
|
69976
|
+
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */;
|
|
69975
69977
|
const valueType = getTypeOfExpression(value);
|
|
69976
69978
|
const removeNullable = equalsOperator !== assumeTrue && everyType(valueType, (t) => !!(t.flags & nullableFlags)) || equalsOperator === assumeTrue && everyType(valueType, (t) => !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)));
|
|
69977
69979
|
return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
|
|
@@ -69985,11 +69987,11 @@ function createTypeChecker(host) {
|
|
|
69985
69987
|
}
|
|
69986
69988
|
const valueType = getTypeOfExpression(value);
|
|
69987
69989
|
const doubleEquals = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */;
|
|
69988
|
-
if (valueType.flags &
|
|
69990
|
+
if (valueType.flags & 98304 /* Nullable */) {
|
|
69989
69991
|
if (!strictNullChecks) {
|
|
69990
69992
|
return type;
|
|
69991
69993
|
}
|
|
69992
|
-
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags &
|
|
69994
|
+
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
|
|
69993
69995
|
return getAdjustedTypeWithFacts(type, facts);
|
|
69994
69996
|
}
|
|
69995
69997
|
if (assumeTrue) {
|
|
@@ -70064,7 +70066,7 @@ function createTypeChecker(host) {
|
|
|
70064
70066
|
if (!hasDefaultClause) {
|
|
70065
70067
|
return caseType;
|
|
70066
70068
|
}
|
|
70067
|
-
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags &
|
|
70069
|
+
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags & 32768 /* Undefined */ ? undefinedType : getRegularTypeOfLiteralType(extractUnitType(t)))));
|
|
70068
70070
|
return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
|
|
70069
70071
|
}
|
|
70070
70072
|
function narrowTypeByTypeName(type, typeName) {
|
|
@@ -70555,10 +70557,10 @@ function createTypeChecker(host) {
|
|
|
70555
70557
|
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
70558
|
}
|
|
70557
70559
|
function isGenericTypeWithUnionConstraint(type) {
|
|
70558
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (
|
|
70560
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
|
|
70559
70561
|
}
|
|
70560
70562
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
70561
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type),
|
|
70563
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
70562
70564
|
}
|
|
70563
70565
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
70564
70566
|
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 +71119,7 @@ function createTypeChecker(host) {
|
|
|
71117
71119
|
flowContainer = getControlFlowContainer(flowContainer);
|
|
71118
71120
|
}
|
|
71119
71121
|
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 */ |
|
|
71122
|
+
const assumeInitialized = isParameter2 || isAlias || isOuterVariable && !isNeverInitialized || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* 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
71123
|
const initialType = isAutomaticTypeInNonNull ? undefinedType : assumeInitialized ? isParameter2 ? removeOptionalityFromDeclaredType(type, declaration) : type : typeIsAutomatic ? undefinedType : getOptionalType(type);
|
|
71122
71124
|
const flowType = isAutomaticTypeInNonNull ? getNonNullableType(getFlowTypeOfReference(node, type, initialType, flowContainer)) : getFlowTypeOfReference(node, type, initialType, flowContainer);
|
|
71123
71125
|
if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
|
|
@@ -71805,7 +71807,7 @@ function createTypeChecker(host) {
|
|
|
71805
71807
|
const functionFlags = getFunctionFlags(functionDecl);
|
|
71806
71808
|
if (functionFlags & 1 /* Generator */) {
|
|
71807
71809
|
return filterType(returnType2, (t) => {
|
|
71808
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
71810
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || checkGeneratorInstantiationAssignabilityToReturnType(
|
|
71809
71811
|
t,
|
|
71810
71812
|
functionFlags,
|
|
71811
71813
|
/*errorNode*/
|
|
@@ -71815,7 +71817,7 @@ function createTypeChecker(host) {
|
|
|
71815
71817
|
}
|
|
71816
71818
|
if (functionFlags & 2 /* Async */) {
|
|
71817
71819
|
return filterType(returnType2, (t) => {
|
|
71818
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
71820
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || !!getAwaitedTypeOfPromise(t);
|
|
71819
71821
|
});
|
|
71820
71822
|
}
|
|
71821
71823
|
return returnType2;
|
|
@@ -72574,7 +72576,7 @@ function createTypeChecker(host) {
|
|
|
72574
72576
|
return getOrCreateTypeFromSignature(fakeSignature);
|
|
72575
72577
|
}
|
|
72576
72578
|
const tagType = checkExpressionCached(context.tagName);
|
|
72577
|
-
if (tagType.flags &
|
|
72579
|
+
if (tagType.flags & 128 /* StringLiteral */) {
|
|
72578
72580
|
const result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
|
|
72579
72581
|
if (!result) {
|
|
72580
72582
|
return errorType;
|
|
@@ -72946,7 +72948,7 @@ function createTypeChecker(host) {
|
|
|
72946
72948
|
}
|
|
72947
72949
|
}
|
|
72948
72950
|
function isNumericComputedName(name) {
|
|
72949
|
-
return isTypeAssignableToKind(checkComputedPropertyName(name),
|
|
72951
|
+
return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */);
|
|
72950
72952
|
}
|
|
72951
72953
|
function checkComputedPropertyName(node) {
|
|
72952
72954
|
const links = getNodeLinks(node.expression);
|
|
@@ -72964,7 +72966,7 @@ function createTypeChecker(host) {
|
|
|
72964
72966
|
getNodeLinks(node.parent.parent).flags |= 32768 /* BlockScopedBindingInLoop */;
|
|
72965
72967
|
}
|
|
72966
72968
|
}
|
|
72967
|
-
if (links.resolvedType.flags &
|
|
72969
|
+
if (links.resolvedType.flags & 98304 /* Nullable */ || !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
|
|
72968
72970
|
error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
|
|
72969
72971
|
}
|
|
72970
72972
|
}
|
|
@@ -72978,7 +72980,7 @@ function createTypeChecker(host) {
|
|
|
72978
72980
|
function isSymbolWithSymbolName(symbol) {
|
|
72979
72981
|
var _a;
|
|
72980
72982
|
const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
|
|
72981
|
-
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name),
|
|
72983
|
+
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */);
|
|
72982
72984
|
}
|
|
72983
72985
|
function isSymbolWithComputedName(symbol) {
|
|
72984
72986
|
var _a;
|
|
@@ -73134,7 +73136,7 @@ function createTypeChecker(host) {
|
|
|
73134
73136
|
Debug.assert(memberDecl.kind === 177 /* GetAccessor */ || memberDecl.kind === 178 /* SetAccessor */);
|
|
73135
73137
|
checkNodeDeferred(memberDecl);
|
|
73136
73138
|
}
|
|
73137
|
-
if (computedNameType && !(computedNameType.flags &
|
|
73139
|
+
if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) {
|
|
73138
73140
|
if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
|
|
73139
73141
|
if (isTypeAssignableTo(computedNameType, numberType)) {
|
|
73140
73142
|
hasComputedNumberProperty = true;
|
|
@@ -73547,9 +73549,9 @@ function createTypeChecker(host) {
|
|
|
73547
73549
|
return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
|
|
73548
73550
|
}
|
|
73549
73551
|
function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
|
|
73550
|
-
if (elementType.flags &
|
|
73552
|
+
if (elementType.flags & 4 /* String */) {
|
|
73551
73553
|
return [anySignature];
|
|
73552
|
-
} else if (elementType.flags &
|
|
73554
|
+
} else if (elementType.flags & 128 /* StringLiteral */) {
|
|
73553
73555
|
const intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
|
|
73554
73556
|
if (!intrinsicType) {
|
|
73555
73557
|
error(caller, Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
|
|
@@ -73931,7 +73933,7 @@ function createTypeChecker(host) {
|
|
|
73931
73933
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
73932
73934
|
reportError(node, facts);
|
|
73933
73935
|
const t = getNonNullableType(type);
|
|
73934
|
-
return t.flags & (
|
|
73936
|
+
return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t;
|
|
73935
73937
|
}
|
|
73936
73938
|
return type;
|
|
73937
73939
|
}
|
|
@@ -73940,7 +73942,7 @@ function createTypeChecker(host) {
|
|
|
73940
73942
|
}
|
|
73941
73943
|
function checkNonNullNonVoidType(type, node) {
|
|
73942
73944
|
const nonNullType = checkNonNullType(type, node);
|
|
73943
|
-
if (nonNullType.flags &
|
|
73945
|
+
if (nonNullType.flags & 16384 /* Void */) {
|
|
73944
73946
|
if (isEntityNameExpression(node)) {
|
|
73945
73947
|
const nodeText = entityNameToString(node);
|
|
73946
73948
|
if (isIdentifier(node) && nodeText === "undefined") {
|
|
@@ -74435,15 +74437,13 @@ function createTypeChecker(host) {
|
|
|
74435
74437
|
function getSuggestionForSymbolNameLookup(symbols, name, meaning) {
|
|
74436
74438
|
const symbol = getSymbol(symbols, name, meaning);
|
|
74437
74439
|
if (symbol) return symbol;
|
|
74438
|
-
let candidates;
|
|
74440
|
+
let candidates = arrayFrom(symbols.values()).sort(compareSymbols);
|
|
74439
74441
|
if (symbols === globals) {
|
|
74440
74442
|
const primitives = mapDefined(
|
|
74441
74443
|
["string", "number", "boolean", "object", "bigint", "symbol"],
|
|
74442
74444
|
(s) => symbols.has(s.charAt(0).toUpperCase() + s.slice(1)) ? createSymbol(524288 /* TypeAlias */, s) : void 0
|
|
74443
74445
|
);
|
|
74444
|
-
candidates = primitives
|
|
74445
|
-
} else {
|
|
74446
|
-
candidates = arrayFrom(symbols.values());
|
|
74446
|
+
candidates = concatenate(candidates, primitives);
|
|
74447
74447
|
}
|
|
74448
74448
|
return getSpellingSuggestionForName(unescapeLeadingUnderscores(name), candidates, meaning);
|
|
74449
74449
|
}
|
|
@@ -74463,7 +74463,7 @@ function createTypeChecker(host) {
|
|
|
74463
74463
|
return result;
|
|
74464
74464
|
}
|
|
74465
74465
|
function getSuggestedSymbolForNonexistentModule(name, targetModule) {
|
|
74466
|
-
return targetModule.exports && getSpellingSuggestionForName(idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */);
|
|
74466
|
+
return targetModule.exports && getSpellingSuggestionForName(idText(name), getExportsOfModuleAsArray(targetModule).sort(compareSymbols), 2623475 /* ModuleMember */);
|
|
74467
74467
|
}
|
|
74468
74468
|
function getSuggestionForNonexistentIndexSignature(objectType, expr, keyedType) {
|
|
74469
74469
|
function hasProp(name) {
|
|
@@ -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 & 128 /* 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 & 16384 /* Void */);
|
|
74723
74723
|
}
|
|
74724
74724
|
function acceptsVoidUndefinedUnknownOrAny(t) {
|
|
74725
|
-
return !!(t.flags & (
|
|
74725
|
+
return !!(t.flags & (16384 /* Void */ | 32768 /* 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, compareTypes) {
|
|
74825
|
+
const context = createInferenceContext(getTypeParametersForMapper(signature), signature, 0 /* None */, compareTypes);
|
|
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 & 12288 /* 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 & 16384 /* 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 & 32768 /* Undefined */ || specifierType.flags & 65536 /* 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, 32768 /* 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 & 32768 /* 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 & 16 /* 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 & 16 /* 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, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* 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, 12288 /* 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, 2112 /* 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, 2112 /* BigIntLike */)) {
|
|
78408
|
+
return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* 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 */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) {
|
|
78438
78438
|
return false;
|
|
78439
78439
|
}
|
|
78440
|
-
return !!(kind &
|
|
78440
|
+
return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || !!(kind & 4096 /* 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 & 98304 /* 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 & 528 /* BooleanLike */ && rightType.flags & 528 /* 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, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* 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, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* 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
|
+
296 /* NumberLike */,
|
|
79044
79044
|
/*strict*/
|
|
79045
79045
|
true
|
|
79046
79046
|
) && isTypeAssignableToKind(
|
|
79047
79047
|
rightType,
|
|
79048
|
-
|
|
79048
|
+
296 /* NumberLike */,
|
|
79049
79049
|
/*strict*/
|
|
79050
79050
|
true
|
|
79051
79051
|
)) {
|
|
79052
79052
|
resultType = numberType;
|
|
79053
79053
|
} else if (isTypeAssignableToKind(
|
|
79054
79054
|
leftType,
|
|
79055
|
-
|
|
79055
|
+
2112 /* BigIntLike */,
|
|
79056
79056
|
/*strict*/
|
|
79057
79057
|
true
|
|
79058
79058
|
) && isTypeAssignableToKind(
|
|
79059
79059
|
rightType,
|
|
79060
|
-
|
|
79060
|
+
2112 /* BigIntLike */,
|
|
79061
79061
|
/*strict*/
|
|
79062
79062
|
true
|
|
79063
79063
|
)) {
|
|
79064
79064
|
resultType = bigintType;
|
|
79065
79065
|
} else if (isTypeAssignableToKind(
|
|
79066
79066
|
leftType,
|
|
79067
|
-
|
|
79067
|
+
402653316 /* StringLike */,
|
|
79068
79068
|
/*strict*/
|
|
79069
79069
|
true
|
|
79070
79070
|
) || isTypeAssignableToKind(
|
|
79071
79071
|
rightType,
|
|
79072
|
-
|
|
79072
|
+
402653316 /* 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 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* 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, 2112 /* BigIntLike */) && isTypeAssignableToKind(right2, 2112 /* 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, 12288 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* 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, 32768 /* 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, 12288 /* 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 & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* 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, 2944 /* 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, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint);
|
|
79625
79625
|
}
|
|
79626
|
-
return !!(contextualType.flags & (
|
|
79626
|
+
return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* 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 & 1024 /* 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 & 16384 /* 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 & 402653316 /* 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 & 402653316 /* 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 & 402653316 /* 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 & 67359327 /* Intrinsic */ && returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* 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, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* 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
|
+
8576 /* 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, 32768 /* 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, 12288 /* 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, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) {
|
|
87085
87085
|
return 2 /* VoidNullableOrNeverType */;
|
|
87086
|
-
} else if (isTypeAssignableToKind(type,
|
|
87086
|
+
} else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) {
|
|
87087
87087
|
return 6 /* BooleanType */;
|
|
87088
|
-
} else if (isTypeAssignableToKind(type,
|
|
87088
|
+
} else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) {
|
|
87089
87089
|
return 3 /* NumberLikeType */;
|
|
87090
|
-
} else if (isTypeAssignableToKind(type,
|
|
87090
|
+
} else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) {
|
|
87091
87091
|
return 4 /* BigIntLikeType */;
|
|
87092
|
-
} else if (isTypeAssignableToKind(type,
|
|
87092
|
+
} else if (isTypeAssignableToKind(type, 402653316 /* 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, 12288 /* 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 & 1056 /* 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 & 8576 /* 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 & 1056 /* EnumLike */);
|
|
88790
88790
|
}
|
|
88791
88791
|
}
|
|
88792
88792
|
function checkAmbientInitializer(node) {
|
|
@@ -89303,292 +89303,6 @@ function createTypeChecker(host) {
|
|
|
89303
89303
|
}
|
|
89304
89304
|
return n1.pos - n2.pos;
|
|
89305
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
|
-
}
|
|
89592
89306
|
}
|
|
89593
89307
|
function isNotAccessor(declaration) {
|
|
89594
89308
|
return !isAccessor(declaration);
|