@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/typescript.js
CHANGED
|
@@ -2286,7 +2286,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2286
2286
|
|
|
2287
2287
|
// src/compiler/corePublic.ts
|
|
2288
2288
|
var versionMajorMinor = "5.9";
|
|
2289
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2289
|
+
var version = `${versionMajorMinor}.0-insiders.20250314`;
|
|
2290
2290
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2291
2291
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2292
2292
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -2981,7 +2981,7 @@ function binarySearchKey(array, key, keySelector, keyComparer, offset) {
|
|
|
2981
2981
|
while (low <= high) {
|
|
2982
2982
|
const middle = low + (high - low >> 1);
|
|
2983
2983
|
const midKey = keySelector(array[middle], middle);
|
|
2984
|
-
switch (
|
|
2984
|
+
switch (keyComparer(midKey, key)) {
|
|
2985
2985
|
case -1 /* LessThan */:
|
|
2986
2986
|
low = middle + 1;
|
|
2987
2987
|
break;
|
|
@@ -4306,8 +4306,8 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
4306
4306
|
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
|
|
4307
4307
|
__tsDebuggerDisplay: {
|
|
4308
4308
|
value() {
|
|
4309
|
-
const typeHeader = this.flags &
|
|
4310
|
-
const remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~
|
|
4309
|
+
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";
|
|
4310
|
+
const remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0;
|
|
4311
4311
|
return `${typeHeader}${this.symbol ? ` '${symbolName(this.symbol)}'` : ""}${remainingObjectFlags ? ` (${formatObjectFlags(remainingObjectFlags)})` : ""}`;
|
|
4312
4312
|
}
|
|
4313
4313
|
},
|
|
@@ -5409,7 +5409,7 @@ var tracingEnabled;
|
|
|
5409
5409
|
const objectFlags = type.objectFlags;
|
|
5410
5410
|
const symbol = type.aliasSymbol ?? type.symbol;
|
|
5411
5411
|
let display;
|
|
5412
|
-
if (objectFlags & 16 /* Anonymous */ | type.flags &
|
|
5412
|
+
if (objectFlags & 16 /* Anonymous */ | type.flags & 2944 /* Literal */) {
|
|
5413
5413
|
try {
|
|
5414
5414
|
display = (_a = type.checker) == null ? void 0 : _a.typeToString(type);
|
|
5415
5415
|
} catch {
|
|
@@ -6429,21 +6429,21 @@ var NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags3) => {
|
|
|
6429
6429
|
var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
6430
6430
|
TypeFlags2[TypeFlags2["Any"] = 1] = "Any";
|
|
6431
6431
|
TypeFlags2[TypeFlags2["Unknown"] = 2] = "Unknown";
|
|
6432
|
-
TypeFlags2[TypeFlags2["
|
|
6433
|
-
TypeFlags2[TypeFlags2["
|
|
6434
|
-
TypeFlags2[TypeFlags2["
|
|
6435
|
-
TypeFlags2[TypeFlags2["
|
|
6436
|
-
TypeFlags2[TypeFlags2["
|
|
6437
|
-
TypeFlags2[TypeFlags2["
|
|
6438
|
-
TypeFlags2[TypeFlags2["
|
|
6439
|
-
TypeFlags2[TypeFlags2["
|
|
6440
|
-
TypeFlags2[TypeFlags2["
|
|
6441
|
-
TypeFlags2[TypeFlags2["
|
|
6442
|
-
TypeFlags2[TypeFlags2["
|
|
6443
|
-
TypeFlags2[TypeFlags2["
|
|
6444
|
-
TypeFlags2[TypeFlags2["
|
|
6445
|
-
TypeFlags2[TypeFlags2["
|
|
6446
|
-
TypeFlags2[TypeFlags2["
|
|
6432
|
+
TypeFlags2[TypeFlags2["String"] = 4] = "String";
|
|
6433
|
+
TypeFlags2[TypeFlags2["Number"] = 8] = "Number";
|
|
6434
|
+
TypeFlags2[TypeFlags2["Boolean"] = 16] = "Boolean";
|
|
6435
|
+
TypeFlags2[TypeFlags2["Enum"] = 32] = "Enum";
|
|
6436
|
+
TypeFlags2[TypeFlags2["BigInt"] = 64] = "BigInt";
|
|
6437
|
+
TypeFlags2[TypeFlags2["StringLiteral"] = 128] = "StringLiteral";
|
|
6438
|
+
TypeFlags2[TypeFlags2["NumberLiteral"] = 256] = "NumberLiteral";
|
|
6439
|
+
TypeFlags2[TypeFlags2["BooleanLiteral"] = 512] = "BooleanLiteral";
|
|
6440
|
+
TypeFlags2[TypeFlags2["EnumLiteral"] = 1024] = "EnumLiteral";
|
|
6441
|
+
TypeFlags2[TypeFlags2["BigIntLiteral"] = 2048] = "BigIntLiteral";
|
|
6442
|
+
TypeFlags2[TypeFlags2["ESSymbol"] = 4096] = "ESSymbol";
|
|
6443
|
+
TypeFlags2[TypeFlags2["UniqueESSymbol"] = 8192] = "UniqueESSymbol";
|
|
6444
|
+
TypeFlags2[TypeFlags2["Void"] = 16384] = "Void";
|
|
6445
|
+
TypeFlags2[TypeFlags2["Undefined"] = 32768] = "Undefined";
|
|
6446
|
+
TypeFlags2[TypeFlags2["Null"] = 65536] = "Null";
|
|
6447
6447
|
TypeFlags2[TypeFlags2["Never"] = 131072] = "Never";
|
|
6448
6448
|
TypeFlags2[TypeFlags2["TypeParameter"] = 262144] = "TypeParameter";
|
|
6449
6449
|
TypeFlags2[TypeFlags2["Object"] = 524288] = "Object";
|
|
@@ -6459,25 +6459,25 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6459
6459
|
TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1";
|
|
6460
6460
|
TypeFlags2[TypeFlags2["Reserved2"] = 1073741824] = "Reserved2";
|
|
6461
6461
|
TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown";
|
|
6462
|
-
TypeFlags2[TypeFlags2["Nullable"] =
|
|
6463
|
-
TypeFlags2[TypeFlags2["Literal"] =
|
|
6464
|
-
TypeFlags2[TypeFlags2["Unit"] =
|
|
6465
|
-
TypeFlags2[TypeFlags2["Freshable"] =
|
|
6466
|
-
TypeFlags2[TypeFlags2["StringOrNumberLiteral"] =
|
|
6467
|
-
TypeFlags2[TypeFlags2["StringOrNumberLiteralOrUnique"] =
|
|
6468
|
-
TypeFlags2[TypeFlags2["DefinitelyFalsy"] =
|
|
6469
|
-
TypeFlags2[TypeFlags2["PossiblyFalsy"] =
|
|
6470
|
-
TypeFlags2[TypeFlags2["Intrinsic"] =
|
|
6471
|
-
TypeFlags2[TypeFlags2["StringLike"] =
|
|
6472
|
-
TypeFlags2[TypeFlags2["NumberLike"] =
|
|
6473
|
-
TypeFlags2[TypeFlags2["BigIntLike"] =
|
|
6474
|
-
TypeFlags2[TypeFlags2["BooleanLike"] =
|
|
6475
|
-
TypeFlags2[TypeFlags2["EnumLike"] =
|
|
6476
|
-
TypeFlags2[TypeFlags2["ESSymbolLike"] =
|
|
6477
|
-
TypeFlags2[TypeFlags2["VoidLike"] =
|
|
6462
|
+
TypeFlags2[TypeFlags2["Nullable"] = 98304] = "Nullable";
|
|
6463
|
+
TypeFlags2[TypeFlags2["Literal"] = 2944] = "Literal";
|
|
6464
|
+
TypeFlags2[TypeFlags2["Unit"] = 109472] = "Unit";
|
|
6465
|
+
TypeFlags2[TypeFlags2["Freshable"] = 2976] = "Freshable";
|
|
6466
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral";
|
|
6467
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique";
|
|
6468
|
+
TypeFlags2[TypeFlags2["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy";
|
|
6469
|
+
TypeFlags2[TypeFlags2["PossiblyFalsy"] = 117724] = "PossiblyFalsy";
|
|
6470
|
+
TypeFlags2[TypeFlags2["Intrinsic"] = 67359327] = "Intrinsic";
|
|
6471
|
+
TypeFlags2[TypeFlags2["StringLike"] = 402653316] = "StringLike";
|
|
6472
|
+
TypeFlags2[TypeFlags2["NumberLike"] = 296] = "NumberLike";
|
|
6473
|
+
TypeFlags2[TypeFlags2["BigIntLike"] = 2112] = "BigIntLike";
|
|
6474
|
+
TypeFlags2[TypeFlags2["BooleanLike"] = 528] = "BooleanLike";
|
|
6475
|
+
TypeFlags2[TypeFlags2["EnumLike"] = 1056] = "EnumLike";
|
|
6476
|
+
TypeFlags2[TypeFlags2["ESSymbolLike"] = 12288] = "ESSymbolLike";
|
|
6477
|
+
TypeFlags2[TypeFlags2["VoidLike"] = 49152] = "VoidLike";
|
|
6478
6478
|
TypeFlags2[TypeFlags2["Primitive"] = 402784252] = "Primitive";
|
|
6479
|
-
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] =
|
|
6480
|
-
TypeFlags2[TypeFlags2["DisjointDomains"] =
|
|
6479
|
+
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
|
|
6480
|
+
TypeFlags2[TypeFlags2["DisjointDomains"] = 469892092] = "DisjointDomains";
|
|
6481
6481
|
TypeFlags2[TypeFlags2["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
6482
6482
|
TypeFlags2[TypeFlags2["StructuredType"] = 3670016] = "StructuredType";
|
|
6483
6483
|
TypeFlags2[TypeFlags2["TypeVariable"] = 8650752] = "TypeVariable";
|
|
@@ -6485,10 +6485,10 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6485
6485
|
TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
|
|
6486
6486
|
TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
|
|
6487
6487
|
TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
|
|
6488
|
-
TypeFlags2[TypeFlags2["ObjectFlagsType"] =
|
|
6488
|
+
TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
|
|
6489
6489
|
TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
|
|
6490
|
-
TypeFlags2[TypeFlags2["Singleton"] =
|
|
6491
|
-
TypeFlags2[TypeFlags2["Narrowable"] =
|
|
6490
|
+
TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
|
|
6491
|
+
TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
|
|
6492
6492
|
TypeFlags2[TypeFlags2["IncludesMask"] = 473694207] = "IncludesMask";
|
|
6493
6493
|
TypeFlags2[TypeFlags2["IncludesMissingType"] = 262144 /* TypeParameter */] = "IncludesMissingType";
|
|
6494
6494
|
TypeFlags2[TypeFlags2["IncludesNonWideningType"] = 4194304 /* Index */] = "IncludesNonWideningType";
|
|
@@ -6497,7 +6497,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6497
6497
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
6498
6498
|
TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable";
|
|
6499
6499
|
TypeFlags2[TypeFlags2["IncludesError"] = 1073741824 /* Reserved2 */] = "IncludesError";
|
|
6500
|
-
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] =
|
|
6500
|
+
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
6501
6501
|
return TypeFlags2;
|
|
6502
6502
|
})(TypeFlags || {});
|
|
6503
6503
|
var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
@@ -6527,11 +6527,11 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6527
6527
|
ObjectFlags3[ObjectFlags3["RequiresWidening"] = 196608] = "RequiresWidening";
|
|
6528
6528
|
ObjectFlags3[ObjectFlags3["PropagatingFlags"] = 458752] = "PropagatingFlags";
|
|
6529
6529
|
ObjectFlags3[ObjectFlags3["InstantiatedMapped"] = 96] = "InstantiatedMapped";
|
|
6530
|
+
ObjectFlags3[ObjectFlags3["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask";
|
|
6530
6531
|
ObjectFlags3[ObjectFlags3["ContainsSpread"] = 2097152] = "ContainsSpread";
|
|
6531
6532
|
ObjectFlags3[ObjectFlags3["ObjectRestType"] = 4194304] = "ObjectRestType";
|
|
6532
6533
|
ObjectFlags3[ObjectFlags3["InstantiationExpressionType"] = 8388608] = "InstantiationExpressionType";
|
|
6533
6534
|
ObjectFlags3[ObjectFlags3["SingleSignatureType"] = 134217728] = "SingleSignatureType";
|
|
6534
|
-
ObjectFlags3[ObjectFlags3["ObjectTypeKindMask"] = 142607679] = "ObjectTypeKindMask";
|
|
6535
6535
|
ObjectFlags3[ObjectFlags3["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone";
|
|
6536
6536
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated";
|
|
6537
6537
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists";
|
|
@@ -21355,7 +21355,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
|
|
|
21355
21355
|
return (_a = symbol.declarations) == null ? void 0 : _a.find(isClassLike);
|
|
21356
21356
|
}
|
|
21357
21357
|
function getObjectFlags(type) {
|
|
21358
|
-
return type.flags &
|
|
21358
|
+
return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
|
|
21359
21359
|
}
|
|
21360
21360
|
function isUMDExportSymbol(symbol) {
|
|
21361
21361
|
return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
|
|
@@ -23246,13 +23246,13 @@ function intrinsicTagNameToString(node) {
|
|
|
23246
23246
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
23247
23247
|
}
|
|
23248
23248
|
function isTypeUsableAsPropertyName(type) {
|
|
23249
|
-
return !!(type.flags &
|
|
23249
|
+
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
23250
23250
|
}
|
|
23251
23251
|
function getPropertyNameFromType(type) {
|
|
23252
|
-
if (type.flags &
|
|
23252
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
23253
23253
|
return type.escapedName;
|
|
23254
23254
|
}
|
|
23255
|
-
if (type.flags & (
|
|
23255
|
+
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
23256
23256
|
return escapeLeadingUnderscores("" + type.value);
|
|
23257
23257
|
}
|
|
23258
23258
|
return Debug.fail();
|
|
@@ -51356,10 +51356,10 @@ function createTypeChecker(host) {
|
|
|
51356
51356
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */, "non-inferrable");
|
|
51357
51357
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
51358
51358
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
51359
|
-
var undefinedType = createIntrinsicType(
|
|
51360
|
-
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(
|
|
51359
|
+
var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined");
|
|
51360
|
+
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */, "widening");
|
|
51361
51361
|
var missingType = createIntrinsicType(
|
|
51362
|
-
|
|
51362
|
+
32768 /* Undefined */,
|
|
51363
51363
|
"undefined",
|
|
51364
51364
|
/*objectFlags*/
|
|
51365
51365
|
void 0,
|
|
@@ -51367,33 +51367,33 @@ function createTypeChecker(host) {
|
|
|
51367
51367
|
);
|
|
51368
51368
|
var undefinedOrMissingType = exactOptionalPropertyTypes ? missingType : undefinedType;
|
|
51369
51369
|
var optionalType = createIntrinsicType(
|
|
51370
|
-
|
|
51370
|
+
32768 /* Undefined */,
|
|
51371
51371
|
"undefined",
|
|
51372
51372
|
/*objectFlags*/
|
|
51373
51373
|
void 0,
|
|
51374
51374
|
"optional"
|
|
51375
51375
|
);
|
|
51376
|
-
var nullType = createIntrinsicType(
|
|
51377
|
-
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(
|
|
51378
|
-
var stringType = createIntrinsicType(
|
|
51379
|
-
var numberType = createIntrinsicType(
|
|
51380
|
-
var bigintType = createIntrinsicType(
|
|
51376
|
+
var nullType = createIntrinsicType(65536 /* Null */, "null");
|
|
51377
|
+
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */, "widening");
|
|
51378
|
+
var stringType = createIntrinsicType(4 /* String */, "string");
|
|
51379
|
+
var numberType = createIntrinsicType(8 /* Number */, "number");
|
|
51380
|
+
var bigintType = createIntrinsicType(64 /* BigInt */, "bigint");
|
|
51381
51381
|
var falseType = createIntrinsicType(
|
|
51382
|
-
|
|
51382
|
+
512 /* BooleanLiteral */,
|
|
51383
51383
|
"false",
|
|
51384
51384
|
/*objectFlags*/
|
|
51385
51385
|
void 0,
|
|
51386
51386
|
"fresh"
|
|
51387
51387
|
);
|
|
51388
|
-
var regularFalseType = createIntrinsicType(
|
|
51388
|
+
var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false");
|
|
51389
51389
|
var trueType = createIntrinsicType(
|
|
51390
|
-
|
|
51390
|
+
512 /* BooleanLiteral */,
|
|
51391
51391
|
"true",
|
|
51392
51392
|
/*objectFlags*/
|
|
51393
51393
|
void 0,
|
|
51394
51394
|
"fresh"
|
|
51395
51395
|
);
|
|
51396
|
-
var regularTrueType = createIntrinsicType(
|
|
51396
|
+
var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true");
|
|
51397
51397
|
trueType.regularType = regularTrueType;
|
|
51398
51398
|
trueType.freshType = trueType;
|
|
51399
51399
|
regularTrueType.regularType = regularTrueType;
|
|
@@ -51403,8 +51403,8 @@ function createTypeChecker(host) {
|
|
|
51403
51403
|
regularFalseType.regularType = regularFalseType;
|
|
51404
51404
|
regularFalseType.freshType = falseType;
|
|
51405
51405
|
var booleanType = getUnionType([regularFalseType, regularTrueType]);
|
|
51406
|
-
var esSymbolType = createIntrinsicType(
|
|
51407
|
-
var voidType = createIntrinsicType(
|
|
51406
|
+
var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol");
|
|
51407
|
+
var voidType = createIntrinsicType(16384 /* Void */, "void");
|
|
51408
51408
|
var neverType = createIntrinsicType(131072 /* Never */, "never");
|
|
51409
51409
|
var silentNeverType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */, "silent");
|
|
51410
51410
|
var implicitNeverType = createIntrinsicType(
|
|
@@ -52691,7 +52691,7 @@ function createTypeChecker(host) {
|
|
|
52691
52691
|
const type = getDeclaredTypeOfSymbol(symbol);
|
|
52692
52692
|
return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(
|
|
52693
52693
|
type,
|
|
52694
|
-
|
|
52694
|
+
384 /* StringOrNumberLiteral */,
|
|
52695
52695
|
/*strict*/
|
|
52696
52696
|
true
|
|
52697
52697
|
);
|
|
@@ -54398,7 +54398,7 @@ function createTypeChecker(host) {
|
|
|
54398
54398
|
return type;
|
|
54399
54399
|
}
|
|
54400
54400
|
function createTypeofType() {
|
|
54401
|
-
return getUnionType(
|
|
54401
|
+
return getUnionType(arrayFrom(typeofNEFacts.keys(), getStringLiteralType));
|
|
54402
54402
|
}
|
|
54403
54403
|
function createTypeParameter(symbol) {
|
|
54404
54404
|
return createTypeWithSymbol(262144 /* TypeParameter */, symbol);
|
|
@@ -54413,6 +54413,7 @@ function createTypeChecker(host) {
|
|
|
54413
54413
|
(result || (result = [])).push(symbol);
|
|
54414
54414
|
}
|
|
54415
54415
|
});
|
|
54416
|
+
result == null ? void 0 : result.sort(compareSymbols);
|
|
54416
54417
|
return result || emptyArray;
|
|
54417
54418
|
}
|
|
54418
54419
|
function isNamedMember(member, escapedName) {
|
|
@@ -55219,7 +55220,7 @@ function createTypeChecker(host) {
|
|
|
55219
55220
|
if (name && isComputedPropertyName(name)) return name;
|
|
55220
55221
|
}
|
|
55221
55222
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
55222
|
-
if (nameType && nameType.flags & (
|
|
55223
|
+
if (nameType && nameType.flags & (1024 /* EnumLiteral */ | 8192 /* UniqueESSymbol */)) {
|
|
55223
55224
|
context.enclosingDeclaration = nameType.symbol.valueDeclaration;
|
|
55224
55225
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, meaning));
|
|
55225
55226
|
}
|
|
@@ -55327,23 +55328,23 @@ function createTypeChecker(host) {
|
|
|
55327
55328
|
if (type.flags & 2 /* Unknown */) {
|
|
55328
55329
|
return factory.createKeywordTypeNode(159 /* UnknownKeyword */);
|
|
55329
55330
|
}
|
|
55330
|
-
if (type.flags &
|
|
55331
|
+
if (type.flags & 4 /* String */) {
|
|
55331
55332
|
context.approximateLength += 6;
|
|
55332
55333
|
return factory.createKeywordTypeNode(154 /* StringKeyword */);
|
|
55333
55334
|
}
|
|
55334
|
-
if (type.flags &
|
|
55335
|
+
if (type.flags & 8 /* Number */) {
|
|
55335
55336
|
context.approximateLength += 6;
|
|
55336
55337
|
return factory.createKeywordTypeNode(150 /* NumberKeyword */);
|
|
55337
55338
|
}
|
|
55338
|
-
if (type.flags &
|
|
55339
|
+
if (type.flags & 64 /* BigInt */) {
|
|
55339
55340
|
context.approximateLength += 6;
|
|
55340
55341
|
return factory.createKeywordTypeNode(163 /* BigIntKeyword */);
|
|
55341
55342
|
}
|
|
55342
|
-
if (type.flags &
|
|
55343
|
+
if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) {
|
|
55343
55344
|
context.approximateLength += 7;
|
|
55344
55345
|
return factory.createKeywordTypeNode(136 /* BooleanKeyword */);
|
|
55345
55346
|
}
|
|
55346
|
-
if (type.flags &
|
|
55347
|
+
if (type.flags & 1056 /* EnumLike */) {
|
|
55347
55348
|
if (type.symbol.flags & 8 /* EnumMember */) {
|
|
55348
55349
|
const parentSymbol = getParentOfSymbol(type.symbol);
|
|
55349
55350
|
const parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */);
|
|
@@ -55372,24 +55373,24 @@ function createTypeChecker(host) {
|
|
|
55372
55373
|
}
|
|
55373
55374
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
55374
55375
|
}
|
|
55375
|
-
if (type.flags &
|
|
55376
|
+
if (type.flags & 128 /* StringLiteral */) {
|
|
55376
55377
|
context.approximateLength += type.value.length + 2;
|
|
55377
55378
|
return factory.createLiteralTypeNode(setEmitFlags(factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */));
|
|
55378
55379
|
}
|
|
55379
|
-
if (type.flags &
|
|
55380
|
+
if (type.flags & 256 /* NumberLiteral */) {
|
|
55380
55381
|
const value = type.value;
|
|
55381
55382
|
context.approximateLength += ("" + value).length;
|
|
55382
55383
|
return factory.createLiteralTypeNode(value < 0 ? factory.createPrefixUnaryExpression(41 /* MinusToken */, factory.createNumericLiteral(-value)) : factory.createNumericLiteral(value));
|
|
55383
55384
|
}
|
|
55384
|
-
if (type.flags &
|
|
55385
|
+
if (type.flags & 2048 /* BigIntLiteral */) {
|
|
55385
55386
|
context.approximateLength += pseudoBigIntToString(type.value).length + 1;
|
|
55386
55387
|
return factory.createLiteralTypeNode(factory.createBigIntLiteral(type.value));
|
|
55387
55388
|
}
|
|
55388
|
-
if (type.flags &
|
|
55389
|
+
if (type.flags & 512 /* BooleanLiteral */) {
|
|
55389
55390
|
context.approximateLength += type.intrinsicName.length;
|
|
55390
55391
|
return factory.createLiteralTypeNode(type.intrinsicName === "true" ? factory.createTrue() : factory.createFalse());
|
|
55391
55392
|
}
|
|
55392
|
-
if (type.flags &
|
|
55393
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
55393
55394
|
if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) {
|
|
55394
55395
|
if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
|
|
55395
55396
|
context.approximateLength += 6;
|
|
@@ -55402,15 +55403,15 @@ function createTypeChecker(host) {
|
|
|
55402
55403
|
context.approximateLength += 13;
|
|
55403
55404
|
return factory.createTypeOperatorNode(158 /* UniqueKeyword */, factory.createKeywordTypeNode(155 /* SymbolKeyword */));
|
|
55404
55405
|
}
|
|
55405
|
-
if (type.flags &
|
|
55406
|
+
if (type.flags & 16384 /* Void */) {
|
|
55406
55407
|
context.approximateLength += 4;
|
|
55407
55408
|
return factory.createKeywordTypeNode(116 /* VoidKeyword */);
|
|
55408
55409
|
}
|
|
55409
|
-
if (type.flags &
|
|
55410
|
+
if (type.flags & 32768 /* Undefined */) {
|
|
55410
55411
|
context.approximateLength += 9;
|
|
55411
55412
|
return factory.createKeywordTypeNode(157 /* UndefinedKeyword */);
|
|
55412
55413
|
}
|
|
55413
|
-
if (type.flags &
|
|
55414
|
+
if (type.flags & 65536 /* Null */) {
|
|
55414
55415
|
context.approximateLength += 4;
|
|
55415
55416
|
return factory.createLiteralTypeNode(factory.createNull());
|
|
55416
55417
|
}
|
|
@@ -55418,7 +55419,7 @@ function createTypeChecker(host) {
|
|
|
55418
55419
|
context.approximateLength += 5;
|
|
55419
55420
|
return factory.createKeywordTypeNode(146 /* NeverKeyword */);
|
|
55420
55421
|
}
|
|
55421
|
-
if (type.flags &
|
|
55422
|
+
if (type.flags & 4096 /* ESSymbol */) {
|
|
55422
55423
|
context.approximateLength += 6;
|
|
55423
55424
|
return factory.createKeywordTypeNode(155 /* SymbolKeyword */);
|
|
55424
55425
|
}
|
|
@@ -56207,7 +56208,7 @@ function createTypeChecker(host) {
|
|
|
56207
56208
|
}
|
|
56208
56209
|
const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
56209
56210
|
if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
|
|
56210
|
-
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags &
|
|
56211
|
+
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */);
|
|
56211
56212
|
for (const signature of signatures) {
|
|
56212
56213
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 173 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
56213
56214
|
typeElements.push(preserveCommentsOn(methodDeclaration, signature.declaration || propertySymbol.valueDeclaration));
|
|
@@ -57247,11 +57248,11 @@ function createTypeChecker(host) {
|
|
|
57247
57248
|
}
|
|
57248
57249
|
if (isComputedPropertyName(name)) {
|
|
57249
57250
|
const type = checkExpression(name.expression);
|
|
57250
|
-
return !!(type.flags &
|
|
57251
|
+
return !!(type.flags & 402653316 /* StringLike */);
|
|
57251
57252
|
}
|
|
57252
57253
|
if (isElementAccessExpression(name)) {
|
|
57253
57254
|
const type = checkExpression(name.argumentExpression);
|
|
57254
|
-
return !!(type.flags &
|
|
57255
|
+
return !!(type.flags & 402653316 /* StringLike */);
|
|
57255
57256
|
}
|
|
57256
57257
|
return isStringLiteral(name);
|
|
57257
57258
|
}
|
|
@@ -57277,7 +57278,7 @@ function createTypeChecker(host) {
|
|
|
57277
57278
|
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote, stringNamed, isMethod) {
|
|
57278
57279
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
57279
57280
|
if (nameType) {
|
|
57280
|
-
if (nameType.flags &
|
|
57281
|
+
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
57281
57282
|
const name = "" + nameType.value;
|
|
57282
57283
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && (stringNamed || !isNumericLiteralName(name))) {
|
|
57283
57284
|
return factory.createStringLiteral(name, !!singleQuote);
|
|
@@ -57287,7 +57288,7 @@ function createTypeChecker(host) {
|
|
|
57287
57288
|
}
|
|
57288
57289
|
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
|
|
57289
57290
|
}
|
|
57290
|
-
if (nameType.flags &
|
|
57291
|
+
if (nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
57291
57292
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
|
|
57292
57293
|
}
|
|
57293
57294
|
}
|
|
@@ -57329,7 +57330,7 @@ function createTypeChecker(host) {
|
|
|
57329
57330
|
return enclosingDeclaration;
|
|
57330
57331
|
}
|
|
57331
57332
|
function serializeInferredTypeForDeclaration(symbol, context, type) {
|
|
57332
|
-
if (type.flags &
|
|
57333
|
+
if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === context.enclosingFile))) {
|
|
57333
57334
|
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
57334
57335
|
}
|
|
57335
57336
|
const result = typeToTypeNodeHelper(type, context);
|
|
@@ -57562,7 +57563,7 @@ function createTypeChecker(host) {
|
|
|
57562
57563
|
}
|
|
57563
57564
|
function serializeExistingTypeNode(context, typeNode, addUndefined) {
|
|
57564
57565
|
const type = getTypeFromTypeNode2(context, typeNode);
|
|
57565
|
-
if (addUndefined && !someType(type, (t) => !!(t.flags &
|
|
57566
|
+
if (addUndefined && !someType(type, (t) => !!(t.flags & 32768 /* Undefined */)) && canReuseTypeNode(context, typeNode)) {
|
|
57566
57567
|
const clone2 = syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode);
|
|
57567
57568
|
if (clone2) {
|
|
57568
57569
|
return factory.createUnionTypeNode([clone2, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
@@ -59101,9 +59102,9 @@ function createTypeChecker(host) {
|
|
|
59101
59102
|
for (let i = 0; i < types.length; i++) {
|
|
59102
59103
|
const t = types[i];
|
|
59103
59104
|
flags |= t.flags;
|
|
59104
|
-
if (!(t.flags &
|
|
59105
|
-
if (t.flags & (
|
|
59106
|
-
const baseType = t.flags &
|
|
59105
|
+
if (!(t.flags & 98304 /* Nullable */)) {
|
|
59106
|
+
if (t.flags & (512 /* BooleanLiteral */ | 1056 /* EnumLike */)) {
|
|
59107
|
+
const baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLikeType(t);
|
|
59107
59108
|
if (baseType.flags & 1048576 /* Union */) {
|
|
59108
59109
|
const count = baseType.types.length;
|
|
59109
59110
|
if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
|
|
@@ -59116,8 +59117,8 @@ function createTypeChecker(host) {
|
|
|
59116
59117
|
result.push(t);
|
|
59117
59118
|
}
|
|
59118
59119
|
}
|
|
59119
|
-
if (flags &
|
|
59120
|
-
if (flags &
|
|
59120
|
+
if (flags & 65536 /* Null */) result.push(nullType);
|
|
59121
|
+
if (flags & 32768 /* Undefined */) result.push(undefinedType);
|
|
59121
59122
|
return result || types;
|
|
59122
59123
|
}
|
|
59123
59124
|
function visibilityToString(flags) {
|
|
@@ -59147,7 +59148,7 @@ function createTypeChecker(host) {
|
|
|
59147
59148
|
function getNameOfSymbolFromNameType(symbol, context) {
|
|
59148
59149
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
59149
59150
|
if (nameType) {
|
|
59150
|
-
if (nameType.flags &
|
|
59151
|
+
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
59151
59152
|
const name = "" + nameType.value;
|
|
59152
59153
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
59153
59154
|
return `"${escapeString(name, 34 /* doubleQuote */)}"`;
|
|
@@ -59157,7 +59158,7 @@ function createTypeChecker(host) {
|
|
|
59157
59158
|
}
|
|
59158
59159
|
return name;
|
|
59159
59160
|
}
|
|
59160
|
-
if (nameType.flags &
|
|
59161
|
+
if (nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
59161
59162
|
return `[${getNameOfSymbolAsWritten(nameType.symbol, context)}]`;
|
|
59162
59163
|
}
|
|
59163
59164
|
}
|
|
@@ -59182,7 +59183,7 @@ function createTypeChecker(host) {
|
|
|
59182
59183
|
}
|
|
59183
59184
|
if (isComputedPropertyName(name2) && !(getCheckFlags(symbol) & 4096 /* Late */)) {
|
|
59184
59185
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
59185
|
-
if (nameType && nameType.flags &
|
|
59186
|
+
if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
59186
59187
|
const result = getNameOfSymbolFromNameType(symbol, context);
|
|
59187
59188
|
if (result !== void 0) {
|
|
59188
59189
|
return result;
|
|
@@ -59463,7 +59464,7 @@ function createTypeChecker(host) {
|
|
|
59463
59464
|
);
|
|
59464
59465
|
}
|
|
59465
59466
|
function getRestType(source, properties, symbol) {
|
|
59466
|
-
source = filterType(source, (t) => !(t.flags &
|
|
59467
|
+
source = filterType(source, (t) => !(t.flags & 98304 /* Nullable */));
|
|
59467
59468
|
if (source.flags & 131072 /* Never */) {
|
|
59468
59469
|
return emptyObjectType;
|
|
59469
59470
|
}
|
|
@@ -59474,7 +59475,7 @@ function createTypeChecker(host) {
|
|
|
59474
59475
|
const spreadableProperties = [];
|
|
59475
59476
|
const unspreadableToRestKeys = [];
|
|
59476
59477
|
for (const prop of getPropertiesOfType(source)) {
|
|
59477
|
-
const literalTypeFromProperty = getLiteralTypeFromProperty(prop,
|
|
59478
|
+
const literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
59478
59479
|
if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) && isSpreadableProperty(prop)) {
|
|
59479
59480
|
spreadableProperties.push(prop);
|
|
59480
59481
|
} else {
|
|
@@ -59507,7 +59508,7 @@ function createTypeChecker(host) {
|
|
|
59507
59508
|
return result;
|
|
59508
59509
|
}
|
|
59509
59510
|
function isGenericTypeWithUndefinedConstraint(type) {
|
|
59510
|
-
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType,
|
|
59511
|
+
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */);
|
|
59511
59512
|
}
|
|
59512
59513
|
function getNonUndefinedType(type) {
|
|
59513
59514
|
const typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, (t) => t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t) : type;
|
|
@@ -59561,7 +59562,7 @@ function createTypeChecker(host) {
|
|
|
59561
59562
|
}
|
|
59562
59563
|
function getLiteralPropertyNameText(name) {
|
|
59563
59564
|
const type = getLiteralTypeFromPropertyName(name);
|
|
59564
|
-
return type.flags & (
|
|
59565
|
+
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
59565
59566
|
}
|
|
59566
59567
|
function getTypeForBindingElement(declaration) {
|
|
59567
59568
|
const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
@@ -59901,7 +59902,7 @@ function createTypeChecker(host) {
|
|
|
59901
59902
|
definedInConstructor = true;
|
|
59902
59903
|
}
|
|
59903
59904
|
}
|
|
59904
|
-
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~
|
|
59905
|
+
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~98304 /* Nullable */)) ? constructorTypes : types;
|
|
59905
59906
|
type = getUnionType(sourceTypes);
|
|
59906
59907
|
}
|
|
59907
59908
|
}
|
|
@@ -59911,7 +59912,7 @@ function createTypeChecker(host) {
|
|
|
59911
59912
|
false,
|
|
59912
59913
|
definedInMethod && !definedInConstructor
|
|
59913
59914
|
));
|
|
59914
|
-
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~
|
|
59915
|
+
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~98304 /* Nullable */)) === neverType) {
|
|
59915
59916
|
reportImplicitAny(symbol.valueDeclaration, anyType);
|
|
59916
59917
|
return anyType;
|
|
59917
59918
|
}
|
|
@@ -60209,13 +60210,13 @@ function createTypeChecker(host) {
|
|
|
60209
60210
|
}
|
|
60210
60211
|
function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors2) {
|
|
60211
60212
|
if (type) {
|
|
60212
|
-
if (type.flags &
|
|
60213
|
+
if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) {
|
|
60213
60214
|
type = getESSymbolLikeTypeForNode(declaration);
|
|
60214
60215
|
}
|
|
60215
60216
|
if (reportErrors2) {
|
|
60216
60217
|
reportErrorsFromWidening(declaration, type);
|
|
60217
60218
|
}
|
|
60218
|
-
if (type.flags &
|
|
60219
|
+
if (type.flags & 8192 /* UniqueESSymbol */ && (isBindingElement(declaration) || !tryGetTypeFromEffectiveTypeNode(declaration)) && type.symbol !== getSymbolOfDeclaration(declaration)) {
|
|
60219
60220
|
type = esSymbolType;
|
|
60220
60221
|
}
|
|
60221
60222
|
return getWidenedType(type);
|
|
@@ -61052,7 +61053,7 @@ function createTypeChecker(host) {
|
|
|
61052
61053
|
return links.declaredType;
|
|
61053
61054
|
}
|
|
61054
61055
|
function getBaseTypeOfEnumLikeType(type) {
|
|
61055
|
-
return type.flags &
|
|
61056
|
+
return type.flags & 1056 /* EnumLike */ && type.symbol.flags & 8 /* EnumMember */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
|
|
61056
61057
|
}
|
|
61057
61058
|
function getDeclaredTypeOfEnum(symbol) {
|
|
61058
61059
|
const links = getSymbolLinks(symbol);
|
|
@@ -61083,7 +61084,7 @@ function createTypeChecker(host) {
|
|
|
61083
61084
|
void 0
|
|
61084
61085
|
) : createComputedEnumType(symbol);
|
|
61085
61086
|
if (enumType.flags & 1048576 /* Union */) {
|
|
61086
|
-
enumType.flags |=
|
|
61087
|
+
enumType.flags |= 1024 /* EnumLiteral */;
|
|
61087
61088
|
enumType.symbol = symbol;
|
|
61088
61089
|
}
|
|
61089
61090
|
links.declaredType = enumType;
|
|
@@ -61091,8 +61092,8 @@ function createTypeChecker(host) {
|
|
|
61091
61092
|
return links.declaredType;
|
|
61092
61093
|
}
|
|
61093
61094
|
function createComputedEnumType(symbol) {
|
|
61094
|
-
const regularType = createTypeWithSymbol(
|
|
61095
|
-
const freshType = createTypeWithSymbol(
|
|
61095
|
+
const regularType = createTypeWithSymbol(32 /* Enum */, symbol);
|
|
61096
|
+
const freshType = createTypeWithSymbol(32 /* Enum */, symbol);
|
|
61096
61097
|
regularType.regularType = regularType;
|
|
61097
61098
|
regularType.freshType = freshType;
|
|
61098
61099
|
freshType.regularType = regularType;
|
|
@@ -61294,7 +61295,7 @@ function createTypeChecker(host) {
|
|
|
61294
61295
|
const earlySymbol = earlySymbols && earlySymbols.get(memberName);
|
|
61295
61296
|
if (!(parent2.flags & 32 /* Class */) && lateSymbol.flags & getExcludedSymbolFlags(symbolFlags)) {
|
|
61296
61297
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
61297
|
-
const name = !(type.flags &
|
|
61298
|
+
const name = !(type.flags & 8192 /* UniqueESSymbol */) && unescapeLeadingUnderscores(memberName) || declarationNameToString(declName);
|
|
61298
61299
|
forEach(declarations, (declaration) => error2(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
61299
61300
|
error2(declName || decl, Diagnostics.Duplicate_property_0, name);
|
|
61300
61301
|
lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
|
|
@@ -61989,7 +61990,7 @@ function createTypeChecker(host) {
|
|
|
61989
61990
|
if (baseConstructorIndexInfo) {
|
|
61990
61991
|
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
|
61991
61992
|
}
|
|
61992
|
-
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags &
|
|
61993
|
+
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || some(type.properties, (prop) => !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */)))) {
|
|
61993
61994
|
indexInfos = append(indexInfos, enumNumberIndexInfo);
|
|
61994
61995
|
}
|
|
61995
61996
|
}
|
|
@@ -62050,7 +62051,7 @@ function createTypeChecker(host) {
|
|
|
62050
62051
|
const limitedConstraint = getLimitedConstraint(type);
|
|
62051
62052
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
62052
62053
|
if (limitedConstraint) {
|
|
62053
|
-
const propertyNameType = getLiteralTypeFromProperty(prop,
|
|
62054
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
62054
62055
|
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
62055
62056
|
continue;
|
|
62056
62057
|
}
|
|
@@ -62103,7 +62104,7 @@ function createTypeChecker(host) {
|
|
|
62103
62104
|
}
|
|
62104
62105
|
if (type.flags & 2097152 /* Intersection */) {
|
|
62105
62106
|
const types = type.types;
|
|
62106
|
-
if (types.length === 2 && !!(types[0].flags & (
|
|
62107
|
+
if (types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType) {
|
|
62107
62108
|
return type;
|
|
62108
62109
|
}
|
|
62109
62110
|
return getIntersectionType(sameMap(type.types, getLowerBoundOfKeyType));
|
|
@@ -62121,7 +62122,7 @@ function createTypeChecker(host) {
|
|
|
62121
62122
|
cb(stringType);
|
|
62122
62123
|
} else {
|
|
62123
62124
|
for (const info of getIndexInfosOfType(type)) {
|
|
62124
|
-
if (!stringsOnly || info.keyType.flags & (
|
|
62125
|
+
if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
62125
62126
|
cb(info.keyType);
|
|
62126
62127
|
}
|
|
62127
62128
|
}
|
|
@@ -62139,7 +62140,7 @@ function createTypeChecker(host) {
|
|
|
62139
62140
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
62140
62141
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
62141
62142
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
62142
|
-
const include =
|
|
62143
|
+
const include = 8576 /* StringOrNumberLiteralOrUnique */;
|
|
62143
62144
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
62144
62145
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
62145
62146
|
modifiersType,
|
|
@@ -62179,8 +62180,8 @@ function createTypeChecker(host) {
|
|
|
62179
62180
|
}
|
|
62180
62181
|
members.set(propName, prop);
|
|
62181
62182
|
}
|
|
62182
|
-
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ |
|
|
62183
|
-
const indexKeyType = propNameType.flags & (1 /* Any */ |
|
|
62183
|
+
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) {
|
|
62184
|
+
const indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : propNameType;
|
|
62184
62185
|
const propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType));
|
|
62185
62186
|
const modifiersIndexInfo = getApplicableIndexInfo(modifiersType, propNameType);
|
|
62186
62187
|
const isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || !(templateModifiers & 2 /* ExcludeReadonly */) && (modifiersIndexInfo == null ? void 0 : modifiersIndexInfo.isReadonly));
|
|
@@ -62205,7 +62206,7 @@ function createTypeChecker(host) {
|
|
|
62205
62206
|
const templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType);
|
|
62206
62207
|
const mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.links.keyType);
|
|
62207
62208
|
const propType = instantiateType(templateType, mapper);
|
|
62208
|
-
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType,
|
|
62209
|
+
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(
|
|
62209
62210
|
propType,
|
|
62210
62211
|
/*isProperty*/
|
|
62211
62212
|
true
|
|
@@ -62499,14 +62500,14 @@ function createTypeChecker(host) {
|
|
|
62499
62500
|
constraints = append(constraints, t);
|
|
62500
62501
|
}
|
|
62501
62502
|
}
|
|
62502
|
-
} else if (t.flags &
|
|
62503
|
+
} else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
62503
62504
|
hasDisjointDomainType = true;
|
|
62504
62505
|
}
|
|
62505
62506
|
}
|
|
62506
62507
|
if (constraints && (targetIsUnion || hasDisjointDomainType)) {
|
|
62507
62508
|
if (hasDisjointDomainType) {
|
|
62508
62509
|
for (const t of types) {
|
|
62509
|
-
if (t.flags &
|
|
62510
|
+
if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
62510
62511
|
constraints = append(constraints, t);
|
|
62511
62512
|
}
|
|
62512
62513
|
}
|
|
@@ -62707,7 +62708,7 @@ function createTypeChecker(host) {
|
|
|
62707
62708
|
function getApparentType(type) {
|
|
62708
62709
|
const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
|
|
62709
62710
|
const objectFlags = getObjectFlags(t);
|
|
62710
|
-
return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags &
|
|
62711
|
+
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;
|
|
62711
62712
|
}
|
|
62712
62713
|
function getReducedApparentType(type) {
|
|
62713
62714
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
@@ -63059,7 +63060,7 @@ function createTypeChecker(host) {
|
|
|
63059
63060
|
)) : applicableInfo ? applicableInfo : stringIndexInfo && isApplicableIndexType(keyType, stringType) ? stringIndexInfo : void 0;
|
|
63060
63061
|
}
|
|
63061
63062
|
function isApplicableIndexType(source, target) {
|
|
63062
|
-
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags &
|
|
63063
|
+
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && isNumericLiteralName(source.value));
|
|
63063
63064
|
}
|
|
63064
63065
|
function getIndexInfosOfStructuredType(type) {
|
|
63065
63066
|
if (type.flags & 3670016 /* StructuredType */) {
|
|
@@ -63388,7 +63389,7 @@ function createTypeChecker(host) {
|
|
|
63388
63389
|
}
|
|
63389
63390
|
if (type || jsdocPredicate) {
|
|
63390
63391
|
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
63391
|
-
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags &
|
|
63392
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 16 /* Boolean */) && getParameterCount(signature) > 0) {
|
|
63392
63393
|
const { declaration } = signature;
|
|
63393
63394
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
63394
63395
|
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
@@ -63673,7 +63674,7 @@ function createTypeChecker(host) {
|
|
|
63673
63674
|
return emptyArray;
|
|
63674
63675
|
}
|
|
63675
63676
|
function isValidIndexKeyType(type) {
|
|
63676
|
-
return !!(type.flags & (
|
|
63677
|
+
return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && some(type.types, isValidIndexKeyType);
|
|
63677
63678
|
}
|
|
63678
63679
|
function getConstraintDeclaration(type) {
|
|
63679
63680
|
return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
|
|
@@ -64174,7 +64175,7 @@ function createTypeChecker(host) {
|
|
|
64174
64175
|
}
|
|
64175
64176
|
function getTypeFromJSDocNullableTypeNode(node) {
|
|
64176
64177
|
const type = getTypeFromTypeNode(node.type);
|
|
64177
|
-
return strictNullChecks ? getNullableType(type,
|
|
64178
|
+
return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type;
|
|
64178
64179
|
}
|
|
64179
64180
|
function getTypeFromTypeReference(node) {
|
|
64180
64181
|
const links = getNodeLinks(node);
|
|
@@ -64947,10 +64948,10 @@ function createTypeChecker(host) {
|
|
|
64947
64948
|
return type.id;
|
|
64948
64949
|
}
|
|
64949
64950
|
function containsType(types, type) {
|
|
64950
|
-
return binarySearch(types, type,
|
|
64951
|
+
return binarySearch(types, type, getTypeId, compareValues) >= 0;
|
|
64951
64952
|
}
|
|
64952
64953
|
function insertType(types, type) {
|
|
64953
|
-
const index = binarySearch(types, type,
|
|
64954
|
+
const index = binarySearch(types, type, getTypeId, compareValues);
|
|
64954
64955
|
if (index < 0) {
|
|
64955
64956
|
types.splice(~index, 0, type);
|
|
64956
64957
|
return true;
|
|
@@ -64965,10 +64966,11 @@ function createTypeChecker(host) {
|
|
|
64965
64966
|
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) includes |= 536870912 /* IncludesConstrainedTypeVariable */;
|
|
64966
64967
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
64967
64968
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
64968
|
-
if (!strictNullChecks && flags &
|
|
64969
|
+
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
64969
64970
|
if (!(getObjectFlags(type) & 65536 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */;
|
|
64970
64971
|
} else {
|
|
64971
|
-
const
|
|
64972
|
+
const len = typeSet.length;
|
|
64973
|
+
const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues);
|
|
64972
64974
|
if (index < 0) {
|
|
64973
64975
|
typeSet.splice(~index, 0, type);
|
|
64974
64976
|
}
|
|
@@ -65046,7 +65048,7 @@ function createTypeChecker(host) {
|
|
|
65046
65048
|
i--;
|
|
65047
65049
|
const t = types[i];
|
|
65048
65050
|
const flags = t.flags;
|
|
65049
|
-
const remove = flags & (
|
|
65051
|
+
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);
|
|
65050
65052
|
if (remove) {
|
|
65051
65053
|
orderedRemoveItemAt(types, i);
|
|
65052
65054
|
}
|
|
@@ -65059,7 +65061,7 @@ function createTypeChecker(host) {
|
|
|
65059
65061
|
while (i > 0) {
|
|
65060
65062
|
i--;
|
|
65061
65063
|
const t = types[i];
|
|
65062
|
-
if (t.flags &
|
|
65064
|
+
if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
|
|
65063
65065
|
orderedRemoveItemAt(types, i);
|
|
65064
65066
|
}
|
|
65065
65067
|
}
|
|
@@ -65157,15 +65159,15 @@ function createTypeChecker(host) {
|
|
|
65157
65159
|
if (includes & 3 /* AnyOrUnknown */) {
|
|
65158
65160
|
return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType : unknownType;
|
|
65159
65161
|
}
|
|
65160
|
-
if (includes &
|
|
65162
|
+
if (includes & 32768 /* Undefined */) {
|
|
65161
65163
|
if (typeSet.length >= 2 && typeSet[0] === undefinedType && typeSet[1] === missingType) {
|
|
65162
65164
|
orderedRemoveItemAt(typeSet, 1);
|
|
65163
65165
|
}
|
|
65164
65166
|
}
|
|
65165
|
-
if (includes & (
|
|
65167
|
+
if (includes & (32 /* Enum */ | 2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) {
|
|
65166
65168
|
removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */));
|
|
65167
65169
|
}
|
|
65168
|
-
if (includes &
|
|
65170
|
+
if (includes & 128 /* StringLiteral */ && includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
65169
65171
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
65170
65172
|
}
|
|
65171
65173
|
if (includes & 536870912 /* IncludesConstrainedTypeVariable */) {
|
|
@@ -65178,7 +65180,7 @@ function createTypeChecker(host) {
|
|
|
65178
65180
|
}
|
|
65179
65181
|
}
|
|
65180
65182
|
if (typeSet.length === 0) {
|
|
65181
|
-
return includes &
|
|
65183
|
+
return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType;
|
|
65182
65184
|
}
|
|
65183
65185
|
}
|
|
65184
65186
|
if (!origin && includes & 1048576 /* Union */) {
|
|
@@ -65201,7 +65203,7 @@ function createTypeChecker(host) {
|
|
|
65201
65203
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
65202
65204
|
}
|
|
65203
65205
|
}
|
|
65204
|
-
const objectFlags = (includes &
|
|
65206
|
+
const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
65205
65207
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
65206
65208
|
}
|
|
65207
65209
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -65246,14 +65248,14 @@ function createTypeChecker(host) {
|
|
|
65246
65248
|
type.objectFlags = precomputedObjectFlags | getPropagatingFlagsOfTypes(
|
|
65247
65249
|
types,
|
|
65248
65250
|
/*excludeKinds*/
|
|
65249
|
-
|
|
65251
|
+
98304 /* Nullable */
|
|
65250
65252
|
);
|
|
65251
65253
|
type.types = types;
|
|
65252
65254
|
type.origin = origin;
|
|
65253
65255
|
type.aliasSymbol = aliasSymbol;
|
|
65254
65256
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
65255
|
-
if (types.length === 2 && types[0].flags &
|
|
65256
|
-
type.flags |=
|
|
65257
|
+
if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
|
|
65258
|
+
type.flags |= 16 /* Boolean */;
|
|
65257
65259
|
type.intrinsicName = "boolean";
|
|
65258
65260
|
}
|
|
65259
65261
|
unionTypes.set(id, type);
|
|
@@ -65282,13 +65284,13 @@ function createTypeChecker(host) {
|
|
|
65282
65284
|
if (flags & 3 /* AnyOrUnknown */) {
|
|
65283
65285
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
65284
65286
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
65285
|
-
} else if (strictNullChecks || !(flags &
|
|
65287
|
+
} else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
|
|
65286
65288
|
if (type === missingType) {
|
|
65287
65289
|
includes |= 262144 /* IncludesMissingType */;
|
|
65288
65290
|
type = undefinedType;
|
|
65289
65291
|
}
|
|
65290
65292
|
if (!typeSet.has(type.id.toString())) {
|
|
65291
|
-
if (type.flags &
|
|
65293
|
+
if (type.flags & 109472 /* Unit */ && includes & 109472 /* Unit */) {
|
|
65292
65294
|
includes |= 67108864 /* NonPrimitive */;
|
|
65293
65295
|
}
|
|
65294
65296
|
typeSet.set(type.id.toString(), type);
|
|
@@ -65309,7 +65311,7 @@ function createTypeChecker(host) {
|
|
|
65309
65311
|
while (i > 0) {
|
|
65310
65312
|
i--;
|
|
65311
65313
|
const t = types[i];
|
|
65312
|
-
const remove = t.flags &
|
|
65314
|
+
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 */;
|
|
65313
65315
|
if (remove) {
|
|
65314
65316
|
orderedRemoveItemAt(types, i);
|
|
65315
65317
|
}
|
|
@@ -65324,7 +65326,7 @@ function createTypeChecker(host) {
|
|
|
65324
65326
|
if (type === undefinedType) {
|
|
65325
65327
|
return containsType(u.types, missingType);
|
|
65326
65328
|
}
|
|
65327
|
-
const primitive = type.flags &
|
|
65329
|
+
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;
|
|
65328
65330
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
65329
65331
|
return false;
|
|
65330
65332
|
}
|
|
@@ -65334,7 +65336,7 @@ function createTypeChecker(host) {
|
|
|
65334
65336
|
}
|
|
65335
65337
|
function extractRedundantTemplateLiterals(types) {
|
|
65336
65338
|
let i = types.length;
|
|
65337
|
-
const literals = filter(types, (t) => !!(t.flags &
|
|
65339
|
+
const literals = filter(types, (t) => !!(t.flags & 128 /* StringLiteral */));
|
|
65338
65340
|
while (i > 0) {
|
|
65339
65341
|
i--;
|
|
65340
65342
|
const t = types[i];
|
|
@@ -65400,7 +65402,7 @@ function createTypeChecker(host) {
|
|
|
65400
65402
|
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
65401
65403
|
types,
|
|
65402
65404
|
/*excludeKinds*/
|
|
65403
|
-
|
|
65405
|
+
98304 /* Nullable */
|
|
65404
65406
|
);
|
|
65405
65407
|
result.types = types;
|
|
65406
65408
|
result.aliasSymbol = aliasSymbol;
|
|
@@ -65415,19 +65417,19 @@ function createTypeChecker(host) {
|
|
|
65415
65417
|
if (includes & 131072 /* Never */) {
|
|
65416
65418
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
65417
65419
|
}
|
|
65418
|
-
if (strictNullChecks && includes &
|
|
65420
|
+
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 */)) {
|
|
65419
65421
|
return neverType;
|
|
65420
65422
|
}
|
|
65421
|
-
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes &
|
|
65423
|
+
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) {
|
|
65422
65424
|
return neverType;
|
|
65423
65425
|
}
|
|
65424
65426
|
if (includes & 1 /* Any */) {
|
|
65425
65427
|
return includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType;
|
|
65426
65428
|
}
|
|
65427
|
-
if (!strictNullChecks && includes &
|
|
65428
|
-
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes &
|
|
65429
|
+
if (!strictNullChecks && includes & 98304 /* Nullable */) {
|
|
65430
|
+
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes & 32768 /* Undefined */ ? undefinedType : nullType;
|
|
65429
65431
|
}
|
|
65430
|
-
if (includes &
|
|
65432
|
+
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 */) {
|
|
65431
65433
|
if (!(flags & 1 /* NoSupertypeReduction */)) removeRedundantSupertypes(typeSet, includes);
|
|
65432
65434
|
}
|
|
65433
65435
|
if (includes & 262144 /* IncludesMissingType */) {
|
|
@@ -65464,12 +65466,12 @@ function createTypeChecker(host) {
|
|
|
65464
65466
|
if (includes & 1048576 /* Union */) {
|
|
65465
65467
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
65466
65468
|
result = getIntersectionType(typeSet, flags, aliasSymbol, aliasTypeArguments);
|
|
65467
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags &
|
|
65469
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
|
|
65468
65470
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
65469
|
-
removeFromEach(typeSet,
|
|
65471
|
+
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
65470
65472
|
result = getUnionType([getIntersectionType(typeSet, flags), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
65471
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags &
|
|
65472
|
-
removeFromEach(typeSet,
|
|
65473
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
65474
|
+
removeFromEach(typeSet, 65536 /* Null */);
|
|
65473
65475
|
result = getUnionType([getIntersectionType(typeSet, flags), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
65474
65476
|
} else if (typeSet.length >= 3 && types.length > 2) {
|
|
65475
65477
|
const middle = Math.floor(typeSet.length / 2);
|
|
@@ -65534,7 +65536,7 @@ function createTypeChecker(host) {
|
|
|
65534
65536
|
const types = map(node.types, getTypeFromTypeNode);
|
|
65535
65537
|
const emptyIndex = types.length === 2 ? types.indexOf(emptyTypeLiteralType) : -1;
|
|
65536
65538
|
const t = emptyIndex >= 0 ? types[1 - emptyIndex] : unknownType;
|
|
65537
|
-
const noSupertypeReduction = !!(t.flags & (
|
|
65539
|
+
const noSupertypeReduction = !!(t.flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */) || t.flags & 134217728 /* TemplateLiteral */ && isPatternLiteralType(t));
|
|
65538
65540
|
links.resolvedType = getIntersectionType(types, noSupertypeReduction ? 1 /* NoSupertypeReduction */ : 0, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
65539
65541
|
}
|
|
65540
65542
|
return links.resolvedType;
|
|
@@ -65568,11 +65570,11 @@ function createTypeChecker(host) {
|
|
|
65568
65570
|
forEachType(constraintType, addMemberForKeyType);
|
|
65569
65571
|
} else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
65570
65572
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
65571
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType,
|
|
65573
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
|
|
65572
65574
|
} else {
|
|
65573
65575
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
65574
65576
|
}
|
|
65575
|
-
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ |
|
|
65577
|
+
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ | 4 /* String */))) : getUnionType(keyTypes);
|
|
65576
65578
|
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
65577
65579
|
return constraintType;
|
|
65578
65580
|
}
|
|
@@ -65627,7 +65629,7 @@ function createTypeChecker(host) {
|
|
|
65627
65629
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
65628
65630
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
65629
65631
|
const propertyTypes = map(getPropertiesOfType(type), (prop) => getLiteralTypeFromProperty(prop, include));
|
|
65630
|
-
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include &
|
|
65632
|
+
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType);
|
|
65631
65633
|
return getUnionType(
|
|
65632
65634
|
concatenate(propertyTypes, indexKeyTypes),
|
|
65633
65635
|
1 /* Literal */,
|
|
@@ -65643,7 +65645,7 @@ function createTypeChecker(host) {
|
|
|
65643
65645
|
}
|
|
65644
65646
|
function getIndexType(type, indexFlags = 0 /* None */) {
|
|
65645
65647
|
type = getReducedType(type);
|
|
65646
|
-
return isNoInferType(type) ? getNoInferType(getIndexType(type.baseType, indexFlags)) : shouldDeferIndexType(type, indexFlags) ? getIndexTypeForGenericType(type, indexFlags) : type.flags & 1048576 /* Union */ ? getIntersectionType(map(type.types, (t) => getIndexType(t, indexFlags))) : type.flags & 2097152 /* Intersection */ ? getUnionType(map(type.types, (t) => getIndexType(t, indexFlags))) : getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, indexFlags) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : type.flags & (1 /* Any */ | 131072 /* Never */) ? stringNumberSymbolType : getLiteralTypeFromProperties(type, (indexFlags & 2 /* NoIndexSignatures */ ?
|
|
65648
|
+
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 */);
|
|
65647
65649
|
}
|
|
65648
65650
|
function getExtractStringType(type) {
|
|
65649
65651
|
const extractTypeAlias = getGlobalExtractSymbol();
|
|
@@ -65701,7 +65703,7 @@ function createTypeChecker(host) {
|
|
|
65701
65703
|
}
|
|
65702
65704
|
newTexts.push(text);
|
|
65703
65705
|
if (every(newTexts, (t) => t === "")) {
|
|
65704
|
-
if (every(newTypes, (t) => !!(t.flags &
|
|
65706
|
+
if (every(newTypes, (t) => !!(t.flags & 4 /* String */))) {
|
|
65705
65707
|
return stringType;
|
|
65706
65708
|
}
|
|
65707
65709
|
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
@@ -65717,7 +65719,7 @@ function createTypeChecker(host) {
|
|
|
65717
65719
|
function addSpans(texts2, types2) {
|
|
65718
65720
|
for (let i = 0; i < types2.length; i++) {
|
|
65719
65721
|
const t = types2[i];
|
|
65720
|
-
if (t.flags & (
|
|
65722
|
+
if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) {
|
|
65721
65723
|
text += getTemplateStringForType(t) || "";
|
|
65722
65724
|
text += texts2[i + 1];
|
|
65723
65725
|
} else if (t.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -65736,7 +65738,7 @@ function createTypeChecker(host) {
|
|
|
65736
65738
|
}
|
|
65737
65739
|
}
|
|
65738
65740
|
function getTemplateStringForType(type) {
|
|
65739
|
-
return type.flags &
|
|
65741
|
+
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;
|
|
65740
65742
|
}
|
|
65741
65743
|
function createTemplateLiteralType(texts, types) {
|
|
65742
65744
|
const type = createType(134217728 /* TemplateLiteral */);
|
|
@@ -65745,9 +65747,9 @@ function createTypeChecker(host) {
|
|
|
65745
65747
|
return type;
|
|
65746
65748
|
}
|
|
65747
65749
|
function getStringMappingType(symbol, type) {
|
|
65748
|
-
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags &
|
|
65750
|
+
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)) : (
|
|
65749
65751
|
// Mapping<Mapping<T>> === Mapping<T>
|
|
65750
|
-
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ |
|
|
65752
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ | 4 /* String */ | 268435456 /* StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : (
|
|
65751
65753
|
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
65752
65754
|
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) : type
|
|
65753
65755
|
)
|
|
@@ -65885,7 +65887,7 @@ function createTypeChecker(host) {
|
|
|
65885
65887
|
}
|
|
65886
65888
|
}
|
|
65887
65889
|
}
|
|
65888
|
-
if (!(indexType.flags &
|
|
65890
|
+
if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) {
|
|
65889
65891
|
if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
|
|
65890
65892
|
return objectType;
|
|
65891
65893
|
}
|
|
@@ -65901,13 +65903,13 @@ function createTypeChecker(host) {
|
|
|
65901
65903
|
}
|
|
65902
65904
|
return void 0;
|
|
65903
65905
|
}
|
|
65904
|
-
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType,
|
|
65906
|
+
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
|
|
65905
65907
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
65906
65908
|
error2(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
|
|
65907
65909
|
return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
|
|
65908
65910
|
}
|
|
65909
65911
|
errorIfWritingToReadonlyIndex(indexInfo);
|
|
65910
|
-
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags &
|
|
65912
|
+
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags & 1024 /* EnumLiteral */ && getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
|
|
65911
65913
|
return getUnionType([indexInfo.type, missingType]);
|
|
65912
65914
|
}
|
|
65913
65915
|
return indexInfo.type;
|
|
@@ -65920,10 +65922,10 @@ function createTypeChecker(host) {
|
|
|
65920
65922
|
}
|
|
65921
65923
|
if (accessExpression && !isConstEnumObjectType(objectType)) {
|
|
65922
65924
|
if (isObjectLiteralType2(objectType)) {
|
|
65923
|
-
if (noImplicitAny && indexType.flags & (
|
|
65925
|
+
if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
65924
65926
|
diagnostics.add(createDiagnosticForNode(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)));
|
|
65925
65927
|
return undefinedType;
|
|
65926
|
-
} else if (indexType.flags & (
|
|
65928
|
+
} else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
|
|
65927
65929
|
const types = map(objectType.properties, (property) => {
|
|
65928
65930
|
return getTypeOfSymbol(property);
|
|
65929
65931
|
});
|
|
@@ -65950,7 +65952,7 @@ function createTypeChecker(host) {
|
|
|
65950
65952
|
error2(accessExpression, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion2);
|
|
65951
65953
|
} else {
|
|
65952
65954
|
let errorInfo;
|
|
65953
|
-
if (indexType.flags &
|
|
65955
|
+
if (indexType.flags & 1024 /* EnumLiteral */) {
|
|
65954
65956
|
errorInfo = chainDiagnosticMessages(
|
|
65955
65957
|
/*details*/
|
|
65956
65958
|
void 0,
|
|
@@ -65958,7 +65960,7 @@ function createTypeChecker(host) {
|
|
|
65958
65960
|
"[" + typeToString(indexType) + "]",
|
|
65959
65961
|
typeToString(objectType)
|
|
65960
65962
|
);
|
|
65961
|
-
} else if (indexType.flags &
|
|
65963
|
+
} else if (indexType.flags & 8192 /* UniqueESSymbol */) {
|
|
65962
65964
|
const symbolName2 = getFullyQualifiedName(indexType.symbol, accessExpression);
|
|
65963
65965
|
errorInfo = chainDiagnosticMessages(
|
|
65964
65966
|
/*details*/
|
|
@@ -65967,7 +65969,7 @@ function createTypeChecker(host) {
|
|
|
65967
65969
|
"[" + symbolName2 + "]",
|
|
65968
65970
|
typeToString(objectType)
|
|
65969
65971
|
);
|
|
65970
|
-
} else if (indexType.flags &
|
|
65972
|
+
} else if (indexType.flags & 128 /* StringLiteral */) {
|
|
65971
65973
|
errorInfo = chainDiagnosticMessages(
|
|
65972
65974
|
/*details*/
|
|
65973
65975
|
void 0,
|
|
@@ -65975,7 +65977,7 @@ function createTypeChecker(host) {
|
|
|
65975
65977
|
indexType.value,
|
|
65976
65978
|
typeToString(objectType)
|
|
65977
65979
|
);
|
|
65978
|
-
} else if (indexType.flags &
|
|
65980
|
+
} else if (indexType.flags & 256 /* NumberLiteral */) {
|
|
65979
65981
|
errorInfo = chainDiagnosticMessages(
|
|
65980
65982
|
/*details*/
|
|
65981
65983
|
void 0,
|
|
@@ -65983,7 +65985,7 @@ function createTypeChecker(host) {
|
|
|
65983
65985
|
indexType.value,
|
|
65984
65986
|
typeToString(objectType)
|
|
65985
65987
|
);
|
|
65986
|
-
} else if (indexType.flags & (
|
|
65988
|
+
} else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
|
|
65987
65989
|
errorInfo = chainDiagnosticMessages(
|
|
65988
65990
|
/*details*/
|
|
65989
65991
|
void 0,
|
|
@@ -66014,9 +66016,9 @@ function createTypeChecker(host) {
|
|
|
66014
66016
|
}
|
|
66015
66017
|
if (accessNode) {
|
|
66016
66018
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
66017
|
-
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (
|
|
66019
|
+
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
66018
66020
|
error2(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
|
|
66019
|
-
} else if (indexType.flags & (
|
|
66021
|
+
} else if (indexType.flags & (4 /* String */ | 8 /* Number */)) {
|
|
66020
66022
|
error2(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
|
|
66021
66023
|
} else {
|
|
66022
66024
|
const typeString = indexNode.kind === 10 /* BigIntLiteral */ ? "bigint" : typeToString(indexType);
|
|
@@ -66040,7 +66042,7 @@ function createTypeChecker(host) {
|
|
|
66040
66042
|
if (type.flags & 2097152 /* Intersection */) {
|
|
66041
66043
|
let seenPlaceholder = false;
|
|
66042
66044
|
for (const t of type.types) {
|
|
66043
|
-
if (t.flags & (
|
|
66045
|
+
if (t.flags & (2944 /* Literal */ | 98304 /* Nullable */) || isPatternLiteralPlaceholderType(t)) {
|
|
66044
66046
|
seenPlaceholder = true;
|
|
66045
66047
|
} else if (!(t.flags & 524288 /* Object */)) {
|
|
66046
66048
|
return false;
|
|
@@ -66048,7 +66050,7 @@ function createTypeChecker(host) {
|
|
|
66048
66050
|
}
|
|
66049
66051
|
return seenPlaceholder;
|
|
66050
66052
|
}
|
|
66051
|
-
return !!(type.flags & (1 /* Any */ |
|
|
66053
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
|
|
66052
66054
|
}
|
|
66053
66055
|
function isPatternLiteralType(type) {
|
|
66054
66056
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
@@ -66113,10 +66115,10 @@ function createTypeChecker(host) {
|
|
|
66113
66115
|
return type[cache] = distributedOverObject;
|
|
66114
66116
|
}
|
|
66115
66117
|
}
|
|
66116
|
-
if (isGenericTupleType(objectType) && indexType.flags &
|
|
66118
|
+
if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) {
|
|
66117
66119
|
const elementType = getElementTypeOfSliceOfTupleType(
|
|
66118
66120
|
objectType,
|
|
66119
|
-
indexType.flags &
|
|
66121
|
+
indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength,
|
|
66120
66122
|
/*endSkipCount*/
|
|
66121
66123
|
0,
|
|
66122
66124
|
writing
|
|
@@ -66169,14 +66171,14 @@ function createTypeChecker(host) {
|
|
|
66169
66171
|
}
|
|
66170
66172
|
function couldAccessOptionalProperty(objectType, indexType) {
|
|
66171
66173
|
const indexConstraint = getBaseConstraintOfType(indexType);
|
|
66172
|
-
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p,
|
|
66174
|
+
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */), indexConstraint));
|
|
66173
66175
|
}
|
|
66174
66176
|
function getIndexedAccessType(objectType, indexType, accessFlags = 0 /* None */, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
66175
66177
|
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
66176
66178
|
}
|
|
66177
66179
|
function indexTypeLessThan(indexType, limit) {
|
|
66178
66180
|
return everyType(indexType, (t) => {
|
|
66179
|
-
if (t.flags &
|
|
66181
|
+
if (t.flags & 384 /* StringOrNumberLiteral */) {
|
|
66180
66182
|
const propName = getPropertyNameFromType(t);
|
|
66181
66183
|
if (isNumericLiteralName(propName)) {
|
|
66182
66184
|
const index = +propName;
|
|
@@ -66191,7 +66193,7 @@ function createTypeChecker(host) {
|
|
|
66191
66193
|
return wildcardType;
|
|
66192
66194
|
}
|
|
66193
66195
|
objectType = getReducedType(objectType);
|
|
66194
|
-
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags &
|
|
66196
|
+
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
|
|
66195
66197
|
indexType = stringType;
|
|
66196
66198
|
}
|
|
66197
66199
|
if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) accessFlags |= 1 /* IncludeUndefined */;
|
|
@@ -66208,7 +66210,7 @@ function createTypeChecker(host) {
|
|
|
66208
66210
|
return type;
|
|
66209
66211
|
}
|
|
66210
66212
|
const apparentObjectType = getReducedApparentType(objectType);
|
|
66211
|
-
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags &
|
|
66213
|
+
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) {
|
|
66212
66214
|
const propTypes = [];
|
|
66213
66215
|
let wasMissingProp = false;
|
|
66214
66216
|
for (const t of indexType.types) {
|
|
@@ -66541,7 +66543,7 @@ function createTypeChecker(host) {
|
|
|
66541
66543
|
return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type);
|
|
66542
66544
|
}
|
|
66543
66545
|
function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
|
|
66544
|
-
return isEmptyObjectType(type) || !!(type.flags & (
|
|
66546
|
+
return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */));
|
|
66545
66547
|
}
|
|
66546
66548
|
function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
|
|
66547
66549
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
@@ -66604,7 +66606,7 @@ function createTypeChecker(host) {
|
|
|
66604
66606
|
if (right.flags & 1048576 /* Union */) {
|
|
66605
66607
|
return checkCrossProductUnion([left, right]) ? mapType(right, (t) => getSpreadType(left, t, symbol, objectFlags, readonly)) : errorType;
|
|
66606
66608
|
}
|
|
66607
|
-
if (right.flags & (
|
|
66609
|
+
if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) {
|
|
66608
66610
|
return left;
|
|
66609
66611
|
}
|
|
66610
66612
|
if (isGenericObjectType(left) || isGenericObjectType(right)) {
|
|
@@ -66686,7 +66688,7 @@ function createTypeChecker(host) {
|
|
|
66686
66688
|
return type;
|
|
66687
66689
|
}
|
|
66688
66690
|
function getFreshTypeOfLiteralType(type) {
|
|
66689
|
-
if (type.flags &
|
|
66691
|
+
if (type.flags & 2976 /* Freshable */) {
|
|
66690
66692
|
if (!type.freshType) {
|
|
66691
66693
|
const freshType = createLiteralType(type.flags, type.value, type.symbol, type);
|
|
66692
66694
|
freshType.freshType = freshType;
|
|
@@ -66697,28 +66699,28 @@ function createTypeChecker(host) {
|
|
|
66697
66699
|
return type;
|
|
66698
66700
|
}
|
|
66699
66701
|
function getRegularTypeOfLiteralType(type) {
|
|
66700
|
-
return type.flags &
|
|
66702
|
+
return type.flags & 2976 /* Freshable */ ? type.regularType : type.flags & 1048576 /* Union */ ? type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType)) : type;
|
|
66701
66703
|
}
|
|
66702
66704
|
function isFreshLiteralType(type) {
|
|
66703
|
-
return !!(type.flags &
|
|
66705
|
+
return !!(type.flags & 2976 /* Freshable */) && type.freshType === type;
|
|
66704
66706
|
}
|
|
66705
66707
|
function getStringLiteralType(value) {
|
|
66706
66708
|
let type;
|
|
66707
|
-
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(
|
|
66709
|
+
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type);
|
|
66708
66710
|
}
|
|
66709
66711
|
function getNumberLiteralType(value) {
|
|
66710
66712
|
let type;
|
|
66711
|
-
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(
|
|
66713
|
+
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type);
|
|
66712
66714
|
}
|
|
66713
66715
|
function getBigIntLiteralType(value) {
|
|
66714
66716
|
let type;
|
|
66715
66717
|
const key = pseudoBigIntToString(value);
|
|
66716
|
-
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(
|
|
66718
|
+
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type);
|
|
66717
66719
|
}
|
|
66718
66720
|
function getEnumLiteralType(value, enumId, symbol) {
|
|
66719
66721
|
let type;
|
|
66720
66722
|
const key = `${enumId}${typeof value === "string" ? "@" : "#"}${value}`;
|
|
66721
|
-
const flags =
|
|
66723
|
+
const flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */);
|
|
66722
66724
|
return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type);
|
|
66723
66725
|
}
|
|
66724
66726
|
function getTypeFromLiteralTypeNode(node) {
|
|
@@ -66732,7 +66734,7 @@ function createTypeChecker(host) {
|
|
|
66732
66734
|
return links.resolvedType;
|
|
66733
66735
|
}
|
|
66734
66736
|
function createUniqueESSymbolType(symbol) {
|
|
66735
|
-
const type = createTypeWithSymbol(
|
|
66737
|
+
const type = createTypeWithSymbol(8192 /* UniqueESSymbol */, symbol);
|
|
66736
66738
|
type.escapedName = `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}`;
|
|
66737
66739
|
return type;
|
|
66738
66740
|
}
|
|
@@ -67120,7 +67122,7 @@ function createTypeChecker(host) {
|
|
|
67120
67122
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
67121
67123
|
target.instantiations.set(id, result);
|
|
67122
67124
|
const resultObjectFlags = getObjectFlags(result);
|
|
67123
|
-
if (result.flags &
|
|
67125
|
+
if (result.flags & 3899393 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
67124
67126
|
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
67125
67127
|
if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
67126
67128
|
if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
|
|
@@ -67249,7 +67251,7 @@ function createTypeChecker(host) {
|
|
|
67249
67251
|
const templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
|
|
67250
67252
|
const propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
|
|
67251
67253
|
const modifiers = getMappedTypeModifiers(type);
|
|
67252
|
-
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType,
|
|
67254
|
+
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(
|
|
67253
67255
|
propType,
|
|
67254
67256
|
/*isProperty*/
|
|
67255
67257
|
true
|
|
@@ -67796,7 +67798,7 @@ function createTypeChecker(host) {
|
|
|
67796
67798
|
createDiagnosticForNode(
|
|
67797
67799
|
targetNode,
|
|
67798
67800
|
Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1,
|
|
67799
|
-
propertyName && !(nameType.flags &
|
|
67801
|
+
propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? unescapeLeadingUnderscores(propertyName) : typeToString(nameType),
|
|
67800
67802
|
typeToString(target)
|
|
67801
67803
|
)
|
|
67802
67804
|
);
|
|
@@ -68039,7 +68041,7 @@ function createTypeChecker(host) {
|
|
|
68039
68041
|
if (!length(node.properties)) return;
|
|
68040
68042
|
for (const prop of node.properties) {
|
|
68041
68043
|
if (isSpreadAssignment(prop)) continue;
|
|
68042
|
-
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop),
|
|
68044
|
+
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop), 8576 /* StringOrNumberLiteralOrUnique */);
|
|
68043
68045
|
if (!type || type.flags & 131072 /* Never */) {
|
|
68044
68046
|
continue;
|
|
68045
68047
|
}
|
|
@@ -68089,7 +68091,7 @@ function createTypeChecker(host) {
|
|
|
68089
68091
|
}
|
|
68090
68092
|
return false;
|
|
68091
68093
|
}
|
|
68092
|
-
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
68094
|
+
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
|
|
68093
68095
|
if (source === target) {
|
|
68094
68096
|
return -1 /* True */;
|
|
68095
68097
|
}
|
|
@@ -68114,7 +68116,7 @@ function createTypeChecker(host) {
|
|
|
68114
68116
|
target,
|
|
68115
68117
|
/*inferenceContext*/
|
|
68116
68118
|
void 0,
|
|
68117
|
-
|
|
68119
|
+
compareTypes
|
|
68118
68120
|
);
|
|
68119
68121
|
}
|
|
68120
68122
|
const sourceCount = getParameterCount(source);
|
|
@@ -68130,12 +68132,12 @@ function createTypeChecker(host) {
|
|
|
68130
68132
|
if (sourceThisType && sourceThisType !== voidType) {
|
|
68131
68133
|
const targetThisType = getThisTypeOfSignature(target);
|
|
68132
68134
|
if (targetThisType) {
|
|
68133
|
-
const related = !strictVariance &&
|
|
68135
|
+
const related = !strictVariance && compareTypes(
|
|
68134
68136
|
sourceThisType,
|
|
68135
68137
|
targetThisType,
|
|
68136
68138
|
/*reportErrors*/
|
|
68137
68139
|
false
|
|
68138
|
-
) ||
|
|
68140
|
+
) || compareTypes(targetThisType, sourceThisType, reportErrors2);
|
|
68139
68141
|
if (!related) {
|
|
68140
68142
|
if (reportErrors2) {
|
|
68141
68143
|
errorReporter(Diagnostics.The_this_types_of_each_signature_are_incompatible);
|
|
@@ -68154,13 +68156,13 @@ function createTypeChecker(host) {
|
|
|
68154
68156
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
68155
68157
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
68156
68158
|
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
68157
|
-
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
68159
|
+
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
68158
68160
|
sourceType,
|
|
68159
68161
|
targetType,
|
|
68160
68162
|
/*reportErrors*/
|
|
68161
68163
|
false
|
|
68162
|
-
) ||
|
|
68163
|
-
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) &&
|
|
68164
|
+
) || compareTypes(targetType, sourceType, reportErrors2);
|
|
68165
|
+
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(
|
|
68164
68166
|
sourceType,
|
|
68165
68167
|
targetType,
|
|
68166
68168
|
/*reportErrors*/
|
|
@@ -68187,7 +68189,7 @@ function createTypeChecker(host) {
|
|
|
68187
68189
|
if (targetTypePredicate) {
|
|
68188
68190
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
68189
68191
|
if (sourceTypePredicate) {
|
|
68190
|
-
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter,
|
|
68192
|
+
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter, compareTypes);
|
|
68191
68193
|
} else if (isIdentifierTypePredicate(targetTypePredicate) || isThisTypePredicate(targetTypePredicate)) {
|
|
68192
68194
|
if (reportErrors2) {
|
|
68193
68195
|
errorReporter(Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
|
|
@@ -68195,12 +68197,12 @@ function createTypeChecker(host) {
|
|
|
68195
68197
|
return 0 /* False */;
|
|
68196
68198
|
}
|
|
68197
68199
|
} else {
|
|
68198
|
-
result &= checkMode & 1 /* BivariantCallback */ &&
|
|
68200
|
+
result &= checkMode & 1 /* BivariantCallback */ && compareTypes(
|
|
68199
68201
|
targetReturnType,
|
|
68200
68202
|
sourceReturnType,
|
|
68201
68203
|
/*reportErrors*/
|
|
68202
68204
|
false
|
|
68203
|
-
) ||
|
|
68205
|
+
) || compareTypes(sourceReturnType, targetReturnType, reportErrors2);
|
|
68204
68206
|
if (!result && reportErrors2 && incompatibleErrorReporter) {
|
|
68205
68207
|
incompatibleErrorReporter(sourceReturnType, targetReturnType);
|
|
68206
68208
|
}
|
|
@@ -68208,7 +68210,7 @@ function createTypeChecker(host) {
|
|
|
68208
68210
|
}
|
|
68209
68211
|
return result;
|
|
68210
68212
|
}
|
|
68211
|
-
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter,
|
|
68213
|
+
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter, compareTypes) {
|
|
68212
68214
|
if (source.kind !== target.kind) {
|
|
68213
68215
|
if (reportErrors2) {
|
|
68214
68216
|
errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
|
|
@@ -68225,7 +68227,7 @@ function createTypeChecker(host) {
|
|
|
68225
68227
|
return 0 /* False */;
|
|
68226
68228
|
}
|
|
68227
68229
|
}
|
|
68228
|
-
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
68230
|
+
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors2) : 0 /* False */;
|
|
68229
68231
|
if (related === 0 /* False */ && reportErrors2) {
|
|
68230
68232
|
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
|
|
68231
68233
|
}
|
|
@@ -68259,18 +68261,18 @@ function createTypeChecker(host) {
|
|
|
68259
68261
|
if (strictNullChecks && type.flags & 1048576 /* Union */) {
|
|
68260
68262
|
if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
|
|
68261
68263
|
const types = type.types;
|
|
68262
|
-
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags &
|
|
68264
|
+
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ && types[1].flags & 65536 /* Null */ && some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
|
|
68263
68265
|
}
|
|
68264
68266
|
return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
|
|
68265
68267
|
}
|
|
68266
68268
|
return false;
|
|
68267
68269
|
}
|
|
68268
68270
|
function containsUndefinedType(type) {
|
|
68269
|
-
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags &
|
|
68271
|
+
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
|
|
68270
68272
|
}
|
|
68271
68273
|
function containsNonMissingUndefinedType(type) {
|
|
68272
68274
|
const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
|
|
68273
|
-
return !!(candidate.flags &
|
|
68275
|
+
return !!(candidate.flags & 32768 /* Undefined */) && candidate !== missingType;
|
|
68274
68276
|
}
|
|
68275
68277
|
function isStringIndexSignatureOnlyType(type) {
|
|
68276
68278
|
return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || type.flags & 3145728 /* UnionOrIntersection */ && every(type.types, isStringIndexSignatureOnlyType) || false;
|
|
@@ -68341,25 +68343,25 @@ function createTypeChecker(host) {
|
|
|
68341
68343
|
if (t & 1 /* Any */ || s & 131072 /* Never */ || source === wildcardType) return true;
|
|
68342
68344
|
if (t & 2 /* Unknown */ && !(relation === strictSubtypeRelation && s & 1 /* Any */)) return true;
|
|
68343
68345
|
if (t & 131072 /* Never */) return false;
|
|
68344
|
-
if (s &
|
|
68345
|
-
if (s &
|
|
68346
|
-
if (s &
|
|
68347
|
-
if (s &
|
|
68348
|
-
if (s &
|
|
68349
|
-
if (s &
|
|
68350
|
-
if (s &
|
|
68351
|
-
if (s &
|
|
68352
|
-
if (s &
|
|
68346
|
+
if (s & 402653316 /* StringLike */ && t & 4 /* String */) return true;
|
|
68347
|
+
if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true;
|
|
68348
|
+
if (s & 296 /* NumberLike */ && t & 8 /* Number */) return true;
|
|
68349
|
+
if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true;
|
|
68350
|
+
if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) return true;
|
|
68351
|
+
if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) return true;
|
|
68352
|
+
if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) return true;
|
|
68353
|
+
if (s & 32 /* Enum */ && t & 32 /* Enum */ && source.symbol.escapedName === target.symbol.escapedName && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
68354
|
+
if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) {
|
|
68353
68355
|
if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
68354
|
-
if (s &
|
|
68356
|
+
if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
68355
68357
|
}
|
|
68356
|
-
if (s &
|
|
68357
|
-
if (s &
|
|
68358
|
+
if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) return true;
|
|
68359
|
+
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) return true;
|
|
68358
68360
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(getObjectFlags(source) & 8192 /* FreshLiteral */))) return true;
|
|
68359
68361
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
68360
68362
|
if (s & 1 /* Any */) return true;
|
|
68361
|
-
if (s &
|
|
68362
|
-
if (s &
|
|
68363
|
+
if (s & 8 /* Number */ && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true;
|
|
68364
|
+
if (s & 256 /* NumberLiteral */ && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */ && source.value === target.value)) return true;
|
|
68363
68365
|
if (isUnknownLikeUnionType(target)) return true;
|
|
68364
68366
|
}
|
|
68365
68367
|
return false;
|
|
@@ -68380,7 +68382,7 @@ function createTypeChecker(host) {
|
|
|
68380
68382
|
}
|
|
68381
68383
|
} else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
|
|
68382
68384
|
if (source.flags !== target.flags) return false;
|
|
68383
|
-
if (source.flags &
|
|
68385
|
+
if (source.flags & 67358815 /* Singleton */) return true;
|
|
68384
68386
|
}
|
|
68385
68387
|
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
68386
68388
|
const related = relation.get(getRelationKey(
|
|
@@ -68434,7 +68436,7 @@ function createTypeChecker(host) {
|
|
|
68434
68436
|
let hasNullableOrEmpty = false;
|
|
68435
68437
|
for (const t of type.types) {
|
|
68436
68438
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
68437
|
-
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags &
|
|
68439
|
+
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
68438
68440
|
if (hasInstantiable && hasNullableOrEmpty) return true;
|
|
68439
68441
|
}
|
|
68440
68442
|
return false;
|
|
@@ -68704,7 +68706,7 @@ function createTypeChecker(host) {
|
|
|
68704
68706
|
} else if (exactOptionalPropertyTypes && getExactOptionalUnassignableProperties(source2, target2).length) {
|
|
68705
68707
|
message = Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties;
|
|
68706
68708
|
} else {
|
|
68707
|
-
if (source2.flags &
|
|
68709
|
+
if (source2.flags & 128 /* StringLiteral */ && target2.flags & 1048576 /* Union */) {
|
|
68708
68710
|
const suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source2, target2);
|
|
68709
68711
|
if (suggestedType) {
|
|
68710
68712
|
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType));
|
|
@@ -68773,7 +68775,7 @@ function createTypeChecker(host) {
|
|
|
68773
68775
|
if (source2 === target2) return -1 /* True */;
|
|
68774
68776
|
if (relation === identityRelation) {
|
|
68775
68777
|
if (source2.flags !== target2.flags) return 0 /* False */;
|
|
68776
|
-
if (source2.flags &
|
|
68778
|
+
if (source2.flags & 67358815 /* Singleton */) return -1 /* True */;
|
|
68777
68779
|
traceUnionsOrIntersectionsTooLarge(source2, target2);
|
|
68778
68780
|
return recursiveTypeRelatedTo(
|
|
68779
68781
|
source2,
|
|
@@ -68787,10 +68789,10 @@ function createTypeChecker(host) {
|
|
|
68787
68789
|
if (source2.flags & 262144 /* TypeParameter */ && getConstraintOfType(source2) === target2) {
|
|
68788
68790
|
return -1 /* True */;
|
|
68789
68791
|
}
|
|
68790
|
-
if (source2.flags &
|
|
68792
|
+
if (source2.flags & 470302716 /* DefinitelyNonNullable */ && target2.flags & 1048576 /* Union */) {
|
|
68791
68793
|
const types = target2.types;
|
|
68792
|
-
const candidate = types.length === 2 && types[0].flags &
|
|
68793
|
-
if (candidate && !(candidate.flags &
|
|
68794
|
+
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;
|
|
68795
|
+
if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
|
|
68794
68796
|
target2 = getNormalizedType(
|
|
68795
68797
|
candidate,
|
|
68796
68798
|
/*writing*/
|
|
@@ -69092,9 +69094,9 @@ function createTypeChecker(host) {
|
|
|
69092
69094
|
if (containsType(targetTypes, source2)) {
|
|
69093
69095
|
return -1 /* True */;
|
|
69094
69096
|
}
|
|
69095
|
-
if (relation !== comparableRelation && getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags &
|
|
69097
|
+
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 */)) {
|
|
69096
69098
|
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
69097
|
-
const primitive = source2.flags &
|
|
69099
|
+
const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
|
|
69098
69100
|
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
69099
69101
|
}
|
|
69100
69102
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
@@ -69189,8 +69191,8 @@ function createTypeChecker(host) {
|
|
|
69189
69191
|
return 0 /* False */;
|
|
69190
69192
|
}
|
|
69191
69193
|
function getUndefinedStrippedTargetIfNeeded(source2, target2) {
|
|
69192
|
-
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags &
|
|
69193
|
-
return extractTypesOfKind(target2, ~
|
|
69194
|
+
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags & 32768 /* Undefined */) && target2.types[0].flags & 32768 /* Undefined */) {
|
|
69195
|
+
return extractTypesOfKind(target2, ~32768 /* Undefined */);
|
|
69194
69196
|
}
|
|
69195
69197
|
return target2;
|
|
69196
69198
|
}
|
|
@@ -69532,7 +69534,7 @@ function createTypeChecker(host) {
|
|
|
69532
69534
|
const mappedKeys = [];
|
|
69533
69535
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
69534
69536
|
modifiersType,
|
|
69535
|
-
|
|
69537
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
69536
69538
|
/*stringsOnly*/
|
|
69537
69539
|
false,
|
|
69538
69540
|
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
@@ -69791,7 +69793,7 @@ function createTypeChecker(host) {
|
|
|
69791
69793
|
if (includeOptional ? !(filteredByApplicability.flags & 131072 /* Never */) : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
|
|
69792
69794
|
const templateType2 = getTemplateTypeFromMappedType(target2);
|
|
69793
69795
|
const typeParameter = getTypeParameterFromMappedType(target2);
|
|
69794
|
-
const nonNullComponent = extractTypesOfKind(templateType2, ~
|
|
69796
|
+
const nonNullComponent = extractTypesOfKind(templateType2, ~98304 /* Nullable */);
|
|
69795
69797
|
if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
|
|
69796
69798
|
if (result2 = isRelatedTo(source2, nonNullComponent.objectType, 2 /* Target */, reportErrors2)) {
|
|
69797
69799
|
return result2;
|
|
@@ -70452,7 +70454,7 @@ function createTypeChecker(host) {
|
|
|
70452
70454
|
for (const sourceProp of excludeProperties(getPropertiesOfType(source2), excludedProperties)) {
|
|
70453
70455
|
if (!getPropertyOfObjectType(target2, sourceProp.escapedName)) {
|
|
70454
70456
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
70455
|
-
if (!(sourceType.flags &
|
|
70457
|
+
if (!(sourceType.flags & 32768 /* Undefined */)) {
|
|
70456
70458
|
if (reportErrors2) {
|
|
70457
70459
|
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target2));
|
|
70458
70460
|
}
|
|
@@ -70680,9 +70682,9 @@ function createTypeChecker(host) {
|
|
|
70680
70682
|
if (isIgnoredJsxProperty(source2, prop)) {
|
|
70681
70683
|
continue;
|
|
70682
70684
|
}
|
|
70683
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
70685
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) {
|
|
70684
70686
|
const propType = getNonMissingTypeOfSymbol(prop);
|
|
70685
|
-
const type = exactOptionalPropertyTypes || propType.flags &
|
|
70687
|
+
const type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) ? propType : getTypeWithFacts(propType, 524288 /* NEUndefined */);
|
|
70686
70688
|
const related = isRelatedTo(
|
|
70687
70689
|
type,
|
|
70688
70690
|
targetInfo.type,
|
|
@@ -70796,7 +70798,7 @@ function createTypeChecker(host) {
|
|
|
70796
70798
|
}
|
|
70797
70799
|
}
|
|
70798
70800
|
function typeCouldHaveTopLevelSingletonTypes(type) {
|
|
70799
|
-
if (type.flags &
|
|
70801
|
+
if (type.flags & 16 /* Boolean */) {
|
|
70800
70802
|
return false;
|
|
70801
70803
|
}
|
|
70802
70804
|
if (type.flags & 3145728 /* UnionOrIntersection */) {
|
|
@@ -70815,7 +70817,7 @@ function createTypeChecker(host) {
|
|
|
70815
70817
|
return getPropertiesOfType(target).filter((targetProp) => isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)));
|
|
70816
70818
|
}
|
|
70817
70819
|
function isExactOptionalPropertyMismatch(source, target) {
|
|
70818
|
-
return !!source && !!target && maybeTypeOfKind(source,
|
|
70820
|
+
return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target);
|
|
70819
70821
|
}
|
|
70820
70822
|
function getExactOptionalProperties(type) {
|
|
70821
70823
|
return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
|
|
@@ -70941,7 +70943,7 @@ function createTypeChecker(host) {
|
|
|
70941
70943
|
}
|
|
70942
70944
|
function hasCovariantVoidArgument(typeArguments, variances) {
|
|
70943
70945
|
for (let i = 0; i < variances.length; i++) {
|
|
70944
|
-
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags &
|
|
70946
|
+
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) {
|
|
70945
70947
|
return true;
|
|
70946
70948
|
}
|
|
70947
70949
|
}
|
|
@@ -71098,7 +71100,7 @@ function createTypeChecker(host) {
|
|
|
71098
71100
|
function isPropertyIdenticalTo(sourceProp, targetProp) {
|
|
71099
71101
|
return compareProperties2(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
|
|
71100
71102
|
}
|
|
71101
|
-
function compareProperties2(sourceProp, targetProp,
|
|
71103
|
+
function compareProperties2(sourceProp, targetProp, compareTypes) {
|
|
71102
71104
|
if (sourceProp === targetProp) {
|
|
71103
71105
|
return -1 /* True */;
|
|
71104
71106
|
}
|
|
@@ -71119,7 +71121,7 @@ function createTypeChecker(host) {
|
|
|
71119
71121
|
if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
|
|
71120
71122
|
return 0 /* False */;
|
|
71121
71123
|
}
|
|
71122
|
-
return
|
|
71124
|
+
return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
71123
71125
|
}
|
|
71124
71126
|
function isMatchingSignature(source, target, partialMatch) {
|
|
71125
71127
|
const sourceParameterCount = getParameterCount(source);
|
|
@@ -71136,7 +71138,7 @@ function createTypeChecker(host) {
|
|
|
71136
71138
|
}
|
|
71137
71139
|
return false;
|
|
71138
71140
|
}
|
|
71139
|
-
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes,
|
|
71141
|
+
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
|
|
71140
71142
|
if (source === target) {
|
|
71141
71143
|
return -1 /* True */;
|
|
71142
71144
|
}
|
|
@@ -71151,7 +71153,7 @@ function createTypeChecker(host) {
|
|
|
71151
71153
|
for (let i = 0; i < target.typeParameters.length; i++) {
|
|
71152
71154
|
const s = source.typeParameters[i];
|
|
71153
71155
|
const t = target.typeParameters[i];
|
|
71154
|
-
if (!(s === t ||
|
|
71156
|
+
if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
|
|
71155
71157
|
return 0 /* False */;
|
|
71156
71158
|
}
|
|
71157
71159
|
}
|
|
@@ -71168,7 +71170,7 @@ function createTypeChecker(host) {
|
|
|
71168
71170
|
if (sourceThisType) {
|
|
71169
71171
|
const targetThisType = getThisTypeOfSignature(target);
|
|
71170
71172
|
if (targetThisType) {
|
|
71171
|
-
const related =
|
|
71173
|
+
const related = compareTypes(sourceThisType, targetThisType);
|
|
71172
71174
|
if (!related) {
|
|
71173
71175
|
return 0 /* False */;
|
|
71174
71176
|
}
|
|
@@ -71180,7 +71182,7 @@ function createTypeChecker(host) {
|
|
|
71180
71182
|
for (let i = 0; i < targetLen; i++) {
|
|
71181
71183
|
const s = getTypeAtPosition(source, i);
|
|
71182
71184
|
const t = getTypeAtPosition(target, i);
|
|
71183
|
-
const related =
|
|
71185
|
+
const related = compareTypes(t, s);
|
|
71184
71186
|
if (!related) {
|
|
71185
71187
|
return 0 /* False */;
|
|
71186
71188
|
}
|
|
@@ -71189,12 +71191,12 @@ function createTypeChecker(host) {
|
|
|
71189
71191
|
if (!ignoreReturnTypes) {
|
|
71190
71192
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
71191
71193
|
const targetTypePredicate = getTypePredicateOfSignature(target);
|
|
71192
|
-
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate,
|
|
71194
|
+
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
|
71193
71195
|
}
|
|
71194
71196
|
return result;
|
|
71195
71197
|
}
|
|
71196
|
-
function compareTypePredicatesIdentical(source, target,
|
|
71197
|
-
return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
71198
|
+
function compareTypePredicatesIdentical(source, target, compareTypes) {
|
|
71199
|
+
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 */;
|
|
71198
71200
|
}
|
|
71199
71201
|
function literalTypesWithSameBaseType(types) {
|
|
71200
71202
|
let commonBaseType;
|
|
@@ -71216,9 +71218,9 @@ function createTypeChecker(host) {
|
|
|
71216
71218
|
if (types.length === 1) {
|
|
71217
71219
|
return types[0];
|
|
71218
71220
|
}
|
|
71219
|
-
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags &
|
|
71221
|
+
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags & 98304 /* Nullable */))) : types;
|
|
71220
71222
|
const superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? getUnionType(primaryTypes) : reduceLeft(primaryTypes, (s, t) => isTypeSubtypeOf(s, t) ? t : s);
|
|
71221
|
-
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) &
|
|
71223
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* Nullable */);
|
|
71222
71224
|
}
|
|
71223
71225
|
function getCommonSubtype(types) {
|
|
71224
71226
|
return reduceLeft(types, (s, t) => isTypeSubtypeOf(t, s) ? t : s);
|
|
@@ -71239,10 +71241,10 @@ function createTypeChecker(host) {
|
|
|
71239
71241
|
return isArrayType(type) ? getTypeArguments(type)[0] : void 0;
|
|
71240
71242
|
}
|
|
71241
71243
|
function isArrayLikeType(type) {
|
|
71242
|
-
return isArrayType(type) || !(type.flags &
|
|
71244
|
+
return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType);
|
|
71243
71245
|
}
|
|
71244
71246
|
function isMutableArrayLikeType(type) {
|
|
71245
|
-
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ |
|
|
71247
|
+
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ | 98304 /* Nullable */)) && isTypeAssignableTo(type, anyArrayType);
|
|
71246
71248
|
}
|
|
71247
71249
|
function getSingleBaseForNonAugmentingSubtype(type) {
|
|
71248
71250
|
if (!(getObjectFlags(type) & 4 /* Reference */) || !(getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
@@ -71282,7 +71284,7 @@ function createTypeChecker(host) {
|
|
|
71282
71284
|
}
|
|
71283
71285
|
function isTupleLikeType(type) {
|
|
71284
71286
|
let lengthType;
|
|
71285
|
-
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags &
|
|
71287
|
+
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags & 256 /* NumberLiteral */));
|
|
71286
71288
|
}
|
|
71287
71289
|
function isArrayOrTupleLikeType(type) {
|
|
71288
71290
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
@@ -71298,10 +71300,10 @@ function createTypeChecker(host) {
|
|
|
71298
71300
|
return void 0;
|
|
71299
71301
|
}
|
|
71300
71302
|
function isNeitherUnitTypeNorNever(type) {
|
|
71301
|
-
return !(type.flags & (
|
|
71303
|
+
return !(type.flags & (109472 /* Unit */ | 131072 /* Never */));
|
|
71302
71304
|
}
|
|
71303
71305
|
function isUnitType(type) {
|
|
71304
|
-
return !!(type.flags &
|
|
71306
|
+
return !!(type.flags & 109472 /* Unit */);
|
|
71305
71307
|
}
|
|
71306
71308
|
function isUnitLikeType(type) {
|
|
71307
71309
|
const t = getBaseConstraintOrType(type);
|
|
@@ -71311,23 +71313,23 @@ function createTypeChecker(host) {
|
|
|
71311
71313
|
return type.flags & 2097152 /* Intersection */ ? find(type.types, isUnitType) || type : type;
|
|
71312
71314
|
}
|
|
71313
71315
|
function isLiteralType(type) {
|
|
71314
|
-
return type.flags &
|
|
71316
|
+
return type.flags & 16 /* Boolean */ ? true : type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : every(type.types, isUnitType) : isUnitType(type);
|
|
71315
71317
|
}
|
|
71316
71318
|
function getBaseTypeOfLiteralType(type) {
|
|
71317
|
-
return type.flags &
|
|
71319
|
+
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;
|
|
71318
71320
|
}
|
|
71319
71321
|
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
71320
71322
|
const key = `B${getTypeId(type)}`;
|
|
71321
71323
|
return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
71322
71324
|
}
|
|
71323
71325
|
function getBaseTypeOfLiteralTypeForComparison(type) {
|
|
71324
|
-
return type.flags & (
|
|
71326
|
+
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;
|
|
71325
71327
|
}
|
|
71326
71328
|
function getWidenedLiteralType(type) {
|
|
71327
|
-
return type.flags &
|
|
71329
|
+
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;
|
|
71328
71330
|
}
|
|
71329
71331
|
function getWidenedUniqueESSymbolType(type) {
|
|
71330
|
-
return type.flags &
|
|
71332
|
+
return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type;
|
|
71331
71333
|
}
|
|
71332
71334
|
function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
|
|
71333
71335
|
if (!isLiteralOfContextualType(type, contextualType)) {
|
|
@@ -71404,11 +71406,11 @@ function createTypeChecker(host) {
|
|
|
71404
71406
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
71405
71407
|
}
|
|
71406
71408
|
function getDefinitelyFalsyPartOfType(type) {
|
|
71407
|
-
return type.flags &
|
|
71409
|
+
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;
|
|
71408
71410
|
}
|
|
71409
71411
|
function getNullableType(type, flags) {
|
|
71410
|
-
const missing = flags & ~type.flags & (
|
|
71411
|
-
return missing === 0 ? type : missing ===
|
|
71412
|
+
const missing = flags & ~type.flags & (32768 /* Undefined */ | 65536 /* Null */);
|
|
71413
|
+
return missing === 0 ? type : missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]);
|
|
71412
71414
|
}
|
|
71413
71415
|
function getOptionalType(type, isProperty = false) {
|
|
71414
71416
|
Debug.assert(strictNullChecks);
|
|
@@ -71451,7 +71453,7 @@ function createTypeChecker(host) {
|
|
|
71451
71453
|
return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */);
|
|
71452
71454
|
}
|
|
71453
71455
|
function isCoercibleUnderDoubleEquals(source, target) {
|
|
71454
|
-
return (source.flags & (
|
|
71456
|
+
return (source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0 && (target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0;
|
|
71455
71457
|
}
|
|
71456
71458
|
function isObjectTypeWithInferableIndex(type) {
|
|
71457
71459
|
const objectFlags = getObjectFlags(type);
|
|
@@ -71584,7 +71586,7 @@ function createTypeChecker(host) {
|
|
|
71584
71586
|
return type.widened;
|
|
71585
71587
|
}
|
|
71586
71588
|
let result;
|
|
71587
|
-
if (type.flags & (1 /* Any */ |
|
|
71589
|
+
if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) {
|
|
71588
71590
|
result = anyType;
|
|
71589
71591
|
} else if (isObjectLiteralType2(type)) {
|
|
71590
71592
|
result = getWidenedTypeOfObjectLiteral(type, context);
|
|
@@ -71596,7 +71598,7 @@ function createTypeChecker(host) {
|
|
|
71596
71598
|
void 0,
|
|
71597
71599
|
type.types
|
|
71598
71600
|
);
|
|
71599
|
-
const widenedTypes = sameMap(type.types, (t) => t.flags &
|
|
71601
|
+
const widenedTypes = sameMap(type.types, (t) => t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext));
|
|
71600
71602
|
result = getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */);
|
|
71601
71603
|
} else if (type.flags & 2097152 /* Intersection */) {
|
|
71602
71604
|
result = getIntersectionType(sameMap(type.types, getWidenedType));
|
|
@@ -71796,18 +71798,18 @@ function createTypeChecker(host) {
|
|
|
71796
71798
|
callback(getReturnTypeOfSignature(source), targetReturnType);
|
|
71797
71799
|
}
|
|
71798
71800
|
}
|
|
71799
|
-
function createInferenceContext(typeParameters, signature, flags,
|
|
71800
|
-
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags,
|
|
71801
|
+
function createInferenceContext(typeParameters, signature, flags, compareTypes) {
|
|
71802
|
+
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
|
|
71801
71803
|
}
|
|
71802
71804
|
function cloneInferenceContext(context, extraFlags = 0) {
|
|
71803
71805
|
return context && createInferenceContextWorker(map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
|
|
71804
71806
|
}
|
|
71805
|
-
function createInferenceContextWorker(inferences, signature, flags,
|
|
71807
|
+
function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
|
|
71806
71808
|
const context = {
|
|
71807
71809
|
inferences,
|
|
71808
71810
|
signature,
|
|
71809
71811
|
flags,
|
|
71810
|
-
compareTypes
|
|
71812
|
+
compareTypes,
|
|
71811
71813
|
mapper: reportUnmeasurableMapper,
|
|
71812
71814
|
// initialize to a noop mapper so the context object is available, but the underlying object shape is right upon construction
|
|
71813
71815
|
nonFixingMapper: reportUnmeasurableMapper
|
|
@@ -71894,8 +71896,8 @@ function createTypeChecker(host) {
|
|
|
71894
71896
|
if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
|
|
71895
71897
|
return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
|
|
71896
71898
|
}
|
|
71897
|
-
const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 134217728 /* SingleSignatureType */ && !!length(type.outerTypeParameters) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags &
|
|
71898
|
-
if (type.flags &
|
|
71899
|
+
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));
|
|
71900
|
+
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
71899
71901
|
type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
71900
71902
|
}
|
|
71901
71903
|
return result;
|
|
@@ -71917,7 +71919,7 @@ function createTypeChecker(host) {
|
|
|
71917
71919
|
function createEmptyObjectTypeFromStringLiteral(type) {
|
|
71918
71920
|
const members = createSymbolTable();
|
|
71919
71921
|
forEachType(type, (t) => {
|
|
71920
|
-
if (!(t.flags &
|
|
71922
|
+
if (!(t.flags & 128 /* StringLiteral */)) {
|
|
71921
71923
|
return;
|
|
71922
71924
|
}
|
|
71923
71925
|
const name = escapeLeadingUnderscores(t.value);
|
|
@@ -71929,7 +71931,7 @@ function createTypeChecker(host) {
|
|
|
71929
71931
|
}
|
|
71930
71932
|
members.set(name, literalProp);
|
|
71931
71933
|
});
|
|
71932
|
-
const indexInfos = type.flags &
|
|
71934
|
+
const indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(
|
|
71933
71935
|
stringType,
|
|
71934
71936
|
emptyObjectType,
|
|
71935
71937
|
/*isReadonly*/
|
|
@@ -72031,7 +72033,7 @@ function createTypeChecker(host) {
|
|
|
72031
72033
|
yield targetProp;
|
|
72032
72034
|
} else if (matchDiscriminantProperties) {
|
|
72033
72035
|
const targetType = getTypeOfSymbol(targetProp);
|
|
72034
|
-
if (targetType.flags &
|
|
72036
|
+
if (targetType.flags & 109472 /* Unit */) {
|
|
72035
72037
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
72036
72038
|
if (!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) {
|
|
72037
72039
|
yield targetProp;
|
|
@@ -72094,7 +72096,7 @@ function createTypeChecker(host) {
|
|
|
72094
72096
|
if (target.flags & 1 /* Any */) {
|
|
72095
72097
|
return true;
|
|
72096
72098
|
}
|
|
72097
|
-
if (target.flags & (
|
|
72099
|
+
if (target.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
72098
72100
|
return isTypeAssignableTo(source, target);
|
|
72099
72101
|
}
|
|
72100
72102
|
if (target.flags & 268435456 /* StringMapping */) {
|
|
@@ -72112,20 +72114,20 @@ function createTypeChecker(host) {
|
|
|
72112
72114
|
if (target.flags & 2097152 /* Intersection */) {
|
|
72113
72115
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
72114
72116
|
}
|
|
72115
|
-
if (target.flags &
|
|
72117
|
+
if (target.flags & 4 /* String */ || isTypeAssignableTo(source, target)) {
|
|
72116
72118
|
return true;
|
|
72117
72119
|
}
|
|
72118
|
-
if (source.flags &
|
|
72120
|
+
if (source.flags & 128 /* StringLiteral */) {
|
|
72119
72121
|
const value = source.value;
|
|
72120
|
-
return !!(target.flags &
|
|
72122
|
+
return !!(target.flags & 8 /* Number */ && isValidNumberString(
|
|
72121
72123
|
value,
|
|
72122
72124
|
/*roundTripOnly*/
|
|
72123
72125
|
false
|
|
72124
|
-
) || target.flags &
|
|
72126
|
+
) || target.flags & 64 /* BigInt */ && isValidBigIntString(
|
|
72125
72127
|
value,
|
|
72126
72128
|
/*roundTripOnly*/
|
|
72127
72129
|
false
|
|
72128
|
-
) || target.flags & (
|
|
72130
|
+
) || target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(source, target) || target.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source, target));
|
|
72129
72131
|
}
|
|
72130
72132
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
72131
72133
|
const texts = source.texts;
|
|
@@ -72134,7 +72136,7 @@ function createTypeChecker(host) {
|
|
|
72134
72136
|
return false;
|
|
72135
72137
|
}
|
|
72136
72138
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
72137
|
-
return source.flags &
|
|
72139
|
+
return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arrayIsEqualTo(source.texts, target.texts) ? map(source.types, (s, i) => {
|
|
72138
72140
|
return isTypeAssignableTo(getBaseConstraintOrType(s), getBaseConstraintOrType(target.types[i])) ? s : getStringLikeTypeForType(s);
|
|
72139
72141
|
}) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
|
|
72140
72142
|
}
|
|
@@ -72143,7 +72145,7 @@ function createTypeChecker(host) {
|
|
|
72143
72145
|
return !!inferences && every(inferences, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]));
|
|
72144
72146
|
}
|
|
72145
72147
|
function getStringLikeTypeForType(type) {
|
|
72146
|
-
return type.flags & (1 /* Any */ |
|
|
72148
|
+
return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
|
|
72147
72149
|
}
|
|
72148
72150
|
function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) {
|
|
72149
72151
|
const lastSourceIndex = sourceTexts.length - 1;
|
|
@@ -72338,7 +72340,7 @@ function createTypeChecker(host) {
|
|
|
72338
72340
|
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
|
|
72339
72341
|
} else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
|
|
72340
72342
|
inferFromContravariantTypes(source.type, target.type);
|
|
72341
|
-
} else if ((isLiteralType(source) || source.flags &
|
|
72343
|
+
} else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) {
|
|
72342
72344
|
const empty = createEmptyObjectTypeFromStringLiteral(source);
|
|
72343
72345
|
inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
72344
72346
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
@@ -72593,29 +72595,29 @@ function createTypeChecker(host) {
|
|
|
72593
72595
|
for (let i = 0; i < types.length; i++) {
|
|
72594
72596
|
const source2 = matches ? matches[i] : neverType;
|
|
72595
72597
|
const target2 = types[i];
|
|
72596
|
-
if (source2.flags &
|
|
72598
|
+
if (source2.flags & 128 /* StringLiteral */ && target2.flags & 8650752 /* TypeVariable */) {
|
|
72597
72599
|
const inferenceContext = getInferenceInfoForType(target2);
|
|
72598
72600
|
const constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : void 0;
|
|
72599
72601
|
if (constraint && !isTypeAny(constraint)) {
|
|
72600
72602
|
const constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
|
|
72601
72603
|
let allTypeFlags = reduceLeft(constraintTypes, (flags, t) => flags | t.flags, 0);
|
|
72602
|
-
if (!(allTypeFlags &
|
|
72604
|
+
if (!(allTypeFlags & 4 /* String */)) {
|
|
72603
72605
|
const str = source2.value;
|
|
72604
|
-
if (allTypeFlags &
|
|
72606
|
+
if (allTypeFlags & 296 /* NumberLike */ && !isValidNumberString(
|
|
72605
72607
|
str,
|
|
72606
72608
|
/*roundTripOnly*/
|
|
72607
72609
|
true
|
|
72608
72610
|
)) {
|
|
72609
|
-
allTypeFlags &= ~
|
|
72611
|
+
allTypeFlags &= ~296 /* NumberLike */;
|
|
72610
72612
|
}
|
|
72611
|
-
if (allTypeFlags &
|
|
72613
|
+
if (allTypeFlags & 2112 /* BigIntLike */ && !isValidBigIntString(
|
|
72612
72614
|
str,
|
|
72613
72615
|
/*roundTripOnly*/
|
|
72614
72616
|
true
|
|
72615
72617
|
)) {
|
|
72616
|
-
allTypeFlags &= ~
|
|
72618
|
+
allTypeFlags &= ~2112 /* BigIntLike */;
|
|
72617
72619
|
}
|
|
72618
|
-
const matchingType = reduceLeft(constraintTypes, (left, right) => !(right.flags & allTypeFlags) ? left : left.flags &
|
|
72620
|
+
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);
|
|
72619
72621
|
if (!(matchingType.flags & 131072 /* Never */)) {
|
|
72620
72622
|
inferFromTypes(matchingType, target2);
|
|
72621
72623
|
continue;
|
|
@@ -72775,7 +72777,7 @@ function createTypeChecker(host) {
|
|
|
72775
72777
|
for (const targetInfo of indexInfos) {
|
|
72776
72778
|
const propTypes = [];
|
|
72777
72779
|
for (const prop of getPropertiesOfType(source)) {
|
|
72778
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
72780
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) {
|
|
72779
72781
|
const propType = getTypeOfSymbol(prop);
|
|
72780
72782
|
propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType);
|
|
72781
72783
|
}
|
|
@@ -72799,7 +72801,7 @@ function createTypeChecker(host) {
|
|
|
72799
72801
|
}
|
|
72800
72802
|
}
|
|
72801
72803
|
function isTypeOrBaseIdenticalTo(s, t) {
|
|
72802
|
-
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags &
|
|
72804
|
+
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */);
|
|
72803
72805
|
}
|
|
72804
72806
|
function isTypeCloselyMatchedBy(s, t) {
|
|
72805
72807
|
return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
|
|
@@ -73051,7 +73053,7 @@ function createTypeChecker(host) {
|
|
|
73051
73053
|
return void 0;
|
|
73052
73054
|
}
|
|
73053
73055
|
function tryGetNameFromType(type) {
|
|
73054
|
-
return type.flags &
|
|
73056
|
+
return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : type.flags & 384 /* StringOrNumberLiteral */ ? escapeLeadingUnderscores("" + type.value) : void 0;
|
|
73055
73057
|
}
|
|
73056
73058
|
function tryGetElementAccessExpressionName(node) {
|
|
73057
73059
|
return isStringOrNumericLiteralLike(node.argumentExpression) ? escapeLeadingUnderscores(node.argumentExpression.text) : isEntityNameExpression(node.argumentExpression) ? tryGetNameFromEntityNameExpression(node.argumentExpression) : void 0;
|
|
@@ -73230,7 +73232,7 @@ function createTypeChecker(host) {
|
|
|
73230
73232
|
}
|
|
73231
73233
|
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
73232
73234
|
const filteredType = filterType(declaredType, (t) => typeMaybeAssignableTo(assignedType, t));
|
|
73233
|
-
const reducedType = assignedType.flags &
|
|
73235
|
+
const reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
73234
73236
|
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
73235
73237
|
}
|
|
73236
73238
|
function isFunctionObjectType(type) {
|
|
@@ -73251,31 +73253,31 @@ function createTypeChecker(host) {
|
|
|
73251
73253
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
73252
73254
|
}
|
|
73253
73255
|
const flags = type.flags;
|
|
73254
|
-
if (flags & (
|
|
73256
|
+
if (flags & (4 /* String */ | 268435456 /* StringMapping */)) {
|
|
73255
73257
|
return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
|
|
73256
73258
|
}
|
|
73257
|
-
if (flags & (
|
|
73258
|
-
const isEmpty = flags &
|
|
73259
|
+
if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) {
|
|
73260
|
+
const isEmpty = flags & 128 /* StringLiteral */ && type.value === "";
|
|
73259
73261
|
return strictNullChecks ? isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
|
|
73260
73262
|
}
|
|
73261
|
-
if (flags & (
|
|
73263
|
+
if (flags & (8 /* Number */ | 32 /* Enum */)) {
|
|
73262
73264
|
return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */;
|
|
73263
73265
|
}
|
|
73264
|
-
if (flags &
|
|
73266
|
+
if (flags & 256 /* NumberLiteral */) {
|
|
73265
73267
|
const isZero = type.value === 0;
|
|
73266
73268
|
return strictNullChecks ? isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */;
|
|
73267
73269
|
}
|
|
73268
|
-
if (flags &
|
|
73270
|
+
if (flags & 64 /* BigInt */) {
|
|
73269
73271
|
return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */;
|
|
73270
73272
|
}
|
|
73271
|
-
if (flags &
|
|
73273
|
+
if (flags & 2048 /* BigIntLiteral */) {
|
|
73272
73274
|
const isZero = isZeroBigInt(type);
|
|
73273
73275
|
return strictNullChecks ? isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */;
|
|
73274
73276
|
}
|
|
73275
|
-
if (flags &
|
|
73277
|
+
if (flags & 16 /* Boolean */) {
|
|
73276
73278
|
return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */;
|
|
73277
73279
|
}
|
|
73278
|
-
if (flags &
|
|
73280
|
+
if (flags & 528 /* BooleanLike */) {
|
|
73279
73281
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
73280
73282
|
}
|
|
73281
73283
|
if (flags & 524288 /* Object */) {
|
|
@@ -73285,16 +73287,16 @@ function createTypeChecker(host) {
|
|
|
73285
73287
|
}
|
|
73286
73288
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
73287
73289
|
}
|
|
73288
|
-
if (flags &
|
|
73290
|
+
if (flags & 16384 /* Void */) {
|
|
73289
73291
|
return 9830144 /* VoidFacts */;
|
|
73290
73292
|
}
|
|
73291
|
-
if (flags &
|
|
73293
|
+
if (flags & 32768 /* Undefined */) {
|
|
73292
73294
|
return 26607360 /* UndefinedFacts */;
|
|
73293
73295
|
}
|
|
73294
|
-
if (flags &
|
|
73296
|
+
if (flags & 65536 /* Null */) {
|
|
73295
73297
|
return 42917664 /* NullFacts */;
|
|
73296
73298
|
}
|
|
73297
|
-
if (flags &
|
|
73299
|
+
if (flags & 12288 /* ESSymbolLike */) {
|
|
73298
73300
|
return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
|
|
73299
73301
|
}
|
|
73300
73302
|
if (flags & 67108864 /* NonPrimitive */) {
|
|
@@ -73517,7 +73519,7 @@ function createTypeChecker(host) {
|
|
|
73517
73519
|
}
|
|
73518
73520
|
return true;
|
|
73519
73521
|
}
|
|
73520
|
-
if (source.flags &
|
|
73522
|
+
if (source.flags & 1056 /* EnumLike */ && getBaseTypeOfEnumLikeType(source) === target) {
|
|
73521
73523
|
return true;
|
|
73522
73524
|
}
|
|
73523
73525
|
return containsType(target.types, source);
|
|
@@ -73602,8 +73604,8 @@ function createTypeChecker(host) {
|
|
|
73602
73604
|
return filterType(type, (t) => (t.flags & kind) !== 0);
|
|
73603
73605
|
}
|
|
73604
73606
|
function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
|
|
73605
|
-
if (maybeTypeOfKind(typeWithPrimitives,
|
|
73606
|
-
return mapType(typeWithPrimitives, (t) => t.flags &
|
|
73607
|
+
if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) {
|
|
73608
|
+
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);
|
|
73607
73609
|
}
|
|
73608
73610
|
return typeWithPrimitives;
|
|
73609
73611
|
}
|
|
@@ -73658,7 +73660,7 @@ function createTypeChecker(host) {
|
|
|
73658
73660
|
const root = getReferenceRoot(node);
|
|
73659
73661
|
const parent2 = root.parent;
|
|
73660
73662
|
const isLengthPushOrUnshift = isPropertyAccessExpression(parent2) && (parent2.name.escapedText === "length" || parent2.parent.kind === 213 /* CallExpression */ && isIdentifier(parent2.name) && isPushOrUnshiftIdentifier(parent2.name));
|
|
73661
|
-
const isElementAssignment = parent2.kind === 212 /* ElementAccessExpression */ && parent2.expression === root && parent2.parent.kind === 226 /* BinaryExpression */ && parent2.parent.operatorToken.kind === 64 /* EqualsToken */ && parent2.parent.left === parent2 && !isAssignmentTarget(parent2.parent) && isTypeAssignableToKind(getTypeOfExpression(parent2.argumentExpression),
|
|
73663
|
+
const isElementAssignment = parent2.kind === 212 /* ElementAccessExpression */ && parent2.expression === root && parent2.parent.kind === 226 /* BinaryExpression */ && parent2.parent.operatorToken.kind === 64 /* EqualsToken */ && parent2.parent.left === parent2 && !isAssignmentTarget(parent2.parent) && isTypeAssignableToKind(getTypeOfExpression(parent2.argumentExpression), 296 /* NumberLike */);
|
|
73662
73664
|
return isLengthPushOrUnshift || isElementAssignment;
|
|
73663
73665
|
}
|
|
73664
73666
|
function isDeclarationWithExplicitTypeAnnotation(node) {
|
|
@@ -74146,7 +74148,7 @@ function createTypeChecker(host) {
|
|
|
74146
74148
|
}
|
|
74147
74149
|
} else {
|
|
74148
74150
|
const indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
|
|
74149
|
-
if (isTypeAssignableToKind(indexType,
|
|
74151
|
+
if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) {
|
|
74150
74152
|
evolvedType2 = addEvolvingArrayElementType(evolvedType2, node.right);
|
|
74151
74153
|
}
|
|
74152
74154
|
}
|
|
@@ -74184,9 +74186,9 @@ function createTypeChecker(host) {
|
|
|
74184
74186
|
} else {
|
|
74185
74187
|
if (strictNullChecks) {
|
|
74186
74188
|
if (optionalChainContainsReference(expr, reference)) {
|
|
74187
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (
|
|
74189
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)));
|
|
74188
74190
|
} else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
|
|
74189
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags &
|
|
74191
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"));
|
|
74190
74192
|
}
|
|
74191
74193
|
}
|
|
74192
74194
|
const access = getDiscriminantPropertyAccess(expr, type);
|
|
@@ -74360,7 +74362,7 @@ function createTypeChecker(host) {
|
|
|
74360
74362
|
return type;
|
|
74361
74363
|
}
|
|
74362
74364
|
const optionalChain = isOptionalChain(access);
|
|
74363
|
-
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type,
|
|
74365
|
+
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type, 98304 /* Nullable */);
|
|
74364
74366
|
let propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName);
|
|
74365
74367
|
if (!propType) {
|
|
74366
74368
|
return type;
|
|
@@ -74582,7 +74584,7 @@ function createTypeChecker(host) {
|
|
|
74582
74584
|
}
|
|
74583
74585
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
74584
74586
|
const equalsOperator = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
74585
|
-
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ?
|
|
74587
|
+
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */;
|
|
74586
74588
|
const valueType = getTypeOfExpression(value);
|
|
74587
74589
|
const removeNullable = equalsOperator !== assumeTrue && everyType(valueType, (t) => !!(t.flags & nullableFlags)) || equalsOperator === assumeTrue && everyType(valueType, (t) => !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)));
|
|
74588
74590
|
return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
|
|
@@ -74596,11 +74598,11 @@ function createTypeChecker(host) {
|
|
|
74596
74598
|
}
|
|
74597
74599
|
const valueType = getTypeOfExpression(value);
|
|
74598
74600
|
const doubleEquals = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */;
|
|
74599
|
-
if (valueType.flags &
|
|
74601
|
+
if (valueType.flags & 98304 /* Nullable */) {
|
|
74600
74602
|
if (!strictNullChecks) {
|
|
74601
74603
|
return type;
|
|
74602
74604
|
}
|
|
74603
|
-
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags &
|
|
74605
|
+
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
|
|
74604
74606
|
return getAdjustedTypeWithFacts(type, facts);
|
|
74605
74607
|
}
|
|
74606
74608
|
if (assumeTrue) {
|
|
@@ -74675,7 +74677,7 @@ function createTypeChecker(host) {
|
|
|
74675
74677
|
if (!hasDefaultClause) {
|
|
74676
74678
|
return caseType;
|
|
74677
74679
|
}
|
|
74678
|
-
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags &
|
|
74680
|
+
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags & 32768 /* Undefined */ ? undefinedType : getRegularTypeOfLiteralType(extractUnitType(t)))));
|
|
74679
74681
|
return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
|
|
74680
74682
|
}
|
|
74681
74683
|
function narrowTypeByTypeName(type, typeName) {
|
|
@@ -75166,10 +75168,10 @@ function createTypeChecker(host) {
|
|
|
75166
75168
|
return parent2.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 166 /* QualifiedName */ || parent2.kind === 213 /* CallExpression */ && parent2.expression === node || parent2.kind === 214 /* NewExpression */ && parent2.expression === node || parent2.kind === 212 /* ElementAccessExpression */ && parent2.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent2.argumentExpression)));
|
|
75167
75169
|
}
|
|
75168
75170
|
function isGenericTypeWithUnionConstraint(type) {
|
|
75169
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (
|
|
75171
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
|
|
75170
75172
|
}
|
|
75171
75173
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
75172
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type),
|
|
75174
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
75173
75175
|
}
|
|
75174
75176
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
75175
75177
|
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 32 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
|
|
@@ -75728,7 +75730,7 @@ function createTypeChecker(host) {
|
|
|
75728
75730
|
flowContainer = getControlFlowContainer(flowContainer);
|
|
75729
75731
|
}
|
|
75730
75732
|
const isNeverInitialized = immediateDeclaration && isVariableDeclaration(immediateDeclaration) && !immediateDeclaration.initializer && !immediateDeclaration.exclamationToken && isMutableLocalVariableDeclaration(immediateDeclaration) && !isSymbolAssignedDefinitely(symbol);
|
|
75731
|
-
const assumeInitialized = isParameter2 || isAlias || isOuterVariable && !isNeverInitialized || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ |
|
|
75733
|
+
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 */;
|
|
75732
75734
|
const initialType = isAutomaticTypeInNonNull ? undefinedType : assumeInitialized ? isParameter2 ? removeOptionalityFromDeclaredType(type, declaration) : type : typeIsAutomatic ? undefinedType : getOptionalType(type);
|
|
75733
75735
|
const flowType = isAutomaticTypeInNonNull ? getNonNullableType(getFlowTypeOfReference(node, type, initialType, flowContainer)) : getFlowTypeOfReference(node, type, initialType, flowContainer);
|
|
75734
75736
|
if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
|
|
@@ -76416,7 +76418,7 @@ function createTypeChecker(host) {
|
|
|
76416
76418
|
const functionFlags = getFunctionFlags(functionDecl);
|
|
76417
76419
|
if (functionFlags & 1 /* Generator */) {
|
|
76418
76420
|
return filterType(returnType2, (t) => {
|
|
76419
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
76421
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || checkGeneratorInstantiationAssignabilityToReturnType(
|
|
76420
76422
|
t,
|
|
76421
76423
|
functionFlags,
|
|
76422
76424
|
/*errorNode*/
|
|
@@ -76426,7 +76428,7 @@ function createTypeChecker(host) {
|
|
|
76426
76428
|
}
|
|
76427
76429
|
if (functionFlags & 2 /* Async */) {
|
|
76428
76430
|
return filterType(returnType2, (t) => {
|
|
76429
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
76431
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || !!getAwaitedTypeOfPromise(t);
|
|
76430
76432
|
});
|
|
76431
76433
|
}
|
|
76432
76434
|
return returnType2;
|
|
@@ -77185,7 +77187,7 @@ function createTypeChecker(host) {
|
|
|
77185
77187
|
return getOrCreateTypeFromSignature(fakeSignature);
|
|
77186
77188
|
}
|
|
77187
77189
|
const tagType = checkExpressionCached(context.tagName);
|
|
77188
|
-
if (tagType.flags &
|
|
77190
|
+
if (tagType.flags & 128 /* StringLiteral */) {
|
|
77189
77191
|
const result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
|
|
77190
77192
|
if (!result) {
|
|
77191
77193
|
return errorType;
|
|
@@ -77557,7 +77559,7 @@ function createTypeChecker(host) {
|
|
|
77557
77559
|
}
|
|
77558
77560
|
}
|
|
77559
77561
|
function isNumericComputedName(name) {
|
|
77560
|
-
return isTypeAssignableToKind(checkComputedPropertyName(name),
|
|
77562
|
+
return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */);
|
|
77561
77563
|
}
|
|
77562
77564
|
function checkComputedPropertyName(node) {
|
|
77563
77565
|
const links = getNodeLinks(node.expression);
|
|
@@ -77575,7 +77577,7 @@ function createTypeChecker(host) {
|
|
|
77575
77577
|
getNodeLinks(node.parent.parent).flags |= 32768 /* BlockScopedBindingInLoop */;
|
|
77576
77578
|
}
|
|
77577
77579
|
}
|
|
77578
|
-
if (links.resolvedType.flags &
|
|
77580
|
+
if (links.resolvedType.flags & 98304 /* Nullable */ || !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
|
|
77579
77581
|
error2(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
|
|
77580
77582
|
}
|
|
77581
77583
|
}
|
|
@@ -77589,7 +77591,7 @@ function createTypeChecker(host) {
|
|
|
77589
77591
|
function isSymbolWithSymbolName(symbol) {
|
|
77590
77592
|
var _a;
|
|
77591
77593
|
const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
|
|
77592
|
-
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name),
|
|
77594
|
+
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */);
|
|
77593
77595
|
}
|
|
77594
77596
|
function isSymbolWithComputedName(symbol) {
|
|
77595
77597
|
var _a;
|
|
@@ -77745,7 +77747,7 @@ function createTypeChecker(host) {
|
|
|
77745
77747
|
Debug.assert(memberDecl.kind === 177 /* GetAccessor */ || memberDecl.kind === 178 /* SetAccessor */);
|
|
77746
77748
|
checkNodeDeferred(memberDecl);
|
|
77747
77749
|
}
|
|
77748
|
-
if (computedNameType && !(computedNameType.flags &
|
|
77750
|
+
if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) {
|
|
77749
77751
|
if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
|
|
77750
77752
|
if (isTypeAssignableTo(computedNameType, numberType)) {
|
|
77751
77753
|
hasComputedNumberProperty = true;
|
|
@@ -78158,9 +78160,9 @@ function createTypeChecker(host) {
|
|
|
78158
78160
|
return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
|
|
78159
78161
|
}
|
|
78160
78162
|
function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
|
|
78161
|
-
if (elementType.flags &
|
|
78163
|
+
if (elementType.flags & 4 /* String */) {
|
|
78162
78164
|
return [anySignature];
|
|
78163
|
-
} else if (elementType.flags &
|
|
78165
|
+
} else if (elementType.flags & 128 /* StringLiteral */) {
|
|
78164
78166
|
const intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
|
|
78165
78167
|
if (!intrinsicType) {
|
|
78166
78168
|
error2(caller, Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
|
|
@@ -78542,7 +78544,7 @@ function createTypeChecker(host) {
|
|
|
78542
78544
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
78543
78545
|
reportError(node, facts);
|
|
78544
78546
|
const t = getNonNullableType(type);
|
|
78545
|
-
return t.flags & (
|
|
78547
|
+
return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t;
|
|
78546
78548
|
}
|
|
78547
78549
|
return type;
|
|
78548
78550
|
}
|
|
@@ -78551,7 +78553,7 @@ function createTypeChecker(host) {
|
|
|
78551
78553
|
}
|
|
78552
78554
|
function checkNonNullNonVoidType(type, node) {
|
|
78553
78555
|
const nonNullType = checkNonNullType(type, node);
|
|
78554
|
-
if (nonNullType.flags &
|
|
78556
|
+
if (nonNullType.flags & 16384 /* Void */) {
|
|
78555
78557
|
if (isEntityNameExpression(node)) {
|
|
78556
78558
|
const nodeText2 = entityNameToString(node);
|
|
78557
78559
|
if (isIdentifier(node) && nodeText2 === "undefined") {
|
|
@@ -79046,15 +79048,13 @@ function createTypeChecker(host) {
|
|
|
79046
79048
|
function getSuggestionForSymbolNameLookup(symbols, name, meaning) {
|
|
79047
79049
|
const symbol = getSymbol2(symbols, name, meaning);
|
|
79048
79050
|
if (symbol) return symbol;
|
|
79049
|
-
let candidates;
|
|
79051
|
+
let candidates = arrayFrom(symbols.values()).sort(compareSymbols);
|
|
79050
79052
|
if (symbols === globals) {
|
|
79051
79053
|
const primitives = mapDefined(
|
|
79052
79054
|
["string", "number", "boolean", "object", "bigint", "symbol"],
|
|
79053
79055
|
(s) => symbols.has(s.charAt(0).toUpperCase() + s.slice(1)) ? createSymbol(524288 /* TypeAlias */, s) : void 0
|
|
79054
79056
|
);
|
|
79055
|
-
candidates = primitives
|
|
79056
|
-
} else {
|
|
79057
|
-
candidates = arrayFrom(symbols.values());
|
|
79057
|
+
candidates = concatenate(candidates, primitives);
|
|
79058
79058
|
}
|
|
79059
79059
|
return getSpellingSuggestionForName(unescapeLeadingUnderscores(name), candidates, meaning);
|
|
79060
79060
|
}
|
|
@@ -79074,7 +79074,7 @@ function createTypeChecker(host) {
|
|
|
79074
79074
|
return result;
|
|
79075
79075
|
}
|
|
79076
79076
|
function getSuggestedSymbolForNonexistentModule(name, targetModule) {
|
|
79077
|
-
return targetModule.exports && getSpellingSuggestionForName(idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */);
|
|
79077
|
+
return targetModule.exports && getSpellingSuggestionForName(idText(name), getExportsOfModuleAsArray(targetModule).sort(compareSymbols), 2623475 /* ModuleMember */);
|
|
79078
79078
|
}
|
|
79079
79079
|
function getSuggestionForNonexistentIndexSignature(objectType, expr, keyedType) {
|
|
79080
79080
|
function hasProp(name) {
|
|
@@ -79098,7 +79098,7 @@ function createTypeChecker(host) {
|
|
|
79098
79098
|
return suggestion;
|
|
79099
79099
|
}
|
|
79100
79100
|
function getSuggestedTypeForNonexistentStringLiteralType(source, target) {
|
|
79101
|
-
const candidates = target.types.filter((type) => !!(type.flags &
|
|
79101
|
+
const candidates = target.types.filter((type) => !!(type.flags & 128 /* StringLiteral */));
|
|
79102
79102
|
return getSpellingSuggestion(source.value, candidates, (type) => type.value);
|
|
79103
79103
|
}
|
|
79104
79104
|
function getSpellingSuggestionForName(name, symbols, meaning) {
|
|
@@ -79330,10 +79330,10 @@ function createTypeChecker(host) {
|
|
|
79330
79330
|
return findIndex(args, isSpreadArgument);
|
|
79331
79331
|
}
|
|
79332
79332
|
function acceptsVoid(t) {
|
|
79333
|
-
return !!(t.flags &
|
|
79333
|
+
return !!(t.flags & 16384 /* Void */);
|
|
79334
79334
|
}
|
|
79335
79335
|
function acceptsVoidUndefinedUnknownOrAny(t) {
|
|
79336
|
-
return !!(t.flags & (
|
|
79336
|
+
return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */));
|
|
79337
79337
|
}
|
|
79338
79338
|
function hasCorrectArity(node, args, signature, signatureHelpTrailingComma = false) {
|
|
79339
79339
|
if (isJsxOpeningFragment(node)) return true;
|
|
@@ -79432,8 +79432,8 @@ function createTypeChecker(host) {
|
|
|
79432
79432
|
}
|
|
79433
79433
|
return void 0;
|
|
79434
79434
|
}
|
|
79435
|
-
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext,
|
|
79436
|
-
const context = createInferenceContext(getTypeParametersForMapper(signature), signature, 0 /* None */,
|
|
79435
|
+
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
|
|
79436
|
+
const context = createInferenceContext(getTypeParametersForMapper(signature), signature, 0 /* None */, compareTypes);
|
|
79437
79437
|
const restType = getEffectiveRestType(contextualSignature);
|
|
79438
79438
|
const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
|
|
79439
79439
|
const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
|
|
@@ -81168,10 +81168,10 @@ function createTypeChecker(host) {
|
|
|
81168
81168
|
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
|
|
81169
81169
|
}
|
|
81170
81170
|
const returnType = getReturnTypeOfSignature(signature);
|
|
81171
|
-
if (returnType.flags &
|
|
81171
|
+
if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) {
|
|
81172
81172
|
return getESSymbolLikeTypeForNode(walkUpParenthesizedExpressions(node.parent));
|
|
81173
81173
|
}
|
|
81174
|
-
if (node.kind === 213 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 244 /* ExpressionStatement */ && returnType.flags &
|
|
81174
|
+
if (node.kind === 213 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 244 /* ExpressionStatement */ && returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) {
|
|
81175
81175
|
if (!isDottedName(node.expression)) {
|
|
81176
81176
|
error2(node.expression, Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
|
|
81177
81177
|
} else if (!getEffectsSignature(node)) {
|
|
@@ -81261,7 +81261,7 @@ function createTypeChecker(host) {
|
|
|
81261
81261
|
for (let i = 2; i < node.arguments.length; ++i) {
|
|
81262
81262
|
checkExpressionCached(node.arguments[i]);
|
|
81263
81263
|
}
|
|
81264
|
-
if (specifierType.flags &
|
|
81264
|
+
if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) {
|
|
81265
81265
|
error2(specifier, Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
|
|
81266
81266
|
}
|
|
81267
81267
|
if (optionsType) {
|
|
@@ -81270,7 +81270,7 @@ function createTypeChecker(host) {
|
|
|
81270
81270
|
true
|
|
81271
81271
|
);
|
|
81272
81272
|
if (importCallOptionsType !== emptyObjectType) {
|
|
81273
|
-
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType,
|
|
81273
|
+
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]);
|
|
81274
81274
|
}
|
|
81275
81275
|
}
|
|
81276
81276
|
const moduleSymbol = resolveExternalModuleName(node, specifier);
|
|
@@ -82316,7 +82316,7 @@ function createTypeChecker(host) {
|
|
|
82316
82316
|
/*contextFlags*/
|
|
82317
82317
|
void 0
|
|
82318
82318
|
);
|
|
82319
|
-
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags &
|
|
82319
|
+
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 32768 /* Undefined */ ? undefinedType : voidType;
|
|
82320
82320
|
return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
|
|
82321
82321
|
// Async function
|
|
82322
82322
|
returnType2
|
|
@@ -82562,10 +82562,10 @@ function createTypeChecker(host) {
|
|
|
82562
82562
|
true
|
|
82563
82563
|
);
|
|
82564
82564
|
const returnType = checkExpressionCached(expr);
|
|
82565
|
-
if (!(returnType.flags &
|
|
82565
|
+
if (!(returnType.flags & 16 /* Boolean */)) return void 0;
|
|
82566
82566
|
return forEach(func.parameters, (param, i) => {
|
|
82567
82567
|
const initType = getTypeOfSymbol(param.symbol);
|
|
82568
|
-
if (!initType || initType.flags &
|
|
82568
|
+
if (!initType || initType.flags & 16 /* Boolean */ || !isIdentifier(param.name) || isSymbolAssigned(param.symbol) || isRestParameter(param)) {
|
|
82569
82569
|
return;
|
|
82570
82570
|
}
|
|
82571
82571
|
const trueType2 = checkIfExpressionRefinesParameter(func, expr, param, initType);
|
|
@@ -82595,7 +82595,7 @@ function createTypeChecker(host) {
|
|
|
82595
82595
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
82596
82596
|
const functionFlags = getFunctionFlags(func);
|
|
82597
82597
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
82598
|
-
if (type && (maybeTypeOfKind(type,
|
|
82598
|
+
if (type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */))) {
|
|
82599
82599
|
return;
|
|
82600
82600
|
}
|
|
82601
82601
|
if (func.kind === 173 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 241 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -82967,11 +82967,11 @@ function createTypeChecker(host) {
|
|
|
82967
82967
|
case 41 /* MinusToken */:
|
|
82968
82968
|
case 55 /* TildeToken */:
|
|
82969
82969
|
checkNonNullType(operandType, node.operand);
|
|
82970
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
82970
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) {
|
|
82971
82971
|
error2(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator));
|
|
82972
82972
|
}
|
|
82973
82973
|
if (node.operator === 40 /* PlusToken */) {
|
|
82974
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
82974
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* BigIntLike */)) {
|
|
82975
82975
|
error2(node.operand, Diagnostics.Operator_0_cannot_be_applied_to_type_1, tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
|
|
82976
82976
|
}
|
|
82977
82977
|
return numberType;
|
|
@@ -83015,8 +83015,8 @@ function createTypeChecker(host) {
|
|
|
83015
83015
|
return getUnaryResultType(operandType);
|
|
83016
83016
|
}
|
|
83017
83017
|
function getUnaryResultType(operandType) {
|
|
83018
|
-
if (maybeTypeOfKind(operandType,
|
|
83019
|
-
return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType,
|
|
83018
|
+
if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) {
|
|
83019
|
+
return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) ? numberOrBigIntType : bigintType;
|
|
83020
83020
|
}
|
|
83021
83021
|
return numberType;
|
|
83022
83022
|
}
|
|
@@ -83045,10 +83045,10 @@ function createTypeChecker(host) {
|
|
|
83045
83045
|
if (source.flags & kind) {
|
|
83046
83046
|
return true;
|
|
83047
83047
|
}
|
|
83048
|
-
if (strict && source.flags & (3 /* AnyOrUnknown */ |
|
|
83048
|
+
if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) {
|
|
83049
83049
|
return false;
|
|
83050
83050
|
}
|
|
83051
|
-
return !!(kind &
|
|
83051
|
+
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);
|
|
83052
83052
|
}
|
|
83053
83053
|
function allTypesAssignableToKind(source, kind, strict) {
|
|
83054
83054
|
return source.flags & 1048576 /* Union */ ? every(source.types, (subType) => allTypesAssignableToKind(subType, kind, strict)) : isTypeAssignableToKind(source, kind, strict);
|
|
@@ -83321,7 +83321,7 @@ function createTypeChecker(host) {
|
|
|
83321
83321
|
}
|
|
83322
83322
|
}
|
|
83323
83323
|
function isTypeEqualityComparableTo(source, target) {
|
|
83324
|
-
return (target.flags &
|
|
83324
|
+
return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target);
|
|
83325
83325
|
}
|
|
83326
83326
|
function createCheckBinaryExpression() {
|
|
83327
83327
|
const trampoline = createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState);
|
|
@@ -83572,7 +83572,7 @@ function createTypeChecker(host) {
|
|
|
83572
83572
|
leftType = checkNonNullType(leftType, left);
|
|
83573
83573
|
rightType = checkNonNullType(rightType, right);
|
|
83574
83574
|
let suggestedOperator;
|
|
83575
|
-
if (leftType.flags &
|
|
83575
|
+
if (leftType.flags & 528 /* BooleanLike */ && rightType.flags & 528 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
|
|
83576
83576
|
error2(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
|
|
83577
83577
|
return numberType;
|
|
83578
83578
|
} else {
|
|
@@ -83592,7 +83592,7 @@ function createTypeChecker(host) {
|
|
|
83592
83592
|
);
|
|
83593
83593
|
let resultType2;
|
|
83594
83594
|
if (isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */) || // Or, if neither could be bigint, implicit coercion results in a number result
|
|
83595
|
-
!(maybeTypeOfKind(leftType,
|
|
83595
|
+
!(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) {
|
|
83596
83596
|
resultType2 = numberType;
|
|
83597
83597
|
} else if (bothAreBigIntLike(leftType, rightType)) {
|
|
83598
83598
|
switch (operator) {
|
|
@@ -83644,43 +83644,43 @@ function createTypeChecker(host) {
|
|
|
83644
83644
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
83645
83645
|
return silentNeverType;
|
|
83646
83646
|
}
|
|
83647
|
-
if (!isTypeAssignableToKind(leftType,
|
|
83647
|
+
if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) {
|
|
83648
83648
|
leftType = checkNonNullType(leftType, left);
|
|
83649
83649
|
rightType = checkNonNullType(rightType, right);
|
|
83650
83650
|
}
|
|
83651
83651
|
let resultType;
|
|
83652
83652
|
if (isTypeAssignableToKind(
|
|
83653
83653
|
leftType,
|
|
83654
|
-
|
|
83654
|
+
296 /* NumberLike */,
|
|
83655
83655
|
/*strict*/
|
|
83656
83656
|
true
|
|
83657
83657
|
) && isTypeAssignableToKind(
|
|
83658
83658
|
rightType,
|
|
83659
|
-
|
|
83659
|
+
296 /* NumberLike */,
|
|
83660
83660
|
/*strict*/
|
|
83661
83661
|
true
|
|
83662
83662
|
)) {
|
|
83663
83663
|
resultType = numberType;
|
|
83664
83664
|
} else if (isTypeAssignableToKind(
|
|
83665
83665
|
leftType,
|
|
83666
|
-
|
|
83666
|
+
2112 /* BigIntLike */,
|
|
83667
83667
|
/*strict*/
|
|
83668
83668
|
true
|
|
83669
83669
|
) && isTypeAssignableToKind(
|
|
83670
83670
|
rightType,
|
|
83671
|
-
|
|
83671
|
+
2112 /* BigIntLike */,
|
|
83672
83672
|
/*strict*/
|
|
83673
83673
|
true
|
|
83674
83674
|
)) {
|
|
83675
83675
|
resultType = bigintType;
|
|
83676
83676
|
} else if (isTypeAssignableToKind(
|
|
83677
83677
|
leftType,
|
|
83678
|
-
|
|
83678
|
+
402653316 /* StringLike */,
|
|
83679
83679
|
/*strict*/
|
|
83680
83680
|
true
|
|
83681
83681
|
) || isTypeAssignableToKind(
|
|
83682
83682
|
rightType,
|
|
83683
|
-
|
|
83683
|
+
402653316 /* StringLike */,
|
|
83684
83684
|
/*strict*/
|
|
83685
83685
|
true
|
|
83686
83686
|
)) {
|
|
@@ -83692,7 +83692,7 @@ function createTypeChecker(host) {
|
|
|
83692
83692
|
return resultType;
|
|
83693
83693
|
}
|
|
83694
83694
|
if (!resultType) {
|
|
83695
|
-
const closeEnoughKind =
|
|
83695
|
+
const closeEnoughKind = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */;
|
|
83696
83696
|
reportOperatorError(
|
|
83697
83697
|
(left2, right2) => isTypeAssignableToKind(left2, closeEnoughKind) && isTypeAssignableToKind(right2, closeEnoughKind)
|
|
83698
83698
|
);
|
|
@@ -83789,7 +83789,7 @@ function createTypeChecker(host) {
|
|
|
83789
83789
|
return Debug.fail();
|
|
83790
83790
|
}
|
|
83791
83791
|
function bothAreBigIntLike(left2, right2) {
|
|
83792
|
-
return isTypeAssignableToKind(left2,
|
|
83792
|
+
return isTypeAssignableToKind(left2, 2112 /* BigIntLike */) && isTypeAssignableToKind(right2, 2112 /* BigIntLike */);
|
|
83793
83793
|
}
|
|
83794
83794
|
function checkAssignmentDeclaration(kind, rightType2) {
|
|
83795
83795
|
if (kind === 2 /* ModuleExports */) {
|
|
@@ -83819,7 +83819,7 @@ function createTypeChecker(host) {
|
|
|
83819
83819
|
(isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
|
|
83820
83820
|
}
|
|
83821
83821
|
function checkForDisallowedESSymbolOperand(operator2) {
|
|
83822
|
-
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType,
|
|
83822
|
+
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : void 0;
|
|
83823
83823
|
if (offendingSymbolOperand) {
|
|
83824
83824
|
error2(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator2));
|
|
83825
83825
|
return false;
|
|
@@ -83858,7 +83858,7 @@ function createTypeChecker(host) {
|
|
|
83858
83858
|
}
|
|
83859
83859
|
if (checkReferenceExpression(left, Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access)) {
|
|
83860
83860
|
let headMessage;
|
|
83861
|
-
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType,
|
|
83861
|
+
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) {
|
|
83862
83862
|
const target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText);
|
|
83863
83863
|
if (isExactOptionalPropertyMismatch(valueType, target)) {
|
|
83864
83864
|
headMessage = Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target;
|
|
@@ -84047,7 +84047,7 @@ function createTypeChecker(host) {
|
|
|
84047
84047
|
const types = [];
|
|
84048
84048
|
for (const span of node.templateSpans) {
|
|
84049
84049
|
const type = checkExpression(span.expression);
|
|
84050
|
-
if (maybeTypeOfKindConsideringBaseConstraint(type,
|
|
84050
|
+
if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) {
|
|
84051
84051
|
error2(span.expression, Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
|
|
84052
84052
|
}
|
|
84053
84053
|
texts.push(span.literal.text);
|
|
@@ -84067,7 +84067,7 @@ function createTypeChecker(host) {
|
|
|
84067
84067
|
return stringType;
|
|
84068
84068
|
}
|
|
84069
84069
|
function isTemplateLiteralContextualType(type) {
|
|
84070
|
-
return !!(type.flags & (
|
|
84070
|
+
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */));
|
|
84071
84071
|
}
|
|
84072
84072
|
function getContextNode2(node) {
|
|
84073
84073
|
if (isJsxAttributes(node) && !isJsxSelfClosingElement(node.parent)) {
|
|
@@ -84088,7 +84088,7 @@ function createTypeChecker(host) {
|
|
|
84088
84088
|
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
84089
84089
|
inferenceContext.intraExpressionInferenceSites = void 0;
|
|
84090
84090
|
}
|
|
84091
|
-
const result = maybeTypeOfKind(type,
|
|
84091
|
+
const result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(
|
|
84092
84092
|
contextualType,
|
|
84093
84093
|
node,
|
|
84094
84094
|
/*contextFlags*/
|
|
@@ -84232,9 +84232,9 @@ function createTypeChecker(host) {
|
|
|
84232
84232
|
}
|
|
84233
84233
|
if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
84234
84234
|
const constraint = getBaseConstraintOfType(contextualType) || unknownType;
|
|
84235
|
-
return maybeTypeOfKind(constraint,
|
|
84235
|
+
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);
|
|
84236
84236
|
}
|
|
84237
|
-
return !!(contextualType.flags & (
|
|
84237
|
+
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 */));
|
|
84238
84238
|
}
|
|
84239
84239
|
return false;
|
|
84240
84240
|
}
|
|
@@ -87095,7 +87095,7 @@ function createTypeChecker(host) {
|
|
|
87095
87095
|
return;
|
|
87096
87096
|
}
|
|
87097
87097
|
const type = location === condExpr2 ? condType : checkExpression(location);
|
|
87098
|
-
if (type.flags &
|
|
87098
|
+
if (type.flags & 1024 /* EnumLiteral */ && isPropertyAccessExpression(location) && (getNodeLinks(location.expression).resolvedSymbol ?? unknownSymbol).flags & 384 /* Enum */) {
|
|
87099
87099
|
error2(location, Diagnostics.This_condition_will_always_return_0, !!type.value ? "true" : "false");
|
|
87100
87100
|
return;
|
|
87101
87101
|
}
|
|
@@ -87187,7 +87187,7 @@ function createTypeChecker(host) {
|
|
|
87187
87187
|
checkSourceElement(node.statement);
|
|
87188
87188
|
}
|
|
87189
87189
|
function checkTruthinessOfType(type, node) {
|
|
87190
|
-
if (type.flags &
|
|
87190
|
+
if (type.flags & 16384 /* Void */) {
|
|
87191
87191
|
error2(node, Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
|
|
87192
87192
|
} else {
|
|
87193
87193
|
const semantics = getSyntacticTruthySemantics(node);
|
|
@@ -87375,11 +87375,11 @@ function createTypeChecker(host) {
|
|
|
87375
87375
|
if (use & 4 /* AllowsStringInputFlag */) {
|
|
87376
87376
|
if (arrayType.flags & 1048576 /* Union */) {
|
|
87377
87377
|
const arrayTypes = inputType.types;
|
|
87378
|
-
const filteredTypes = filter(arrayTypes, (t) => !(t.flags &
|
|
87378
|
+
const filteredTypes = filter(arrayTypes, (t) => !(t.flags & 402653316 /* StringLike */));
|
|
87379
87379
|
if (filteredTypes !== arrayTypes) {
|
|
87380
87380
|
arrayType = getUnionType(filteredTypes, 2 /* Subtype */);
|
|
87381
87381
|
}
|
|
87382
|
-
} else if (arrayType.flags &
|
|
87382
|
+
} else if (arrayType.flags & 402653316 /* StringLike */) {
|
|
87383
87383
|
arrayType = neverType;
|
|
87384
87384
|
}
|
|
87385
87385
|
hasStringConstituent = arrayType !== inputType;
|
|
@@ -87404,7 +87404,7 @@ function createTypeChecker(host) {
|
|
|
87404
87404
|
}
|
|
87405
87405
|
const arrayElementType = getIndexTypeOfType(arrayType, numberType);
|
|
87406
87406
|
if (hasStringConstituent && arrayElementType) {
|
|
87407
|
-
if (arrayElementType.flags &
|
|
87407
|
+
if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) {
|
|
87408
87408
|
return stringType;
|
|
87409
87409
|
}
|
|
87410
87410
|
return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */);
|
|
@@ -87455,7 +87455,7 @@ function createTypeChecker(host) {
|
|
|
87455
87455
|
return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
|
|
87456
87456
|
}
|
|
87457
87457
|
function createIterationTypes(yieldType = neverType, returnType = neverType, nextType = unknownType) {
|
|
87458
|
-
if (yieldType.flags &
|
|
87458
|
+
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 */)) {
|
|
87459
87459
|
const id = getTypeListId([yieldType, returnType, nextType]);
|
|
87460
87460
|
let iterationTypes = iterationTypesCache.get(id);
|
|
87461
87461
|
if (!iterationTypes) {
|
|
@@ -87951,7 +87951,7 @@ function createTypeChecker(host) {
|
|
|
87951
87951
|
}
|
|
87952
87952
|
function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
|
|
87953
87953
|
const type = unwrapReturnType(returnType, getFunctionFlags(func));
|
|
87954
|
-
return !!(type && (maybeTypeOfKind(type,
|
|
87954
|
+
return !!(type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */)));
|
|
87955
87955
|
}
|
|
87956
87956
|
function checkReturnStatement(node) {
|
|
87957
87957
|
if (checkGrammarStatementInAmbientContext(node)) {
|
|
@@ -88148,7 +88148,7 @@ function createTypeChecker(host) {
|
|
|
88148
88148
|
if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) {
|
|
88149
88149
|
checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(
|
|
88150
88150
|
prop,
|
|
88151
|
-
|
|
88151
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
88152
88152
|
/*includeNonPublic*/
|
|
88153
88153
|
true
|
|
88154
88154
|
), getNonMissingTypeOfSymbol(prop));
|
|
@@ -89619,7 +89619,7 @@ function createTypeChecker(host) {
|
|
|
89619
89619
|
true
|
|
89620
89620
|
);
|
|
89621
89621
|
if (importAttributesType !== emptyObjectType) {
|
|
89622
|
-
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType,
|
|
89622
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
|
|
89623
89623
|
}
|
|
89624
89624
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
89625
89625
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
@@ -91171,7 +91171,7 @@ function createTypeChecker(host) {
|
|
|
91171
91171
|
return getStringLiteralType(name.text);
|
|
91172
91172
|
case 167 /* ComputedPropertyName */:
|
|
91173
91173
|
const nameType = checkComputedPropertyName(name);
|
|
91174
|
-
return isTypeAssignableToKind(nameType,
|
|
91174
|
+
return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType;
|
|
91175
91175
|
default:
|
|
91176
91176
|
return Debug.fail("Unsupported property name.");
|
|
91177
91177
|
}
|
|
@@ -91692,19 +91692,19 @@ function createTypeChecker(host) {
|
|
|
91692
91692
|
return isTypeOnly ? 11 /* ObjectType */ : 0 /* Unknown */;
|
|
91693
91693
|
} else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
91694
91694
|
return 11 /* ObjectType */;
|
|
91695
|
-
} else if (isTypeAssignableToKind(type,
|
|
91695
|
+
} else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) {
|
|
91696
91696
|
return 2 /* VoidNullableOrNeverType */;
|
|
91697
|
-
} else if (isTypeAssignableToKind(type,
|
|
91697
|
+
} else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) {
|
|
91698
91698
|
return 6 /* BooleanType */;
|
|
91699
|
-
} else if (isTypeAssignableToKind(type,
|
|
91699
|
+
} else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) {
|
|
91700
91700
|
return 3 /* NumberLikeType */;
|
|
91701
|
-
} else if (isTypeAssignableToKind(type,
|
|
91701
|
+
} else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) {
|
|
91702
91702
|
return 4 /* BigIntLikeType */;
|
|
91703
|
-
} else if (isTypeAssignableToKind(type,
|
|
91703
|
+
} else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) {
|
|
91704
91704
|
return 5 /* StringLikeType */;
|
|
91705
91705
|
} else if (isTupleType(type)) {
|
|
91706
91706
|
return 7 /* ArrayLikeType */;
|
|
91707
|
-
} else if (isTypeAssignableToKind(type,
|
|
91707
|
+
} else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) {
|
|
91708
91708
|
return 8 /* ESSymbolType */;
|
|
91709
91709
|
} else if (isFunctionType(type)) {
|
|
91710
91710
|
return 10 /* TypeWithCallSignature */;
|
|
@@ -91847,7 +91847,7 @@ function createTypeChecker(host) {
|
|
|
91847
91847
|
return false;
|
|
91848
91848
|
}
|
|
91849
91849
|
function literalTypeToNode(type, enclosing, tracker) {
|
|
91850
|
-
const enumResult = type.flags &
|
|
91850
|
+
const enumResult = type.flags & 1056 /* EnumLike */ ? nodeBuilder.symbolToExpression(
|
|
91851
91851
|
type.symbol,
|
|
91852
91852
|
111551 /* Value */,
|
|
91853
91853
|
enclosing,
|
|
@@ -92866,7 +92866,7 @@ function createTypeChecker(host) {
|
|
|
92866
92866
|
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
|
|
92867
92867
|
}
|
|
92868
92868
|
const type = getTypeFromTypeNode(parameter.type);
|
|
92869
|
-
if (someType(type, (t) => !!(t.flags &
|
|
92869
|
+
if (someType(type, (t) => !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */)) || isGenericType(type)) {
|
|
92870
92870
|
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead);
|
|
92871
92871
|
}
|
|
92872
92872
|
if (!everyType(type, isValidIndexKeyType)) {
|
|
@@ -93397,7 +93397,7 @@ function createTypeChecker(host) {
|
|
|
93397
93397
|
}
|
|
93398
93398
|
function isSimpleLiteralEnumReference(expr) {
|
|
93399
93399
|
if ((isPropertyAccessExpression(expr) || isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression)) && isEntityNameExpression(expr.expression)) {
|
|
93400
|
-
return !!(checkExpressionCached(expr).flags &
|
|
93400
|
+
return !!(checkExpressionCached(expr).flags & 1056 /* EnumLike */);
|
|
93401
93401
|
}
|
|
93402
93402
|
}
|
|
93403
93403
|
function checkAmbientInitializer(node) {
|
|
@@ -93914,292 +93914,6 @@ function createTypeChecker(host) {
|
|
|
93914
93914
|
}
|
|
93915
93915
|
return n1.pos - n2.pos;
|
|
93916
93916
|
}
|
|
93917
|
-
function compareTypes(t1, t2) {
|
|
93918
|
-
if (t1 === t2) return 0;
|
|
93919
|
-
if (t1 === void 0) return 1;
|
|
93920
|
-
if (t2 === void 0) return -1;
|
|
93921
|
-
let c = getSortOrderFlags(t1) - getSortOrderFlags(t2);
|
|
93922
|
-
if (c !== 0) return c;
|
|
93923
|
-
c = compareTypeNames(t1, t2);
|
|
93924
|
-
if (c !== 0) return c;
|
|
93925
|
-
if (t1.flags & (1 /* Any */ | 2 /* Unknown */ | 32 /* String */ | 64 /* Number */ | 256 /* Boolean */ | 128 /* BigInt */ | 512 /* ESSymbol */ | 16 /* Void */ | 4 /* Undefined */ | 8 /* Null */ | 131072 /* Never */ | 67108864 /* NonPrimitive */)) {
|
|
93926
|
-
} else if (t1.flags & 524288 /* Object */) {
|
|
93927
|
-
const c2 = compareSymbols(t1.symbol, t2.symbol);
|
|
93928
|
-
if (c2 !== 0) return c2;
|
|
93929
|
-
if (getObjectFlags(t1) & 4 /* Reference */ && getObjectFlags(t2) & 4 /* Reference */) {
|
|
93930
|
-
const r1 = t1;
|
|
93931
|
-
const r2 = t2;
|
|
93932
|
-
if (getObjectFlags(r1.target) & 8 /* Tuple */ && getObjectFlags(r2.target) & 8 /* Tuple */) {
|
|
93933
|
-
const c3 = compareTupleTypes(r1.target, r2.target);
|
|
93934
|
-
if (c3 !== 0) {
|
|
93935
|
-
return c3;
|
|
93936
|
-
}
|
|
93937
|
-
}
|
|
93938
|
-
if (r1.node === void 0 && r2.node === void 0) {
|
|
93939
|
-
const c3 = compareTypeLists(t1.resolvedTypeArguments, t2.resolvedTypeArguments);
|
|
93940
|
-
if (c3 !== 0) {
|
|
93941
|
-
return c3;
|
|
93942
|
-
}
|
|
93943
|
-
} else {
|
|
93944
|
-
let c3 = compareNodes(r1.node, r2.node);
|
|
93945
|
-
if (c3 !== 0) {
|
|
93946
|
-
return c3;
|
|
93947
|
-
}
|
|
93948
|
-
c3 = compareTypeMappers(t1.mapper, t2.mapper);
|
|
93949
|
-
if (c3 !== 0) {
|
|
93950
|
-
return c3;
|
|
93951
|
-
}
|
|
93952
|
-
}
|
|
93953
|
-
} else if (getObjectFlags(t1) & 4 /* Reference */) {
|
|
93954
|
-
return -1;
|
|
93955
|
-
} else if (getObjectFlags(t2) & 4 /* Reference */) {
|
|
93956
|
-
return 1;
|
|
93957
|
-
} else {
|
|
93958
|
-
let c3 = getObjectFlags(t1) & 142607679 /* ObjectTypeKindMask */ - getObjectFlags(t2) & 142607679 /* ObjectTypeKindMask */;
|
|
93959
|
-
if (c3 !== 0) {
|
|
93960
|
-
return c3;
|
|
93961
|
-
}
|
|
93962
|
-
c3 = compareTypeMappers(t1.mapper, t2.mapper);
|
|
93963
|
-
if (c3 !== 0) {
|
|
93964
|
-
return c3;
|
|
93965
|
-
}
|
|
93966
|
-
}
|
|
93967
|
-
} else if (t1.flags & 1048576 /* Union */) {
|
|
93968
|
-
const o1 = t1.origin;
|
|
93969
|
-
const o2 = t2.origin;
|
|
93970
|
-
if (o1 === void 0 && o2 === void 0) {
|
|
93971
|
-
const c2 = compareTypeLists(t1.types, t2.types);
|
|
93972
|
-
if (c2 !== 0) {
|
|
93973
|
-
return c2;
|
|
93974
|
-
}
|
|
93975
|
-
} else if (o1 === void 0) {
|
|
93976
|
-
return 1;
|
|
93977
|
-
} else if (o2 === void 0) {
|
|
93978
|
-
return -1;
|
|
93979
|
-
} else {
|
|
93980
|
-
const c2 = compareTypes(o1, o2);
|
|
93981
|
-
if (c2 !== 0) {
|
|
93982
|
-
return c2;
|
|
93983
|
-
}
|
|
93984
|
-
}
|
|
93985
|
-
} else if (t1.flags & 2097152 /* Intersection */) {
|
|
93986
|
-
const c2 = compareTypeLists(t1.types, t2.types);
|
|
93987
|
-
if (c2 !== 0) {
|
|
93988
|
-
return c2;
|
|
93989
|
-
}
|
|
93990
|
-
} else if (t1.flags & (32768 /* EnumLiteral */ | 16384 /* UniqueESSymbol */)) {
|
|
93991
|
-
const c2 = compareSymbols(t1.symbol, t2.symbol);
|
|
93992
|
-
if (c2 !== 0) {
|
|
93993
|
-
return c2;
|
|
93994
|
-
}
|
|
93995
|
-
} else if (t1.flags & 1024 /* StringLiteral */) {
|
|
93996
|
-
const c2 = compareComparableValues(t1.value, t2.value);
|
|
93997
|
-
if (c2 !== 0) {
|
|
93998
|
-
return c2;
|
|
93999
|
-
}
|
|
94000
|
-
} else if (t1.flags & 2048 /* NumberLiteral */) {
|
|
94001
|
-
const c2 = compareComparableValues(t1.value, t2.value);
|
|
94002
|
-
if (c2 !== 0) {
|
|
94003
|
-
return c2;
|
|
94004
|
-
}
|
|
94005
|
-
} else if (t1.flags & 4096 /* BooleanLiteral */) {
|
|
94006
|
-
const b1 = t1.intrinsicName === "true";
|
|
94007
|
-
const b2 = t2.intrinsicName === "true";
|
|
94008
|
-
if (b1 !== b2) {
|
|
94009
|
-
if (b1) {
|
|
94010
|
-
return 1;
|
|
94011
|
-
}
|
|
94012
|
-
return -1;
|
|
94013
|
-
}
|
|
94014
|
-
} else if (t1.flags & 262144 /* TypeParameter */) {
|
|
94015
|
-
const c2 = compareSymbols(t1.symbol, t2.symbol);
|
|
94016
|
-
if (c2 !== 0) {
|
|
94017
|
-
return c2;
|
|
94018
|
-
}
|
|
94019
|
-
} else if (t1.flags & 4194304 /* Index */) {
|
|
94020
|
-
let c2 = compareTypes(t1.type, t2.type);
|
|
94021
|
-
if (c2 !== 0) {
|
|
94022
|
-
return c2;
|
|
94023
|
-
}
|
|
94024
|
-
c2 = t1.flags - t2.flags;
|
|
94025
|
-
if (c2 !== 0) {
|
|
94026
|
-
return c2;
|
|
94027
|
-
}
|
|
94028
|
-
} else if (t1.flags & 8388608 /* IndexedAccess */) {
|
|
94029
|
-
let c2 = compareTypes(t1.objectType, t2.objectType);
|
|
94030
|
-
if (c2 !== 0) {
|
|
94031
|
-
return c2;
|
|
94032
|
-
}
|
|
94033
|
-
c2 = compareTypes(t1.indexType, t2.indexType);
|
|
94034
|
-
if (c2 !== 0) {
|
|
94035
|
-
return c2;
|
|
94036
|
-
}
|
|
94037
|
-
} else if (t1.flags & 16777216 /* Conditional */) {
|
|
94038
|
-
let c2 = compareNodes(t1.root.node, t2.root.node);
|
|
94039
|
-
if (c2 !== 0) {
|
|
94040
|
-
return c2;
|
|
94041
|
-
}
|
|
94042
|
-
c2 = compareTypeMappers(t1.mapper, t2.mapper);
|
|
94043
|
-
if (c2 !== 0) {
|
|
94044
|
-
return c2;
|
|
94045
|
-
}
|
|
94046
|
-
} else if (t1.flags & 33554432 /* Substitution */) {
|
|
94047
|
-
let c2 = compareTypes(t1.baseType, t2.baseType);
|
|
94048
|
-
if (c2 !== 0) {
|
|
94049
|
-
return c2;
|
|
94050
|
-
}
|
|
94051
|
-
c2 = compareTypes(t1.constraint, t2.constraint);
|
|
94052
|
-
if (c2 !== 0) {
|
|
94053
|
-
return c2;
|
|
94054
|
-
}
|
|
94055
|
-
} else if (t1.flags & 134217728 /* TemplateLiteral */) {
|
|
94056
|
-
let c2 = slicesCompareString(t1.texts, t2.texts);
|
|
94057
|
-
if (c2 !== 0) {
|
|
94058
|
-
return c2;
|
|
94059
|
-
}
|
|
94060
|
-
c2 = compareTypeLists(t1.types, t2.types);
|
|
94061
|
-
if (c2 !== 0) {
|
|
94062
|
-
return c2;
|
|
94063
|
-
}
|
|
94064
|
-
} else if (t1.flags & 268435456 /* StringMapping */) {
|
|
94065
|
-
const c2 = compareTypes(t1.type, t2.type);
|
|
94066
|
-
if (c2 !== 0) {
|
|
94067
|
-
return c2;
|
|
94068
|
-
}
|
|
94069
|
-
}
|
|
94070
|
-
return t1.id - t2.id;
|
|
94071
|
-
function slicesCompareString(s1, s2) {
|
|
94072
|
-
for (let i = 0; i < s1.length; i++) {
|
|
94073
|
-
if (i > s2.length) {
|
|
94074
|
-
return 1;
|
|
94075
|
-
}
|
|
94076
|
-
const v1 = s1[i];
|
|
94077
|
-
const v2 = s2[i];
|
|
94078
|
-
const c2 = compareComparableValues(v1, v2);
|
|
94079
|
-
if (c2 !== 0) return c2;
|
|
94080
|
-
}
|
|
94081
|
-
if (s1.length < s2.length) {
|
|
94082
|
-
return -1;
|
|
94083
|
-
}
|
|
94084
|
-
return 0;
|
|
94085
|
-
}
|
|
94086
|
-
}
|
|
94087
|
-
function getSortOrderFlags(t) {
|
|
94088
|
-
return (t.flags & 65536 /* Enum */) >> 1 | t.flags & ~65536 /* Enum */;
|
|
94089
|
-
}
|
|
94090
|
-
function compareTypeNames(t1, t2) {
|
|
94091
|
-
const s1 = getTypeNameSymbol(t1);
|
|
94092
|
-
const s2 = getTypeNameSymbol(t2);
|
|
94093
|
-
if (s1 === s2) {
|
|
94094
|
-
if (t1.aliasTypeArguments !== void 0) {
|
|
94095
|
-
return compareTypeLists(t1.aliasTypeArguments, t2.aliasTypeArguments);
|
|
94096
|
-
}
|
|
94097
|
-
return 0;
|
|
94098
|
-
}
|
|
94099
|
-
if (s1 === void 0) {
|
|
94100
|
-
return 1;
|
|
94101
|
-
}
|
|
94102
|
-
if (s2 === void 0) {
|
|
94103
|
-
return -1;
|
|
94104
|
-
}
|
|
94105
|
-
return compareComparableValues(s1.escapedName, s2.escapedName);
|
|
94106
|
-
}
|
|
94107
|
-
function getTypeNameSymbol(t) {
|
|
94108
|
-
if (t.aliasSymbol !== void 0) {
|
|
94109
|
-
return t.aliasSymbol;
|
|
94110
|
-
}
|
|
94111
|
-
if (t.flags & (262144 /* TypeParameter */ | 268435456 /* StringMapping */) || getObjectFlags(t) & (3 /* ClassOrInterface */ | 4 /* Reference */)) {
|
|
94112
|
-
return t.symbol;
|
|
94113
|
-
}
|
|
94114
|
-
return void 0;
|
|
94115
|
-
}
|
|
94116
|
-
function compareTupleTypes(t1, t2) {
|
|
94117
|
-
var _a;
|
|
94118
|
-
if (t1 === t2) {
|
|
94119
|
-
return 0;
|
|
94120
|
-
}
|
|
94121
|
-
if (t1.readonly === t2.readonly) {
|
|
94122
|
-
return t1.readonly ? 1 : -1;
|
|
94123
|
-
}
|
|
94124
|
-
if (t1.elementFlags.length !== t2.elementFlags.length) {
|
|
94125
|
-
return t1.elementFlags.length - t2.elementFlags.length;
|
|
94126
|
-
}
|
|
94127
|
-
for (let i = 0; i < t1.elementFlags.length; i++) {
|
|
94128
|
-
const c = t1.elementFlags[i] - t2.elementFlags[i];
|
|
94129
|
-
if (c !== 0) {
|
|
94130
|
-
return c;
|
|
94131
|
-
}
|
|
94132
|
-
}
|
|
94133
|
-
for (let i = 0; i < (((_a = t1.labeledElementDeclarations) == null ? void 0 : _a.length) ?? 0); i++) {
|
|
94134
|
-
const c = compareElementLabels(t1.labeledElementDeclarations[i], t2.labeledElementDeclarations[i]);
|
|
94135
|
-
if (c !== 0) {
|
|
94136
|
-
return c;
|
|
94137
|
-
}
|
|
94138
|
-
}
|
|
94139
|
-
return 0;
|
|
94140
|
-
}
|
|
94141
|
-
function compareElementLabels(n1, n2) {
|
|
94142
|
-
if (n1 === n2) {
|
|
94143
|
-
return 0;
|
|
94144
|
-
}
|
|
94145
|
-
if (n1 === void 0) {
|
|
94146
|
-
return -1;
|
|
94147
|
-
}
|
|
94148
|
-
if (n2 === void 0) {
|
|
94149
|
-
return 1;
|
|
94150
|
-
}
|
|
94151
|
-
return compareComparableValues(n1.name.escapedText, n2.name.escapedText);
|
|
94152
|
-
}
|
|
94153
|
-
function compareTypeLists(s1, s2) {
|
|
94154
|
-
if (length(s1) !== length(s2)) {
|
|
94155
|
-
return length(s1) - length(s2);
|
|
94156
|
-
}
|
|
94157
|
-
for (let i = 0; i < length(s1); i++) {
|
|
94158
|
-
const c = compareTypes(s1[i], s2 == null ? void 0 : s2[i]);
|
|
94159
|
-
if (c !== 0) return c;
|
|
94160
|
-
}
|
|
94161
|
-
return 0;
|
|
94162
|
-
}
|
|
94163
|
-
function compareTypeMappers(m1, m2) {
|
|
94164
|
-
if (m1 === m2) {
|
|
94165
|
-
return 0;
|
|
94166
|
-
}
|
|
94167
|
-
if (m1 === void 0) {
|
|
94168
|
-
return 1;
|
|
94169
|
-
}
|
|
94170
|
-
if (m2 === void 0) {
|
|
94171
|
-
return -1;
|
|
94172
|
-
}
|
|
94173
|
-
const kind1 = m1.kind;
|
|
94174
|
-
const kind2 = m2.kind;
|
|
94175
|
-
if (kind1 !== kind2) {
|
|
94176
|
-
return kind1 - kind2;
|
|
94177
|
-
}
|
|
94178
|
-
switch (kind1) {
|
|
94179
|
-
case 0 /* Simple */: {
|
|
94180
|
-
const c = compareTypes(m1.source, m2.source);
|
|
94181
|
-
if (c !== 0) {
|
|
94182
|
-
return c;
|
|
94183
|
-
}
|
|
94184
|
-
return compareTypes(m1.target, m2.target);
|
|
94185
|
-
}
|
|
94186
|
-
case 1 /* Array */: {
|
|
94187
|
-
const c = compareTypeLists(m1.sources, m2.sources);
|
|
94188
|
-
if (c !== 0) {
|
|
94189
|
-
return c;
|
|
94190
|
-
}
|
|
94191
|
-
return compareTypeLists(m1.targets, m2.targets);
|
|
94192
|
-
}
|
|
94193
|
-
case 5 /* Merged */: {
|
|
94194
|
-
const c = compareTypeMappers(m1.mapper1, m2.mapper1);
|
|
94195
|
-
if (c !== 0) {
|
|
94196
|
-
return c;
|
|
94197
|
-
}
|
|
94198
|
-
return compareTypeMappers(m1.mapper2, m2.mapper2);
|
|
94199
|
-
}
|
|
94200
|
-
}
|
|
94201
|
-
return 0;
|
|
94202
|
-
}
|
|
94203
93917
|
}
|
|
94204
93918
|
function isNotAccessor(declaration) {
|
|
94205
93919
|
return !isAccessor(declaration);
|
|
@@ -139972,7 +139686,7 @@ function isStringOrRegularExpressionOrTemplateLiteral(kind) {
|
|
|
139972
139686
|
return false;
|
|
139973
139687
|
}
|
|
139974
139688
|
function areIntersectedTypesAvoidingStringReduction(checker, t1, t2) {
|
|
139975
|
-
return !!(t1.flags &
|
|
139689
|
+
return !!(t1.flags & 4 /* String */) && checker.isEmptyAnonymousObjectType(t2);
|
|
139976
139690
|
}
|
|
139977
139691
|
function isStringAndEmptyAnonymousObjectIntersection(type) {
|
|
139978
139692
|
if (!type.isIntersection()) {
|
|
@@ -150527,7 +150241,7 @@ function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFi
|
|
|
150527
150241
|
const start = first(statements).getStart();
|
|
150528
150242
|
const end = last(statements).end;
|
|
150529
150243
|
expressionDiagnostic = createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected);
|
|
150530
|
-
} else if (checker.getTypeAtLocation(expression).flags & (
|
|
150244
|
+
} else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) {
|
|
150531
150245
|
expressionDiagnostic = createDiagnosticForNode(expression, Messages.uselessConstantType);
|
|
150532
150246
|
}
|
|
150533
150247
|
for (const scope of scopes) {
|
|
@@ -151584,13 +151298,13 @@ var TypeObject = class {
|
|
|
151584
151298
|
return !!(this.flags & 3145728 /* UnionOrIntersection */);
|
|
151585
151299
|
}
|
|
151586
151300
|
isLiteral() {
|
|
151587
|
-
return !!(this.flags & (
|
|
151301
|
+
return !!(this.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */));
|
|
151588
151302
|
}
|
|
151589
151303
|
isStringLiteral() {
|
|
151590
|
-
return !!(this.flags &
|
|
151304
|
+
return !!(this.flags & 128 /* StringLiteral */);
|
|
151591
151305
|
}
|
|
151592
151306
|
isNumberLiteral() {
|
|
151593
|
-
return !!(this.flags &
|
|
151307
|
+
return !!(this.flags & 256 /* NumberLiteral */);
|
|
151594
151308
|
}
|
|
151595
151309
|
isTypeParameter() {
|
|
151596
151310
|
return !!(this.flags & 262144 /* TypeParameter */);
|
|
@@ -160320,7 +160034,7 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
|
160320
160034
|
return { kind: 0 /* TypeLikeDeclaration */, token, call, modifierFlags, parentDeclaration: declaration, declSourceFile, isJSFile };
|
|
160321
160035
|
}
|
|
160322
160036
|
const enumDeclaration = find(symbol.declarations, isEnumDeclaration);
|
|
160323
|
-
if (enumDeclaration && !(leftExpressionType.flags &
|
|
160037
|
+
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* EnumLike */) && !isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
160324
160038
|
return { kind: 1 /* Enum */, token, parentDeclaration: enumDeclaration };
|
|
160325
160039
|
}
|
|
160326
160040
|
return void 0;
|
|
@@ -160496,7 +160210,7 @@ function addMethodDeclaration(context, changes, callExpression, name, modifierFl
|
|
|
160496
160210
|
function addEnumMemberDeclaration(changes, checker, { token, parentDeclaration }) {
|
|
160497
160211
|
const hasStringInitializer = some(parentDeclaration.members, (member) => {
|
|
160498
160212
|
const type = checker.getTypeAtLocation(member);
|
|
160499
|
-
return !!(type && type.flags &
|
|
160213
|
+
return !!(type && type.flags & 402653316 /* StringLike */);
|
|
160500
160214
|
});
|
|
160501
160215
|
const sourceFile = parentDeclaration.getSourceFile();
|
|
160502
160216
|
const enumMember = factory.createEnumMember(token, hasStringInitializer ? factory.createStringLiteral(token.text) : void 0);
|
|
@@ -160584,23 +160298,23 @@ function tryGetValueFromType(context, checker, importAdder, quotePreference, typ
|
|
|
160584
160298
|
if (type.flags & 3 /* AnyOrUnknown */) {
|
|
160585
160299
|
return createUndefined();
|
|
160586
160300
|
}
|
|
160587
|
-
if (type.flags & (
|
|
160301
|
+
if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
160588
160302
|
return factory.createStringLiteral(
|
|
160589
160303
|
"",
|
|
160590
160304
|
/* isSingleQuote */
|
|
160591
160305
|
quotePreference === 0 /* Single */
|
|
160592
160306
|
);
|
|
160593
160307
|
}
|
|
160594
|
-
if (type.flags &
|
|
160308
|
+
if (type.flags & 8 /* Number */) {
|
|
160595
160309
|
return factory.createNumericLiteral(0);
|
|
160596
160310
|
}
|
|
160597
|
-
if (type.flags &
|
|
160311
|
+
if (type.flags & 64 /* BigInt */) {
|
|
160598
160312
|
return factory.createBigIntLiteral("0n");
|
|
160599
160313
|
}
|
|
160600
|
-
if (type.flags &
|
|
160314
|
+
if (type.flags & 16 /* Boolean */) {
|
|
160601
160315
|
return factory.createFalse();
|
|
160602
160316
|
}
|
|
160603
|
-
if (type.flags &
|
|
160317
|
+
if (type.flags & 1056 /* EnumLike */) {
|
|
160604
160318
|
const enumMember = type.symbol.exports ? firstOrUndefinedIterator(type.symbol.exports.values()) : type.symbol;
|
|
160605
160319
|
const symbol = type.symbol.parent && type.symbol.parent.flags & 256 /* RegularEnum */ ? type.symbol.parent : type.symbol;
|
|
160606
160320
|
const name = checker.symbolToExpression(
|
|
@@ -160613,26 +160327,26 @@ function tryGetValueFromType(context, checker, importAdder, quotePreference, typ
|
|
|
160613
160327
|
);
|
|
160614
160328
|
return enumMember === void 0 || name === void 0 ? factory.createNumericLiteral(0) : factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember));
|
|
160615
160329
|
}
|
|
160616
|
-
if (type.flags &
|
|
160330
|
+
if (type.flags & 256 /* NumberLiteral */) {
|
|
160617
160331
|
return factory.createNumericLiteral(type.value);
|
|
160618
160332
|
}
|
|
160619
|
-
if (type.flags &
|
|
160333
|
+
if (type.flags & 2048 /* BigIntLiteral */) {
|
|
160620
160334
|
return factory.createBigIntLiteral(type.value);
|
|
160621
160335
|
}
|
|
160622
|
-
if (type.flags &
|
|
160336
|
+
if (type.flags & 128 /* StringLiteral */) {
|
|
160623
160337
|
return factory.createStringLiteral(
|
|
160624
160338
|
type.value,
|
|
160625
160339
|
/* isSingleQuote */
|
|
160626
160340
|
quotePreference === 0 /* Single */
|
|
160627
160341
|
);
|
|
160628
160342
|
}
|
|
160629
|
-
if (type.flags &
|
|
160343
|
+
if (type.flags & 512 /* BooleanLiteral */) {
|
|
160630
160344
|
return type === checker.getFalseType() || type === checker.getFalseType(
|
|
160631
160345
|
/*fresh*/
|
|
160632
160346
|
true
|
|
160633
160347
|
) ? factory.createFalse() : factory.createTrue();
|
|
160634
160348
|
}
|
|
160635
|
-
if (type.flags &
|
|
160349
|
+
if (type.flags & 65536 /* Null */) {
|
|
160636
160350
|
return factory.createNull();
|
|
160637
160351
|
}
|
|
160638
160352
|
if (type.flags & 1048576 /* Union */) {
|
|
@@ -162078,7 +161792,7 @@ registerCodeFix({
|
|
|
162078
161792
|
const info = getInfo15(err.file, err.start, checker);
|
|
162079
161793
|
if (!info) return;
|
|
162080
161794
|
const { typeNode, type } = info;
|
|
162081
|
-
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId56 === fixIdNullable ? checker.getNullableType(type,
|
|
161795
|
+
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId56 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
162082
161796
|
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
162083
161797
|
});
|
|
162084
161798
|
}
|
|
@@ -162367,7 +162081,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
162367
162081
|
}
|
|
162368
162082
|
const variableDeclaration = findAncestor(targetNode, isVariableDeclaration);
|
|
162369
162083
|
const type = variableDeclaration && typeChecker.getTypeAtLocation(variableDeclaration);
|
|
162370
|
-
if (type && type.flags &
|
|
162084
|
+
if (type && type.flags & 8192 /* UniqueESSymbol */) {
|
|
162371
162085
|
return void 0;
|
|
162372
162086
|
}
|
|
162373
162087
|
if (!(isExpressionTarget || isShorthandPropertyAssignmentTarget)) return void 0;
|
|
@@ -162848,7 +162562,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
162848
162562
|
mutatedTarget: false
|
|
162849
162563
|
};
|
|
162850
162564
|
function getFlags(type2) {
|
|
162851
|
-
return (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type2.flags &
|
|
162565
|
+
return (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type2.flags & 8192 /* UniqueESSymbol */ ? 1048576 /* AllowUniqueESSymbolType */ : 0 /* None */;
|
|
162852
162566
|
}
|
|
162853
162567
|
}
|
|
162854
162568
|
function createTypeOfFromEntityNameExpression(node) {
|
|
@@ -163822,7 +163536,7 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163822
163536
|
case 32 /* GreaterThanToken */:
|
|
163823
163537
|
case 34 /* GreaterThanEqualsToken */:
|
|
163824
163538
|
const operandType = checker.getTypeAtLocation(parent2.left === node ? parent2.right : parent2.left);
|
|
163825
|
-
if (operandType.flags &
|
|
163539
|
+
if (operandType.flags & 1056 /* EnumLike */) {
|
|
163826
163540
|
addCandidateType(usage, operandType);
|
|
163827
163541
|
} else {
|
|
163828
163542
|
usage.isNumber = true;
|
|
@@ -163831,11 +163545,11 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163831
163545
|
case 65 /* PlusEqualsToken */:
|
|
163832
163546
|
case 40 /* PlusToken */:
|
|
163833
163547
|
const otherOperandType = checker.getTypeAtLocation(parent2.left === node ? parent2.right : parent2.left);
|
|
163834
|
-
if (otherOperandType.flags &
|
|
163548
|
+
if (otherOperandType.flags & 1056 /* EnumLike */) {
|
|
163835
163549
|
addCandidateType(usage, otherOperandType);
|
|
163836
|
-
} else if (otherOperandType.flags &
|
|
163550
|
+
} else if (otherOperandType.flags & 296 /* NumberLike */) {
|
|
163837
163551
|
usage.isNumber = true;
|
|
163838
|
-
} else if (otherOperandType.flags &
|
|
163552
|
+
} else if (otherOperandType.flags & 402653316 /* StringLike */) {
|
|
163839
163553
|
usage.isString = true;
|
|
163840
163554
|
} else if (otherOperandType.flags & 1 /* Any */) {
|
|
163841
163555
|
} else {
|
|
@@ -163912,7 +163626,7 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163912
163626
|
const indexType = checker.getTypeAtLocation(parent2.argumentExpression);
|
|
163913
163627
|
const indexUsage = createEmptyUsage();
|
|
163914
163628
|
calculateUsageOfNode(parent2, indexUsage);
|
|
163915
|
-
if (indexType.flags &
|
|
163629
|
+
if (indexType.flags & 296 /* NumberLike */) {
|
|
163916
163630
|
usage.numberIndex = indexUsage;
|
|
163917
163631
|
} else {
|
|
163918
163632
|
usage.stringIndex = indexUsage;
|
|
@@ -163950,11 +163664,11 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163950
163664
|
low: (t) => t === stringNumber
|
|
163951
163665
|
},
|
|
163952
163666
|
{
|
|
163953
|
-
high: (t) => !(t.flags & (1 /* Any */ |
|
|
163954
|
-
low: (t) => !!(t.flags & (1 /* Any */ |
|
|
163667
|
+
high: (t) => !(t.flags & (1 /* Any */ | 16384 /* Void */)),
|
|
163668
|
+
low: (t) => !!(t.flags & (1 /* Any */ | 16384 /* Void */))
|
|
163955
163669
|
},
|
|
163956
163670
|
{
|
|
163957
|
-
high: (t) => !(t.flags & (
|
|
163671
|
+
high: (t) => !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(getObjectFlags(t) & 16 /* Anonymous */),
|
|
163958
163672
|
low: (t) => !!(getObjectFlags(t) & 16 /* Anonymous */)
|
|
163959
163673
|
}
|
|
163960
163674
|
];
|
|
@@ -165467,7 +165181,7 @@ function getInitializer(checker, propertyDeclaration) {
|
|
|
165467
165181
|
return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type));
|
|
165468
165182
|
}
|
|
165469
165183
|
function getDefaultValueFromType(checker, type) {
|
|
165470
|
-
if (type.flags &
|
|
165184
|
+
if (type.flags & 512 /* BooleanLiteral */) {
|
|
165471
165185
|
return type === checker.getFalseType() || type === checker.getFalseType(
|
|
165472
165186
|
/*fresh*/
|
|
165473
165187
|
true
|
|
@@ -165476,7 +165190,7 @@ function getDefaultValueFromType(checker, type) {
|
|
|
165476
165190
|
return factory.createStringLiteral(type.value);
|
|
165477
165191
|
} else if (type.isNumberLiteral()) {
|
|
165478
165192
|
return factory.createNumericLiteral(type.value);
|
|
165479
|
-
} else if (type.flags &
|
|
165193
|
+
} else if (type.flags & 2048 /* BigIntLiteral */) {
|
|
165480
165194
|
return factory.createBigIntLiteral(type.value);
|
|
165481
165195
|
} else if (type.isUnion()) {
|
|
165482
165196
|
return firstDefined(type.types, (t) => getDefaultValueFromType(checker, t));
|
|
@@ -166641,7 +166355,7 @@ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, i
|
|
|
166641
166355
|
} else {
|
|
166642
166356
|
if (initializer) {
|
|
166643
166357
|
const inferredType = checker.getTypeAtLocation(initializer.parent);
|
|
166644
|
-
if (!(inferredType.flags & (1 /* Any */ |
|
|
166358
|
+
if (!(inferredType.flags & (1 /* Any */ | 16384 /* Void */))) {
|
|
166645
166359
|
const sourceFile = initializer.getSourceFile();
|
|
166646
166360
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
166647
166361
|
const builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */;
|
|
@@ -166873,7 +166587,7 @@ function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options,
|
|
|
166873
166587
|
const importAdder = ts_codefix_exports.createImportAdder(sourceFile, program, preferences, host);
|
|
166874
166588
|
const elements = [];
|
|
166875
166589
|
for (const type of switchType.types) {
|
|
166876
|
-
if (type.flags &
|
|
166590
|
+
if (type.flags & 1024 /* EnumLiteral */) {
|
|
166877
166591
|
Debug.assert(type.symbol, "An enum member type should have a symbol");
|
|
166878
166592
|
Debug.assert(type.symbol.parent, "An enum member type should have a parent symbol (the enum symbol)");
|
|
166879
166593
|
const enumValue = type.symbol.valueDeclaration && checker.getConstantValue(type.symbol.valueDeclaration);
|
|
@@ -167167,8 +166881,8 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
|
|
|
167167
166881
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none" && !(isJsxAttribute(location.parent) && location.parent.initializer)) {
|
|
167168
166882
|
let useBraces2 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
167169
166883
|
const type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
167170
|
-
if (preferences.jsxAttributeCompletionStyle === "auto" && !(type.flags &
|
|
167171
|
-
if (type.flags &
|
|
166884
|
+
if (preferences.jsxAttributeCompletionStyle === "auto" && !(type.flags & 528 /* BooleanLike */) && !(type.flags & 1048576 /* Union */ && find(type.types, (type2) => !!(type2.flags & 528 /* BooleanLike */)))) {
|
|
166885
|
+
if (type.flags & 402653316 /* StringLike */ || type.flags & 1048576 /* Union */ && every(type.types, (type2) => !!(type2.flags & (402653316 /* StringLike */ | 32768 /* Undefined */) || isStringAndEmptyAnonymousObjectIntersection(type2)))) {
|
|
167172
166886
|
insertText = `${escapeSnippetText(name)}=${quote(sourceFile, preferences, "$1")}`;
|
|
167173
166887
|
isSnippet = true;
|
|
167174
166888
|
} else {
|
|
@@ -168425,7 +168139,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
168425
168139
|
const isLiteralExpected = !tryCast(previousToken, isStringLiteralLike) && !isJsxIdentifierExpected;
|
|
168426
168140
|
const literals = !isLiteralExpected ? [] : mapDefined(
|
|
168427
168141
|
contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]),
|
|
168428
|
-
(t) => t.isLiteral() && !(t.flags &
|
|
168142
|
+
(t) => t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : void 0
|
|
168429
168143
|
);
|
|
168430
168144
|
const recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker);
|
|
168431
168145
|
return {
|
|
@@ -170529,7 +170243,7 @@ function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, check
|
|
|
170529
170243
|
type = propType;
|
|
170530
170244
|
}
|
|
170531
170245
|
}
|
|
170532
|
-
isNewIdentifier = isNewIdentifier || !!(type.flags &
|
|
170246
|
+
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
170533
170247
|
return getStringLiteralTypes(type, uniques);
|
|
170534
170248
|
});
|
|
170535
170249
|
return length(types) ? { kind: 2 /* Types */, types, isNewIdentifier } : void 0;
|
|
@@ -170560,7 +170274,7 @@ function stringLiteralCompletionsForObjectLiteral(checker, objectLiteralExpressi
|
|
|
170560
170274
|
function getStringLiteralTypes(type, uniques = /* @__PURE__ */ new Set()) {
|
|
170561
170275
|
if (!type) return emptyArray;
|
|
170562
170276
|
type = skipConstraint(type);
|
|
170563
|
-
return type.isUnion() ? flatMap(type.types, (t) => getStringLiteralTypes(t, uniques)) : type.isStringLiteral() && !(type.flags &
|
|
170277
|
+
return type.isUnion() ? flatMap(type.types, (t) => getStringLiteralTypes(t, uniques)) : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && addToSeen(uniques, type.value) ? [type] : emptyArray;
|
|
170564
170278
|
}
|
|
170565
170279
|
function nameAndKind(name, kind, extension) {
|
|
170566
170280
|
return { name, kind, extension };
|
|
@@ -174003,7 +173717,7 @@ function getTypeDefinitionAtPosition(typeChecker, sourceFile, position) {
|
|
|
174003
173717
|
return typeDefinitions.length ? [...getFirstTypeArgumentDefinitions(typeChecker, resolvedType, node, failedAliasResolution), ...typeDefinitions] : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, skipAlias(symbol, typeChecker), node, failedAliasResolution) : void 0;
|
|
174004
173718
|
}
|
|
174005
173719
|
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
174006
|
-
return flatMap(type.isUnion() && !(type.flags &
|
|
173720
|
+
return flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], (t) => t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution));
|
|
174007
173721
|
}
|
|
174008
173722
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
174009
173723
|
if (type.symbol === symbol || // At `const f = () => {}`, the symbol is `f` and the type symbol is at `() => {}`
|
|
@@ -176707,7 +176421,7 @@ function getRenameInfoForNode(node, typeChecker, sourceFile, program, preference
|
|
|
176707
176421
|
if (!symbol) {
|
|
176708
176422
|
if (isStringLiteralLike(node)) {
|
|
176709
176423
|
const type = getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker);
|
|
176710
|
-
if (type && (type.flags &
|
|
176424
|
+
if (type && (type.flags & 128 /* StringLiteral */ || type.flags & 1048576 /* Union */ && every(type.types, (type2) => !!(type2.flags & 128 /* StringLiteral */)))) {
|
|
176711
176425
|
return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile);
|
|
176712
176426
|
}
|
|
176713
176427
|
} else if (isLabelName(node)) {
|