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