@typescript-deploys/pr-build 5.9.0-pr-61399-3 → 5.9.0-pr-61359-4
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 +869 -743
- package/lib/typescript.d.ts +28 -28
- package/lib/typescript.js +908 -785
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -298,7 +298,6 @@ __export(typescript_exports, {
|
|
|
298
298
|
commonOptionsWithBuild: () => commonOptionsWithBuild,
|
|
299
299
|
compact: () => compact,
|
|
300
300
|
compareBooleans: () => compareBooleans,
|
|
301
|
-
compareComparableValues: () => compareComparableValues,
|
|
302
301
|
compareDataObjects: () => compareDataObjects,
|
|
303
302
|
compareDiagnostics: () => compareDiagnostics,
|
|
304
303
|
compareEmitHelpers: () => compareEmitHelpers,
|
|
@@ -2286,7 +2285,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2286
2285
|
|
|
2287
2286
|
// src/compiler/corePublic.ts
|
|
2288
2287
|
var versionMajorMinor = "5.9";
|
|
2289
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2288
|
+
var version = `${versionMajorMinor}.0-insiders.20250320`;
|
|
2290
2289
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2291
2290
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2292
2291
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -2981,7 +2980,7 @@ function binarySearchKey(array, key, keySelector, keyComparer, offset) {
|
|
|
2981
2980
|
while (low <= high) {
|
|
2982
2981
|
const middle = low + (high - low >> 1);
|
|
2983
2982
|
const midKey = keySelector(array[middle], middle);
|
|
2984
|
-
switch (
|
|
2983
|
+
switch (keyComparer(midKey, key)) {
|
|
2985
2984
|
case -1 /* LessThan */:
|
|
2986
2985
|
low = middle + 1;
|
|
2987
2986
|
break;
|
|
@@ -4306,8 +4305,8 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
4306
4305
|
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
|
|
4307
4306
|
__tsDebuggerDisplay: {
|
|
4308
4307
|
value() {
|
|
4309
|
-
const typeHeader = this.flags &
|
|
4310
|
-
const remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~
|
|
4308
|
+
const typeHeader = this.flags & 67359327 /* Intrinsic */ ? `IntrinsicType ${this.intrinsicName}${this.debugIntrinsicName ? ` (${this.debugIntrinsicName})` : ""}` : this.flags & 98304 /* Nullable */ ? "NullableType" : this.flags & 384 /* StringOrNumberLiteral */ ? `LiteralType ${JSON.stringify(this.value)}` : this.flags & 2048 /* BigIntLiteral */ ? `LiteralType ${this.value.negative ? "-" : ""}${this.value.base10Value}n` : this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : this.flags & 32 /* Enum */ ? "EnumType" : this.flags & 1048576 /* Union */ ? "UnionType" : this.flags & 2097152 /* Intersection */ ? "IntersectionType" : this.flags & 4194304 /* Index */ ? "IndexType" : this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : this.flags & 16777216 /* Conditional */ ? "ConditionalType" : this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : this.flags & 524288 /* Object */ ? this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : this.objectFlags & 4 /* Reference */ ? "TypeReference" : this.objectFlags & 8 /* Tuple */ ? "TupleType" : this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : this.objectFlags & 32 /* Mapped */ ? "MappedType" : this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type";
|
|
4309
|
+
const remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0;
|
|
4311
4310
|
return `${typeHeader}${this.symbol ? ` '${symbolName(this.symbol)}'` : ""}${remainingObjectFlags ? ` (${formatObjectFlags(remainingObjectFlags)})` : ""}`;
|
|
4312
4311
|
}
|
|
4313
4312
|
},
|
|
@@ -5409,7 +5408,7 @@ var tracingEnabled;
|
|
|
5409
5408
|
const objectFlags = type.objectFlags;
|
|
5410
5409
|
const symbol = type.aliasSymbol ?? type.symbol;
|
|
5411
5410
|
let display;
|
|
5412
|
-
if (objectFlags & 16 /* Anonymous */ | type.flags &
|
|
5411
|
+
if (objectFlags & 16 /* Anonymous */ | type.flags & 2944 /* Literal */) {
|
|
5413
5412
|
try {
|
|
5414
5413
|
display = (_a = type.checker) == null ? void 0 : _a.typeToString(type);
|
|
5415
5414
|
} catch {
|
|
@@ -6429,21 +6428,21 @@ var NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags3) => {
|
|
|
6429
6428
|
var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
6430
6429
|
TypeFlags2[TypeFlags2["Any"] = 1] = "Any";
|
|
6431
6430
|
TypeFlags2[TypeFlags2["Unknown"] = 2] = "Unknown";
|
|
6432
|
-
TypeFlags2[TypeFlags2["
|
|
6433
|
-
TypeFlags2[TypeFlags2["
|
|
6434
|
-
TypeFlags2[TypeFlags2["
|
|
6435
|
-
TypeFlags2[TypeFlags2["
|
|
6436
|
-
TypeFlags2[TypeFlags2["
|
|
6437
|
-
TypeFlags2[TypeFlags2["
|
|
6438
|
-
TypeFlags2[TypeFlags2["
|
|
6439
|
-
TypeFlags2[TypeFlags2["
|
|
6440
|
-
TypeFlags2[TypeFlags2["
|
|
6441
|
-
TypeFlags2[TypeFlags2["
|
|
6442
|
-
TypeFlags2[TypeFlags2["
|
|
6443
|
-
TypeFlags2[TypeFlags2["
|
|
6444
|
-
TypeFlags2[TypeFlags2["
|
|
6445
|
-
TypeFlags2[TypeFlags2["
|
|
6446
|
-
TypeFlags2[TypeFlags2["
|
|
6431
|
+
TypeFlags2[TypeFlags2["String"] = 4] = "String";
|
|
6432
|
+
TypeFlags2[TypeFlags2["Number"] = 8] = "Number";
|
|
6433
|
+
TypeFlags2[TypeFlags2["Boolean"] = 16] = "Boolean";
|
|
6434
|
+
TypeFlags2[TypeFlags2["Enum"] = 32] = "Enum";
|
|
6435
|
+
TypeFlags2[TypeFlags2["BigInt"] = 64] = "BigInt";
|
|
6436
|
+
TypeFlags2[TypeFlags2["StringLiteral"] = 128] = "StringLiteral";
|
|
6437
|
+
TypeFlags2[TypeFlags2["NumberLiteral"] = 256] = "NumberLiteral";
|
|
6438
|
+
TypeFlags2[TypeFlags2["BooleanLiteral"] = 512] = "BooleanLiteral";
|
|
6439
|
+
TypeFlags2[TypeFlags2["EnumLiteral"] = 1024] = "EnumLiteral";
|
|
6440
|
+
TypeFlags2[TypeFlags2["BigIntLiteral"] = 2048] = "BigIntLiteral";
|
|
6441
|
+
TypeFlags2[TypeFlags2["ESSymbol"] = 4096] = "ESSymbol";
|
|
6442
|
+
TypeFlags2[TypeFlags2["UniqueESSymbol"] = 8192] = "UniqueESSymbol";
|
|
6443
|
+
TypeFlags2[TypeFlags2["Void"] = 16384] = "Void";
|
|
6444
|
+
TypeFlags2[TypeFlags2["Undefined"] = 32768] = "Undefined";
|
|
6445
|
+
TypeFlags2[TypeFlags2["Null"] = 65536] = "Null";
|
|
6447
6446
|
TypeFlags2[TypeFlags2["Never"] = 131072] = "Never";
|
|
6448
6447
|
TypeFlags2[TypeFlags2["TypeParameter"] = 262144] = "TypeParameter";
|
|
6449
6448
|
TypeFlags2[TypeFlags2["Object"] = 524288] = "Object";
|
|
@@ -6459,25 +6458,25 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6459
6458
|
TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1";
|
|
6460
6459
|
TypeFlags2[TypeFlags2["Reserved2"] = 1073741824] = "Reserved2";
|
|
6461
6460
|
TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown";
|
|
6462
|
-
TypeFlags2[TypeFlags2["Nullable"] =
|
|
6463
|
-
TypeFlags2[TypeFlags2["Literal"] =
|
|
6464
|
-
TypeFlags2[TypeFlags2["Unit"] =
|
|
6465
|
-
TypeFlags2[TypeFlags2["Freshable"] =
|
|
6466
|
-
TypeFlags2[TypeFlags2["StringOrNumberLiteral"] =
|
|
6467
|
-
TypeFlags2[TypeFlags2["StringOrNumberLiteralOrUnique"] =
|
|
6468
|
-
TypeFlags2[TypeFlags2["DefinitelyFalsy"] =
|
|
6469
|
-
TypeFlags2[TypeFlags2["PossiblyFalsy"] =
|
|
6470
|
-
TypeFlags2[TypeFlags2["Intrinsic"] =
|
|
6471
|
-
TypeFlags2[TypeFlags2["StringLike"] =
|
|
6472
|
-
TypeFlags2[TypeFlags2["NumberLike"] =
|
|
6473
|
-
TypeFlags2[TypeFlags2["BigIntLike"] =
|
|
6474
|
-
TypeFlags2[TypeFlags2["BooleanLike"] =
|
|
6475
|
-
TypeFlags2[TypeFlags2["EnumLike"] =
|
|
6476
|
-
TypeFlags2[TypeFlags2["ESSymbolLike"] =
|
|
6477
|
-
TypeFlags2[TypeFlags2["VoidLike"] =
|
|
6461
|
+
TypeFlags2[TypeFlags2["Nullable"] = 98304] = "Nullable";
|
|
6462
|
+
TypeFlags2[TypeFlags2["Literal"] = 2944] = "Literal";
|
|
6463
|
+
TypeFlags2[TypeFlags2["Unit"] = 109472] = "Unit";
|
|
6464
|
+
TypeFlags2[TypeFlags2["Freshable"] = 2976] = "Freshable";
|
|
6465
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral";
|
|
6466
|
+
TypeFlags2[TypeFlags2["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique";
|
|
6467
|
+
TypeFlags2[TypeFlags2["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy";
|
|
6468
|
+
TypeFlags2[TypeFlags2["PossiblyFalsy"] = 117724] = "PossiblyFalsy";
|
|
6469
|
+
TypeFlags2[TypeFlags2["Intrinsic"] = 67359327] = "Intrinsic";
|
|
6470
|
+
TypeFlags2[TypeFlags2["StringLike"] = 402653316] = "StringLike";
|
|
6471
|
+
TypeFlags2[TypeFlags2["NumberLike"] = 296] = "NumberLike";
|
|
6472
|
+
TypeFlags2[TypeFlags2["BigIntLike"] = 2112] = "BigIntLike";
|
|
6473
|
+
TypeFlags2[TypeFlags2["BooleanLike"] = 528] = "BooleanLike";
|
|
6474
|
+
TypeFlags2[TypeFlags2["EnumLike"] = 1056] = "EnumLike";
|
|
6475
|
+
TypeFlags2[TypeFlags2["ESSymbolLike"] = 12288] = "ESSymbolLike";
|
|
6476
|
+
TypeFlags2[TypeFlags2["VoidLike"] = 49152] = "VoidLike";
|
|
6478
6477
|
TypeFlags2[TypeFlags2["Primitive"] = 402784252] = "Primitive";
|
|
6479
|
-
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] =
|
|
6480
|
-
TypeFlags2[TypeFlags2["DisjointDomains"] =
|
|
6478
|
+
TypeFlags2[TypeFlags2["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
|
|
6479
|
+
TypeFlags2[TypeFlags2["DisjointDomains"] = 469892092] = "DisjointDomains";
|
|
6481
6480
|
TypeFlags2[TypeFlags2["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
|
|
6482
6481
|
TypeFlags2[TypeFlags2["StructuredType"] = 3670016] = "StructuredType";
|
|
6483
6482
|
TypeFlags2[TypeFlags2["TypeVariable"] = 8650752] = "TypeVariable";
|
|
@@ -6485,10 +6484,10 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6485
6484
|
TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
|
|
6486
6485
|
TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
|
|
6487
6486
|
TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
|
|
6488
|
-
TypeFlags2[TypeFlags2["ObjectFlagsType"] =
|
|
6487
|
+
TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
|
|
6489
6488
|
TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
|
|
6490
|
-
TypeFlags2[TypeFlags2["Singleton"] =
|
|
6491
|
-
TypeFlags2[TypeFlags2["Narrowable"] =
|
|
6489
|
+
TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
|
|
6490
|
+
TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
|
|
6492
6491
|
TypeFlags2[TypeFlags2["IncludesMask"] = 473694207] = "IncludesMask";
|
|
6493
6492
|
TypeFlags2[TypeFlags2["IncludesMissingType"] = 262144 /* TypeParameter */] = "IncludesMissingType";
|
|
6494
6493
|
TypeFlags2[TypeFlags2["IncludesNonWideningType"] = 4194304 /* Index */] = "IncludesNonWideningType";
|
|
@@ -6497,7 +6496,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
6497
6496
|
TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
|
|
6498
6497
|
TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable";
|
|
6499
6498
|
TypeFlags2[TypeFlags2["IncludesError"] = 1073741824 /* Reserved2 */] = "IncludesError";
|
|
6500
|
-
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] =
|
|
6499
|
+
TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
|
|
6501
6500
|
return TypeFlags2;
|
|
6502
6501
|
})(TypeFlags || {});
|
|
6503
6502
|
var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
@@ -6527,11 +6526,11 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6527
6526
|
ObjectFlags3[ObjectFlags3["RequiresWidening"] = 196608] = "RequiresWidening";
|
|
6528
6527
|
ObjectFlags3[ObjectFlags3["PropagatingFlags"] = 458752] = "PropagatingFlags";
|
|
6529
6528
|
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";
|
|
6535
6534
|
ObjectFlags3[ObjectFlags3["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone";
|
|
6536
6535
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated";
|
|
6537
6536
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists";
|
|
@@ -6539,6 +6538,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6539
6538
|
ObjectFlags3[ObjectFlags3["IsGenericObjectType"] = 4194304] = "IsGenericObjectType";
|
|
6540
6539
|
ObjectFlags3[ObjectFlags3["IsGenericIndexType"] = 8388608] = "IsGenericIndexType";
|
|
6541
6540
|
ObjectFlags3[ObjectFlags3["IsGenericType"] = 12582912] = "IsGenericType";
|
|
6541
|
+
ObjectFlags3[ObjectFlags3["IsNarrowingType"] = 16777216] = "IsNarrowingType";
|
|
6542
6542
|
ObjectFlags3[ObjectFlags3["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
|
6543
6543
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
|
6544
6544
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
@@ -21355,7 +21355,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
|
|
|
21355
21355
|
return (_a = symbol.declarations) == null ? void 0 : _a.find(isClassLike);
|
|
21356
21356
|
}
|
|
21357
21357
|
function getObjectFlags(type) {
|
|
21358
|
-
return type.flags &
|
|
21358
|
+
return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
|
|
21359
21359
|
}
|
|
21360
21360
|
function isUMDExportSymbol(symbol) {
|
|
21361
21361
|
return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
|
|
@@ -23246,13 +23246,13 @@ function intrinsicTagNameToString(node) {
|
|
|
23246
23246
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
23247
23247
|
}
|
|
23248
23248
|
function isTypeUsableAsPropertyName(type) {
|
|
23249
|
-
return !!(type.flags &
|
|
23249
|
+
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
23250
23250
|
}
|
|
23251
23251
|
function getPropertyNameFromType(type) {
|
|
23252
|
-
if (type.flags &
|
|
23252
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
23253
23253
|
return type.escapedName;
|
|
23254
23254
|
}
|
|
23255
|
-
if (type.flags & (
|
|
23255
|
+
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
23256
23256
|
return escapeLeadingUnderscores("" + type.value);
|
|
23257
23257
|
}
|
|
23258
23258
|
return Debug.fail();
|
|
@@ -49413,6 +49413,8 @@ function getContainerFlags(node) {
|
|
|
49413
49413
|
case 185 /* ConstructorType */:
|
|
49414
49414
|
case 175 /* ClassStaticBlockDeclaration */:
|
|
49415
49415
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
|
|
49416
|
+
case 351 /* JSDocImportTag */:
|
|
49417
|
+
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
|
|
49416
49418
|
case 218 /* FunctionExpression */:
|
|
49417
49419
|
case 219 /* ArrowFunction */:
|
|
49418
49420
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */;
|
|
@@ -50774,7 +50776,6 @@ function createTypeChecker(host) {
|
|
|
50774
50776
|
};
|
|
50775
50777
|
var cancellationToken;
|
|
50776
50778
|
var scanner2;
|
|
50777
|
-
var fileIndexMap = new Map(host.getSourceFiles().map((file, i) => [file, i]));
|
|
50778
50779
|
var Symbol48 = objectAllocator.getSymbolConstructor();
|
|
50779
50780
|
var Type29 = objectAllocator.getTypeConstructor();
|
|
50780
50781
|
var Signature13 = objectAllocator.getSignatureConstructor();
|
|
@@ -51356,10 +51357,10 @@ function createTypeChecker(host) {
|
|
|
51356
51357
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */, "non-inferrable");
|
|
51357
51358
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
51358
51359
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
51359
|
-
var undefinedType = createIntrinsicType(
|
|
51360
|
-
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(
|
|
51360
|
+
var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined");
|
|
51361
|
+
var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */, "widening");
|
|
51361
51362
|
var missingType = createIntrinsicType(
|
|
51362
|
-
|
|
51363
|
+
32768 /* Undefined */,
|
|
51363
51364
|
"undefined",
|
|
51364
51365
|
/*objectFlags*/
|
|
51365
51366
|
void 0,
|
|
@@ -51367,33 +51368,33 @@ function createTypeChecker(host) {
|
|
|
51367
51368
|
);
|
|
51368
51369
|
var undefinedOrMissingType = exactOptionalPropertyTypes ? missingType : undefinedType;
|
|
51369
51370
|
var optionalType = createIntrinsicType(
|
|
51370
|
-
|
|
51371
|
+
32768 /* Undefined */,
|
|
51371
51372
|
"undefined",
|
|
51372
51373
|
/*objectFlags*/
|
|
51373
51374
|
void 0,
|
|
51374
51375
|
"optional"
|
|
51375
51376
|
);
|
|
51376
|
-
var nullType = createIntrinsicType(
|
|
51377
|
-
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(
|
|
51378
|
-
var stringType = createIntrinsicType(
|
|
51379
|
-
var numberType = createIntrinsicType(
|
|
51380
|
-
var bigintType = createIntrinsicType(
|
|
51377
|
+
var nullType = createIntrinsicType(65536 /* Null */, "null");
|
|
51378
|
+
var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */, "widening");
|
|
51379
|
+
var stringType = createIntrinsicType(4 /* String */, "string");
|
|
51380
|
+
var numberType = createIntrinsicType(8 /* Number */, "number");
|
|
51381
|
+
var bigintType = createIntrinsicType(64 /* BigInt */, "bigint");
|
|
51381
51382
|
var falseType = createIntrinsicType(
|
|
51382
|
-
|
|
51383
|
+
512 /* BooleanLiteral */,
|
|
51383
51384
|
"false",
|
|
51384
51385
|
/*objectFlags*/
|
|
51385
51386
|
void 0,
|
|
51386
51387
|
"fresh"
|
|
51387
51388
|
);
|
|
51388
|
-
var regularFalseType = createIntrinsicType(
|
|
51389
|
+
var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false");
|
|
51389
51390
|
var trueType = createIntrinsicType(
|
|
51390
|
-
|
|
51391
|
+
512 /* BooleanLiteral */,
|
|
51391
51392
|
"true",
|
|
51392
51393
|
/*objectFlags*/
|
|
51393
51394
|
void 0,
|
|
51394
51395
|
"fresh"
|
|
51395
51396
|
);
|
|
51396
|
-
var regularTrueType = createIntrinsicType(
|
|
51397
|
+
var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true");
|
|
51397
51398
|
trueType.regularType = regularTrueType;
|
|
51398
51399
|
trueType.freshType = trueType;
|
|
51399
51400
|
regularTrueType.regularType = regularTrueType;
|
|
@@ -51403,8 +51404,8 @@ function createTypeChecker(host) {
|
|
|
51403
51404
|
regularFalseType.regularType = regularFalseType;
|
|
51404
51405
|
regularFalseType.freshType = falseType;
|
|
51405
51406
|
var booleanType = getUnionType([regularFalseType, regularTrueType]);
|
|
51406
|
-
var esSymbolType = createIntrinsicType(
|
|
51407
|
-
var voidType = createIntrinsicType(
|
|
51407
|
+
var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol");
|
|
51408
|
+
var voidType = createIntrinsicType(16384 /* Void */, "void");
|
|
51408
51409
|
var neverType = createIntrinsicType(131072 /* Never */, "never");
|
|
51409
51410
|
var silentNeverType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */, "silent");
|
|
51410
51411
|
var implicitNeverType = createIntrinsicType(
|
|
@@ -51788,6 +51789,7 @@ function createTypeChecker(host) {
|
|
|
51788
51789
|
[".jsx", ".jsx"],
|
|
51789
51790
|
[".json", ".json"]
|
|
51790
51791
|
];
|
|
51792
|
+
var narrowableReturnTypeCache = /* @__PURE__ */ new Map();
|
|
51791
51793
|
initializeTypeChecker();
|
|
51792
51794
|
return checker;
|
|
51793
51795
|
function isDefinitelyReferenceToGlobalSymbolObject(node) {
|
|
@@ -52691,7 +52693,7 @@ function createTypeChecker(host) {
|
|
|
52691
52693
|
const type = getDeclaredTypeOfSymbol(symbol);
|
|
52692
52694
|
return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(
|
|
52693
52695
|
type,
|
|
52694
|
-
|
|
52696
|
+
384 /* StringOrNumberLiteral */,
|
|
52695
52697
|
/*strict*/
|
|
52696
52698
|
true
|
|
52697
52699
|
);
|
|
@@ -54398,7 +54400,7 @@ function createTypeChecker(host) {
|
|
|
54398
54400
|
return type;
|
|
54399
54401
|
}
|
|
54400
54402
|
function createTypeofType() {
|
|
54401
|
-
return getUnionType(
|
|
54403
|
+
return getUnionType(arrayFrom(typeofNEFacts.keys(), getStringLiteralType));
|
|
54402
54404
|
}
|
|
54403
54405
|
function createTypeParameter(symbol) {
|
|
54404
54406
|
return createTypeWithSymbol(262144 /* TypeParameter */, symbol);
|
|
@@ -55018,10 +55020,11 @@ function createTypeChecker(host) {
|
|
|
55018
55020
|
serializeExistingTypeNode(context, typeNode, addUndefined) {
|
|
55019
55021
|
return serializeExistingTypeNode(context, typeNode, !!addUndefined);
|
|
55020
55022
|
},
|
|
55021
|
-
serializeReturnTypeForSignature(syntacticContext, signatureDeclaration) {
|
|
55023
|
+
serializeReturnTypeForSignature(syntacticContext, signatureDeclaration, symbol) {
|
|
55022
55024
|
const context = syntacticContext;
|
|
55023
55025
|
const signature = getSignatureFromDeclaration(signatureDeclaration);
|
|
55024
|
-
|
|
55026
|
+
symbol ?? (symbol = getSymbolOfDeclaration(signatureDeclaration));
|
|
55027
|
+
const returnType = context.enclosingSymbolTypes.get(getSymbolId(symbol)) ?? instantiateType(getReturnTypeOfSignature(signature), context.mapper);
|
|
55025
55028
|
return serializeInferredReturnTypeForSignature(context, signature, returnType);
|
|
55026
55029
|
},
|
|
55027
55030
|
serializeTypeOfExpression(syntacticContext, expr) {
|
|
@@ -55035,7 +55038,7 @@ function createTypeChecker(host) {
|
|
|
55035
55038
|
symbol ?? (symbol = getSymbolOfDeclaration(declaration));
|
|
55036
55039
|
let type = (_a = context.enclosingSymbolTypes) == null ? void 0 : _a.get(getSymbolId(symbol));
|
|
55037
55040
|
if (type === void 0) {
|
|
55038
|
-
type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? instantiateType(getWidenedLiteralType(getTypeOfSymbol(symbol)), context.mapper) : errorType;
|
|
55041
|
+
type = symbol.flags & 98304 /* Accessor */ && declaration.kind === 178 /* SetAccessor */ ? instantiateType(getWriteTypeOfSymbol(symbol), context.mapper) : symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? instantiateType(getWidenedLiteralType(getTypeOfSymbol(symbol)), context.mapper) : errorType;
|
|
55039
55042
|
}
|
|
55040
55043
|
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
|
|
55041
55044
|
if (addUndefinedForParameter) {
|
|
@@ -55219,7 +55222,7 @@ function createTypeChecker(host) {
|
|
|
55219
55222
|
if (name && isComputedPropertyName(name)) return name;
|
|
55220
55223
|
}
|
|
55221
55224
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
55222
|
-
if (nameType && nameType.flags & (
|
|
55225
|
+
if (nameType && nameType.flags & (1024 /* EnumLiteral */ | 8192 /* UniqueESSymbol */)) {
|
|
55223
55226
|
context.enclosingDeclaration = nameType.symbol.valueDeclaration;
|
|
55224
55227
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, meaning));
|
|
55225
55228
|
}
|
|
@@ -55327,23 +55330,23 @@ function createTypeChecker(host) {
|
|
|
55327
55330
|
if (type.flags & 2 /* Unknown */) {
|
|
55328
55331
|
return factory.createKeywordTypeNode(159 /* UnknownKeyword */);
|
|
55329
55332
|
}
|
|
55330
|
-
if (type.flags &
|
|
55333
|
+
if (type.flags & 4 /* String */) {
|
|
55331
55334
|
context.approximateLength += 6;
|
|
55332
55335
|
return factory.createKeywordTypeNode(154 /* StringKeyword */);
|
|
55333
55336
|
}
|
|
55334
|
-
if (type.flags &
|
|
55337
|
+
if (type.flags & 8 /* Number */) {
|
|
55335
55338
|
context.approximateLength += 6;
|
|
55336
55339
|
return factory.createKeywordTypeNode(150 /* NumberKeyword */);
|
|
55337
55340
|
}
|
|
55338
|
-
if (type.flags &
|
|
55341
|
+
if (type.flags & 64 /* BigInt */) {
|
|
55339
55342
|
context.approximateLength += 6;
|
|
55340
55343
|
return factory.createKeywordTypeNode(163 /* BigIntKeyword */);
|
|
55341
55344
|
}
|
|
55342
|
-
if (type.flags &
|
|
55345
|
+
if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) {
|
|
55343
55346
|
context.approximateLength += 7;
|
|
55344
55347
|
return factory.createKeywordTypeNode(136 /* BooleanKeyword */);
|
|
55345
55348
|
}
|
|
55346
|
-
if (type.flags &
|
|
55349
|
+
if (type.flags & 1056 /* EnumLike */) {
|
|
55347
55350
|
if (type.symbol.flags & 8 /* EnumMember */) {
|
|
55348
55351
|
const parentSymbol = getParentOfSymbol(type.symbol);
|
|
55349
55352
|
const parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */);
|
|
@@ -55372,24 +55375,24 @@ function createTypeChecker(host) {
|
|
|
55372
55375
|
}
|
|
55373
55376
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
55374
55377
|
}
|
|
55375
|
-
if (type.flags &
|
|
55378
|
+
if (type.flags & 128 /* StringLiteral */) {
|
|
55376
55379
|
context.approximateLength += type.value.length + 2;
|
|
55377
55380
|
return factory.createLiteralTypeNode(setEmitFlags(factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */));
|
|
55378
55381
|
}
|
|
55379
|
-
if (type.flags &
|
|
55382
|
+
if (type.flags & 256 /* NumberLiteral */) {
|
|
55380
55383
|
const value = type.value;
|
|
55381
55384
|
context.approximateLength += ("" + value).length;
|
|
55382
55385
|
return factory.createLiteralTypeNode(value < 0 ? factory.createPrefixUnaryExpression(41 /* MinusToken */, factory.createNumericLiteral(-value)) : factory.createNumericLiteral(value));
|
|
55383
55386
|
}
|
|
55384
|
-
if (type.flags &
|
|
55387
|
+
if (type.flags & 2048 /* BigIntLiteral */) {
|
|
55385
55388
|
context.approximateLength += pseudoBigIntToString(type.value).length + 1;
|
|
55386
55389
|
return factory.createLiteralTypeNode(factory.createBigIntLiteral(type.value));
|
|
55387
55390
|
}
|
|
55388
|
-
if (type.flags &
|
|
55391
|
+
if (type.flags & 512 /* BooleanLiteral */) {
|
|
55389
55392
|
context.approximateLength += type.intrinsicName.length;
|
|
55390
55393
|
return factory.createLiteralTypeNode(type.intrinsicName === "true" ? factory.createTrue() : factory.createFalse());
|
|
55391
55394
|
}
|
|
55392
|
-
if (type.flags &
|
|
55395
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
55393
55396
|
if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) {
|
|
55394
55397
|
if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
|
|
55395
55398
|
context.approximateLength += 6;
|
|
@@ -55402,15 +55405,15 @@ function createTypeChecker(host) {
|
|
|
55402
55405
|
context.approximateLength += 13;
|
|
55403
55406
|
return factory.createTypeOperatorNode(158 /* UniqueKeyword */, factory.createKeywordTypeNode(155 /* SymbolKeyword */));
|
|
55404
55407
|
}
|
|
55405
|
-
if (type.flags &
|
|
55408
|
+
if (type.flags & 16384 /* Void */) {
|
|
55406
55409
|
context.approximateLength += 4;
|
|
55407
55410
|
return factory.createKeywordTypeNode(116 /* VoidKeyword */);
|
|
55408
55411
|
}
|
|
55409
|
-
if (type.flags &
|
|
55412
|
+
if (type.flags & 32768 /* Undefined */) {
|
|
55410
55413
|
context.approximateLength += 9;
|
|
55411
55414
|
return factory.createKeywordTypeNode(157 /* UndefinedKeyword */);
|
|
55412
55415
|
}
|
|
55413
|
-
if (type.flags &
|
|
55416
|
+
if (type.flags & 65536 /* Null */) {
|
|
55414
55417
|
context.approximateLength += 4;
|
|
55415
55418
|
return factory.createLiteralTypeNode(factory.createNull());
|
|
55416
55419
|
}
|
|
@@ -55418,7 +55421,7 @@ function createTypeChecker(host) {
|
|
|
55418
55421
|
context.approximateLength += 5;
|
|
55419
55422
|
return factory.createKeywordTypeNode(146 /* NeverKeyword */);
|
|
55420
55423
|
}
|
|
55421
|
-
if (type.flags &
|
|
55424
|
+
if (type.flags & 4096 /* ESSymbol */) {
|
|
55422
55425
|
context.approximateLength += 6;
|
|
55423
55426
|
return factory.createKeywordTypeNode(155 /* SymbolKeyword */);
|
|
55424
55427
|
}
|
|
@@ -56184,12 +56187,13 @@ function createTypeChecker(host) {
|
|
|
56184
56187
|
if (propertySymbol.flags & 98304 /* Accessor */) {
|
|
56185
56188
|
const writeType = getWriteTypeOfSymbol(propertySymbol);
|
|
56186
56189
|
if (propertyType !== writeType && !isErrorType(propertyType) && !isErrorType(writeType)) {
|
|
56190
|
+
const symbolMapper = getSymbolLinks(propertySymbol).mapper;
|
|
56187
56191
|
const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */);
|
|
56188
56192
|
const getterSignature = getSignatureFromDeclaration(getterDeclaration);
|
|
56189
56193
|
typeElements.push(
|
|
56190
56194
|
setCommentRange2(
|
|
56191
56195
|
context,
|
|
56192
|
-
signatureToSignatureDeclarationHelper(getterSignature, 177 /* GetAccessor */, context, { name: propertyName }),
|
|
56196
|
+
signatureToSignatureDeclarationHelper(symbolMapper ? instantiateSignature(getterSignature, symbolMapper) : getterSignature, 177 /* GetAccessor */, context, { name: propertyName }),
|
|
56193
56197
|
getterDeclaration
|
|
56194
56198
|
)
|
|
56195
56199
|
);
|
|
@@ -56198,7 +56202,7 @@ function createTypeChecker(host) {
|
|
|
56198
56202
|
typeElements.push(
|
|
56199
56203
|
setCommentRange2(
|
|
56200
56204
|
context,
|
|
56201
|
-
signatureToSignatureDeclarationHelper(setterSignature, 178 /* SetAccessor */, context, { name: propertyName }),
|
|
56205
|
+
signatureToSignatureDeclarationHelper(symbolMapper ? instantiateSignature(setterSignature, symbolMapper) : setterSignature, 178 /* SetAccessor */, context, { name: propertyName }),
|
|
56202
56206
|
setterDeclaration
|
|
56203
56207
|
)
|
|
56204
56208
|
);
|
|
@@ -56207,7 +56211,7 @@ function createTypeChecker(host) {
|
|
|
56207
56211
|
}
|
|
56208
56212
|
const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
56209
56213
|
if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
|
|
56210
|
-
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags &
|
|
56214
|
+
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */);
|
|
56211
56215
|
for (const signature of signatures) {
|
|
56212
56216
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 173 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
56213
56217
|
typeElements.push(preserveCommentsOn(methodDeclaration, signature.declaration || propertySymbol.valueDeclaration));
|
|
@@ -57247,11 +57251,11 @@ function createTypeChecker(host) {
|
|
|
57247
57251
|
}
|
|
57248
57252
|
if (isComputedPropertyName(name)) {
|
|
57249
57253
|
const type = checkExpression(name.expression);
|
|
57250
|
-
return !!(type.flags &
|
|
57254
|
+
return !!(type.flags & 402653316 /* StringLike */);
|
|
57251
57255
|
}
|
|
57252
57256
|
if (isElementAccessExpression(name)) {
|
|
57253
57257
|
const type = checkExpression(name.argumentExpression);
|
|
57254
|
-
return !!(type.flags &
|
|
57258
|
+
return !!(type.flags & 402653316 /* StringLike */);
|
|
57255
57259
|
}
|
|
57256
57260
|
return isStringLiteral(name);
|
|
57257
57261
|
}
|
|
@@ -57277,7 +57281,7 @@ function createTypeChecker(host) {
|
|
|
57277
57281
|
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote, stringNamed, isMethod) {
|
|
57278
57282
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
57279
57283
|
if (nameType) {
|
|
57280
|
-
if (nameType.flags &
|
|
57284
|
+
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
57281
57285
|
const name = "" + nameType.value;
|
|
57282
57286
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && (stringNamed || !isNumericLiteralName(name))) {
|
|
57283
57287
|
return factory.createStringLiteral(name, !!singleQuote);
|
|
@@ -57287,7 +57291,7 @@ function createTypeChecker(host) {
|
|
|
57287
57291
|
}
|
|
57288
57292
|
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
|
|
57289
57293
|
}
|
|
57290
|
-
if (nameType.flags &
|
|
57294
|
+
if (nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
57291
57295
|
return factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
|
|
57292
57296
|
}
|
|
57293
57297
|
}
|
|
@@ -57329,7 +57333,7 @@ function createTypeChecker(host) {
|
|
|
57329
57333
|
return enclosingDeclaration;
|
|
57330
57334
|
}
|
|
57331
57335
|
function serializeInferredTypeForDeclaration(symbol, context, type) {
|
|
57332
|
-
if (type.flags &
|
|
57336
|
+
if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === context.enclosingFile))) {
|
|
57333
57337
|
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
57334
57338
|
}
|
|
57335
57339
|
const result = typeToTypeNodeHelper(type, context);
|
|
@@ -57341,13 +57345,13 @@ function createTypeChecker(host) {
|
|
|
57341
57345
|
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
|
|
57342
57346
|
const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
|
57343
57347
|
if (decl) {
|
|
57348
|
+
const restore = addSymbolTypeToContext(context, symbol, type);
|
|
57344
57349
|
if (isAccessor(decl)) {
|
|
57345
57350
|
result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
|
|
57346
57351
|
} else if (hasInferredType(decl) && !nodeIsSynthesized(decl) && !(getObjectFlags(type) & 196608 /* RequiresWidening */)) {
|
|
57347
|
-
const restore = addSymbolTypeToContext(context, symbol, type);
|
|
57348
57352
|
result = syntacticNodeBuilder.serializeTypeOfDeclaration(decl, symbol, context);
|
|
57349
|
-
restore();
|
|
57350
57353
|
}
|
|
57354
|
+
restore();
|
|
57351
57355
|
}
|
|
57352
57356
|
if (!result) {
|
|
57353
57357
|
if (addUndefinedForParameter) {
|
|
@@ -57562,7 +57566,7 @@ function createTypeChecker(host) {
|
|
|
57562
57566
|
}
|
|
57563
57567
|
function serializeExistingTypeNode(context, typeNode, addUndefined) {
|
|
57564
57568
|
const type = getTypeFromTypeNode2(context, typeNode);
|
|
57565
|
-
if (addUndefined && !someType(type, (t) => !!(t.flags &
|
|
57569
|
+
if (addUndefined && !someType(type, (t) => !!(t.flags & 32768 /* Undefined */)) && canReuseTypeNode(context, typeNode)) {
|
|
57566
57570
|
const clone2 = syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode);
|
|
57567
57571
|
if (clone2) {
|
|
57568
57572
|
return factory.createUnionTypeNode([clone2, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
@@ -59101,9 +59105,9 @@ function createTypeChecker(host) {
|
|
|
59101
59105
|
for (let i = 0; i < types.length; i++) {
|
|
59102
59106
|
const t = types[i];
|
|
59103
59107
|
flags |= t.flags;
|
|
59104
|
-
if (!(t.flags &
|
|
59105
|
-
if (t.flags & (
|
|
59106
|
-
const baseType = t.flags &
|
|
59108
|
+
if (!(t.flags & 98304 /* Nullable */)) {
|
|
59109
|
+
if (t.flags & (512 /* BooleanLiteral */ | 1056 /* EnumLike */)) {
|
|
59110
|
+
const baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLikeType(t);
|
|
59107
59111
|
if (baseType.flags & 1048576 /* Union */) {
|
|
59108
59112
|
const count = baseType.types.length;
|
|
59109
59113
|
if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
|
|
@@ -59116,8 +59120,8 @@ function createTypeChecker(host) {
|
|
|
59116
59120
|
result.push(t);
|
|
59117
59121
|
}
|
|
59118
59122
|
}
|
|
59119
|
-
if (flags &
|
|
59120
|
-
if (flags &
|
|
59123
|
+
if (flags & 65536 /* Null */) result.push(nullType);
|
|
59124
|
+
if (flags & 32768 /* Undefined */) result.push(undefinedType);
|
|
59121
59125
|
return result || types;
|
|
59122
59126
|
}
|
|
59123
59127
|
function visibilityToString(flags) {
|
|
@@ -59147,7 +59151,7 @@ function createTypeChecker(host) {
|
|
|
59147
59151
|
function getNameOfSymbolFromNameType(symbol, context) {
|
|
59148
59152
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
59149
59153
|
if (nameType) {
|
|
59150
|
-
if (nameType.flags &
|
|
59154
|
+
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
59151
59155
|
const name = "" + nameType.value;
|
|
59152
59156
|
if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
59153
59157
|
return `"${escapeString(name, 34 /* doubleQuote */)}"`;
|
|
@@ -59157,7 +59161,7 @@ function createTypeChecker(host) {
|
|
|
59157
59161
|
}
|
|
59158
59162
|
return name;
|
|
59159
59163
|
}
|
|
59160
|
-
if (nameType.flags &
|
|
59164
|
+
if (nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
59161
59165
|
return `[${getNameOfSymbolAsWritten(nameType.symbol, context)}]`;
|
|
59162
59166
|
}
|
|
59163
59167
|
}
|
|
@@ -59182,7 +59186,7 @@ function createTypeChecker(host) {
|
|
|
59182
59186
|
}
|
|
59183
59187
|
if (isComputedPropertyName(name2) && !(getCheckFlags(symbol) & 4096 /* Late */)) {
|
|
59184
59188
|
const nameType = getSymbolLinks(symbol).nameType;
|
|
59185
|
-
if (nameType && nameType.flags &
|
|
59189
|
+
if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
59186
59190
|
const result = getNameOfSymbolFromNameType(symbol, context);
|
|
59187
59191
|
if (result !== void 0) {
|
|
59188
59192
|
return result;
|
|
@@ -59463,7 +59467,7 @@ function createTypeChecker(host) {
|
|
|
59463
59467
|
);
|
|
59464
59468
|
}
|
|
59465
59469
|
function getRestType(source, properties, symbol) {
|
|
59466
|
-
source = filterType(source, (t) => !(t.flags &
|
|
59470
|
+
source = filterType(source, (t) => !(t.flags & 98304 /* Nullable */));
|
|
59467
59471
|
if (source.flags & 131072 /* Never */) {
|
|
59468
59472
|
return emptyObjectType;
|
|
59469
59473
|
}
|
|
@@ -59474,7 +59478,7 @@ function createTypeChecker(host) {
|
|
|
59474
59478
|
const spreadableProperties = [];
|
|
59475
59479
|
const unspreadableToRestKeys = [];
|
|
59476
59480
|
for (const prop of getPropertiesOfType(source)) {
|
|
59477
|
-
const literalTypeFromProperty = getLiteralTypeFromProperty(prop,
|
|
59481
|
+
const literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
59478
59482
|
if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) && !(getDeclarationModifierFlagsFromSymbol(prop) & (2 /* Private */ | 4 /* Protected */)) && isSpreadableProperty(prop)) {
|
|
59479
59483
|
spreadableProperties.push(prop);
|
|
59480
59484
|
} else {
|
|
@@ -59507,7 +59511,7 @@ function createTypeChecker(host) {
|
|
|
59507
59511
|
return result;
|
|
59508
59512
|
}
|
|
59509
59513
|
function isGenericTypeWithUndefinedConstraint(type) {
|
|
59510
|
-
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType,
|
|
59514
|
+
return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */);
|
|
59511
59515
|
}
|
|
59512
59516
|
function getNonUndefinedType(type) {
|
|
59513
59517
|
const typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, (t) => t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t) : type;
|
|
@@ -59561,7 +59565,7 @@ function createTypeChecker(host) {
|
|
|
59561
59565
|
}
|
|
59562
59566
|
function getLiteralPropertyNameText(name) {
|
|
59563
59567
|
const type = getLiteralTypeFromPropertyName(name);
|
|
59564
|
-
return type.flags & (
|
|
59568
|
+
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
59565
59569
|
}
|
|
59566
59570
|
function getTypeForBindingElement(declaration) {
|
|
59567
59571
|
const checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
@@ -59901,7 +59905,7 @@ function createTypeChecker(host) {
|
|
|
59901
59905
|
definedInConstructor = true;
|
|
59902
59906
|
}
|
|
59903
59907
|
}
|
|
59904
|
-
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~
|
|
59908
|
+
const sourceTypes = some(constructorTypes, (t) => !!(t.flags & ~98304 /* Nullable */)) ? constructorTypes : types;
|
|
59905
59909
|
type = getUnionType(sourceTypes);
|
|
59906
59910
|
}
|
|
59907
59911
|
}
|
|
@@ -59911,7 +59915,7 @@ function createTypeChecker(host) {
|
|
|
59911
59915
|
false,
|
|
59912
59916
|
definedInMethod && !definedInConstructor
|
|
59913
59917
|
));
|
|
59914
|
-
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~
|
|
59918
|
+
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~98304 /* Nullable */)) === neverType) {
|
|
59915
59919
|
reportImplicitAny(symbol.valueDeclaration, anyType);
|
|
59916
59920
|
return anyType;
|
|
59917
59921
|
}
|
|
@@ -60209,13 +60213,13 @@ function createTypeChecker(host) {
|
|
|
60209
60213
|
}
|
|
60210
60214
|
function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors2) {
|
|
60211
60215
|
if (type) {
|
|
60212
|
-
if (type.flags &
|
|
60216
|
+
if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) {
|
|
60213
60217
|
type = getESSymbolLikeTypeForNode(declaration);
|
|
60214
60218
|
}
|
|
60215
60219
|
if (reportErrors2) {
|
|
60216
60220
|
reportErrorsFromWidening(declaration, type);
|
|
60217
60221
|
}
|
|
60218
|
-
if (type.flags &
|
|
60222
|
+
if (type.flags & 8192 /* UniqueESSymbol */ && (isBindingElement(declaration) || !tryGetTypeFromEffectiveTypeNode(declaration)) && type.symbol !== getSymbolOfDeclaration(declaration)) {
|
|
60219
60223
|
type = esSymbolType;
|
|
60220
60224
|
}
|
|
60221
60225
|
return getWidenedType(type);
|
|
@@ -61052,7 +61056,7 @@ function createTypeChecker(host) {
|
|
|
61052
61056
|
return links.declaredType;
|
|
61053
61057
|
}
|
|
61054
61058
|
function getBaseTypeOfEnumLikeType(type) {
|
|
61055
|
-
return type.flags &
|
|
61059
|
+
return type.flags & 1056 /* EnumLike */ && type.symbol.flags & 8 /* EnumMember */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
|
|
61056
61060
|
}
|
|
61057
61061
|
function getDeclaredTypeOfEnum(symbol) {
|
|
61058
61062
|
const links = getSymbolLinks(symbol);
|
|
@@ -61083,7 +61087,7 @@ function createTypeChecker(host) {
|
|
|
61083
61087
|
void 0
|
|
61084
61088
|
) : createComputedEnumType(symbol);
|
|
61085
61089
|
if (enumType.flags & 1048576 /* Union */) {
|
|
61086
|
-
enumType.flags |=
|
|
61090
|
+
enumType.flags |= 1024 /* EnumLiteral */;
|
|
61087
61091
|
enumType.symbol = symbol;
|
|
61088
61092
|
}
|
|
61089
61093
|
links.declaredType = enumType;
|
|
@@ -61091,8 +61095,8 @@ function createTypeChecker(host) {
|
|
|
61091
61095
|
return links.declaredType;
|
|
61092
61096
|
}
|
|
61093
61097
|
function createComputedEnumType(symbol) {
|
|
61094
|
-
const regularType = createTypeWithSymbol(
|
|
61095
|
-
const freshType = createTypeWithSymbol(
|
|
61098
|
+
const regularType = createTypeWithSymbol(32 /* Enum */, symbol);
|
|
61099
|
+
const freshType = createTypeWithSymbol(32 /* Enum */, symbol);
|
|
61096
61100
|
regularType.regularType = regularType;
|
|
61097
61101
|
regularType.freshType = freshType;
|
|
61098
61102
|
freshType.regularType = regularType;
|
|
@@ -61294,7 +61298,7 @@ function createTypeChecker(host) {
|
|
|
61294
61298
|
const earlySymbol = earlySymbols && earlySymbols.get(memberName);
|
|
61295
61299
|
if (!(parent2.flags & 32 /* Class */) && lateSymbol.flags & getExcludedSymbolFlags(symbolFlags)) {
|
|
61296
61300
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
61297
|
-
const name = !(type.flags &
|
|
61301
|
+
const name = !(type.flags & 8192 /* UniqueESSymbol */) && unescapeLeadingUnderscores(memberName) || declarationNameToString(declName);
|
|
61298
61302
|
forEach(declarations, (declaration) => error2(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
61299
61303
|
error2(declName || decl, Diagnostics.Duplicate_property_0, name);
|
|
61300
61304
|
lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
|
|
@@ -61989,7 +61993,7 @@ function createTypeChecker(host) {
|
|
|
61989
61993
|
if (baseConstructorIndexInfo) {
|
|
61990
61994
|
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
|
61991
61995
|
}
|
|
61992
|
-
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags &
|
|
61996
|
+
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || some(type.properties, (prop) => !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */)))) {
|
|
61993
61997
|
indexInfos = append(indexInfos, enumNumberIndexInfo);
|
|
61994
61998
|
}
|
|
61995
61999
|
}
|
|
@@ -62050,7 +62054,7 @@ function createTypeChecker(host) {
|
|
|
62050
62054
|
const limitedConstraint = getLimitedConstraint(type);
|
|
62051
62055
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
62052
62056
|
if (limitedConstraint) {
|
|
62053
|
-
const propertyNameType = getLiteralTypeFromProperty(prop,
|
|
62057
|
+
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
62054
62058
|
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
62055
62059
|
continue;
|
|
62056
62060
|
}
|
|
@@ -62103,7 +62107,7 @@ function createTypeChecker(host) {
|
|
|
62103
62107
|
}
|
|
62104
62108
|
if (type.flags & 2097152 /* Intersection */) {
|
|
62105
62109
|
const types = type.types;
|
|
62106
|
-
if (types.length === 2 && !!(types[0].flags & (
|
|
62110
|
+
if (types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType) {
|
|
62107
62111
|
return type;
|
|
62108
62112
|
}
|
|
62109
62113
|
return getIntersectionType(sameMap(type.types, getLowerBoundOfKeyType));
|
|
@@ -62121,7 +62125,7 @@ function createTypeChecker(host) {
|
|
|
62121
62125
|
cb(stringType);
|
|
62122
62126
|
} else {
|
|
62123
62127
|
for (const info of getIndexInfosOfType(type)) {
|
|
62124
|
-
if (!stringsOnly || info.keyType.flags & (
|
|
62128
|
+
if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
62125
62129
|
cb(info.keyType);
|
|
62126
62130
|
}
|
|
62127
62131
|
}
|
|
@@ -62139,7 +62143,7 @@ function createTypeChecker(host) {
|
|
|
62139
62143
|
const templateType = getTemplateTypeFromMappedType(mappedType);
|
|
62140
62144
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
62141
62145
|
const templateModifiers = getMappedTypeModifiers(type);
|
|
62142
|
-
const include =
|
|
62146
|
+
const include = 8576 /* StringOrNumberLiteralOrUnique */;
|
|
62143
62147
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
62144
62148
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
62145
62149
|
modifiersType,
|
|
@@ -62179,8 +62183,8 @@ function createTypeChecker(host) {
|
|
|
62179
62183
|
}
|
|
62180
62184
|
members.set(propName, prop);
|
|
62181
62185
|
}
|
|
62182
|
-
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ |
|
|
62183
|
-
const indexKeyType = propNameType.flags & (1 /* Any */ |
|
|
62186
|
+
} else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) {
|
|
62187
|
+
const indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : propNameType;
|
|
62184
62188
|
const propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType));
|
|
62185
62189
|
const modifiersIndexInfo = getApplicableIndexInfo(modifiersType, propNameType);
|
|
62186
62190
|
const isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || !(templateModifiers & 2 /* ExcludeReadonly */) && (modifiersIndexInfo == null ? void 0 : modifiersIndexInfo.isReadonly));
|
|
@@ -62205,7 +62209,7 @@ function createTypeChecker(host) {
|
|
|
62205
62209
|
const templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType);
|
|
62206
62210
|
const mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.links.keyType);
|
|
62207
62211
|
const propType = instantiateType(templateType, mapper);
|
|
62208
|
-
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType,
|
|
62212
|
+
let type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(
|
|
62209
62213
|
propType,
|
|
62210
62214
|
/*isProperty*/
|
|
62211
62215
|
true
|
|
@@ -62499,14 +62503,14 @@ function createTypeChecker(host) {
|
|
|
62499
62503
|
constraints = append(constraints, t);
|
|
62500
62504
|
}
|
|
62501
62505
|
}
|
|
62502
|
-
} else if (t.flags &
|
|
62506
|
+
} else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
62503
62507
|
hasDisjointDomainType = true;
|
|
62504
62508
|
}
|
|
62505
62509
|
}
|
|
62506
62510
|
if (constraints && (targetIsUnion || hasDisjointDomainType)) {
|
|
62507
62511
|
if (hasDisjointDomainType) {
|
|
62508
62512
|
for (const t of types) {
|
|
62509
|
-
if (t.flags &
|
|
62513
|
+
if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) {
|
|
62510
62514
|
constraints = append(constraints, t);
|
|
62511
62515
|
}
|
|
62512
62516
|
}
|
|
@@ -62707,7 +62711,7 @@ function createTypeChecker(host) {
|
|
|
62707
62711
|
function getApparentType(type) {
|
|
62708
62712
|
const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
|
|
62709
62713
|
const objectFlags = getObjectFlags(t);
|
|
62710
|
-
return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags &
|
|
62714
|
+
return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? stringNumberSymbolType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
|
|
62711
62715
|
}
|
|
62712
62716
|
function getReducedApparentType(type) {
|
|
62713
62717
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
@@ -63059,7 +63063,7 @@ function createTypeChecker(host) {
|
|
|
63059
63063
|
)) : applicableInfo ? applicableInfo : stringIndexInfo && isApplicableIndexType(keyType, stringType) ? stringIndexInfo : void 0;
|
|
63060
63064
|
}
|
|
63061
63065
|
function isApplicableIndexType(source, target) {
|
|
63062
|
-
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags &
|
|
63066
|
+
return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && isNumericLiteralName(source.value));
|
|
63063
63067
|
}
|
|
63064
63068
|
function getIndexInfosOfStructuredType(type) {
|
|
63065
63069
|
if (type.flags & 3670016 /* StructuredType */) {
|
|
@@ -63388,7 +63392,7 @@ function createTypeChecker(host) {
|
|
|
63388
63392
|
}
|
|
63389
63393
|
if (type || jsdocPredicate) {
|
|
63390
63394
|
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
63391
|
-
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags &
|
|
63395
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 16 /* Boolean */) && getParameterCount(signature) > 0) {
|
|
63392
63396
|
const { declaration } = signature;
|
|
63393
63397
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
63394
63398
|
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
@@ -63673,7 +63677,7 @@ function createTypeChecker(host) {
|
|
|
63673
63677
|
return emptyArray;
|
|
63674
63678
|
}
|
|
63675
63679
|
function isValidIndexKeyType(type) {
|
|
63676
|
-
return !!(type.flags & (
|
|
63680
|
+
return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && some(type.types, isValidIndexKeyType);
|
|
63677
63681
|
}
|
|
63678
63682
|
function getConstraintDeclaration(type) {
|
|
63679
63683
|
return mapDefined(filter(type.symbol && type.symbol.declarations, isTypeParameterDeclaration), getEffectiveConstraintOfTypeParameter)[0];
|
|
@@ -64049,11 +64053,14 @@ function createTypeChecker(host) {
|
|
|
64049
64053
|
function isNoInferType(type) {
|
|
64050
64054
|
return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
|
|
64051
64055
|
}
|
|
64052
|
-
function
|
|
64053
|
-
return
|
|
64056
|
+
function isNarrowingSubstitutionType(type) {
|
|
64057
|
+
return !!(type.flags & 33554432 /* Substitution */ && type.objectFlags & 16777216 /* IsNarrowingType */);
|
|
64054
64058
|
}
|
|
64055
|
-
function
|
|
64056
|
-
|
|
64059
|
+
function getSubstitutionType(baseType, constraint, isNarrowed) {
|
|
64060
|
+
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint, isNarrowed);
|
|
64061
|
+
}
|
|
64062
|
+
function getOrCreateSubstitutionType(baseType, constraint, isNarrowed) {
|
|
64063
|
+
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}${isNarrowed ? ">N" : ""}`;
|
|
64057
64064
|
const cached = substitutionTypes.get(id);
|
|
64058
64065
|
if (cached) {
|
|
64059
64066
|
return cached;
|
|
@@ -64061,6 +64068,9 @@ function createTypeChecker(host) {
|
|
|
64061
64068
|
const result = createType(33554432 /* Substitution */);
|
|
64062
64069
|
result.baseType = baseType;
|
|
64063
64070
|
result.constraint = constraint;
|
|
64071
|
+
if (isNarrowed) {
|
|
64072
|
+
result.objectFlags |= 16777216 /* IsNarrowingType */;
|
|
64073
|
+
}
|
|
64064
64074
|
substitutionTypes.set(id, result);
|
|
64065
64075
|
return result;
|
|
64066
64076
|
}
|
|
@@ -64174,7 +64184,7 @@ function createTypeChecker(host) {
|
|
|
64174
64184
|
}
|
|
64175
64185
|
function getTypeFromJSDocNullableTypeNode(node) {
|
|
64176
64186
|
const type = getTypeFromTypeNode(node.type);
|
|
64177
|
-
return strictNullChecks ? getNullableType(type,
|
|
64187
|
+
return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type;
|
|
64178
64188
|
}
|
|
64179
64189
|
function getTypeFromTypeReference(node) {
|
|
64180
64190
|
const links = getNodeLinks(node);
|
|
@@ -64947,10 +64957,10 @@ function createTypeChecker(host) {
|
|
|
64947
64957
|
return type.id;
|
|
64948
64958
|
}
|
|
64949
64959
|
function containsType(types, type) {
|
|
64950
|
-
return binarySearch(types, type,
|
|
64960
|
+
return binarySearch(types, type, getTypeId, compareValues) >= 0;
|
|
64951
64961
|
}
|
|
64952
64962
|
function insertType(types, type) {
|
|
64953
|
-
const index = binarySearch(types, type,
|
|
64963
|
+
const index = binarySearch(types, type, getTypeId, compareValues);
|
|
64954
64964
|
if (index < 0) {
|
|
64955
64965
|
types.splice(~index, 0, type);
|
|
64956
64966
|
return true;
|
|
@@ -64965,10 +64975,11 @@ function createTypeChecker(host) {
|
|
|
64965
64975
|
if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) includes |= 536870912 /* IncludesConstrainedTypeVariable */;
|
|
64966
64976
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
64967
64977
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
64968
|
-
if (!strictNullChecks && flags &
|
|
64978
|
+
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
64969
64979
|
if (!(getObjectFlags(type) & 65536 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */;
|
|
64970
64980
|
} else {
|
|
64971
|
-
const
|
|
64981
|
+
const len = typeSet.length;
|
|
64982
|
+
const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues);
|
|
64972
64983
|
if (index < 0) {
|
|
64973
64984
|
typeSet.splice(~index, 0, type);
|
|
64974
64985
|
}
|
|
@@ -65046,7 +65057,7 @@ function createTypeChecker(host) {
|
|
|
65046
65057
|
i--;
|
|
65047
65058
|
const t = types[i];
|
|
65048
65059
|
const flags = t.flags;
|
|
65049
|
-
const remove = flags & (
|
|
65060
|
+
const remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || isFreshLiteralType(t) && containsType(types, t.regularType);
|
|
65050
65061
|
if (remove) {
|
|
65051
65062
|
orderedRemoveItemAt(types, i);
|
|
65052
65063
|
}
|
|
@@ -65059,7 +65070,7 @@ function createTypeChecker(host) {
|
|
|
65059
65070
|
while (i > 0) {
|
|
65060
65071
|
i--;
|
|
65061
65072
|
const t = types[i];
|
|
65062
|
-
if (t.flags &
|
|
65073
|
+
if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) {
|
|
65063
65074
|
orderedRemoveItemAt(types, i);
|
|
65064
65075
|
}
|
|
65065
65076
|
}
|
|
@@ -65157,15 +65168,15 @@ function createTypeChecker(host) {
|
|
|
65157
65168
|
if (includes & 3 /* AnyOrUnknown */) {
|
|
65158
65169
|
return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType : unknownType;
|
|
65159
65170
|
}
|
|
65160
|
-
if (includes &
|
|
65171
|
+
if (includes & 32768 /* Undefined */) {
|
|
65161
65172
|
if (typeSet.length >= 2 && typeSet[0] === undefinedType && typeSet[1] === missingType) {
|
|
65162
65173
|
orderedRemoveItemAt(typeSet, 1);
|
|
65163
65174
|
}
|
|
65164
65175
|
}
|
|
65165
|
-
if (includes & (
|
|
65176
|
+
if (includes & (32 /* Enum */ | 2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) {
|
|
65166
65177
|
removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */));
|
|
65167
65178
|
}
|
|
65168
|
-
if (includes &
|
|
65179
|
+
if (includes & 128 /* StringLiteral */ && includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
65169
65180
|
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
|
65170
65181
|
}
|
|
65171
65182
|
if (includes & 536870912 /* IncludesConstrainedTypeVariable */) {
|
|
@@ -65178,7 +65189,7 @@ function createTypeChecker(host) {
|
|
|
65178
65189
|
}
|
|
65179
65190
|
}
|
|
65180
65191
|
if (typeSet.length === 0) {
|
|
65181
|
-
return includes &
|
|
65192
|
+
return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType;
|
|
65182
65193
|
}
|
|
65183
65194
|
}
|
|
65184
65195
|
if (!origin && includes & 1048576 /* Union */) {
|
|
@@ -65201,7 +65212,7 @@ function createTypeChecker(host) {
|
|
|
65201
65212
|
origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
|
|
65202
65213
|
}
|
|
65203
65214
|
}
|
|
65204
|
-
const objectFlags = (includes &
|
|
65215
|
+
const objectFlags = (includes & 36323331 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0);
|
|
65205
65216
|
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
65206
65217
|
}
|
|
65207
65218
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
@@ -65246,14 +65257,14 @@ function createTypeChecker(host) {
|
|
|
65246
65257
|
type.objectFlags = precomputedObjectFlags | getPropagatingFlagsOfTypes(
|
|
65247
65258
|
types,
|
|
65248
65259
|
/*excludeKinds*/
|
|
65249
|
-
|
|
65260
|
+
98304 /* Nullable */
|
|
65250
65261
|
);
|
|
65251
65262
|
type.types = types;
|
|
65252
65263
|
type.origin = origin;
|
|
65253
65264
|
type.aliasSymbol = aliasSymbol;
|
|
65254
65265
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
65255
|
-
if (types.length === 2 && types[0].flags &
|
|
65256
|
-
type.flags |=
|
|
65266
|
+
if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
|
|
65267
|
+
type.flags |= 16 /* Boolean */;
|
|
65257
65268
|
type.intrinsicName = "boolean";
|
|
65258
65269
|
}
|
|
65259
65270
|
unionTypes.set(id, type);
|
|
@@ -65282,13 +65293,13 @@ function createTypeChecker(host) {
|
|
|
65282
65293
|
if (flags & 3 /* AnyOrUnknown */) {
|
|
65283
65294
|
if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
|
|
65284
65295
|
if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
|
|
65285
|
-
} else if (strictNullChecks || !(flags &
|
|
65296
|
+
} else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
|
|
65286
65297
|
if (type === missingType) {
|
|
65287
65298
|
includes |= 262144 /* IncludesMissingType */;
|
|
65288
65299
|
type = undefinedType;
|
|
65289
65300
|
}
|
|
65290
65301
|
if (!typeSet.has(type.id.toString())) {
|
|
65291
|
-
if (type.flags &
|
|
65302
|
+
if (type.flags & 109472 /* Unit */ && includes & 109472 /* Unit */) {
|
|
65292
65303
|
includes |= 67108864 /* NonPrimitive */;
|
|
65293
65304
|
}
|
|
65294
65305
|
typeSet.set(type.id.toString(), type);
|
|
@@ -65309,7 +65320,7 @@ function createTypeChecker(host) {
|
|
|
65309
65320
|
while (i > 0) {
|
|
65310
65321
|
i--;
|
|
65311
65322
|
const t = types[i];
|
|
65312
|
-
const remove = t.flags &
|
|
65323
|
+
const remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ || isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */;
|
|
65313
65324
|
if (remove) {
|
|
65314
65325
|
orderedRemoveItemAt(types, i);
|
|
65315
65326
|
}
|
|
@@ -65324,7 +65335,7 @@ function createTypeChecker(host) {
|
|
|
65324
65335
|
if (type === undefinedType) {
|
|
65325
65336
|
return containsType(u.types, missingType);
|
|
65326
65337
|
}
|
|
65327
|
-
const primitive = type.flags &
|
|
65338
|
+
const primitive = type.flags & 128 /* StringLiteral */ ? stringType : type.flags & (32 /* Enum */ | 256 /* NumberLiteral */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : void 0;
|
|
65328
65339
|
if (!primitive || !containsType(u.types, primitive)) {
|
|
65329
65340
|
return false;
|
|
65330
65341
|
}
|
|
@@ -65334,7 +65345,7 @@ function createTypeChecker(host) {
|
|
|
65334
65345
|
}
|
|
65335
65346
|
function extractRedundantTemplateLiterals(types) {
|
|
65336
65347
|
let i = types.length;
|
|
65337
|
-
const literals = filter(types, (t) => !!(t.flags &
|
|
65348
|
+
const literals = filter(types, (t) => !!(t.flags & 128 /* StringLiteral */));
|
|
65338
65349
|
while (i > 0) {
|
|
65339
65350
|
i--;
|
|
65340
65351
|
const t = types[i];
|
|
@@ -65400,7 +65411,7 @@ function createTypeChecker(host) {
|
|
|
65400
65411
|
result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
|
|
65401
65412
|
types,
|
|
65402
65413
|
/*excludeKinds*/
|
|
65403
|
-
|
|
65414
|
+
98304 /* Nullable */
|
|
65404
65415
|
);
|
|
65405
65416
|
result.types = types;
|
|
65406
65417
|
result.aliasSymbol = aliasSymbol;
|
|
@@ -65415,19 +65426,19 @@ function createTypeChecker(host) {
|
|
|
65415
65426
|
if (includes & 131072 /* Never */) {
|
|
65416
65427
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
65417
65428
|
}
|
|
65418
|
-
if (strictNullChecks && includes &
|
|
65429
|
+
if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) {
|
|
65419
65430
|
return neverType;
|
|
65420
65431
|
}
|
|
65421
|
-
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes &
|
|
65432
|
+
if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) {
|
|
65422
65433
|
return neverType;
|
|
65423
65434
|
}
|
|
65424
65435
|
if (includes & 1 /* Any */) {
|
|
65425
65436
|
return includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType;
|
|
65426
65437
|
}
|
|
65427
|
-
if (!strictNullChecks && includes &
|
|
65428
|
-
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes &
|
|
65438
|
+
if (!strictNullChecks && includes & 98304 /* Nullable */) {
|
|
65439
|
+
return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes & 32768 /* Undefined */ ? undefinedType : nullType;
|
|
65429
65440
|
}
|
|
65430
|
-
if (includes &
|
|
65441
|
+
if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || includes & 16384 /* Void */ && includes & 32768 /* Undefined */ || includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) {
|
|
65431
65442
|
if (!(flags & 1 /* NoSupertypeReduction */)) removeRedundantSupertypes(typeSet, includes);
|
|
65432
65443
|
}
|
|
65433
65444
|
if (includes & 262144 /* IncludesMissingType */) {
|
|
@@ -65464,12 +65475,12 @@ function createTypeChecker(host) {
|
|
|
65464
65475
|
if (includes & 1048576 /* Union */) {
|
|
65465
65476
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
65466
65477
|
result = getIntersectionType(typeSet, flags, aliasSymbol, aliasTypeArguments);
|
|
65467
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags &
|
|
65478
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && t.types[0].flags & 32768 /* Undefined */))) {
|
|
65468
65479
|
const containedUndefinedType = some(typeSet, containsMissingType) ? missingType : undefinedType;
|
|
65469
|
-
removeFromEach(typeSet,
|
|
65480
|
+
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
65470
65481
|
result = getUnionType([getIntersectionType(typeSet, flags), containedUndefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
65471
|
-
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags &
|
|
65472
|
-
removeFromEach(typeSet,
|
|
65482
|
+
} else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
|
|
65483
|
+
removeFromEach(typeSet, 65536 /* Null */);
|
|
65473
65484
|
result = getUnionType([getIntersectionType(typeSet, flags), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
65474
65485
|
} else if (typeSet.length >= 3 && types.length > 2) {
|
|
65475
65486
|
const middle = Math.floor(typeSet.length / 2);
|
|
@@ -65534,7 +65545,7 @@ function createTypeChecker(host) {
|
|
|
65534
65545
|
const types = map(node.types, getTypeFromTypeNode);
|
|
65535
65546
|
const emptyIndex = types.length === 2 ? types.indexOf(emptyTypeLiteralType) : -1;
|
|
65536
65547
|
const t = emptyIndex >= 0 ? types[1 - emptyIndex] : unknownType;
|
|
65537
|
-
const noSupertypeReduction = !!(t.flags & (
|
|
65548
|
+
const noSupertypeReduction = !!(t.flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */) || t.flags & 134217728 /* TemplateLiteral */ && isPatternLiteralType(t));
|
|
65538
65549
|
links.resolvedType = getIntersectionType(types, noSupertypeReduction ? 1 /* NoSupertypeReduction */ : 0, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
65539
65550
|
}
|
|
65540
65551
|
return links.resolvedType;
|
|
@@ -65568,11 +65579,11 @@ function createTypeChecker(host) {
|
|
|
65568
65579
|
forEachType(constraintType, addMemberForKeyType);
|
|
65569
65580
|
} else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
65570
65581
|
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
65571
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType,
|
|
65582
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
|
|
65572
65583
|
} else {
|
|
65573
65584
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
65574
65585
|
}
|
|
65575
|
-
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ |
|
|
65586
|
+
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ | 4 /* String */))) : getUnionType(keyTypes);
|
|
65576
65587
|
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
65577
65588
|
return constraintType;
|
|
65578
65589
|
}
|
|
@@ -65627,7 +65638,7 @@ function createTypeChecker(host) {
|
|
|
65627
65638
|
function getLiteralTypeFromProperties(type, include, includeOrigin) {
|
|
65628
65639
|
const origin = includeOrigin && (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : void 0;
|
|
65629
65640
|
const propertyTypes = map(getPropertiesOfType(type), (prop) => getLiteralTypeFromProperty(prop, include));
|
|
65630
|
-
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include &
|
|
65641
|
+
const indexKeyTypes = map(getIndexInfosOfType(type), (info) => info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType);
|
|
65631
65642
|
return getUnionType(
|
|
65632
65643
|
concatenate(propertyTypes, indexKeyTypes),
|
|
65633
65644
|
1 /* Literal */,
|
|
@@ -65643,7 +65654,7 @@ function createTypeChecker(host) {
|
|
|
65643
65654
|
}
|
|
65644
65655
|
function getIndexType(type, indexFlags = 0 /* None */) {
|
|
65645
65656
|
type = getReducedType(type);
|
|
65646
|
-
return isNoInferType(type) ? getNoInferType(getIndexType(type.baseType, indexFlags)) : shouldDeferIndexType(type, indexFlags) ? getIndexTypeForGenericType(type, indexFlags) : type.flags & 1048576 /* Union */ ? getIntersectionType(map(type.types, (t) => getIndexType(t, indexFlags))) : type.flags & 2097152 /* Intersection */ ? getUnionType(map(type.types, (t) => getIndexType(t, indexFlags))) : getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, indexFlags) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : type.flags & (1 /* Any */ | 131072 /* Never */) ? stringNumberSymbolType : getLiteralTypeFromProperties(type, (indexFlags & 2 /* NoIndexSignatures */ ?
|
|
65657
|
+
return isNoInferType(type) ? getNoInferType(getIndexType(type.baseType, indexFlags)) : shouldDeferIndexType(type, indexFlags) ? getIndexTypeForGenericType(type, indexFlags) : type.flags & 1048576 /* Union */ ? getIntersectionType(map(type.types, (t) => getIndexType(t, indexFlags))) : type.flags & 2097152 /* Intersection */ ? getUnionType(map(type.types, (t) => getIndexType(t, indexFlags))) : getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, indexFlags) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : type.flags & (1 /* Any */ | 131072 /* Never */) ? stringNumberSymbolType : getLiteralTypeFromProperties(type, (indexFlags & 2 /* NoIndexSignatures */ ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (indexFlags & 1 /* StringsOnly */ ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), indexFlags === 0 /* None */);
|
|
65647
65658
|
}
|
|
65648
65659
|
function getExtractStringType(type) {
|
|
65649
65660
|
const extractTypeAlias = getGlobalExtractSymbol();
|
|
@@ -65701,7 +65712,7 @@ function createTypeChecker(host) {
|
|
|
65701
65712
|
}
|
|
65702
65713
|
newTexts.push(text);
|
|
65703
65714
|
if (every(newTexts, (t) => t === "")) {
|
|
65704
|
-
if (every(newTypes, (t) => !!(t.flags &
|
|
65715
|
+
if (every(newTypes, (t) => !!(t.flags & 4 /* String */))) {
|
|
65705
65716
|
return stringType;
|
|
65706
65717
|
}
|
|
65707
65718
|
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
@@ -65717,7 +65728,7 @@ function createTypeChecker(host) {
|
|
|
65717
65728
|
function addSpans(texts2, types2) {
|
|
65718
65729
|
for (let i = 0; i < types2.length; i++) {
|
|
65719
65730
|
const t = types2[i];
|
|
65720
|
-
if (t.flags & (
|
|
65731
|
+
if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) {
|
|
65721
65732
|
text += getTemplateStringForType(t) || "";
|
|
65722
65733
|
text += texts2[i + 1];
|
|
65723
65734
|
} else if (t.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -65736,7 +65747,7 @@ function createTypeChecker(host) {
|
|
|
65736
65747
|
}
|
|
65737
65748
|
}
|
|
65738
65749
|
function getTemplateStringForType(type) {
|
|
65739
|
-
return type.flags &
|
|
65750
|
+
return type.flags & 128 /* StringLiteral */ ? type.value : type.flags & 256 /* NumberLiteral */ ? "" + type.value : type.flags & 2048 /* BigIntLiteral */ ? pseudoBigIntToString(type.value) : type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : void 0;
|
|
65740
65751
|
}
|
|
65741
65752
|
function createTemplateLiteralType(texts, types) {
|
|
65742
65753
|
const type = createType(134217728 /* TemplateLiteral */);
|
|
@@ -65745,9 +65756,9 @@ function createTypeChecker(host) {
|
|
|
65745
65756
|
return type;
|
|
65746
65757
|
}
|
|
65747
65758
|
function getStringMappingType(symbol, type) {
|
|
65748
|
-
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags &
|
|
65759
|
+
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, (t) => getStringMappingType(symbol, t)) : type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType(...applyTemplateStringMapping(symbol, type.texts, type.types)) : (
|
|
65749
65760
|
// Mapping<Mapping<T>> === Mapping<T>
|
|
65750
|
-
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ |
|
|
65761
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : type.flags & (1 /* Any */ | 4 /* String */ | 268435456 /* StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : (
|
|
65751
65762
|
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
65752
65763
|
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) : type
|
|
65753
65764
|
)
|
|
@@ -65885,7 +65896,7 @@ function createTypeChecker(host) {
|
|
|
65885
65896
|
}
|
|
65886
65897
|
}
|
|
65887
65898
|
}
|
|
65888
|
-
if (!(indexType.flags &
|
|
65899
|
+
if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) {
|
|
65889
65900
|
if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
|
|
65890
65901
|
return objectType;
|
|
65891
65902
|
}
|
|
@@ -65901,13 +65912,13 @@ function createTypeChecker(host) {
|
|
|
65901
65912
|
}
|
|
65902
65913
|
return void 0;
|
|
65903
65914
|
}
|
|
65904
|
-
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType,
|
|
65915
|
+
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
|
|
65905
65916
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
65906
65917
|
error2(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
|
|
65907
65918
|
return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
|
|
65908
65919
|
}
|
|
65909
65920
|
errorIfWritingToReadonlyIndex(indexInfo);
|
|
65910
|
-
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags &
|
|
65921
|
+
if (accessFlags & 1 /* IncludeUndefined */ && !(objectType.symbol && objectType.symbol.flags & (256 /* RegularEnum */ | 128 /* ConstEnum */) && (indexType.symbol && indexType.flags & 1024 /* EnumLiteral */ && getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
|
|
65911
65922
|
return getUnionType([indexInfo.type, missingType]);
|
|
65912
65923
|
}
|
|
65913
65924
|
return indexInfo.type;
|
|
@@ -65920,10 +65931,10 @@ function createTypeChecker(host) {
|
|
|
65920
65931
|
}
|
|
65921
65932
|
if (accessExpression && !isConstEnumObjectType(objectType)) {
|
|
65922
65933
|
if (isObjectLiteralType2(objectType)) {
|
|
65923
|
-
if (noImplicitAny && indexType.flags & (
|
|
65934
|
+
if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
65924
65935
|
diagnostics.add(createDiagnosticForNode(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)));
|
|
65925
65936
|
return undefinedType;
|
|
65926
|
-
} else if (indexType.flags & (
|
|
65937
|
+
} else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
|
|
65927
65938
|
const types = map(objectType.properties, (property) => {
|
|
65928
65939
|
return getTypeOfSymbol(property);
|
|
65929
65940
|
});
|
|
@@ -65950,7 +65961,7 @@ function createTypeChecker(host) {
|
|
|
65950
65961
|
error2(accessExpression, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion2);
|
|
65951
65962
|
} else {
|
|
65952
65963
|
let errorInfo;
|
|
65953
|
-
if (indexType.flags &
|
|
65964
|
+
if (indexType.flags & 1024 /* EnumLiteral */) {
|
|
65954
65965
|
errorInfo = chainDiagnosticMessages(
|
|
65955
65966
|
/*details*/
|
|
65956
65967
|
void 0,
|
|
@@ -65958,7 +65969,7 @@ function createTypeChecker(host) {
|
|
|
65958
65969
|
"[" + typeToString(indexType) + "]",
|
|
65959
65970
|
typeToString(objectType)
|
|
65960
65971
|
);
|
|
65961
|
-
} else if (indexType.flags &
|
|
65972
|
+
} else if (indexType.flags & 8192 /* UniqueESSymbol */) {
|
|
65962
65973
|
const symbolName2 = getFullyQualifiedName(indexType.symbol, accessExpression);
|
|
65963
65974
|
errorInfo = chainDiagnosticMessages(
|
|
65964
65975
|
/*details*/
|
|
@@ -65967,7 +65978,7 @@ function createTypeChecker(host) {
|
|
|
65967
65978
|
"[" + symbolName2 + "]",
|
|
65968
65979
|
typeToString(objectType)
|
|
65969
65980
|
);
|
|
65970
|
-
} else if (indexType.flags &
|
|
65981
|
+
} else if (indexType.flags & 128 /* StringLiteral */) {
|
|
65971
65982
|
errorInfo = chainDiagnosticMessages(
|
|
65972
65983
|
/*details*/
|
|
65973
65984
|
void 0,
|
|
@@ -65975,7 +65986,7 @@ function createTypeChecker(host) {
|
|
|
65975
65986
|
indexType.value,
|
|
65976
65987
|
typeToString(objectType)
|
|
65977
65988
|
);
|
|
65978
|
-
} else if (indexType.flags &
|
|
65989
|
+
} else if (indexType.flags & 256 /* NumberLiteral */) {
|
|
65979
65990
|
errorInfo = chainDiagnosticMessages(
|
|
65980
65991
|
/*details*/
|
|
65981
65992
|
void 0,
|
|
@@ -65983,7 +65994,7 @@ function createTypeChecker(host) {
|
|
|
65983
65994
|
indexType.value,
|
|
65984
65995
|
typeToString(objectType)
|
|
65985
65996
|
);
|
|
65986
|
-
} else if (indexType.flags & (
|
|
65997
|
+
} else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
|
|
65987
65998
|
errorInfo = chainDiagnosticMessages(
|
|
65988
65999
|
/*details*/
|
|
65989
66000
|
void 0,
|
|
@@ -66014,9 +66025,9 @@ function createTypeChecker(host) {
|
|
|
66014
66025
|
}
|
|
66015
66026
|
if (accessNode) {
|
|
66016
66027
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
66017
|
-
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (
|
|
66028
|
+
if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
66018
66029
|
error2(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
|
|
66019
|
-
} else if (indexType.flags & (
|
|
66030
|
+
} else if (indexType.flags & (4 /* String */ | 8 /* Number */)) {
|
|
66020
66031
|
error2(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
|
|
66021
66032
|
} else {
|
|
66022
66033
|
const typeString = indexNode.kind === 10 /* BigIntLiteral */ ? "bigint" : typeToString(indexType);
|
|
@@ -66040,7 +66051,7 @@ function createTypeChecker(host) {
|
|
|
66040
66051
|
if (type.flags & 2097152 /* Intersection */) {
|
|
66041
66052
|
let seenPlaceholder = false;
|
|
66042
66053
|
for (const t of type.types) {
|
|
66043
|
-
if (t.flags & (
|
|
66054
|
+
if (t.flags & (2944 /* Literal */ | 98304 /* Nullable */) || isPatternLiteralPlaceholderType(t)) {
|
|
66044
66055
|
seenPlaceholder = true;
|
|
66045
66056
|
} else if (!(t.flags & 524288 /* Object */)) {
|
|
66046
66057
|
return false;
|
|
@@ -66048,7 +66059,7 @@ function createTypeChecker(host) {
|
|
|
66048
66059
|
}
|
|
66049
66060
|
return seenPlaceholder;
|
|
66050
66061
|
}
|
|
66051
|
-
return !!(type.flags & (1 /* Any */ |
|
|
66062
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
|
|
66052
66063
|
}
|
|
66053
66064
|
function isPatternLiteralType(type) {
|
|
66054
66065
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
@@ -66113,10 +66124,10 @@ function createTypeChecker(host) {
|
|
|
66113
66124
|
return type[cache] = distributedOverObject;
|
|
66114
66125
|
}
|
|
66115
66126
|
}
|
|
66116
|
-
if (isGenericTupleType(objectType) && indexType.flags &
|
|
66127
|
+
if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) {
|
|
66117
66128
|
const elementType = getElementTypeOfSliceOfTupleType(
|
|
66118
66129
|
objectType,
|
|
66119
|
-
indexType.flags &
|
|
66130
|
+
indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength,
|
|
66120
66131
|
/*endSkipCount*/
|
|
66121
66132
|
0,
|
|
66122
66133
|
writing
|
|
@@ -66169,14 +66180,14 @@ function createTypeChecker(host) {
|
|
|
66169
66180
|
}
|
|
66170
66181
|
function couldAccessOptionalProperty(objectType, indexType) {
|
|
66171
66182
|
const indexConstraint = getBaseConstraintOfType(indexType);
|
|
66172
|
-
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p,
|
|
66183
|
+
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */), indexConstraint));
|
|
66173
66184
|
}
|
|
66174
66185
|
function getIndexedAccessType(objectType, indexType, accessFlags = 0 /* None */, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
66175
66186
|
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
66176
66187
|
}
|
|
66177
66188
|
function indexTypeLessThan(indexType, limit) {
|
|
66178
66189
|
return everyType(indexType, (t) => {
|
|
66179
|
-
if (t.flags &
|
|
66190
|
+
if (t.flags & 384 /* StringOrNumberLiteral */) {
|
|
66180
66191
|
const propName = getPropertyNameFromType(t);
|
|
66181
66192
|
if (isNumericLiteralName(propName)) {
|
|
66182
66193
|
const index = +propName;
|
|
@@ -66191,7 +66202,7 @@ function createTypeChecker(host) {
|
|
|
66191
66202
|
return wildcardType;
|
|
66192
66203
|
}
|
|
66193
66204
|
objectType = getReducedType(objectType);
|
|
66194
|
-
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags &
|
|
66205
|
+
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
|
|
66195
66206
|
indexType = stringType;
|
|
66196
66207
|
}
|
|
66197
66208
|
if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) accessFlags |= 1 /* IncludeUndefined */;
|
|
@@ -66208,7 +66219,7 @@ function createTypeChecker(host) {
|
|
|
66208
66219
|
return type;
|
|
66209
66220
|
}
|
|
66210
66221
|
const apparentObjectType = getReducedApparentType(objectType);
|
|
66211
|
-
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags &
|
|
66222
|
+
if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) {
|
|
66212
66223
|
const propTypes = [];
|
|
66213
66224
|
let wasMissingProp = false;
|
|
66214
66225
|
for (const t of indexType.types) {
|
|
@@ -66265,7 +66276,7 @@ function createTypeChecker(host) {
|
|
|
66265
66276
|
function isDeferredType(type, checkTuples) {
|
|
66266
66277
|
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
66267
66278
|
}
|
|
66268
|
-
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
|
|
66279
|
+
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing) {
|
|
66269
66280
|
let result;
|
|
66270
66281
|
let extraTypes;
|
|
66271
66282
|
let tailCount = 0;
|
|
@@ -66282,10 +66293,11 @@ function createTypeChecker(host) {
|
|
|
66282
66293
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
66283
66294
|
return wildcardType;
|
|
66284
66295
|
}
|
|
66296
|
+
const effectiveCheckType = forNarrowing && isNarrowingSubstitutionType(checkType) ? checkType.constraint : checkType;
|
|
66285
66297
|
const checkTypeNode = skipTypeParentheses(root.node.checkType);
|
|
66286
66298
|
const extendsTypeNode = skipTypeParentheses(root.node.extendsType);
|
|
66287
66299
|
const checkTuples = isSimpleTupleType(checkTypeNode) && isSimpleTupleType(extendsTypeNode) && length(checkTypeNode.elements) === length(extendsTypeNode.elements);
|
|
66288
|
-
const checkTypeDeferred = isDeferredType(
|
|
66300
|
+
const checkTypeDeferred = isDeferredType(effectiveCheckType, checkTuples);
|
|
66289
66301
|
let combinedMapper;
|
|
66290
66302
|
if (root.inferTypeParameters) {
|
|
66291
66303
|
const context = createInferenceContext(
|
|
@@ -66304,8 +66316,8 @@ function createTypeChecker(host) {
|
|
|
66304
66316
|
}
|
|
66305
66317
|
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
|
66306
66318
|
if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
|
|
66307
|
-
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (
|
|
66308
|
-
if (
|
|
66319
|
+
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (effectiveCheckType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(effectiveCheckType), getPermissiveInstantiation(inferredExtendsType)))) {
|
|
66320
|
+
if (effectiveCheckType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(effectiveCheckType)))) {
|
|
66309
66321
|
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
|
|
66310
66322
|
}
|
|
66311
66323
|
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
|
@@ -66322,7 +66334,7 @@ function createTypeChecker(host) {
|
|
|
66322
66334
|
result = instantiateType(falseType2, mapper);
|
|
66323
66335
|
break;
|
|
66324
66336
|
}
|
|
66325
|
-
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(
|
|
66337
|
+
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(effectiveCheckType), getRestrictiveInstantiation(inferredExtendsType))) {
|
|
66326
66338
|
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
|
66327
66339
|
const trueMapper = combinedMapper || mapper;
|
|
66328
66340
|
if (canTailRecurse(trueType2, trueMapper)) {
|
|
@@ -66541,7 +66553,7 @@ function createTypeChecker(host) {
|
|
|
66541
66553
|
return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type);
|
|
66542
66554
|
}
|
|
66543
66555
|
function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
|
|
66544
|
-
return isEmptyObjectType(type) || !!(type.flags & (
|
|
66556
|
+
return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */));
|
|
66545
66557
|
}
|
|
66546
66558
|
function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
|
|
66547
66559
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
@@ -66604,7 +66616,7 @@ function createTypeChecker(host) {
|
|
|
66604
66616
|
if (right.flags & 1048576 /* Union */) {
|
|
66605
66617
|
return checkCrossProductUnion([left, right]) ? mapType(right, (t) => getSpreadType(left, t, symbol, objectFlags, readonly)) : errorType;
|
|
66606
66618
|
}
|
|
66607
|
-
if (right.flags & (
|
|
66619
|
+
if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) {
|
|
66608
66620
|
return left;
|
|
66609
66621
|
}
|
|
66610
66622
|
if (isGenericObjectType(left) || isGenericObjectType(right)) {
|
|
@@ -66686,7 +66698,7 @@ function createTypeChecker(host) {
|
|
|
66686
66698
|
return type;
|
|
66687
66699
|
}
|
|
66688
66700
|
function getFreshTypeOfLiteralType(type) {
|
|
66689
|
-
if (type.flags &
|
|
66701
|
+
if (type.flags & 2976 /* Freshable */) {
|
|
66690
66702
|
if (!type.freshType) {
|
|
66691
66703
|
const freshType = createLiteralType(type.flags, type.value, type.symbol, type);
|
|
66692
66704
|
freshType.freshType = freshType;
|
|
@@ -66697,28 +66709,28 @@ function createTypeChecker(host) {
|
|
|
66697
66709
|
return type;
|
|
66698
66710
|
}
|
|
66699
66711
|
function getRegularTypeOfLiteralType(type) {
|
|
66700
|
-
return type.flags &
|
|
66712
|
+
return type.flags & 2976 /* Freshable */ ? type.regularType : type.flags & 1048576 /* Union */ ? type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType)) : type;
|
|
66701
66713
|
}
|
|
66702
66714
|
function isFreshLiteralType(type) {
|
|
66703
|
-
return !!(type.flags &
|
|
66715
|
+
return !!(type.flags & 2976 /* Freshable */) && type.freshType === type;
|
|
66704
66716
|
}
|
|
66705
66717
|
function getStringLiteralType(value) {
|
|
66706
66718
|
let type;
|
|
66707
|
-
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(
|
|
66719
|
+
return stringLiteralTypes.get(value) || (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type);
|
|
66708
66720
|
}
|
|
66709
66721
|
function getNumberLiteralType(value) {
|
|
66710
66722
|
let type;
|
|
66711
|
-
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(
|
|
66723
|
+
return numberLiteralTypes.get(value) || (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type);
|
|
66712
66724
|
}
|
|
66713
66725
|
function getBigIntLiteralType(value) {
|
|
66714
66726
|
let type;
|
|
66715
66727
|
const key = pseudoBigIntToString(value);
|
|
66716
|
-
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(
|
|
66728
|
+
return bigIntLiteralTypes.get(key) || (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type);
|
|
66717
66729
|
}
|
|
66718
66730
|
function getEnumLiteralType(value, enumId, symbol) {
|
|
66719
66731
|
let type;
|
|
66720
66732
|
const key = `${enumId}${typeof value === "string" ? "@" : "#"}${value}`;
|
|
66721
|
-
const flags =
|
|
66733
|
+
const flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */);
|
|
66722
66734
|
return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type);
|
|
66723
66735
|
}
|
|
66724
66736
|
function getTypeFromLiteralTypeNode(node) {
|
|
@@ -66732,7 +66744,7 @@ function createTypeChecker(host) {
|
|
|
66732
66744
|
return links.resolvedType;
|
|
66733
66745
|
}
|
|
66734
66746
|
function createUniqueESSymbolType(symbol) {
|
|
66735
|
-
const type = createTypeWithSymbol(
|
|
66747
|
+
const type = createTypeWithSymbol(8192 /* UniqueESSymbol */, symbol);
|
|
66736
66748
|
type.escapedName = `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}`;
|
|
66737
66749
|
return type;
|
|
66738
66750
|
}
|
|
@@ -67120,7 +67132,7 @@ function createTypeChecker(host) {
|
|
|
67120
67132
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
67121
67133
|
target.instantiations.set(id, result);
|
|
67122
67134
|
const resultObjectFlags = getObjectFlags(result);
|
|
67123
|
-
if (result.flags &
|
|
67135
|
+
if (result.flags & 3899393 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
67124
67136
|
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
67125
67137
|
if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
67126
67138
|
if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
|
|
@@ -67249,7 +67261,7 @@ function createTypeChecker(host) {
|
|
|
67249
67261
|
const templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
|
|
67250
67262
|
const propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
|
|
67251
67263
|
const modifiers = getMappedTypeModifiers(type);
|
|
67252
|
-
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType,
|
|
67264
|
+
return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(
|
|
67253
67265
|
propType,
|
|
67254
67266
|
/*isProperty*/
|
|
67255
67267
|
true
|
|
@@ -67288,8 +67300,44 @@ function createTypeChecker(host) {
|
|
|
67288
67300
|
if (!result) {
|
|
67289
67301
|
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
|
67290
67302
|
const checkType = root.checkType;
|
|
67291
|
-
|
|
67292
|
-
|
|
67303
|
+
let distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
|
|
67304
|
+
let narrowingBaseType;
|
|
67305
|
+
const forNarrowing = distributionType && isNarrowingSubstitutionType(distributionType) && isNarrowableConditionalType(
|
|
67306
|
+
type,
|
|
67307
|
+
/*hadNonPrimitiveExtendsType*/
|
|
67308
|
+
[],
|
|
67309
|
+
mapper
|
|
67310
|
+
);
|
|
67311
|
+
if (forNarrowing) {
|
|
67312
|
+
narrowingBaseType = distributionType.baseType;
|
|
67313
|
+
distributionType = getReducedType(distributionType.constraint);
|
|
67314
|
+
}
|
|
67315
|
+
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
|
67316
|
+
if (narrowingBaseType) {
|
|
67317
|
+
result = mapTypeToIntersection(
|
|
67318
|
+
distributionType,
|
|
67319
|
+
(t) => getConditionalType(
|
|
67320
|
+
root,
|
|
67321
|
+
prependTypeMapping(checkType, getSubstitutionType(
|
|
67322
|
+
narrowingBaseType,
|
|
67323
|
+
t,
|
|
67324
|
+
/*isNarrowed*/
|
|
67325
|
+
true
|
|
67326
|
+
), newMapper),
|
|
67327
|
+
forConstraint,
|
|
67328
|
+
/*aliasSymbol*/
|
|
67329
|
+
void 0,
|
|
67330
|
+
/*aliasTypeArguments*/
|
|
67331
|
+
void 0,
|
|
67332
|
+
forNarrowing
|
|
67333
|
+
)
|
|
67334
|
+
);
|
|
67335
|
+
} else {
|
|
67336
|
+
result = mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments);
|
|
67337
|
+
}
|
|
67338
|
+
} else {
|
|
67339
|
+
result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
|
|
67340
|
+
}
|
|
67293
67341
|
root.instantiations.set(id, result);
|
|
67294
67342
|
}
|
|
67295
67343
|
return result;
|
|
@@ -67796,7 +67844,7 @@ function createTypeChecker(host) {
|
|
|
67796
67844
|
createDiagnosticForNode(
|
|
67797
67845
|
targetNode,
|
|
67798
67846
|
Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1,
|
|
67799
|
-
propertyName && !(nameType.flags &
|
|
67847
|
+
propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? unescapeLeadingUnderscores(propertyName) : typeToString(nameType),
|
|
67800
67848
|
typeToString(target)
|
|
67801
67849
|
)
|
|
67802
67850
|
);
|
|
@@ -68039,7 +68087,7 @@ function createTypeChecker(host) {
|
|
|
68039
68087
|
if (!length(node.properties)) return;
|
|
68040
68088
|
for (const prop of node.properties) {
|
|
68041
68089
|
if (isSpreadAssignment(prop)) continue;
|
|
68042
|
-
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop),
|
|
68090
|
+
const type = getLiteralTypeFromProperty(getSymbolOfDeclaration(prop), 8576 /* StringOrNumberLiteralOrUnique */);
|
|
68043
68091
|
if (!type || type.flags & 131072 /* Never */) {
|
|
68044
68092
|
continue;
|
|
68045
68093
|
}
|
|
@@ -68089,7 +68137,7 @@ function createTypeChecker(host) {
|
|
|
68089
68137
|
}
|
|
68090
68138
|
return false;
|
|
68091
68139
|
}
|
|
68092
|
-
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
68140
|
+
function compareSignaturesRelated(source, target, checkMode, reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
|
|
68093
68141
|
if (source === target) {
|
|
68094
68142
|
return -1 /* True */;
|
|
68095
68143
|
}
|
|
@@ -68114,7 +68162,7 @@ function createTypeChecker(host) {
|
|
|
68114
68162
|
target,
|
|
68115
68163
|
/*inferenceContext*/
|
|
68116
68164
|
void 0,
|
|
68117
|
-
|
|
68165
|
+
compareTypes
|
|
68118
68166
|
);
|
|
68119
68167
|
}
|
|
68120
68168
|
const sourceCount = getParameterCount(source);
|
|
@@ -68130,12 +68178,12 @@ function createTypeChecker(host) {
|
|
|
68130
68178
|
if (sourceThisType && sourceThisType !== voidType) {
|
|
68131
68179
|
const targetThisType = getThisTypeOfSignature(target);
|
|
68132
68180
|
if (targetThisType) {
|
|
68133
|
-
const related = !strictVariance &&
|
|
68181
|
+
const related = !strictVariance && compareTypes(
|
|
68134
68182
|
sourceThisType,
|
|
68135
68183
|
targetThisType,
|
|
68136
68184
|
/*reportErrors*/
|
|
68137
68185
|
false
|
|
68138
|
-
) ||
|
|
68186
|
+
) || compareTypes(targetThisType, sourceThisType, reportErrors2);
|
|
68139
68187
|
if (!related) {
|
|
68140
68188
|
if (reportErrors2) {
|
|
68141
68189
|
errorReporter(Diagnostics.The_this_types_of_each_signature_are_incompatible);
|
|
@@ -68154,13 +68202,13 @@ function createTypeChecker(host) {
|
|
|
68154
68202
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
68155
68203
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
68156
68204
|
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && getTypeFacts(sourceType, 50331648 /* IsUndefinedOrNull */) === getTypeFacts(targetType, 50331648 /* IsUndefinedOrNull */);
|
|
68157
|
-
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter,
|
|
68205
|
+
let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, checkMode & 8 /* StrictArity */ | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors2, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(
|
|
68158
68206
|
sourceType,
|
|
68159
68207
|
targetType,
|
|
68160
68208
|
/*reportErrors*/
|
|
68161
68209
|
false
|
|
68162
|
-
) ||
|
|
68163
|
-
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) &&
|
|
68210
|
+
) || compareTypes(targetType, sourceType, reportErrors2);
|
|
68211
|
+
if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(
|
|
68164
68212
|
sourceType,
|
|
68165
68213
|
targetType,
|
|
68166
68214
|
/*reportErrors*/
|
|
@@ -68187,7 +68235,7 @@ function createTypeChecker(host) {
|
|
|
68187
68235
|
if (targetTypePredicate) {
|
|
68188
68236
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
68189
68237
|
if (sourceTypePredicate) {
|
|
68190
|
-
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter,
|
|
68238
|
+
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter, compareTypes);
|
|
68191
68239
|
} else if (isIdentifierTypePredicate(targetTypePredicate) || isThisTypePredicate(targetTypePredicate)) {
|
|
68192
68240
|
if (reportErrors2) {
|
|
68193
68241
|
errorReporter(Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
|
|
@@ -68195,12 +68243,12 @@ function createTypeChecker(host) {
|
|
|
68195
68243
|
return 0 /* False */;
|
|
68196
68244
|
}
|
|
68197
68245
|
} else {
|
|
68198
|
-
result &= checkMode & 1 /* BivariantCallback */ &&
|
|
68246
|
+
result &= checkMode & 1 /* BivariantCallback */ && compareTypes(
|
|
68199
68247
|
targetReturnType,
|
|
68200
68248
|
sourceReturnType,
|
|
68201
68249
|
/*reportErrors*/
|
|
68202
68250
|
false
|
|
68203
|
-
) ||
|
|
68251
|
+
) || compareTypes(sourceReturnType, targetReturnType, reportErrors2);
|
|
68204
68252
|
if (!result && reportErrors2 && incompatibleErrorReporter) {
|
|
68205
68253
|
incompatibleErrorReporter(sourceReturnType, targetReturnType);
|
|
68206
68254
|
}
|
|
@@ -68208,7 +68256,7 @@ function createTypeChecker(host) {
|
|
|
68208
68256
|
}
|
|
68209
68257
|
return result;
|
|
68210
68258
|
}
|
|
68211
|
-
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter,
|
|
68259
|
+
function compareTypePredicateRelatedTo(source, target, reportErrors2, errorReporter, compareTypes) {
|
|
68212
68260
|
if (source.kind !== target.kind) {
|
|
68213
68261
|
if (reportErrors2) {
|
|
68214
68262
|
errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
|
|
@@ -68225,7 +68273,7 @@ function createTypeChecker(host) {
|
|
|
68225
68273
|
return 0 /* False */;
|
|
68226
68274
|
}
|
|
68227
68275
|
}
|
|
68228
|
-
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
68276
|
+
const related = source.type === target.type ? -1 /* True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors2) : 0 /* False */;
|
|
68229
68277
|
if (related === 0 /* False */ && reportErrors2) {
|
|
68230
68278
|
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
|
|
68231
68279
|
}
|
|
@@ -68259,18 +68307,18 @@ function createTypeChecker(host) {
|
|
|
68259
68307
|
if (strictNullChecks && type.flags & 1048576 /* Union */) {
|
|
68260
68308
|
if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) {
|
|
68261
68309
|
const types = type.types;
|
|
68262
|
-
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags &
|
|
68310
|
+
type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ && types[1].flags & 65536 /* Null */ && some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0);
|
|
68263
68311
|
}
|
|
68264
68312
|
return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */);
|
|
68265
68313
|
}
|
|
68266
68314
|
return false;
|
|
68267
68315
|
}
|
|
68268
68316
|
function containsUndefinedType(type) {
|
|
68269
|
-
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags &
|
|
68317
|
+
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
|
|
68270
68318
|
}
|
|
68271
68319
|
function containsNonMissingUndefinedType(type) {
|
|
68272
68320
|
const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
|
|
68273
|
-
return !!(candidate.flags &
|
|
68321
|
+
return !!(candidate.flags & 32768 /* Undefined */) && candidate !== missingType;
|
|
68274
68322
|
}
|
|
68275
68323
|
function isStringIndexSignatureOnlyType(type) {
|
|
68276
68324
|
return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || type.flags & 3145728 /* UnionOrIntersection */ && every(type.types, isStringIndexSignatureOnlyType) || false;
|
|
@@ -68341,25 +68389,25 @@ function createTypeChecker(host) {
|
|
|
68341
68389
|
if (t & 1 /* Any */ || s & 131072 /* Never */ || source === wildcardType) return true;
|
|
68342
68390
|
if (t & 2 /* Unknown */ && !(relation === strictSubtypeRelation && s & 1 /* Any */)) return true;
|
|
68343
68391
|
if (t & 131072 /* Never */) return false;
|
|
68344
|
-
if (s &
|
|
68345
|
-
if (s &
|
|
68346
|
-
if (s &
|
|
68347
|
-
if (s &
|
|
68348
|
-
if (s &
|
|
68349
|
-
if (s &
|
|
68350
|
-
if (s &
|
|
68351
|
-
if (s &
|
|
68352
|
-
if (s &
|
|
68392
|
+
if (s & 402653316 /* StringLike */ && t & 4 /* String */) return true;
|
|
68393
|
+
if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true;
|
|
68394
|
+
if (s & 296 /* NumberLike */ && t & 8 /* Number */) return true;
|
|
68395
|
+
if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true;
|
|
68396
|
+
if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) return true;
|
|
68397
|
+
if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) return true;
|
|
68398
|
+
if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) return true;
|
|
68399
|
+
if (s & 32 /* Enum */ && t & 32 /* Enum */ && source.symbol.escapedName === target.symbol.escapedName && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
68400
|
+
if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) {
|
|
68353
68401
|
if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
68354
|
-
if (s &
|
|
68402
|
+
if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
|
68355
68403
|
}
|
|
68356
|
-
if (s &
|
|
68357
|
-
if (s &
|
|
68404
|
+
if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) return true;
|
|
68405
|
+
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) return true;
|
|
68358
68406
|
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(getObjectFlags(source) & 8192 /* FreshLiteral */))) return true;
|
|
68359
68407
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
68360
68408
|
if (s & 1 /* Any */) return true;
|
|
68361
|
-
if (s &
|
|
68362
|
-
if (s &
|
|
68409
|
+
if (s & 8 /* Number */ && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true;
|
|
68410
|
+
if (s & 256 /* NumberLiteral */ && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */ && source.value === target.value)) return true;
|
|
68363
68411
|
if (isUnknownLikeUnionType(target)) return true;
|
|
68364
68412
|
}
|
|
68365
68413
|
return false;
|
|
@@ -68380,7 +68428,7 @@ function createTypeChecker(host) {
|
|
|
68380
68428
|
}
|
|
68381
68429
|
} else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
|
|
68382
68430
|
if (source.flags !== target.flags) return false;
|
|
68383
|
-
if (source.flags &
|
|
68431
|
+
if (source.flags & 67358815 /* Singleton */) return true;
|
|
68384
68432
|
}
|
|
68385
68433
|
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
|
|
68386
68434
|
const related = relation.get(getRelationKey(
|
|
@@ -68432,10 +68480,12 @@ function createTypeChecker(host) {
|
|
|
68432
68480
|
function shouldNormalizeIntersection(type) {
|
|
68433
68481
|
let hasInstantiable = false;
|
|
68434
68482
|
let hasNullableOrEmpty = false;
|
|
68483
|
+
let hasSubstitution = false;
|
|
68435
68484
|
for (const t of type.types) {
|
|
68436
68485
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
68437
|
-
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags &
|
|
68438
|
-
|
|
68486
|
+
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
68487
|
+
hasSubstitution || (hasSubstitution = isNarrowingSubstitutionType(t));
|
|
68488
|
+
if (hasInstantiable && hasNullableOrEmpty || hasSubstitution) return true;
|
|
68439
68489
|
}
|
|
68440
68490
|
return false;
|
|
68441
68491
|
}
|
|
@@ -68704,7 +68754,7 @@ function createTypeChecker(host) {
|
|
|
68704
68754
|
} else if (exactOptionalPropertyTypes && getExactOptionalUnassignableProperties(source2, target2).length) {
|
|
68705
68755
|
message = Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties;
|
|
68706
68756
|
} else {
|
|
68707
|
-
if (source2.flags &
|
|
68757
|
+
if (source2.flags & 128 /* StringLiteral */ && target2.flags & 1048576 /* Union */) {
|
|
68708
68758
|
const suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source2, target2);
|
|
68709
68759
|
if (suggestedType) {
|
|
68710
68760
|
reportError(Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType));
|
|
@@ -68773,7 +68823,7 @@ function createTypeChecker(host) {
|
|
|
68773
68823
|
if (source2 === target2) return -1 /* True */;
|
|
68774
68824
|
if (relation === identityRelation) {
|
|
68775
68825
|
if (source2.flags !== target2.flags) return 0 /* False */;
|
|
68776
|
-
if (source2.flags &
|
|
68826
|
+
if (source2.flags & 67358815 /* Singleton */) return -1 /* True */;
|
|
68777
68827
|
traceUnionsOrIntersectionsTooLarge(source2, target2);
|
|
68778
68828
|
return recursiveTypeRelatedTo(
|
|
68779
68829
|
source2,
|
|
@@ -68787,10 +68837,10 @@ function createTypeChecker(host) {
|
|
|
68787
68837
|
if (source2.flags & 262144 /* TypeParameter */ && getConstraintOfType(source2) === target2) {
|
|
68788
68838
|
return -1 /* True */;
|
|
68789
68839
|
}
|
|
68790
|
-
if (source2.flags &
|
|
68840
|
+
if (source2.flags & 470302716 /* DefinitelyNonNullable */ && target2.flags & 1048576 /* Union */) {
|
|
68791
68841
|
const types = target2.types;
|
|
68792
|
-
const candidate = types.length === 2 && types[0].flags &
|
|
68793
|
-
if (candidate && !(candidate.flags &
|
|
68842
|
+
const candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : void 0;
|
|
68843
|
+
if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
|
|
68794
68844
|
target2 = getNormalizedType(
|
|
68795
68845
|
candidate,
|
|
68796
68846
|
/*writing*/
|
|
@@ -69092,9 +69142,9 @@ function createTypeChecker(host) {
|
|
|
69092
69142
|
if (containsType(targetTypes, source2)) {
|
|
69093
69143
|
return -1 /* True */;
|
|
69094
69144
|
}
|
|
69095
|
-
if (relation !== comparableRelation && getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags &
|
|
69145
|
+
if (relation !== comparableRelation && getObjectFlags(target2) & 32768 /* PrimitiveUnion */ && !(source2.flags & 1024 /* EnumLiteral */) && (source2.flags & (128 /* StringLiteral */ | 512 /* BooleanLiteral */ | 2048 /* BigIntLiteral */) || (relation === subtypeRelation || relation === strictSubtypeRelation) && source2.flags & 256 /* NumberLiteral */)) {
|
|
69096
69146
|
const alternateForm = source2 === source2.regularType ? source2.freshType : source2.regularType;
|
|
69097
|
-
const primitive = source2.flags &
|
|
69147
|
+
const primitive = source2.flags & 128 /* StringLiteral */ ? stringType : source2.flags & 256 /* NumberLiteral */ ? numberType : source2.flags & 2048 /* BigIntLiteral */ ? bigintType : void 0;
|
|
69098
69148
|
return primitive && containsType(targetTypes, primitive) || alternateForm && containsType(targetTypes, alternateForm) ? -1 /* True */ : 0 /* False */;
|
|
69099
69149
|
}
|
|
69100
69150
|
const match = getMatchingUnionConstituentForType(target2, source2);
|
|
@@ -69189,8 +69239,8 @@ function createTypeChecker(host) {
|
|
|
69189
69239
|
return 0 /* False */;
|
|
69190
69240
|
}
|
|
69191
69241
|
function getUndefinedStrippedTargetIfNeeded(source2, target2) {
|
|
69192
|
-
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags &
|
|
69193
|
-
return extractTypesOfKind(target2, ~
|
|
69242
|
+
if (source2.flags & 1048576 /* Union */ && target2.flags & 1048576 /* Union */ && !(source2.types[0].flags & 32768 /* Undefined */) && target2.types[0].flags & 32768 /* Undefined */) {
|
|
69243
|
+
return extractTypesOfKind(target2, ~32768 /* Undefined */);
|
|
69194
69244
|
}
|
|
69195
69245
|
return target2;
|
|
69196
69246
|
}
|
|
@@ -69532,7 +69582,7 @@ function createTypeChecker(host) {
|
|
|
69532
69582
|
const mappedKeys = [];
|
|
69533
69583
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
69534
69584
|
modifiersType,
|
|
69535
|
-
|
|
69585
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
69536
69586
|
/*stringsOnly*/
|
|
69537
69587
|
false,
|
|
69538
69588
|
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
@@ -69791,7 +69841,7 @@ function createTypeChecker(host) {
|
|
|
69791
69841
|
if (includeOptional ? !(filteredByApplicability.flags & 131072 /* Never */) : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
|
|
69792
69842
|
const templateType2 = getTemplateTypeFromMappedType(target2);
|
|
69793
69843
|
const typeParameter = getTypeParameterFromMappedType(target2);
|
|
69794
|
-
const nonNullComponent = extractTypesOfKind(templateType2, ~
|
|
69844
|
+
const nonNullComponent = extractTypesOfKind(templateType2, ~98304 /* Nullable */);
|
|
69795
69845
|
if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
|
|
69796
69846
|
if (result2 = isRelatedTo(source2, nonNullComponent.objectType, 2 /* Target */, reportErrors2)) {
|
|
69797
69847
|
return result2;
|
|
@@ -70452,7 +70502,7 @@ function createTypeChecker(host) {
|
|
|
70452
70502
|
for (const sourceProp of excludeProperties(getPropertiesOfType(source2), excludedProperties)) {
|
|
70453
70503
|
if (!getPropertyOfObjectType(target2, sourceProp.escapedName)) {
|
|
70454
70504
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
70455
|
-
if (!(sourceType.flags &
|
|
70505
|
+
if (!(sourceType.flags & 32768 /* Undefined */)) {
|
|
70456
70506
|
if (reportErrors2) {
|
|
70457
70507
|
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target2));
|
|
70458
70508
|
}
|
|
@@ -70680,9 +70730,9 @@ function createTypeChecker(host) {
|
|
|
70680
70730
|
if (isIgnoredJsxProperty(source2, prop)) {
|
|
70681
70731
|
continue;
|
|
70682
70732
|
}
|
|
70683
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
70733
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) {
|
|
70684
70734
|
const propType = getNonMissingTypeOfSymbol(prop);
|
|
70685
|
-
const type = exactOptionalPropertyTypes || propType.flags &
|
|
70735
|
+
const type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) ? propType : getTypeWithFacts(propType, 524288 /* NEUndefined */);
|
|
70686
70736
|
const related = isRelatedTo(
|
|
70687
70737
|
type,
|
|
70688
70738
|
targetInfo.type,
|
|
@@ -70796,7 +70846,7 @@ function createTypeChecker(host) {
|
|
|
70796
70846
|
}
|
|
70797
70847
|
}
|
|
70798
70848
|
function typeCouldHaveTopLevelSingletonTypes(type) {
|
|
70799
|
-
if (type.flags &
|
|
70849
|
+
if (type.flags & 16 /* Boolean */) {
|
|
70800
70850
|
return false;
|
|
70801
70851
|
}
|
|
70802
70852
|
if (type.flags & 3145728 /* UnionOrIntersection */) {
|
|
@@ -70815,7 +70865,7 @@ function createTypeChecker(host) {
|
|
|
70815
70865
|
return getPropertiesOfType(target).filter((targetProp) => isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)));
|
|
70816
70866
|
}
|
|
70817
70867
|
function isExactOptionalPropertyMismatch(source, target) {
|
|
70818
|
-
return !!source && !!target && maybeTypeOfKind(source,
|
|
70868
|
+
return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target);
|
|
70819
70869
|
}
|
|
70820
70870
|
function getExactOptionalProperties(type) {
|
|
70821
70871
|
return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
|
|
@@ -70941,7 +70991,7 @@ function createTypeChecker(host) {
|
|
|
70941
70991
|
}
|
|
70942
70992
|
function hasCovariantVoidArgument(typeArguments, variances) {
|
|
70943
70993
|
for (let i = 0; i < variances.length; i++) {
|
|
70944
|
-
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags &
|
|
70994
|
+
if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) {
|
|
70945
70995
|
return true;
|
|
70946
70996
|
}
|
|
70947
70997
|
}
|
|
@@ -71098,7 +71148,7 @@ function createTypeChecker(host) {
|
|
|
71098
71148
|
function isPropertyIdenticalTo(sourceProp, targetProp) {
|
|
71099
71149
|
return compareProperties2(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
|
|
71100
71150
|
}
|
|
71101
|
-
function compareProperties2(sourceProp, targetProp,
|
|
71151
|
+
function compareProperties2(sourceProp, targetProp, compareTypes) {
|
|
71102
71152
|
if (sourceProp === targetProp) {
|
|
71103
71153
|
return -1 /* True */;
|
|
71104
71154
|
}
|
|
@@ -71119,7 +71169,7 @@ function createTypeChecker(host) {
|
|
|
71119
71169
|
if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
|
|
71120
71170
|
return 0 /* False */;
|
|
71121
71171
|
}
|
|
71122
|
-
return
|
|
71172
|
+
return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
71123
71173
|
}
|
|
71124
71174
|
function isMatchingSignature(source, target, partialMatch) {
|
|
71125
71175
|
const sourceParameterCount = getParameterCount(source);
|
|
@@ -71136,7 +71186,7 @@ function createTypeChecker(host) {
|
|
|
71136
71186
|
}
|
|
71137
71187
|
return false;
|
|
71138
71188
|
}
|
|
71139
|
-
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes,
|
|
71189
|
+
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
|
|
71140
71190
|
if (source === target) {
|
|
71141
71191
|
return -1 /* True */;
|
|
71142
71192
|
}
|
|
@@ -71151,7 +71201,7 @@ function createTypeChecker(host) {
|
|
|
71151
71201
|
for (let i = 0; i < target.typeParameters.length; i++) {
|
|
71152
71202
|
const s = source.typeParameters[i];
|
|
71153
71203
|
const t = target.typeParameters[i];
|
|
71154
|
-
if (!(s === t ||
|
|
71204
|
+
if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
|
|
71155
71205
|
return 0 /* False */;
|
|
71156
71206
|
}
|
|
71157
71207
|
}
|
|
@@ -71168,7 +71218,7 @@ function createTypeChecker(host) {
|
|
|
71168
71218
|
if (sourceThisType) {
|
|
71169
71219
|
const targetThisType = getThisTypeOfSignature(target);
|
|
71170
71220
|
if (targetThisType) {
|
|
71171
|
-
const related =
|
|
71221
|
+
const related = compareTypes(sourceThisType, targetThisType);
|
|
71172
71222
|
if (!related) {
|
|
71173
71223
|
return 0 /* False */;
|
|
71174
71224
|
}
|
|
@@ -71180,7 +71230,7 @@ function createTypeChecker(host) {
|
|
|
71180
71230
|
for (let i = 0; i < targetLen; i++) {
|
|
71181
71231
|
const s = getTypeAtPosition(source, i);
|
|
71182
71232
|
const t = getTypeAtPosition(target, i);
|
|
71183
|
-
const related =
|
|
71233
|
+
const related = compareTypes(t, s);
|
|
71184
71234
|
if (!related) {
|
|
71185
71235
|
return 0 /* False */;
|
|
71186
71236
|
}
|
|
@@ -71189,12 +71239,12 @@ function createTypeChecker(host) {
|
|
|
71189
71239
|
if (!ignoreReturnTypes) {
|
|
71190
71240
|
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
71191
71241
|
const targetTypePredicate = getTypePredicateOfSignature(target);
|
|
71192
|
-
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate,
|
|
71242
|
+
result &= sourceTypePredicate || targetTypePredicate ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
|
71193
71243
|
}
|
|
71194
71244
|
return result;
|
|
71195
71245
|
}
|
|
71196
|
-
function compareTypePredicatesIdentical(source, target,
|
|
71197
|
-
return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : source.type && target.type ?
|
|
71246
|
+
function compareTypePredicatesIdentical(source, target, compareTypes) {
|
|
71247
|
+
return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : source.type === target.type ? -1 /* True */ : source.type && target.type ? compareTypes(source.type, target.type) : 0 /* False */;
|
|
71198
71248
|
}
|
|
71199
71249
|
function literalTypesWithSameBaseType(types) {
|
|
71200
71250
|
let commonBaseType;
|
|
@@ -71216,9 +71266,9 @@ function createTypeChecker(host) {
|
|
|
71216
71266
|
if (types.length === 1) {
|
|
71217
71267
|
return types[0];
|
|
71218
71268
|
}
|
|
71219
|
-
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags &
|
|
71269
|
+
const primaryTypes = strictNullChecks ? sameMap(types, (t) => filterType(t, (u) => !(u.flags & 98304 /* Nullable */))) : types;
|
|
71220
71270
|
const superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? getUnionType(primaryTypes) : reduceLeft(primaryTypes, (s, t) => isTypeSubtypeOf(s, t) ? t : s);
|
|
71221
|
-
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) &
|
|
71271
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* Nullable */);
|
|
71222
71272
|
}
|
|
71223
71273
|
function getCommonSubtype(types) {
|
|
71224
71274
|
return reduceLeft(types, (s, t) => isTypeSubtypeOf(t, s) ? t : s);
|
|
@@ -71239,10 +71289,10 @@ function createTypeChecker(host) {
|
|
|
71239
71289
|
return isArrayType(type) ? getTypeArguments(type)[0] : void 0;
|
|
71240
71290
|
}
|
|
71241
71291
|
function isArrayLikeType(type) {
|
|
71242
|
-
return isArrayType(type) || !(type.flags &
|
|
71292
|
+
return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType);
|
|
71243
71293
|
}
|
|
71244
71294
|
function isMutableArrayLikeType(type) {
|
|
71245
|
-
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ |
|
|
71295
|
+
return isMutableArrayOrTuple(type) || !(type.flags & (1 /* Any */ | 98304 /* Nullable */)) && isTypeAssignableTo(type, anyArrayType);
|
|
71246
71296
|
}
|
|
71247
71297
|
function getSingleBaseForNonAugmentingSubtype(type) {
|
|
71248
71298
|
if (!(getObjectFlags(type) & 4 /* Reference */) || !(getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
@@ -71282,7 +71332,7 @@ function createTypeChecker(host) {
|
|
|
71282
71332
|
}
|
|
71283
71333
|
function isTupleLikeType(type) {
|
|
71284
71334
|
let lengthType;
|
|
71285
|
-
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags &
|
|
71335
|
+
return isTupleType(type) || !!getPropertyOfType(type, "0") || isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length")) && everyType(lengthType, (t) => !!(t.flags & 256 /* NumberLiteral */));
|
|
71286
71336
|
}
|
|
71287
71337
|
function isArrayOrTupleLikeType(type) {
|
|
71288
71338
|
return isArrayLikeType(type) || isTupleLikeType(type);
|
|
@@ -71298,10 +71348,10 @@ function createTypeChecker(host) {
|
|
|
71298
71348
|
return void 0;
|
|
71299
71349
|
}
|
|
71300
71350
|
function isNeitherUnitTypeNorNever(type) {
|
|
71301
|
-
return !(type.flags & (
|
|
71351
|
+
return !(type.flags & (109472 /* Unit */ | 131072 /* Never */));
|
|
71302
71352
|
}
|
|
71303
71353
|
function isUnitType(type) {
|
|
71304
|
-
return !!(type.flags &
|
|
71354
|
+
return !!(type.flags & 109472 /* Unit */);
|
|
71305
71355
|
}
|
|
71306
71356
|
function isUnitLikeType(type) {
|
|
71307
71357
|
const t = getBaseConstraintOrType(type);
|
|
@@ -71311,23 +71361,23 @@ function createTypeChecker(host) {
|
|
|
71311
71361
|
return type.flags & 2097152 /* Intersection */ ? find(type.types, isUnitType) || type : type;
|
|
71312
71362
|
}
|
|
71313
71363
|
function isLiteralType(type) {
|
|
71314
|
-
return type.flags &
|
|
71364
|
+
return type.flags & 16 /* Boolean */ ? true : type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : every(type.types, isUnitType) : isUnitType(type);
|
|
71315
71365
|
}
|
|
71316
71366
|
function getBaseTypeOfLiteralType(type) {
|
|
71317
|
-
return type.flags &
|
|
71367
|
+
return type.flags & 1056 /* EnumLike */ ? getBaseTypeOfEnumLikeType(type) : type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 512 /* BooleanLiteral */ ? booleanType : type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) : type;
|
|
71318
71368
|
}
|
|
71319
71369
|
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
71320
71370
|
const key = `B${getTypeId(type)}`;
|
|
71321
71371
|
return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
71322
71372
|
}
|
|
71323
71373
|
function getBaseTypeOfLiteralTypeForComparison(type) {
|
|
71324
|
-
return type.flags & (
|
|
71374
|
+
return type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : type.flags & (256 /* NumberLiteral */ | 32 /* Enum */) ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 512 /* BooleanLiteral */ ? booleanType : type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralTypeForComparison) : type;
|
|
71325
71375
|
}
|
|
71326
71376
|
function getWidenedLiteralType(type) {
|
|
71327
|
-
return type.flags &
|
|
71377
|
+
return type.flags & 1056 /* EnumLike */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLikeType(type) : type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : type;
|
|
71328
71378
|
}
|
|
71329
71379
|
function getWidenedUniqueESSymbolType(type) {
|
|
71330
|
-
return type.flags &
|
|
71380
|
+
return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type;
|
|
71331
71381
|
}
|
|
71332
71382
|
function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
|
|
71333
71383
|
if (!isLiteralOfContextualType(type, contextualType)) {
|
|
@@ -71404,11 +71454,11 @@ function createTypeChecker(host) {
|
|
|
71404
71454
|
return mapType(type, getDefinitelyFalsyPartOfType);
|
|
71405
71455
|
}
|
|
71406
71456
|
function getDefinitelyFalsyPartOfType(type) {
|
|
71407
|
-
return type.flags &
|
|
71457
|
+
return type.flags & 4 /* String */ ? emptyStringType : type.flags & 8 /* Number */ ? zeroType : type.flags & 64 /* BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || type.flags & 128 /* StringLiteral */ && type.value === "" || type.flags & 256 /* NumberLiteral */ && type.value === 0 || type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : neverType;
|
|
71408
71458
|
}
|
|
71409
71459
|
function getNullableType(type, flags) {
|
|
71410
|
-
const missing = flags & ~type.flags & (
|
|
71411
|
-
return missing === 0 ? type : missing ===
|
|
71460
|
+
const missing = flags & ~type.flags & (32768 /* Undefined */ | 65536 /* Null */);
|
|
71461
|
+
return missing === 0 ? type : missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]);
|
|
71412
71462
|
}
|
|
71413
71463
|
function getOptionalType(type, isProperty = false) {
|
|
71414
71464
|
Debug.assert(strictNullChecks);
|
|
@@ -71451,7 +71501,7 @@ function createTypeChecker(host) {
|
|
|
71451
71501
|
return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */);
|
|
71452
71502
|
}
|
|
71453
71503
|
function isCoercibleUnderDoubleEquals(source, target) {
|
|
71454
|
-
return (source.flags & (
|
|
71504
|
+
return (source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0 && (target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0;
|
|
71455
71505
|
}
|
|
71456
71506
|
function isObjectTypeWithInferableIndex(type) {
|
|
71457
71507
|
const objectFlags = getObjectFlags(type);
|
|
@@ -71584,7 +71634,7 @@ function createTypeChecker(host) {
|
|
|
71584
71634
|
return type.widened;
|
|
71585
71635
|
}
|
|
71586
71636
|
let result;
|
|
71587
|
-
if (type.flags & (1 /* Any */ |
|
|
71637
|
+
if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) {
|
|
71588
71638
|
result = anyType;
|
|
71589
71639
|
} else if (isObjectLiteralType2(type)) {
|
|
71590
71640
|
result = getWidenedTypeOfObjectLiteral(type, context);
|
|
@@ -71596,7 +71646,7 @@ function createTypeChecker(host) {
|
|
|
71596
71646
|
void 0,
|
|
71597
71647
|
type.types
|
|
71598
71648
|
);
|
|
71599
|
-
const widenedTypes = sameMap(type.types, (t) => t.flags &
|
|
71649
|
+
const widenedTypes = sameMap(type.types, (t) => t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext));
|
|
71600
71650
|
result = getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */);
|
|
71601
71651
|
} else if (type.flags & 2097152 /* Intersection */) {
|
|
71602
71652
|
result = getIntersectionType(sameMap(type.types, getWidenedType));
|
|
@@ -71796,18 +71846,18 @@ function createTypeChecker(host) {
|
|
|
71796
71846
|
callback(getReturnTypeOfSignature(source), targetReturnType);
|
|
71797
71847
|
}
|
|
71798
71848
|
}
|
|
71799
|
-
function createInferenceContext(typeParameters, signature, flags,
|
|
71800
|
-
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags,
|
|
71849
|
+
function createInferenceContext(typeParameters, signature, flags, compareTypes) {
|
|
71850
|
+
return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
|
|
71801
71851
|
}
|
|
71802
71852
|
function cloneInferenceContext(context, extraFlags = 0) {
|
|
71803
71853
|
return context && createInferenceContextWorker(map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
|
|
71804
71854
|
}
|
|
71805
|
-
function createInferenceContextWorker(inferences, signature, flags,
|
|
71855
|
+
function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
|
|
71806
71856
|
const context = {
|
|
71807
71857
|
inferences,
|
|
71808
71858
|
signature,
|
|
71809
71859
|
flags,
|
|
71810
|
-
compareTypes
|
|
71860
|
+
compareTypes,
|
|
71811
71861
|
mapper: reportUnmeasurableMapper,
|
|
71812
71862
|
// initialize to a noop mapper so the context object is available, but the underlying object shape is right upon construction
|
|
71813
71863
|
nonFixingMapper: reportUnmeasurableMapper
|
|
@@ -71894,8 +71944,8 @@ function createTypeChecker(host) {
|
|
|
71894
71944
|
if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
|
|
71895
71945
|
return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
|
|
71896
71946
|
}
|
|
71897
|
-
const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 134217728 /* SingleSignatureType */ && !!length(type.outerTypeParameters) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags &
|
|
71898
|
-
if (type.flags &
|
|
71947
|
+
const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 134217728 /* SingleSignatureType */ && !!length(type.outerTypeParameters) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
|
|
71948
|
+
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
71899
71949
|
type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
71900
71950
|
}
|
|
71901
71951
|
return result;
|
|
@@ -71917,7 +71967,7 @@ function createTypeChecker(host) {
|
|
|
71917
71967
|
function createEmptyObjectTypeFromStringLiteral(type) {
|
|
71918
71968
|
const members = createSymbolTable();
|
|
71919
71969
|
forEachType(type, (t) => {
|
|
71920
|
-
if (!(t.flags &
|
|
71970
|
+
if (!(t.flags & 128 /* StringLiteral */)) {
|
|
71921
71971
|
return;
|
|
71922
71972
|
}
|
|
71923
71973
|
const name = escapeLeadingUnderscores(t.value);
|
|
@@ -71929,7 +71979,7 @@ function createTypeChecker(host) {
|
|
|
71929
71979
|
}
|
|
71930
71980
|
members.set(name, literalProp);
|
|
71931
71981
|
});
|
|
71932
|
-
const indexInfos = type.flags &
|
|
71982
|
+
const indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(
|
|
71933
71983
|
stringType,
|
|
71934
71984
|
emptyObjectType,
|
|
71935
71985
|
/*isReadonly*/
|
|
@@ -72031,7 +72081,7 @@ function createTypeChecker(host) {
|
|
|
72031
72081
|
yield targetProp;
|
|
72032
72082
|
} else if (matchDiscriminantProperties) {
|
|
72033
72083
|
const targetType = getTypeOfSymbol(targetProp);
|
|
72034
|
-
if (targetType.flags &
|
|
72084
|
+
if (targetType.flags & 109472 /* Unit */) {
|
|
72035
72085
|
const sourceType = getTypeOfSymbol(sourceProp);
|
|
72036
72086
|
if (!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) {
|
|
72037
72087
|
yield targetProp;
|
|
@@ -72094,7 +72144,7 @@ function createTypeChecker(host) {
|
|
|
72094
72144
|
if (target.flags & 1 /* Any */) {
|
|
72095
72145
|
return true;
|
|
72096
72146
|
}
|
|
72097
|
-
if (target.flags & (
|
|
72147
|
+
if (target.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
72098
72148
|
return isTypeAssignableTo(source, target);
|
|
72099
72149
|
}
|
|
72100
72150
|
if (target.flags & 268435456 /* StringMapping */) {
|
|
@@ -72112,20 +72162,20 @@ function createTypeChecker(host) {
|
|
|
72112
72162
|
if (target.flags & 2097152 /* Intersection */) {
|
|
72113
72163
|
return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
|
|
72114
72164
|
}
|
|
72115
|
-
if (target.flags &
|
|
72165
|
+
if (target.flags & 4 /* String */ || isTypeAssignableTo(source, target)) {
|
|
72116
72166
|
return true;
|
|
72117
72167
|
}
|
|
72118
|
-
if (source.flags &
|
|
72168
|
+
if (source.flags & 128 /* StringLiteral */) {
|
|
72119
72169
|
const value = source.value;
|
|
72120
|
-
return !!(target.flags &
|
|
72170
|
+
return !!(target.flags & 8 /* Number */ && isValidNumberString(
|
|
72121
72171
|
value,
|
|
72122
72172
|
/*roundTripOnly*/
|
|
72123
72173
|
false
|
|
72124
|
-
) || target.flags &
|
|
72174
|
+
) || target.flags & 64 /* BigInt */ && isValidBigIntString(
|
|
72125
72175
|
value,
|
|
72126
72176
|
/*roundTripOnly*/
|
|
72127
72177
|
false
|
|
72128
|
-
) || target.flags & (
|
|
72178
|
+
) || target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(source, target) || target.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source, target));
|
|
72129
72179
|
}
|
|
72130
72180
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
72131
72181
|
const texts = source.texts;
|
|
@@ -72134,7 +72184,7 @@ function createTypeChecker(host) {
|
|
|
72134
72184
|
return false;
|
|
72135
72185
|
}
|
|
72136
72186
|
function inferTypesFromTemplateLiteralType(source, target) {
|
|
72137
|
-
return source.flags &
|
|
72187
|
+
return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], emptyArray, target) : source.flags & 134217728 /* TemplateLiteral */ ? arrayIsEqualTo(source.texts, target.texts) ? map(source.types, (s, i) => {
|
|
72138
72188
|
return isTypeAssignableTo(getBaseConstraintOrType(s), getBaseConstraintOrType(target.types[i])) ? s : getStringLikeTypeForType(s);
|
|
72139
72189
|
}) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : void 0;
|
|
72140
72190
|
}
|
|
@@ -72143,7 +72193,7 @@ function createTypeChecker(host) {
|
|
|
72143
72193
|
return !!inferences && every(inferences, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]));
|
|
72144
72194
|
}
|
|
72145
72195
|
function getStringLikeTypeForType(type) {
|
|
72146
|
-
return type.flags & (1 /* Any */ |
|
|
72196
|
+
return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
|
|
72147
72197
|
}
|
|
72148
72198
|
function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) {
|
|
72149
72199
|
const lastSourceIndex = sourceTexts.length - 1;
|
|
@@ -72338,7 +72388,7 @@ function createTypeChecker(host) {
|
|
|
72338
72388
|
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
|
|
72339
72389
|
} else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
|
|
72340
72390
|
inferFromContravariantTypes(source.type, target.type);
|
|
72341
|
-
} else if ((isLiteralType(source) || source.flags &
|
|
72391
|
+
} else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) {
|
|
72342
72392
|
const empty = createEmptyObjectTypeFromStringLiteral(source);
|
|
72343
72393
|
inferFromContravariantTypesWithPriority(empty, target.type, 256 /* LiteralKeyof */);
|
|
72344
72394
|
} else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
|
|
@@ -72593,29 +72643,29 @@ function createTypeChecker(host) {
|
|
|
72593
72643
|
for (let i = 0; i < types.length; i++) {
|
|
72594
72644
|
const source2 = matches ? matches[i] : neverType;
|
|
72595
72645
|
const target2 = types[i];
|
|
72596
|
-
if (source2.flags &
|
|
72646
|
+
if (source2.flags & 128 /* StringLiteral */ && target2.flags & 8650752 /* TypeVariable */) {
|
|
72597
72647
|
const inferenceContext = getInferenceInfoForType(target2);
|
|
72598
72648
|
const constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : void 0;
|
|
72599
72649
|
if (constraint && !isTypeAny(constraint)) {
|
|
72600
72650
|
const constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
|
|
72601
72651
|
let allTypeFlags = reduceLeft(constraintTypes, (flags, t) => flags | t.flags, 0);
|
|
72602
|
-
if (!(allTypeFlags &
|
|
72652
|
+
if (!(allTypeFlags & 4 /* String */)) {
|
|
72603
72653
|
const str = source2.value;
|
|
72604
|
-
if (allTypeFlags &
|
|
72654
|
+
if (allTypeFlags & 296 /* NumberLike */ && !isValidNumberString(
|
|
72605
72655
|
str,
|
|
72606
72656
|
/*roundTripOnly*/
|
|
72607
72657
|
true
|
|
72608
72658
|
)) {
|
|
72609
|
-
allTypeFlags &= ~
|
|
72659
|
+
allTypeFlags &= ~296 /* NumberLike */;
|
|
72610
72660
|
}
|
|
72611
|
-
if (allTypeFlags &
|
|
72661
|
+
if (allTypeFlags & 2112 /* BigIntLike */ && !isValidBigIntString(
|
|
72612
72662
|
str,
|
|
72613
72663
|
/*roundTripOnly*/
|
|
72614
72664
|
true
|
|
72615
72665
|
)) {
|
|
72616
|
-
allTypeFlags &= ~
|
|
72666
|
+
allTypeFlags &= ~2112 /* BigIntLike */;
|
|
72617
72667
|
}
|
|
72618
|
-
const matchingType = reduceLeft(constraintTypes, (left, right) => !(right.flags & allTypeFlags) ? left : left.flags &
|
|
72668
|
+
const matchingType = reduceLeft(constraintTypes, (left, right) => !(right.flags & allTypeFlags) ? left : left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source2 : left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source2, right) ? source2 : left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str === applyStringMapping(right.symbol, str) ? source2 : left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str ? right : left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str) : left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str) : left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str ? right : left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str) : left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && pseudoBigIntToString(right.value) === str ? right : left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str === "true" ? trueType : str === "false" ? falseType : booleanType : left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str ? right : left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str ? right : left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str ? right : left, neverType);
|
|
72619
72669
|
if (!(matchingType.flags & 131072 /* Never */)) {
|
|
72620
72670
|
inferFromTypes(matchingType, target2);
|
|
72621
72671
|
continue;
|
|
@@ -72775,7 +72825,7 @@ function createTypeChecker(host) {
|
|
|
72775
72825
|
for (const targetInfo of indexInfos) {
|
|
72776
72826
|
const propTypes = [];
|
|
72777
72827
|
for (const prop of getPropertiesOfType(source)) {
|
|
72778
|
-
if (isApplicableIndexType(getLiteralTypeFromProperty(prop,
|
|
72828
|
+
if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) {
|
|
72779
72829
|
const propType = getTypeOfSymbol(prop);
|
|
72780
72830
|
propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType);
|
|
72781
72831
|
}
|
|
@@ -72799,7 +72849,7 @@ function createTypeChecker(host) {
|
|
|
72799
72849
|
}
|
|
72800
72850
|
}
|
|
72801
72851
|
function isTypeOrBaseIdenticalTo(s, t) {
|
|
72802
|
-
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags &
|
|
72852
|
+
return t === missingType ? s === t : isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */);
|
|
72803
72853
|
}
|
|
72804
72854
|
function isTypeCloselyMatchedBy(s, t) {
|
|
72805
72855
|
return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
|
|
@@ -73051,7 +73101,7 @@ function createTypeChecker(host) {
|
|
|
73051
73101
|
return void 0;
|
|
73052
73102
|
}
|
|
73053
73103
|
function tryGetNameFromType(type) {
|
|
73054
|
-
return type.flags &
|
|
73104
|
+
return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : type.flags & 384 /* StringOrNumberLiteral */ ? escapeLeadingUnderscores("" + type.value) : void 0;
|
|
73055
73105
|
}
|
|
73056
73106
|
function tryGetElementAccessExpressionName(node) {
|
|
73057
73107
|
return isStringOrNumericLiteralLike(node.argumentExpression) ? escapeLeadingUnderscores(node.argumentExpression.text) : isEntityNameExpression(node.argumentExpression) ? tryGetNameFromEntityNameExpression(node.argumentExpression) : void 0;
|
|
@@ -73230,7 +73280,7 @@ function createTypeChecker(host) {
|
|
|
73230
73280
|
}
|
|
73231
73281
|
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
73232
73282
|
const filteredType = filterType(declaredType, (t) => typeMaybeAssignableTo(assignedType, t));
|
|
73233
|
-
const reducedType = assignedType.flags &
|
|
73283
|
+
const reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
73234
73284
|
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
73235
73285
|
}
|
|
73236
73286
|
function isFunctionObjectType(type) {
|
|
@@ -73251,31 +73301,31 @@ function createTypeChecker(host) {
|
|
|
73251
73301
|
type = getBaseConstraintOfType(type) || unknownType;
|
|
73252
73302
|
}
|
|
73253
73303
|
const flags = type.flags;
|
|
73254
|
-
if (flags & (
|
|
73304
|
+
if (flags & (4 /* String */ | 268435456 /* StringMapping */)) {
|
|
73255
73305
|
return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
|
|
73256
73306
|
}
|
|
73257
|
-
if (flags & (
|
|
73258
|
-
const isEmpty = flags &
|
|
73307
|
+
if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) {
|
|
73308
|
+
const isEmpty = flags & 128 /* StringLiteral */ && type.value === "";
|
|
73259
73309
|
return strictNullChecks ? isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
|
|
73260
73310
|
}
|
|
73261
|
-
if (flags & (
|
|
73311
|
+
if (flags & (8 /* Number */ | 32 /* Enum */)) {
|
|
73262
73312
|
return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */;
|
|
73263
73313
|
}
|
|
73264
|
-
if (flags &
|
|
73314
|
+
if (flags & 256 /* NumberLiteral */) {
|
|
73265
73315
|
const isZero = type.value === 0;
|
|
73266
73316
|
return strictNullChecks ? isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */;
|
|
73267
73317
|
}
|
|
73268
|
-
if (flags &
|
|
73318
|
+
if (flags & 64 /* BigInt */) {
|
|
73269
73319
|
return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */;
|
|
73270
73320
|
}
|
|
73271
|
-
if (flags &
|
|
73321
|
+
if (flags & 2048 /* BigIntLiteral */) {
|
|
73272
73322
|
const isZero = isZeroBigInt(type);
|
|
73273
73323
|
return strictNullChecks ? isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */;
|
|
73274
73324
|
}
|
|
73275
|
-
if (flags &
|
|
73325
|
+
if (flags & 16 /* Boolean */) {
|
|
73276
73326
|
return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */;
|
|
73277
73327
|
}
|
|
73278
|
-
if (flags &
|
|
73328
|
+
if (flags & 528 /* BooleanLike */) {
|
|
73279
73329
|
return strictNullChecks ? type === falseType || type === regularFalseType ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : type === falseType || type === regularFalseType ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
73280
73330
|
}
|
|
73281
73331
|
if (flags & 524288 /* Object */) {
|
|
@@ -73285,16 +73335,16 @@ function createTypeChecker(host) {
|
|
|
73285
73335
|
}
|
|
73286
73336
|
return getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728e3 /* FunctionFacts */ : strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
|
|
73287
73337
|
}
|
|
73288
|
-
if (flags &
|
|
73338
|
+
if (flags & 16384 /* Void */) {
|
|
73289
73339
|
return 9830144 /* VoidFacts */;
|
|
73290
73340
|
}
|
|
73291
|
-
if (flags &
|
|
73341
|
+
if (flags & 32768 /* Undefined */) {
|
|
73292
73342
|
return 26607360 /* UndefinedFacts */;
|
|
73293
73343
|
}
|
|
73294
|
-
if (flags &
|
|
73344
|
+
if (flags & 65536 /* Null */) {
|
|
73295
73345
|
return 42917664 /* NullFacts */;
|
|
73296
73346
|
}
|
|
73297
|
-
if (flags &
|
|
73347
|
+
if (flags & 12288 /* ESSymbolLike */) {
|
|
73298
73348
|
return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
|
|
73299
73349
|
}
|
|
73300
73350
|
if (flags & 67108864 /* NonPrimitive */) {
|
|
@@ -73517,7 +73567,7 @@ function createTypeChecker(host) {
|
|
|
73517
73567
|
}
|
|
73518
73568
|
return true;
|
|
73519
73569
|
}
|
|
73520
|
-
if (source.flags &
|
|
73570
|
+
if (source.flags & 1056 /* EnumLike */ && getBaseTypeOfEnumLikeType(source) === target) {
|
|
73521
73571
|
return true;
|
|
73522
73572
|
}
|
|
73523
73573
|
return containsType(target.types, source);
|
|
@@ -73595,6 +73645,18 @@ function createTypeChecker(host) {
|
|
|
73595
73645
|
}
|
|
73596
73646
|
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
|
73597
73647
|
}
|
|
73648
|
+
function mapTypeToIntersection(type, mapper) {
|
|
73649
|
+
if (type.flags & 131072 /* Never */) {
|
|
73650
|
+
return type;
|
|
73651
|
+
}
|
|
73652
|
+
if (!(type.flags & 1048576 /* Union */)) {
|
|
73653
|
+
return mapper(type);
|
|
73654
|
+
}
|
|
73655
|
+
const origin = type.origin;
|
|
73656
|
+
const types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
|
|
73657
|
+
const mappedTypes = types.map((t) => t.flags & 1048576 /* Union */ ? mapTypeToIntersection(t, mapper) : mapper(t));
|
|
73658
|
+
return getIntersectionType(mappedTypes);
|
|
73659
|
+
}
|
|
73598
73660
|
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
73599
73661
|
return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
|
|
73600
73662
|
}
|
|
@@ -73602,8 +73664,8 @@ function createTypeChecker(host) {
|
|
|
73602
73664
|
return filterType(type, (t) => (t.flags & kind) !== 0);
|
|
73603
73665
|
}
|
|
73604
73666
|
function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
|
|
73605
|
-
if (maybeTypeOfKind(typeWithPrimitives,
|
|
73606
|
-
return mapType(typeWithPrimitives, (t) => t.flags &
|
|
73667
|
+
if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) {
|
|
73668
|
+
return mapType(typeWithPrimitives, (t) => t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t);
|
|
73607
73669
|
}
|
|
73608
73670
|
return typeWithPrimitives;
|
|
73609
73671
|
}
|
|
@@ -73658,7 +73720,7 @@ function createTypeChecker(host) {
|
|
|
73658
73720
|
const root = getReferenceRoot(node);
|
|
73659
73721
|
const parent2 = root.parent;
|
|
73660
73722
|
const isLengthPushOrUnshift = isPropertyAccessExpression(parent2) && (parent2.name.escapedText === "length" || parent2.parent.kind === 213 /* CallExpression */ && isIdentifier(parent2.name) && isPushOrUnshiftIdentifier(parent2.name));
|
|
73661
|
-
const isElementAssignment = parent2.kind === 212 /* ElementAccessExpression */ && parent2.expression === root && parent2.parent.kind === 226 /* BinaryExpression */ && parent2.parent.operatorToken.kind === 64 /* EqualsToken */ && parent2.parent.left === parent2 && !isAssignmentTarget(parent2.parent) && isTypeAssignableToKind(getTypeOfExpression(parent2.argumentExpression),
|
|
73723
|
+
const isElementAssignment = parent2.kind === 212 /* ElementAccessExpression */ && parent2.expression === root && parent2.parent.kind === 226 /* BinaryExpression */ && parent2.parent.operatorToken.kind === 64 /* EqualsToken */ && parent2.parent.left === parent2 && !isAssignmentTarget(parent2.parent) && isTypeAssignableToKind(getTypeOfExpression(parent2.argumentExpression), 296 /* NumberLike */);
|
|
73662
73724
|
return isLengthPushOrUnshift || isElementAssignment;
|
|
73663
73725
|
}
|
|
73664
73726
|
function isDeclarationWithExplicitTypeAnnotation(node) {
|
|
@@ -74146,7 +74208,7 @@ function createTypeChecker(host) {
|
|
|
74146
74208
|
}
|
|
74147
74209
|
} else {
|
|
74148
74210
|
const indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
|
|
74149
|
-
if (isTypeAssignableToKind(indexType,
|
|
74211
|
+
if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) {
|
|
74150
74212
|
evolvedType2 = addEvolvingArrayElementType(evolvedType2, node.right);
|
|
74151
74213
|
}
|
|
74152
74214
|
}
|
|
@@ -74184,9 +74246,9 @@ function createTypeChecker(host) {
|
|
|
74184
74246
|
} else {
|
|
74185
74247
|
if (strictNullChecks) {
|
|
74186
74248
|
if (optionalChainContainsReference(expr, reference)) {
|
|
74187
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (
|
|
74249
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)));
|
|
74188
74250
|
} else if (expr.kind === 221 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
|
|
74189
|
-
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags &
|
|
74251
|
+
type = narrowTypeBySwitchOptionalChainContainment(type, flow.node, (t) => !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"));
|
|
74190
74252
|
}
|
|
74191
74253
|
}
|
|
74192
74254
|
const access = getDiscriminantPropertyAccess(expr, type);
|
|
@@ -74360,7 +74422,7 @@ function createTypeChecker(host) {
|
|
|
74360
74422
|
return type;
|
|
74361
74423
|
}
|
|
74362
74424
|
const optionalChain = isOptionalChain(access);
|
|
74363
|
-
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type,
|
|
74425
|
+
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type, 98304 /* Nullable */);
|
|
74364
74426
|
let propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName);
|
|
74365
74427
|
if (!propType) {
|
|
74366
74428
|
return type;
|
|
@@ -74582,7 +74644,7 @@ function createTypeChecker(host) {
|
|
|
74582
74644
|
}
|
|
74583
74645
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
74584
74646
|
const equalsOperator = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
74585
|
-
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ?
|
|
74647
|
+
const nullableFlags = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */;
|
|
74586
74648
|
const valueType = getTypeOfExpression(value);
|
|
74587
74649
|
const removeNullable = equalsOperator !== assumeTrue && everyType(valueType, (t) => !!(t.flags & nullableFlags)) || equalsOperator === assumeTrue && everyType(valueType, (t) => !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)));
|
|
74588
74650
|
return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
|
|
@@ -74596,11 +74658,11 @@ function createTypeChecker(host) {
|
|
|
74596
74658
|
}
|
|
74597
74659
|
const valueType = getTypeOfExpression(value);
|
|
74598
74660
|
const doubleEquals = operator === 35 /* EqualsEqualsToken */ || operator === 36 /* ExclamationEqualsToken */;
|
|
74599
|
-
if (valueType.flags &
|
|
74661
|
+
if (valueType.flags & 98304 /* Nullable */) {
|
|
74600
74662
|
if (!strictNullChecks) {
|
|
74601
74663
|
return type;
|
|
74602
74664
|
}
|
|
74603
|
-
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags &
|
|
74665
|
+
const facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
|
|
74604
74666
|
return getAdjustedTypeWithFacts(type, facts);
|
|
74605
74667
|
}
|
|
74606
74668
|
if (assumeTrue) {
|
|
@@ -74675,7 +74737,7 @@ function createTypeChecker(host) {
|
|
|
74675
74737
|
if (!hasDefaultClause) {
|
|
74676
74738
|
return caseType;
|
|
74677
74739
|
}
|
|
74678
|
-
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags &
|
|
74740
|
+
const defaultType = filterType(type, (t) => !(isUnitLikeType(t) && contains(switchTypes, t.flags & 32768 /* Undefined */ ? undefinedType : getRegularTypeOfLiteralType(extractUnitType(t)))));
|
|
74679
74741
|
return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
|
|
74680
74742
|
}
|
|
74681
74743
|
function narrowTypeByTypeName(type, typeName) {
|
|
@@ -75166,10 +75228,10 @@ function createTypeChecker(host) {
|
|
|
75166
75228
|
return parent2.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 166 /* QualifiedName */ || parent2.kind === 213 /* CallExpression */ && parent2.expression === node || parent2.kind === 214 /* NewExpression */ && parent2.expression === node || parent2.kind === 212 /* ElementAccessExpression */ && parent2.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent2.argumentExpression)));
|
|
75167
75229
|
}
|
|
75168
75230
|
function isGenericTypeWithUnionConstraint(type) {
|
|
75169
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (
|
|
75231
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithUnionConstraint) : !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
|
|
75170
75232
|
}
|
|
75171
75233
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
75172
|
-
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type),
|
|
75234
|
+
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
75173
75235
|
}
|
|
75174
75236
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
75175
75237
|
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(
|
|
@@ -75179,11 +75241,11 @@ function createTypeChecker(host) {
|
|
|
75179
75241
|
));
|
|
75180
75242
|
return contextualType && !isGenericType(contextualType);
|
|
75181
75243
|
}
|
|
75182
|
-
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
75244
|
+
function getNarrowableTypeForReference(type, reference, checkMode, forReturnTypeNarrowing) {
|
|
75183
75245
|
if (isNoInferType(type)) {
|
|
75184
75246
|
type = type.baseType;
|
|
75185
75247
|
}
|
|
75186
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
75248
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (forReturnTypeNarrowing || isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
75187
75249
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
75188
75250
|
}
|
|
75189
75251
|
function isExportOrExportExpression(location) {
|
|
@@ -75728,7 +75790,7 @@ function createTypeChecker(host) {
|
|
|
75728
75790
|
flowContainer = getControlFlowContainer(flowContainer);
|
|
75729
75791
|
}
|
|
75730
75792
|
const isNeverInitialized = immediateDeclaration && isVariableDeclaration(immediateDeclaration) && !immediateDeclaration.initializer && !immediateDeclaration.exclamationToken && isMutableLocalVariableDeclaration(immediateDeclaration) && !isSymbolAssignedDefinitely(symbol);
|
|
75731
|
-
const assumeInitialized = isParameter2 || isAlias || isOuterVariable && !isNeverInitialized || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ |
|
|
75793
|
+
const assumeInitialized = isParameter2 || isAlias || isOuterVariable && !isNeverInitialized || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || isInTypeQuery(node) || isInAmbientOrTypeNode(node) || node.parent.kind === 281 /* ExportSpecifier */) || node.parent.kind === 235 /* NonNullExpression */ || declaration.kind === 260 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 33554432 /* Ambient */;
|
|
75732
75794
|
const initialType = isAutomaticTypeInNonNull ? undefinedType : assumeInitialized ? isParameter2 ? removeOptionalityFromDeclaredType(type, declaration) : type : typeIsAutomatic ? undefinedType : getOptionalType(type);
|
|
75733
75795
|
const flowType = isAutomaticTypeInNonNull ? getNonNullableType(getFlowTypeOfReference(node, type, initialType, flowContainer)) : getFlowTypeOfReference(node, type, initialType, flowContainer);
|
|
75734
75796
|
if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
|
|
@@ -76310,9 +76372,16 @@ function createTypeChecker(host) {
|
|
|
76310
76372
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
76311
76373
|
const func = getContainingFunction(node);
|
|
76312
76374
|
if (func) {
|
|
76375
|
+
const functionFlags = getFunctionFlags(func);
|
|
76376
|
+
const links = getNodeLinks(node);
|
|
76377
|
+
if (links.contextualReturnType) {
|
|
76378
|
+
if (functionFlags & 2 /* Async */) {
|
|
76379
|
+
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
76380
|
+
}
|
|
76381
|
+
return links.contextualReturnType;
|
|
76382
|
+
}
|
|
76313
76383
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
76314
76384
|
if (contextualReturnType) {
|
|
76315
|
-
const functionFlags = getFunctionFlags(func);
|
|
76316
76385
|
if (functionFlags & 1 /* Generator */) {
|
|
76317
76386
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
|
76318
76387
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
|
@@ -76416,7 +76485,7 @@ function createTypeChecker(host) {
|
|
|
76416
76485
|
const functionFlags = getFunctionFlags(functionDecl);
|
|
76417
76486
|
if (functionFlags & 1 /* Generator */) {
|
|
76418
76487
|
return filterType(returnType2, (t) => {
|
|
76419
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
76488
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || checkGeneratorInstantiationAssignabilityToReturnType(
|
|
76420
76489
|
t,
|
|
76421
76490
|
functionFlags,
|
|
76422
76491
|
/*errorNode*/
|
|
@@ -76426,7 +76495,7 @@ function createTypeChecker(host) {
|
|
|
76426
76495
|
}
|
|
76427
76496
|
if (functionFlags & 2 /* Async */) {
|
|
76428
76497
|
return filterType(returnType2, (t) => {
|
|
76429
|
-
return !!(t.flags & (3 /* AnyOrUnknown */ |
|
|
76498
|
+
return !!(t.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 58982400 /* InstantiableNonPrimitive */)) || !!getAwaitedTypeOfPromise(t);
|
|
76430
76499
|
});
|
|
76431
76500
|
}
|
|
76432
76501
|
return returnType2;
|
|
@@ -77010,6 +77079,13 @@ function createTypeChecker(host) {
|
|
|
77010
77079
|
if (index >= 0) {
|
|
77011
77080
|
return contextualTypes[index];
|
|
77012
77081
|
}
|
|
77082
|
+
const links = getNodeLinks(node);
|
|
77083
|
+
if (links.contextualReturnType) {
|
|
77084
|
+
if (node.flags & 65536 /* AwaitContext */) {
|
|
77085
|
+
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
77086
|
+
}
|
|
77087
|
+
return links.contextualReturnType;
|
|
77088
|
+
}
|
|
77013
77089
|
const { parent: parent2 } = node;
|
|
77014
77090
|
switch (parent2.kind) {
|
|
77015
77091
|
case 260 /* VariableDeclaration */:
|
|
@@ -77185,7 +77261,7 @@ function createTypeChecker(host) {
|
|
|
77185
77261
|
return getOrCreateTypeFromSignature(fakeSignature);
|
|
77186
77262
|
}
|
|
77187
77263
|
const tagType = checkExpressionCached(context.tagName);
|
|
77188
|
-
if (tagType.flags &
|
|
77264
|
+
if (tagType.flags & 128 /* StringLiteral */) {
|
|
77189
77265
|
const result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
|
|
77190
77266
|
if (!result) {
|
|
77191
77267
|
return errorType;
|
|
@@ -77557,7 +77633,7 @@ function createTypeChecker(host) {
|
|
|
77557
77633
|
}
|
|
77558
77634
|
}
|
|
77559
77635
|
function isNumericComputedName(name) {
|
|
77560
|
-
return isTypeAssignableToKind(checkComputedPropertyName(name),
|
|
77636
|
+
return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */);
|
|
77561
77637
|
}
|
|
77562
77638
|
function checkComputedPropertyName(node) {
|
|
77563
77639
|
const links = getNodeLinks(node.expression);
|
|
@@ -77575,7 +77651,7 @@ function createTypeChecker(host) {
|
|
|
77575
77651
|
getNodeLinks(node.parent.parent).flags |= 32768 /* BlockScopedBindingInLoop */;
|
|
77576
77652
|
}
|
|
77577
77653
|
}
|
|
77578
|
-
if (links.resolvedType.flags &
|
|
77654
|
+
if (links.resolvedType.flags & 98304 /* Nullable */ || !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
|
|
77579
77655
|
error2(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
|
|
77580
77656
|
}
|
|
77581
77657
|
}
|
|
@@ -77589,7 +77665,7 @@ function createTypeChecker(host) {
|
|
|
77589
77665
|
function isSymbolWithSymbolName(symbol) {
|
|
77590
77666
|
var _a;
|
|
77591
77667
|
const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
|
|
77592
|
-
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name),
|
|
77668
|
+
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */);
|
|
77593
77669
|
}
|
|
77594
77670
|
function isSymbolWithComputedName(symbol) {
|
|
77595
77671
|
var _a;
|
|
@@ -77745,7 +77821,7 @@ function createTypeChecker(host) {
|
|
|
77745
77821
|
Debug.assert(memberDecl.kind === 177 /* GetAccessor */ || memberDecl.kind === 178 /* SetAccessor */);
|
|
77746
77822
|
checkNodeDeferred(memberDecl);
|
|
77747
77823
|
}
|
|
77748
|
-
if (computedNameType && !(computedNameType.flags &
|
|
77824
|
+
if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) {
|
|
77749
77825
|
if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
|
|
77750
77826
|
if (isTypeAssignableTo(computedNameType, numberType)) {
|
|
77751
77827
|
hasComputedNumberProperty = true;
|
|
@@ -78158,9 +78234,9 @@ function createTypeChecker(host) {
|
|
|
78158
78234
|
return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
|
|
78159
78235
|
}
|
|
78160
78236
|
function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
|
|
78161
|
-
if (elementType.flags &
|
|
78237
|
+
if (elementType.flags & 4 /* String */) {
|
|
78162
78238
|
return [anySignature];
|
|
78163
|
-
} else if (elementType.flags &
|
|
78239
|
+
} else if (elementType.flags & 128 /* StringLiteral */) {
|
|
78164
78240
|
const intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
|
|
78165
78241
|
if (!intrinsicType) {
|
|
78166
78242
|
error2(caller, Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
|
|
@@ -78542,7 +78618,7 @@ function createTypeChecker(host) {
|
|
|
78542
78618
|
if (facts & 50331648 /* IsUndefinedOrNull */) {
|
|
78543
78619
|
reportError(node, facts);
|
|
78544
78620
|
const t = getNonNullableType(type);
|
|
78545
|
-
return t.flags & (
|
|
78621
|
+
return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t;
|
|
78546
78622
|
}
|
|
78547
78623
|
return type;
|
|
78548
78624
|
}
|
|
@@ -78551,7 +78627,7 @@ function createTypeChecker(host) {
|
|
|
78551
78627
|
}
|
|
78552
78628
|
function checkNonNullNonVoidType(type, node) {
|
|
78553
78629
|
const nonNullType = checkNonNullType(type, node);
|
|
78554
|
-
if (nonNullType.flags &
|
|
78630
|
+
if (nonNullType.flags & 16384 /* Void */) {
|
|
78555
78631
|
if (isEntityNameExpression(node)) {
|
|
78556
78632
|
const nodeText2 = entityNameToString(node);
|
|
78557
78633
|
if (isIdentifier(node) && nodeText2 === "undefined") {
|
|
@@ -79098,7 +79174,7 @@ function createTypeChecker(host) {
|
|
|
79098
79174
|
return suggestion;
|
|
79099
79175
|
}
|
|
79100
79176
|
function getSuggestedTypeForNonexistentStringLiteralType(source, target) {
|
|
79101
|
-
const candidates = target.types.filter((type) => !!(type.flags &
|
|
79177
|
+
const candidates = target.types.filter((type) => !!(type.flags & 128 /* StringLiteral */));
|
|
79102
79178
|
return getSpellingSuggestion(source.value, candidates, (type) => type.value);
|
|
79103
79179
|
}
|
|
79104
79180
|
function getSpellingSuggestionForName(name, symbols, meaning) {
|
|
@@ -79330,10 +79406,10 @@ function createTypeChecker(host) {
|
|
|
79330
79406
|
return findIndex(args, isSpreadArgument);
|
|
79331
79407
|
}
|
|
79332
79408
|
function acceptsVoid(t) {
|
|
79333
|
-
return !!(t.flags &
|
|
79409
|
+
return !!(t.flags & 16384 /* Void */);
|
|
79334
79410
|
}
|
|
79335
79411
|
function acceptsVoidUndefinedUnknownOrAny(t) {
|
|
79336
|
-
return !!(t.flags & (
|
|
79412
|
+
return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */));
|
|
79337
79413
|
}
|
|
79338
79414
|
function hasCorrectArity(node, args, signature, signatureHelpTrailingComma = false) {
|
|
79339
79415
|
if (isJsxOpeningFragment(node)) return true;
|
|
@@ -79432,8 +79508,8 @@ function createTypeChecker(host) {
|
|
|
79432
79508
|
}
|
|
79433
79509
|
return void 0;
|
|
79434
79510
|
}
|
|
79435
|
-
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext,
|
|
79436
|
-
const context = createInferenceContext(getTypeParametersForMapper(signature), signature, 0 /* None */,
|
|
79511
|
+
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
|
|
79512
|
+
const context = createInferenceContext(getTypeParametersForMapper(signature), signature, 0 /* None */, compareTypes);
|
|
79437
79513
|
const restType = getEffectiveRestType(contextualSignature);
|
|
79438
79514
|
const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
|
|
79439
79515
|
const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
|
|
@@ -81168,10 +81244,10 @@ function createTypeChecker(host) {
|
|
|
81168
81244
|
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
|
|
81169
81245
|
}
|
|
81170
81246
|
const returnType = getReturnTypeOfSignature(signature);
|
|
81171
|
-
if (returnType.flags &
|
|
81247
|
+
if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) {
|
|
81172
81248
|
return getESSymbolLikeTypeForNode(walkUpParenthesizedExpressions(node.parent));
|
|
81173
81249
|
}
|
|
81174
|
-
if (node.kind === 213 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 244 /* ExpressionStatement */ && returnType.flags &
|
|
81250
|
+
if (node.kind === 213 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 244 /* ExpressionStatement */ && returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) {
|
|
81175
81251
|
if (!isDottedName(node.expression)) {
|
|
81176
81252
|
error2(node.expression, Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
|
|
81177
81253
|
} else if (!getEffectsSignature(node)) {
|
|
@@ -81261,7 +81337,7 @@ function createTypeChecker(host) {
|
|
|
81261
81337
|
for (let i = 2; i < node.arguments.length; ++i) {
|
|
81262
81338
|
checkExpressionCached(node.arguments[i]);
|
|
81263
81339
|
}
|
|
81264
|
-
if (specifierType.flags &
|
|
81340
|
+
if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) {
|
|
81265
81341
|
error2(specifier, Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
|
|
81266
81342
|
}
|
|
81267
81343
|
if (optionsType) {
|
|
@@ -81270,7 +81346,7 @@ function createTypeChecker(host) {
|
|
|
81270
81346
|
true
|
|
81271
81347
|
);
|
|
81272
81348
|
if (importCallOptionsType !== emptyObjectType) {
|
|
81273
|
-
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType,
|
|
81349
|
+
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]);
|
|
81274
81350
|
}
|
|
81275
81351
|
}
|
|
81276
81352
|
const moduleSymbol = resolveExternalModuleName(node, specifier);
|
|
@@ -81394,8 +81470,8 @@ function createTypeChecker(host) {
|
|
|
81394
81470
|
grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
|
|
81395
81471
|
}
|
|
81396
81472
|
if (compilerOptions.erasableSyntaxOnly) {
|
|
81397
|
-
const start = node.
|
|
81398
|
-
const end =
|
|
81473
|
+
const start = skipTrivia(file.text, node.pos);
|
|
81474
|
+
const end = node.expression.pos;
|
|
81399
81475
|
diagnostics.add(createFileDiagnostic(file, start, end - start, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled));
|
|
81400
81476
|
}
|
|
81401
81477
|
}
|
|
@@ -82316,7 +82392,7 @@ function createTypeChecker(host) {
|
|
|
82316
82392
|
/*contextFlags*/
|
|
82317
82393
|
void 0
|
|
82318
82394
|
);
|
|
82319
|
-
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags &
|
|
82395
|
+
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 32768 /* Undefined */ ? undefinedType : voidType;
|
|
82320
82396
|
return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
|
|
82321
82397
|
// Async function
|
|
82322
82398
|
returnType2
|
|
@@ -82562,10 +82638,10 @@ function createTypeChecker(host) {
|
|
|
82562
82638
|
true
|
|
82563
82639
|
);
|
|
82564
82640
|
const returnType = checkExpressionCached(expr);
|
|
82565
|
-
if (!(returnType.flags &
|
|
82641
|
+
if (!(returnType.flags & 16 /* Boolean */)) return void 0;
|
|
82566
82642
|
return forEach(func.parameters, (param, i) => {
|
|
82567
82643
|
const initType = getTypeOfSymbol(param.symbol);
|
|
82568
|
-
if (!initType || initType.flags &
|
|
82644
|
+
if (!initType || initType.flags & 16 /* Boolean */ || !isIdentifier(param.name) || isSymbolAssigned(param.symbol) || isRestParameter(param)) {
|
|
82569
82645
|
return;
|
|
82570
82646
|
}
|
|
82571
82647
|
const trueType2 = checkIfExpressionRefinesParameter(func, expr, param, initType);
|
|
@@ -82595,7 +82671,7 @@ function createTypeChecker(host) {
|
|
|
82595
82671
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
82596
82672
|
const functionFlags = getFunctionFlags(func);
|
|
82597
82673
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
82598
|
-
if (type && (maybeTypeOfKind(type,
|
|
82674
|
+
if (type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */))) {
|
|
82599
82675
|
return;
|
|
82600
82676
|
}
|
|
82601
82677
|
if (func.kind === 173 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 241 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -82967,11 +83043,11 @@ function createTypeChecker(host) {
|
|
|
82967
83043
|
case 41 /* MinusToken */:
|
|
82968
83044
|
case 55 /* TildeToken */:
|
|
82969
83045
|
checkNonNullType(operandType, node.operand);
|
|
82970
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
83046
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) {
|
|
82971
83047
|
error2(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator));
|
|
82972
83048
|
}
|
|
82973
83049
|
if (node.operator === 40 /* PlusToken */) {
|
|
82974
|
-
if (maybeTypeOfKindConsideringBaseConstraint(operandType,
|
|
83050
|
+
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* BigIntLike */)) {
|
|
82975
83051
|
error2(node.operand, Diagnostics.Operator_0_cannot_be_applied_to_type_1, tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
|
|
82976
83052
|
}
|
|
82977
83053
|
return numberType;
|
|
@@ -83015,8 +83091,8 @@ function createTypeChecker(host) {
|
|
|
83015
83091
|
return getUnaryResultType(operandType);
|
|
83016
83092
|
}
|
|
83017
83093
|
function getUnaryResultType(operandType) {
|
|
83018
|
-
if (maybeTypeOfKind(operandType,
|
|
83019
|
-
return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType,
|
|
83094
|
+
if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) {
|
|
83095
|
+
return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) ? numberOrBigIntType : bigintType;
|
|
83020
83096
|
}
|
|
83021
83097
|
return numberType;
|
|
83022
83098
|
}
|
|
@@ -83045,10 +83121,10 @@ function createTypeChecker(host) {
|
|
|
83045
83121
|
if (source.flags & kind) {
|
|
83046
83122
|
return true;
|
|
83047
83123
|
}
|
|
83048
|
-
if (strict && source.flags & (3 /* AnyOrUnknown */ |
|
|
83124
|
+
if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) {
|
|
83049
83125
|
return false;
|
|
83050
83126
|
}
|
|
83051
|
-
return !!(kind &
|
|
83127
|
+
return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType);
|
|
83052
83128
|
}
|
|
83053
83129
|
function allTypesAssignableToKind(source, kind, strict) {
|
|
83054
83130
|
return source.flags & 1048576 /* Union */ ? every(source.types, (subType) => allTypesAssignableToKind(subType, kind, strict)) : isTypeAssignableToKind(source, kind, strict);
|
|
@@ -83321,7 +83397,7 @@ function createTypeChecker(host) {
|
|
|
83321
83397
|
}
|
|
83322
83398
|
}
|
|
83323
83399
|
function isTypeEqualityComparableTo(source, target) {
|
|
83324
|
-
return (target.flags &
|
|
83400
|
+
return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target);
|
|
83325
83401
|
}
|
|
83326
83402
|
function createCheckBinaryExpression() {
|
|
83327
83403
|
const trampoline = createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState);
|
|
@@ -83572,7 +83648,7 @@ function createTypeChecker(host) {
|
|
|
83572
83648
|
leftType = checkNonNullType(leftType, left);
|
|
83573
83649
|
rightType = checkNonNullType(rightType, right);
|
|
83574
83650
|
let suggestedOperator;
|
|
83575
|
-
if (leftType.flags &
|
|
83651
|
+
if (leftType.flags & 528 /* BooleanLike */ && rightType.flags & 528 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
|
|
83576
83652
|
error2(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
|
|
83577
83653
|
return numberType;
|
|
83578
83654
|
} else {
|
|
@@ -83592,7 +83668,7 @@ function createTypeChecker(host) {
|
|
|
83592
83668
|
);
|
|
83593
83669
|
let resultType2;
|
|
83594
83670
|
if (isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */) || // Or, if neither could be bigint, implicit coercion results in a number result
|
|
83595
|
-
!(maybeTypeOfKind(leftType,
|
|
83671
|
+
!(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) {
|
|
83596
83672
|
resultType2 = numberType;
|
|
83597
83673
|
} else if (bothAreBigIntLike(leftType, rightType)) {
|
|
83598
83674
|
switch (operator) {
|
|
@@ -83644,43 +83720,43 @@ function createTypeChecker(host) {
|
|
|
83644
83720
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
83645
83721
|
return silentNeverType;
|
|
83646
83722
|
}
|
|
83647
|
-
if (!isTypeAssignableToKind(leftType,
|
|
83723
|
+
if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) {
|
|
83648
83724
|
leftType = checkNonNullType(leftType, left);
|
|
83649
83725
|
rightType = checkNonNullType(rightType, right);
|
|
83650
83726
|
}
|
|
83651
83727
|
let resultType;
|
|
83652
83728
|
if (isTypeAssignableToKind(
|
|
83653
83729
|
leftType,
|
|
83654
|
-
|
|
83730
|
+
296 /* NumberLike */,
|
|
83655
83731
|
/*strict*/
|
|
83656
83732
|
true
|
|
83657
83733
|
) && isTypeAssignableToKind(
|
|
83658
83734
|
rightType,
|
|
83659
|
-
|
|
83735
|
+
296 /* NumberLike */,
|
|
83660
83736
|
/*strict*/
|
|
83661
83737
|
true
|
|
83662
83738
|
)) {
|
|
83663
83739
|
resultType = numberType;
|
|
83664
83740
|
} else if (isTypeAssignableToKind(
|
|
83665
83741
|
leftType,
|
|
83666
|
-
|
|
83742
|
+
2112 /* BigIntLike */,
|
|
83667
83743
|
/*strict*/
|
|
83668
83744
|
true
|
|
83669
83745
|
) && isTypeAssignableToKind(
|
|
83670
83746
|
rightType,
|
|
83671
|
-
|
|
83747
|
+
2112 /* BigIntLike */,
|
|
83672
83748
|
/*strict*/
|
|
83673
83749
|
true
|
|
83674
83750
|
)) {
|
|
83675
83751
|
resultType = bigintType;
|
|
83676
83752
|
} else if (isTypeAssignableToKind(
|
|
83677
83753
|
leftType,
|
|
83678
|
-
|
|
83754
|
+
402653316 /* StringLike */,
|
|
83679
83755
|
/*strict*/
|
|
83680
83756
|
true
|
|
83681
83757
|
) || isTypeAssignableToKind(
|
|
83682
83758
|
rightType,
|
|
83683
|
-
|
|
83759
|
+
402653316 /* StringLike */,
|
|
83684
83760
|
/*strict*/
|
|
83685
83761
|
true
|
|
83686
83762
|
)) {
|
|
@@ -83692,7 +83768,7 @@ function createTypeChecker(host) {
|
|
|
83692
83768
|
return resultType;
|
|
83693
83769
|
}
|
|
83694
83770
|
if (!resultType) {
|
|
83695
|
-
const closeEnoughKind =
|
|
83771
|
+
const closeEnoughKind = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */;
|
|
83696
83772
|
reportOperatorError(
|
|
83697
83773
|
(left2, right2) => isTypeAssignableToKind(left2, closeEnoughKind) && isTypeAssignableToKind(right2, closeEnoughKind)
|
|
83698
83774
|
);
|
|
@@ -83789,7 +83865,7 @@ function createTypeChecker(host) {
|
|
|
83789
83865
|
return Debug.fail();
|
|
83790
83866
|
}
|
|
83791
83867
|
function bothAreBigIntLike(left2, right2) {
|
|
83792
|
-
return isTypeAssignableToKind(left2,
|
|
83868
|
+
return isTypeAssignableToKind(left2, 2112 /* BigIntLike */) && isTypeAssignableToKind(right2, 2112 /* BigIntLike */);
|
|
83793
83869
|
}
|
|
83794
83870
|
function checkAssignmentDeclaration(kind, rightType2) {
|
|
83795
83871
|
if (kind === 2 /* ModuleExports */) {
|
|
@@ -83819,7 +83895,7 @@ function createTypeChecker(host) {
|
|
|
83819
83895
|
(isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
|
|
83820
83896
|
}
|
|
83821
83897
|
function checkForDisallowedESSymbolOperand(operator2) {
|
|
83822
|
-
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType,
|
|
83898
|
+
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : void 0;
|
|
83823
83899
|
if (offendingSymbolOperand) {
|
|
83824
83900
|
error2(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator2));
|
|
83825
83901
|
return false;
|
|
@@ -83858,7 +83934,7 @@ function createTypeChecker(host) {
|
|
|
83858
83934
|
}
|
|
83859
83935
|
if (checkReferenceExpression(left, Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access)) {
|
|
83860
83936
|
let headMessage;
|
|
83861
|
-
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType,
|
|
83937
|
+
if (exactOptionalPropertyTypes && isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) {
|
|
83862
83938
|
const target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText);
|
|
83863
83939
|
if (isExactOptionalPropertyMismatch(valueType, target)) {
|
|
83864
83940
|
headMessage = Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target;
|
|
@@ -84047,7 +84123,7 @@ function createTypeChecker(host) {
|
|
|
84047
84123
|
const types = [];
|
|
84048
84124
|
for (const span of node.templateSpans) {
|
|
84049
84125
|
const type = checkExpression(span.expression);
|
|
84050
|
-
if (maybeTypeOfKindConsideringBaseConstraint(type,
|
|
84126
|
+
if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) {
|
|
84051
84127
|
error2(span.expression, Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
|
|
84052
84128
|
}
|
|
84053
84129
|
texts.push(span.literal.text);
|
|
@@ -84067,7 +84143,7 @@ function createTypeChecker(host) {
|
|
|
84067
84143
|
return stringType;
|
|
84068
84144
|
}
|
|
84069
84145
|
function isTemplateLiteralContextualType(type) {
|
|
84070
|
-
return !!(type.flags & (
|
|
84146
|
+
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */));
|
|
84071
84147
|
}
|
|
84072
84148
|
function getContextNode2(node) {
|
|
84073
84149
|
if (isJsxAttributes(node) && !isJsxSelfClosingElement(node.parent)) {
|
|
@@ -84088,7 +84164,7 @@ function createTypeChecker(host) {
|
|
|
84088
84164
|
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
84089
84165
|
inferenceContext.intraExpressionInferenceSites = void 0;
|
|
84090
84166
|
}
|
|
84091
|
-
const result = maybeTypeOfKind(type,
|
|
84167
|
+
const result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(
|
|
84092
84168
|
contextualType,
|
|
84093
84169
|
node,
|
|
84094
84170
|
/*contextFlags*/
|
|
@@ -84232,9 +84308,9 @@ function createTypeChecker(host) {
|
|
|
84232
84308
|
}
|
|
84233
84309
|
if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
84234
84310
|
const constraint = getBaseConstraintOfType(contextualType) || unknownType;
|
|
84235
|
-
return maybeTypeOfKind(constraint,
|
|
84311
|
+
return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint);
|
|
84236
84312
|
}
|
|
84237
|
-
return !!(contextualType.flags & (
|
|
84313
|
+
return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */));
|
|
84238
84314
|
}
|
|
84239
84315
|
return false;
|
|
84240
84316
|
}
|
|
@@ -87095,7 +87171,7 @@ function createTypeChecker(host) {
|
|
|
87095
87171
|
return;
|
|
87096
87172
|
}
|
|
87097
87173
|
const type = location === condExpr2 ? condType : checkExpression(location);
|
|
87098
|
-
if (type.flags &
|
|
87174
|
+
if (type.flags & 1024 /* EnumLiteral */ && isPropertyAccessExpression(location) && (getNodeLinks(location.expression).resolvedSymbol ?? unknownSymbol).flags & 384 /* Enum */) {
|
|
87099
87175
|
error2(location, Diagnostics.This_condition_will_always_return_0, !!type.value ? "true" : "false");
|
|
87100
87176
|
return;
|
|
87101
87177
|
}
|
|
@@ -87187,7 +87263,7 @@ function createTypeChecker(host) {
|
|
|
87187
87263
|
checkSourceElement(node.statement);
|
|
87188
87264
|
}
|
|
87189
87265
|
function checkTruthinessOfType(type, node) {
|
|
87190
|
-
if (type.flags &
|
|
87266
|
+
if (type.flags & 16384 /* Void */) {
|
|
87191
87267
|
error2(node, Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
|
|
87192
87268
|
} else {
|
|
87193
87269
|
const semantics = getSyntacticTruthySemantics(node);
|
|
@@ -87375,11 +87451,11 @@ function createTypeChecker(host) {
|
|
|
87375
87451
|
if (use & 4 /* AllowsStringInputFlag */) {
|
|
87376
87452
|
if (arrayType.flags & 1048576 /* Union */) {
|
|
87377
87453
|
const arrayTypes = inputType.types;
|
|
87378
|
-
const filteredTypes = filter(arrayTypes, (t) => !(t.flags &
|
|
87454
|
+
const filteredTypes = filter(arrayTypes, (t) => !(t.flags & 402653316 /* StringLike */));
|
|
87379
87455
|
if (filteredTypes !== arrayTypes) {
|
|
87380
87456
|
arrayType = getUnionType(filteredTypes, 2 /* Subtype */);
|
|
87381
87457
|
}
|
|
87382
|
-
} else if (arrayType.flags &
|
|
87458
|
+
} else if (arrayType.flags & 402653316 /* StringLike */) {
|
|
87383
87459
|
arrayType = neverType;
|
|
87384
87460
|
}
|
|
87385
87461
|
hasStringConstituent = arrayType !== inputType;
|
|
@@ -87404,7 +87480,7 @@ function createTypeChecker(host) {
|
|
|
87404
87480
|
}
|
|
87405
87481
|
const arrayElementType = getIndexTypeOfType(arrayType, numberType);
|
|
87406
87482
|
if (hasStringConstituent && arrayElementType) {
|
|
87407
|
-
if (arrayElementType.flags &
|
|
87483
|
+
if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) {
|
|
87408
87484
|
return stringType;
|
|
87409
87485
|
}
|
|
87410
87486
|
return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */);
|
|
@@ -87455,7 +87531,7 @@ function createTypeChecker(host) {
|
|
|
87455
87531
|
return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
|
|
87456
87532
|
}
|
|
87457
87533
|
function createIterationTypes(yieldType = neverType, returnType = neverType, nextType = unknownType) {
|
|
87458
|
-
if (yieldType.flags &
|
|
87534
|
+
if (yieldType.flags & 67359327 /* Intrinsic */ && returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) {
|
|
87459
87535
|
const id = getTypeListId([yieldType, returnType, nextType]);
|
|
87460
87536
|
let iterationTypes = iterationTypesCache.get(id);
|
|
87461
87537
|
if (!iterationTypes) {
|
|
@@ -87951,7 +88027,7 @@ function createTypeChecker(host) {
|
|
|
87951
88027
|
}
|
|
87952
88028
|
function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
|
|
87953
88029
|
const type = unwrapReturnType(returnType, getFunctionFlags(func));
|
|
87954
|
-
return !!(type && (maybeTypeOfKind(type,
|
|
88030
|
+
return !!(type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */)));
|
|
87955
88031
|
}
|
|
87956
88032
|
function checkReturnStatement(node) {
|
|
87957
88033
|
if (checkGrammarStatementInAmbientContext(node)) {
|
|
@@ -88024,7 +88100,374 @@ function createTypeChecker(host) {
|
|
|
88024
88100
|
) : exprType;
|
|
88025
88101
|
const effectiveExpr = expr && getEffectiveCheckNode(expr);
|
|
88026
88102
|
const errorNode = inReturnStatement && !inConditionalExpression ? node : effectiveExpr;
|
|
88027
|
-
|
|
88103
|
+
if (!(unwrappedReturnType.flags & (8388608 /* IndexedAccess */ | 16777216 /* Conditional */)) || !couldContainTypeVariables(unwrappedReturnType)) {
|
|
88104
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
88105
|
+
return;
|
|
88106
|
+
}
|
|
88107
|
+
if (checkTypeAssignableTo(
|
|
88108
|
+
unwrappedExprType,
|
|
88109
|
+
unwrappedReturnType,
|
|
88110
|
+
/*errorNode*/
|
|
88111
|
+
void 0
|
|
88112
|
+
)) {
|
|
88113
|
+
return;
|
|
88114
|
+
}
|
|
88115
|
+
let narrowPosition = node;
|
|
88116
|
+
let narrowFlowNode = inReturnStatement && node.flowNode;
|
|
88117
|
+
if (expr && isConditionalExpression(expr.parent)) {
|
|
88118
|
+
narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
|
|
88119
|
+
narrowPosition = expr;
|
|
88120
|
+
}
|
|
88121
|
+
if (!narrowFlowNode) {
|
|
88122
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
88123
|
+
return;
|
|
88124
|
+
}
|
|
88125
|
+
const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
|
|
88126
|
+
container,
|
|
88127
|
+
/*includeThisTypes*/
|
|
88128
|
+
false
|
|
88129
|
+
), getEffectiveTypeParameterDeclarations(container));
|
|
88130
|
+
const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
|
|
88131
|
+
if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
|
|
88132
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
88133
|
+
return;
|
|
88134
|
+
}
|
|
88135
|
+
const narrowedTypeParameters = [];
|
|
88136
|
+
const narrowedTypes = [];
|
|
88137
|
+
for (const [typeParam, symbol, narrowReference] of narrowableTypeParameters) {
|
|
88138
|
+
resetNodeId(narrowReference);
|
|
88139
|
+
let baseReference = narrowReference;
|
|
88140
|
+
while (isAccessExpression(baseReference)) {
|
|
88141
|
+
baseReference = baseReference.expression;
|
|
88142
|
+
}
|
|
88143
|
+
getNodeLinks(baseReference).resolvedSymbol = symbol;
|
|
88144
|
+
setParent(narrowReference, narrowPosition.parent);
|
|
88145
|
+
narrowReference.flowNode = narrowFlowNode;
|
|
88146
|
+
const initialType = getNarrowableTypeForReference(
|
|
88147
|
+
typeParam,
|
|
88148
|
+
narrowReference,
|
|
88149
|
+
/*checkMode*/
|
|
88150
|
+
void 0,
|
|
88151
|
+
/*forReturnTypeNarrowing*/
|
|
88152
|
+
true
|
|
88153
|
+
);
|
|
88154
|
+
if (initialType === typeParam) {
|
|
88155
|
+
continue;
|
|
88156
|
+
}
|
|
88157
|
+
const flowType = getFlowTypeOfReference(narrowReference, initialType);
|
|
88158
|
+
const exprType2 = getTypeFromFlowType(flowType);
|
|
88159
|
+
if (exprType2.flags & 3 /* AnyOrUnknown */ || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
|
|
88160
|
+
continue;
|
|
88161
|
+
}
|
|
88162
|
+
const narrowedType = getSubstitutionType(
|
|
88163
|
+
typeParam,
|
|
88164
|
+
exprType2,
|
|
88165
|
+
/*isNarrowed*/
|
|
88166
|
+
true
|
|
88167
|
+
);
|
|
88168
|
+
narrowedTypeParameters.push(typeParam);
|
|
88169
|
+
narrowedTypes.push(narrowedType);
|
|
88170
|
+
}
|
|
88171
|
+
const narrowMapper = createTypeMapper(narrowedTypeParameters, narrowedTypes);
|
|
88172
|
+
const narrowedReturnType = instantiateType(
|
|
88173
|
+
unwrappedReturnType,
|
|
88174
|
+
narrowMapper
|
|
88175
|
+
);
|
|
88176
|
+
if (expr) {
|
|
88177
|
+
const links = getNodeLinks(expr);
|
|
88178
|
+
if (!links.contextualReturnType) {
|
|
88179
|
+
links.contextualReturnType = narrowedReturnType;
|
|
88180
|
+
}
|
|
88181
|
+
}
|
|
88182
|
+
const narrowedExprType = expr ? checkExpression(expr) : undefinedType;
|
|
88183
|
+
const narrowedUnwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
88184
|
+
narrowedExprType,
|
|
88185
|
+
/*withAlias*/
|
|
88186
|
+
false,
|
|
88187
|
+
node,
|
|
88188
|
+
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
88189
|
+
) : narrowedExprType;
|
|
88190
|
+
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, effectiveExpr);
|
|
88191
|
+
}
|
|
88192
|
+
function resetNodeId(node) {
|
|
88193
|
+
node.id = void 0;
|
|
88194
|
+
forEachChildRecursively(node, resetNodeId);
|
|
88195
|
+
}
|
|
88196
|
+
function getNarrowableTypeParameters(candidates) {
|
|
88197
|
+
const narrowableParams = [];
|
|
88198
|
+
for (const typeParam of candidates) {
|
|
88199
|
+
const constraint = getConstraintOfTypeParameter(typeParam);
|
|
88200
|
+
if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
|
|
88201
|
+
if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
|
|
88202
|
+
const declaration = typeParam.symbol.declarations[0];
|
|
88203
|
+
const container = isJSDocTemplateTag(declaration.parent) ? getJSDocHost(declaration.parent) : declaration.parent;
|
|
88204
|
+
if (!isFunctionLike(container)) continue;
|
|
88205
|
+
let paramReference;
|
|
88206
|
+
let referencePath;
|
|
88207
|
+
let hasInvalidReference = false;
|
|
88208
|
+
for (const paramDecl of container.parameters) {
|
|
88209
|
+
const typeNode = getEffectiveTypeAnnotationNode(paramDecl);
|
|
88210
|
+
if (!typeNode) continue;
|
|
88211
|
+
const result = getValidTypeParameterReference(typeNode, typeParam, []);
|
|
88212
|
+
if (!result) {
|
|
88213
|
+
hasInvalidReference = true;
|
|
88214
|
+
break;
|
|
88215
|
+
}
|
|
88216
|
+
if (isArray(result)) {
|
|
88217
|
+
if (referencePath) {
|
|
88218
|
+
hasInvalidReference = true;
|
|
88219
|
+
break;
|
|
88220
|
+
}
|
|
88221
|
+
referencePath = result;
|
|
88222
|
+
paramReference = paramDecl;
|
|
88223
|
+
}
|
|
88224
|
+
}
|
|
88225
|
+
if (!hasInvalidReference && referencePath && validateOptionality(paramReference, constraint, referencePath)) {
|
|
88226
|
+
const symbolAndReference = constructNarrowableReference(paramReference, referencePath);
|
|
88227
|
+
if (symbolAndReference) {
|
|
88228
|
+
if (symbolAndReference[0] && symbolAndReference[0] !== unknownSymbol) {
|
|
88229
|
+
narrowableParams.push([typeParam, symbolAndReference[0], symbolAndReference[1]]);
|
|
88230
|
+
}
|
|
88231
|
+
}
|
|
88232
|
+
}
|
|
88233
|
+
}
|
|
88234
|
+
}
|
|
88235
|
+
return narrowableParams;
|
|
88236
|
+
function isReferenceToTypeParameter(typeParam, node) {
|
|
88237
|
+
return getTypeFromTypeReference(node) === typeParam;
|
|
88238
|
+
}
|
|
88239
|
+
function isTypeParameterReferenced(typeParam, node) {
|
|
88240
|
+
return isReferenced(node);
|
|
88241
|
+
function isReferenced(node2) {
|
|
88242
|
+
if (isTypeReferenceNode(node2)) {
|
|
88243
|
+
return isReferenceToTypeParameter(typeParam, node2) || some(node2.typeArguments, isReferenced);
|
|
88244
|
+
}
|
|
88245
|
+
if (isTypeQueryNode(node2)) {
|
|
88246
|
+
return isTypeParameterPossiblyReferenced(typeParam, node2);
|
|
88247
|
+
}
|
|
88248
|
+
return !!forEachChild(node2, isReferenced);
|
|
88249
|
+
}
|
|
88250
|
+
}
|
|
88251
|
+
function getValidTypeParameterReference(typeNode, typeParam, path) {
|
|
88252
|
+
var _a;
|
|
88253
|
+
switch (typeNode.kind) {
|
|
88254
|
+
case 183 /* TypeReference */:
|
|
88255
|
+
const type = getTypeFromTypeReference(typeNode);
|
|
88256
|
+
if (type === typeParam) {
|
|
88257
|
+
return path;
|
|
88258
|
+
}
|
|
88259
|
+
const typeArgs = typeNode.typeArguments;
|
|
88260
|
+
const typeArgsReferencingT = typeArgs == null ? void 0 : typeArgs.filter((node) => isTypeParameterReferenced(typeParam, node));
|
|
88261
|
+
if (!typeArgsReferencingT || typeArgsReferencingT.length === 0) return true;
|
|
88262
|
+
if (typeArgsReferencingT && typeArgsReferencingT.length > 1) return false;
|
|
88263
|
+
const typeArg = typeArgsReferencingT[0];
|
|
88264
|
+
if (!(typeArg.kind & 183 /* TypeReference */)) return false;
|
|
88265
|
+
if (!type.symbol || !type.symbol.declarations || type.symbol.declarations.length !== 1) return false;
|
|
88266
|
+
const typeDeclaration = type.symbol.declarations[0];
|
|
88267
|
+
let aliasDeclaration;
|
|
88268
|
+
if (isTypeLiteralNode(typeDeclaration)) {
|
|
88269
|
+
aliasDeclaration = walkUpParenthesizedTypes(typeDeclaration.parent);
|
|
88270
|
+
if (!isTypeAliasDeclaration(aliasDeclaration)) return false;
|
|
88271
|
+
} else if (isInterfaceDeclaration(typeDeclaration)) {
|
|
88272
|
+
aliasDeclaration = typeDeclaration;
|
|
88273
|
+
} else {
|
|
88274
|
+
return false;
|
|
88275
|
+
}
|
|
88276
|
+
const typeArgIndex = typeArgs.findIndex((arg) => arg === typeArg);
|
|
88277
|
+
const matchingTypeParamDecl = (_a = aliasDeclaration.typeParameters) == null ? void 0 : _a[typeArgIndex];
|
|
88278
|
+
if (!matchingTypeParamDecl) return false;
|
|
88279
|
+
const matchingTypeParam = getDeclaredTypeOfTypeParameter(matchingTypeParamDecl.symbol);
|
|
88280
|
+
return getValidTypeParameterReference(typeDeclaration, matchingTypeParam, path);
|
|
88281
|
+
case 264 /* InterfaceDeclaration */:
|
|
88282
|
+
const extendsTypes = flatMap(typeNode.heritageClauses, (clause) => clause.types);
|
|
88283
|
+
const relevantExtendsTypes = extendsTypes.filter((node) => isTypeParameterReferenced(typeParam, node));
|
|
88284
|
+
if (relevantExtendsTypes && relevantExtendsTypes.length > 1) {
|
|
88285
|
+
return false;
|
|
88286
|
+
}
|
|
88287
|
+
const result = getValidTypeParameterReferenceFromTypeElements(typeNode.members, typeParam, path);
|
|
88288
|
+
if (relevantExtendsTypes && relevantExtendsTypes.length === 1) {
|
|
88289
|
+
if (result !== true) {
|
|
88290
|
+
return false;
|
|
88291
|
+
}
|
|
88292
|
+
return getValidTypeParameterReference(relevantExtendsTypes[0], typeParam, path);
|
|
88293
|
+
}
|
|
88294
|
+
return result;
|
|
88295
|
+
case 187 /* TypeLiteral */:
|
|
88296
|
+
return getValidTypeParameterReferenceFromTypeElements(typeNode.members, typeParam, path);
|
|
88297
|
+
case 193 /* IntersectionType */:
|
|
88298
|
+
let validPath;
|
|
88299
|
+
for (const type2 of typeNode.types) {
|
|
88300
|
+
const result2 = getValidTypeParameterReference(type2, typeParam, path);
|
|
88301
|
+
if (!result2) {
|
|
88302
|
+
return false;
|
|
88303
|
+
}
|
|
88304
|
+
if (isArray(result2)) {
|
|
88305
|
+
if (validPath) {
|
|
88306
|
+
return false;
|
|
88307
|
+
}
|
|
88308
|
+
validPath = result2;
|
|
88309
|
+
}
|
|
88310
|
+
}
|
|
88311
|
+
return validPath ?? true;
|
|
88312
|
+
default:
|
|
88313
|
+
return !isTypeParameterReferenced(typeParam, typeNode);
|
|
88314
|
+
}
|
|
88315
|
+
}
|
|
88316
|
+
function getValidTypeParameterReferenceFromTypeElements(members, typeParam, path) {
|
|
88317
|
+
let validPath;
|
|
88318
|
+
for (const member of members) {
|
|
88319
|
+
if (!isTypeParameterReferenced(typeParam, member)) {
|
|
88320
|
+
continue;
|
|
88321
|
+
}
|
|
88322
|
+
if (!isPropertySignature(member)) {
|
|
88323
|
+
return false;
|
|
88324
|
+
}
|
|
88325
|
+
if (!isIdentifier(member.name) && !isStringLiteral(member.name)) {
|
|
88326
|
+
return false;
|
|
88327
|
+
}
|
|
88328
|
+
const result = getValidTypeParameterReference(member.type, typeParam, [...path, member]);
|
|
88329
|
+
if (!result) {
|
|
88330
|
+
return false;
|
|
88331
|
+
}
|
|
88332
|
+
if (isArray(result)) {
|
|
88333
|
+
if (validPath) {
|
|
88334
|
+
return false;
|
|
88335
|
+
}
|
|
88336
|
+
validPath = result;
|
|
88337
|
+
}
|
|
88338
|
+
}
|
|
88339
|
+
return validPath ?? true;
|
|
88340
|
+
}
|
|
88341
|
+
function validateOptionality(paramDecl, constraint, path) {
|
|
88342
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
88343
|
+
if (path[i].questionToken) {
|
|
88344
|
+
return false;
|
|
88345
|
+
}
|
|
88346
|
+
}
|
|
88347
|
+
const paramIsOptional = !!paramDecl.questionToken || isJSDocOptionalParameter(paramDecl);
|
|
88348
|
+
if (paramIsOptional && path.length > 0) {
|
|
88349
|
+
return false;
|
|
88350
|
+
}
|
|
88351
|
+
const isOptional = paramIsOptional || path.length > 0 && path[path.length - 1].questionToken;
|
|
88352
|
+
if (isOptional && strictNullChecks && !containsUndefinedType(constraint)) {
|
|
88353
|
+
return false;
|
|
88354
|
+
}
|
|
88355
|
+
return true;
|
|
88356
|
+
}
|
|
88357
|
+
function constructNarrowableReference(paramDecl, path) {
|
|
88358
|
+
let currentName = paramDecl.name;
|
|
88359
|
+
let i = 0;
|
|
88360
|
+
for (; i < path.length; i++) {
|
|
88361
|
+
if (isIdentifier(currentName)) {
|
|
88362
|
+
break;
|
|
88363
|
+
} else if (isObjectBindingPattern(currentName)) {
|
|
88364
|
+
const name = path[i].name;
|
|
88365
|
+
let nameText;
|
|
88366
|
+
if (isIdentifier(name)) nameText = name.escapedText;
|
|
88367
|
+
else {
|
|
88368
|
+
const rawText = getLiteralPropertyNameText(name);
|
|
88369
|
+
if (rawText) nameText = escapeLeadingUnderscores(rawText);
|
|
88370
|
+
}
|
|
88371
|
+
const element = currentName.elements.find((element2) => {
|
|
88372
|
+
const propertyName = getDestructuringPropertyName(element2);
|
|
88373
|
+
const propertyNameText = propertyName && escapeLeadingUnderscores(propertyName);
|
|
88374
|
+
return nameText && propertyNameText && nameText === propertyNameText;
|
|
88375
|
+
});
|
|
88376
|
+
if (!element) {
|
|
88377
|
+
return void 0;
|
|
88378
|
+
}
|
|
88379
|
+
currentName = element.name;
|
|
88380
|
+
} else {
|
|
88381
|
+
return void 0;
|
|
88382
|
+
}
|
|
88383
|
+
}
|
|
88384
|
+
if (!isIdentifier(currentName)) {
|
|
88385
|
+
return void 0;
|
|
88386
|
+
}
|
|
88387
|
+
let result = factory.cloneNode(currentName);
|
|
88388
|
+
const initialSymbol = getSymbolOfDeclaration(currentName.parent);
|
|
88389
|
+
for (let j = i; j < path.length; j++) {
|
|
88390
|
+
result = addName(result, path[j].name);
|
|
88391
|
+
}
|
|
88392
|
+
return [initialSymbol, result];
|
|
88393
|
+
}
|
|
88394
|
+
function addName(exp, name) {
|
|
88395
|
+
name = factory.cloneNode(name);
|
|
88396
|
+
if (isIdentifier(name)) {
|
|
88397
|
+
const accessExp = factory.createPropertyAccessExpression(exp, name);
|
|
88398
|
+
setParent(name, accessExp);
|
|
88399
|
+
setParent(exp, accessExp);
|
|
88400
|
+
return accessExp;
|
|
88401
|
+
} else {
|
|
88402
|
+
const accessExp = factory.createElementAccessExpression(exp, name);
|
|
88403
|
+
setParent(name, accessExp);
|
|
88404
|
+
setParent(exp, accessExp);
|
|
88405
|
+
return accessExp;
|
|
88406
|
+
}
|
|
88407
|
+
}
|
|
88408
|
+
}
|
|
88409
|
+
function isNarrowableReturnType(returnType) {
|
|
88410
|
+
return isConditionalType(returnType) ? isNarrowableConditionalType(
|
|
88411
|
+
returnType,
|
|
88412
|
+
/*hadNonPrimitiveExtendsType*/
|
|
88413
|
+
[]
|
|
88414
|
+
) : !!(returnType.indexType.flags & 262144 /* TypeParameter */);
|
|
88415
|
+
}
|
|
88416
|
+
function isNarrowableConditionalType(type, hadNonPrimitiveExtendsType, mapper) {
|
|
88417
|
+
const typeArguments = mapper && map(type.root.outerTypeParameters, (t) => {
|
|
88418
|
+
const mapped = getMappedType(t, mapper);
|
|
88419
|
+
if (isNarrowingSubstitutionType(mapped)) {
|
|
88420
|
+
return mapped.baseType;
|
|
88421
|
+
}
|
|
88422
|
+
return mapped;
|
|
88423
|
+
});
|
|
88424
|
+
const id = `${type.id}:${getTypeListId(typeArguments)}:${getTypeListId(hadNonPrimitiveExtendsType)}`;
|
|
88425
|
+
let result = narrowableReturnTypeCache.get(id);
|
|
88426
|
+
if (result === void 0) {
|
|
88427
|
+
const nonNarrowingMapper = type.root.outerTypeParameters && typeArguments && createTypeMapper(type.root.outerTypeParameters, typeArguments);
|
|
88428
|
+
const instantiatedType = instantiateType(type, nonNarrowingMapper);
|
|
88429
|
+
result = isConditionalType(instantiatedType) && isNarrowableConditionalTypeWorker(instantiatedType, hadNonPrimitiveExtendsType);
|
|
88430
|
+
narrowableReturnTypeCache.set(id, result);
|
|
88431
|
+
}
|
|
88432
|
+
return result;
|
|
88433
|
+
}
|
|
88434
|
+
function isNarrowableConditionalTypeWorker(type, hadNonPrimitiveExtendsType) {
|
|
88435
|
+
if (!type.root.isDistributive) {
|
|
88436
|
+
return false;
|
|
88437
|
+
}
|
|
88438
|
+
if (type.root.inferTypeParameters) {
|
|
88439
|
+
return false;
|
|
88440
|
+
}
|
|
88441
|
+
if (!(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
88442
|
+
return false;
|
|
88443
|
+
}
|
|
88444
|
+
const constraintType = getConstraintOfTypeParameter(type.checkType);
|
|
88445
|
+
if (!constraintType || !(constraintType.flags & 1048576 /* Union */)) {
|
|
88446
|
+
return false;
|
|
88447
|
+
}
|
|
88448
|
+
if (!everyType(type.extendsType, (extendsType) => some(
|
|
88449
|
+
constraintType.types,
|
|
88450
|
+
(constraintType2) => isTypeAssignableTo(constraintType2, extendsType)
|
|
88451
|
+
))) {
|
|
88452
|
+
return false;
|
|
88453
|
+
}
|
|
88454
|
+
const hasNonPrimitive = someType(type.extendsType, (type2) => (type2.flags & 402784252 /* Primitive */) === 0);
|
|
88455
|
+
if (hasNonPrimitive && hadNonPrimitiveExtendsType.includes(type.checkType)) {
|
|
88456
|
+
return false;
|
|
88457
|
+
}
|
|
88458
|
+
if (hasNonPrimitive) {
|
|
88459
|
+
hadNonPrimitiveExtendsType = hadNonPrimitiveExtendsType.slice();
|
|
88460
|
+
hadNonPrimitiveExtendsType.push(type.checkType);
|
|
88461
|
+
}
|
|
88462
|
+
const trueType2 = getTrueTypeFromConditionalType(type);
|
|
88463
|
+
const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2, hadNonPrimitiveExtendsType) : true;
|
|
88464
|
+
if (!isValidTrueType) return false;
|
|
88465
|
+
const falseType2 = getFalseTypeFromConditionalType(type);
|
|
88466
|
+
const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2, hadNonPrimitiveExtendsType) : falseType2 === neverType;
|
|
88467
|
+
return isValidFalseType;
|
|
88468
|
+
}
|
|
88469
|
+
function isConditionalType(type) {
|
|
88470
|
+
return !!(type.flags & 16777216 /* Conditional */);
|
|
88028
88471
|
}
|
|
88029
88472
|
function checkWithStatement(node) {
|
|
88030
88473
|
if (!checkGrammarStatementInAmbientContext(node)) {
|
|
@@ -88148,7 +88591,7 @@ function createTypeChecker(host) {
|
|
|
88148
88591
|
if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) {
|
|
88149
88592
|
checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(
|
|
88150
88593
|
prop,
|
|
88151
|
-
|
|
88594
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
88152
88595
|
/*includeNonPublic*/
|
|
88153
88596
|
true
|
|
88154
88597
|
), getNonMissingTypeOfSymbol(prop));
|
|
@@ -89619,7 +90062,7 @@ function createTypeChecker(host) {
|
|
|
89619
90062
|
true
|
|
89620
90063
|
);
|
|
89621
90064
|
if (importAttributesType !== emptyObjectType) {
|
|
89622
|
-
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType,
|
|
90065
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
|
|
89623
90066
|
}
|
|
89624
90067
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
89625
90068
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
@@ -91171,7 +91614,7 @@ function createTypeChecker(host) {
|
|
|
91171
91614
|
return getStringLiteralType(name.text);
|
|
91172
91615
|
case 167 /* ComputedPropertyName */:
|
|
91173
91616
|
const nameType = checkComputedPropertyName(name);
|
|
91174
|
-
return isTypeAssignableToKind(nameType,
|
|
91617
|
+
return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType;
|
|
91175
91618
|
default:
|
|
91176
91619
|
return Debug.fail("Unsupported property name.");
|
|
91177
91620
|
}
|
|
@@ -91692,19 +92135,19 @@ function createTypeChecker(host) {
|
|
|
91692
92135
|
return isTypeOnly ? 11 /* ObjectType */ : 0 /* Unknown */;
|
|
91693
92136
|
} else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
91694
92137
|
return 11 /* ObjectType */;
|
|
91695
|
-
} else if (isTypeAssignableToKind(type,
|
|
92138
|
+
} else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) {
|
|
91696
92139
|
return 2 /* VoidNullableOrNeverType */;
|
|
91697
|
-
} else if (isTypeAssignableToKind(type,
|
|
92140
|
+
} else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) {
|
|
91698
92141
|
return 6 /* BooleanType */;
|
|
91699
|
-
} else if (isTypeAssignableToKind(type,
|
|
92142
|
+
} else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) {
|
|
91700
92143
|
return 3 /* NumberLikeType */;
|
|
91701
|
-
} else if (isTypeAssignableToKind(type,
|
|
92144
|
+
} else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) {
|
|
91702
92145
|
return 4 /* BigIntLikeType */;
|
|
91703
|
-
} else if (isTypeAssignableToKind(type,
|
|
92146
|
+
} else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) {
|
|
91704
92147
|
return 5 /* StringLikeType */;
|
|
91705
92148
|
} else if (isTupleType(type)) {
|
|
91706
92149
|
return 7 /* ArrayLikeType */;
|
|
91707
|
-
} else if (isTypeAssignableToKind(type,
|
|
92150
|
+
} else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) {
|
|
91708
92151
|
return 8 /* ESSymbolType */;
|
|
91709
92152
|
} else if (isFunctionType(type)) {
|
|
91710
92153
|
return 10 /* TypeWithCallSignature */;
|
|
@@ -91847,7 +92290,7 @@ function createTypeChecker(host) {
|
|
|
91847
92290
|
return false;
|
|
91848
92291
|
}
|
|
91849
92292
|
function literalTypeToNode(type, enclosing, tracker) {
|
|
91850
|
-
const enumResult = type.flags &
|
|
92293
|
+
const enumResult = type.flags & 1056 /* EnumLike */ ? nodeBuilder.symbolToExpression(
|
|
91851
92294
|
type.symbol,
|
|
91852
92295
|
111551 /* Value */,
|
|
91853
92296
|
enclosing,
|
|
@@ -92866,7 +93309,7 @@ function createTypeChecker(host) {
|
|
|
92866
93309
|
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
|
|
92867
93310
|
}
|
|
92868
93311
|
const type = getTypeFromTypeNode(parameter.type);
|
|
92869
|
-
if (someType(type, (t) => !!(t.flags &
|
|
93312
|
+
if (someType(type, (t) => !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */)) || isGenericType(type)) {
|
|
92870
93313
|
return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead);
|
|
92871
93314
|
}
|
|
92872
93315
|
if (!everyType(type, isValidIndexKeyType)) {
|
|
@@ -93397,7 +93840,7 @@ function createTypeChecker(host) {
|
|
|
93397
93840
|
}
|
|
93398
93841
|
function isSimpleLiteralEnumReference(expr) {
|
|
93399
93842
|
if ((isPropertyAccessExpression(expr) || isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression)) && isEntityNameExpression(expr.expression)) {
|
|
93400
|
-
return !!(checkExpressionCached(expr).flags &
|
|
93843
|
+
return !!(checkExpressionCached(expr).flags & 1056 /* EnumLike */);
|
|
93401
93844
|
}
|
|
93402
93845
|
}
|
|
93403
93846
|
function checkAmbientInitializer(node) {
|
|
@@ -93887,319 +94330,6 @@ function createTypeChecker(host) {
|
|
|
93887
94330
|
Debug.assert(specifier && nodeIsSynthesized(specifier) && specifier.text === "tslib", `Expected sourceFile.imports[0] to be the synthesized tslib import`);
|
|
93888
94331
|
return specifier;
|
|
93889
94332
|
}
|
|
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
|
-
}
|
|
94203
94333
|
}
|
|
94204
94334
|
function isNotAccessor(declaration) {
|
|
94205
94335
|
return !isAccessor(declaration);
|
|
@@ -137498,12 +137628,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
137498
137628
|
return withNewScope(context, node, () => serializeTypeAnnotationOfDeclaration(accessorType, context, node, symbol) ?? inferTypeOfDeclaration(node, symbol, context));
|
|
137499
137629
|
}
|
|
137500
137630
|
if (accessorDeclarations.getAccessor) {
|
|
137501
|
-
return withNewScope(context, accessorDeclarations.getAccessor, () => createReturnFromSignature(
|
|
137502
|
-
accessorDeclarations.getAccessor,
|
|
137503
|
-
/*symbol*/
|
|
137504
|
-
void 0,
|
|
137505
|
-
context
|
|
137506
|
-
));
|
|
137631
|
+
return withNewScope(context, accessorDeclarations.getAccessor, () => createReturnFromSignature(accessorDeclarations.getAccessor, symbol, context));
|
|
137507
137632
|
}
|
|
137508
137633
|
return void 0;
|
|
137509
137634
|
}
|
|
@@ -137613,14 +137738,14 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
137613
137738
|
}
|
|
137614
137739
|
return resolver.serializeTypeOfExpression(context, node) ?? factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
137615
137740
|
}
|
|
137616
|
-
function inferReturnTypeOfSignatureSignature(node, context, reportFallback) {
|
|
137741
|
+
function inferReturnTypeOfSignatureSignature(node, context, symbol, reportFallback) {
|
|
137617
137742
|
if (reportFallback) {
|
|
137618
137743
|
context.tracker.reportInferenceFallback(node);
|
|
137619
137744
|
}
|
|
137620
137745
|
if (context.noInferenceFallback === true) {
|
|
137621
137746
|
return factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
137622
137747
|
}
|
|
137623
|
-
return resolver.serializeReturnTypeForSignature(context, node) ?? factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
137748
|
+
return resolver.serializeReturnTypeForSignature(context, node, symbol) ?? factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
137624
137749
|
}
|
|
137625
137750
|
function inferAccessorType(node, allAccessors, context, symbol, reportFallback = true) {
|
|
137626
137751
|
if (node.kind === 177 /* GetAccessor */) {
|
|
@@ -138055,7 +138180,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
138055
138180
|
} else if (isValueSignatureDeclaration(fn)) {
|
|
138056
138181
|
returnType = typeFromSingleReturnExpression(fn, context);
|
|
138057
138182
|
}
|
|
138058
|
-
return returnType.type !== void 0 ? returnType.type : inferReturnTypeOfSignatureSignature(fn, context, reportFallback && returnType.reportFallback && !returnTypeNode);
|
|
138183
|
+
return returnType.type !== void 0 ? returnType.type : inferReturnTypeOfSignatureSignature(fn, context, symbol, reportFallback && returnType.reportFallback && !returnTypeNode);
|
|
138059
138184
|
}
|
|
138060
138185
|
function typeFromSingleReturnExpression(declaration, context) {
|
|
138061
138186
|
let candidateExpr;
|
|
@@ -139972,7 +140097,7 @@ function isStringOrRegularExpressionOrTemplateLiteral(kind) {
|
|
|
139972
140097
|
return false;
|
|
139973
140098
|
}
|
|
139974
140099
|
function areIntersectedTypesAvoidingStringReduction(checker, t1, t2) {
|
|
139975
|
-
return !!(t1.flags &
|
|
140100
|
+
return !!(t1.flags & 4 /* String */) && checker.isEmptyAnonymousObjectType(t2);
|
|
139976
140101
|
}
|
|
139977
140102
|
function isStringAndEmptyAnonymousObjectIntersection(type) {
|
|
139978
140103
|
if (!type.isIntersection()) {
|
|
@@ -150527,7 +150652,7 @@ function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFi
|
|
|
150527
150652
|
const start = first(statements).getStart();
|
|
150528
150653
|
const end = last(statements).end;
|
|
150529
150654
|
expressionDiagnostic = createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected);
|
|
150530
|
-
} else if (checker.getTypeAtLocation(expression).flags & (
|
|
150655
|
+
} else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) {
|
|
150531
150656
|
expressionDiagnostic = createDiagnosticForNode(expression, Messages.uselessConstantType);
|
|
150532
150657
|
}
|
|
150533
150658
|
for (const scope of scopes) {
|
|
@@ -151584,13 +151709,13 @@ var TypeObject = class {
|
|
|
151584
151709
|
return !!(this.flags & 3145728 /* UnionOrIntersection */);
|
|
151585
151710
|
}
|
|
151586
151711
|
isLiteral() {
|
|
151587
|
-
return !!(this.flags & (
|
|
151712
|
+
return !!(this.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */));
|
|
151588
151713
|
}
|
|
151589
151714
|
isStringLiteral() {
|
|
151590
|
-
return !!(this.flags &
|
|
151715
|
+
return !!(this.flags & 128 /* StringLiteral */);
|
|
151591
151716
|
}
|
|
151592
151717
|
isNumberLiteral() {
|
|
151593
|
-
return !!(this.flags &
|
|
151718
|
+
return !!(this.flags & 256 /* NumberLiteral */);
|
|
151594
151719
|
}
|
|
151595
151720
|
isTypeParameter() {
|
|
151596
151721
|
return !!(this.flags & 262144 /* TypeParameter */);
|
|
@@ -160320,7 +160445,7 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
|
160320
160445
|
return { kind: 0 /* TypeLikeDeclaration */, token, call, modifierFlags, parentDeclaration: declaration, declSourceFile, isJSFile };
|
|
160321
160446
|
}
|
|
160322
160447
|
const enumDeclaration = find(symbol.declarations, isEnumDeclaration);
|
|
160323
|
-
if (enumDeclaration && !(leftExpressionType.flags &
|
|
160448
|
+
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* EnumLike */) && !isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
160324
160449
|
return { kind: 1 /* Enum */, token, parentDeclaration: enumDeclaration };
|
|
160325
160450
|
}
|
|
160326
160451
|
return void 0;
|
|
@@ -160496,7 +160621,7 @@ function addMethodDeclaration(context, changes, callExpression, name, modifierFl
|
|
|
160496
160621
|
function addEnumMemberDeclaration(changes, checker, { token, parentDeclaration }) {
|
|
160497
160622
|
const hasStringInitializer = some(parentDeclaration.members, (member) => {
|
|
160498
160623
|
const type = checker.getTypeAtLocation(member);
|
|
160499
|
-
return !!(type && type.flags &
|
|
160624
|
+
return !!(type && type.flags & 402653316 /* StringLike */);
|
|
160500
160625
|
});
|
|
160501
160626
|
const sourceFile = parentDeclaration.getSourceFile();
|
|
160502
160627
|
const enumMember = factory.createEnumMember(token, hasStringInitializer ? factory.createStringLiteral(token.text) : void 0);
|
|
@@ -160584,23 +160709,23 @@ function tryGetValueFromType(context, checker, importAdder, quotePreference, typ
|
|
|
160584
160709
|
if (type.flags & 3 /* AnyOrUnknown */) {
|
|
160585
160710
|
return createUndefined();
|
|
160586
160711
|
}
|
|
160587
|
-
if (type.flags & (
|
|
160712
|
+
if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
160588
160713
|
return factory.createStringLiteral(
|
|
160589
160714
|
"",
|
|
160590
160715
|
/* isSingleQuote */
|
|
160591
160716
|
quotePreference === 0 /* Single */
|
|
160592
160717
|
);
|
|
160593
160718
|
}
|
|
160594
|
-
if (type.flags &
|
|
160719
|
+
if (type.flags & 8 /* Number */) {
|
|
160595
160720
|
return factory.createNumericLiteral(0);
|
|
160596
160721
|
}
|
|
160597
|
-
if (type.flags &
|
|
160722
|
+
if (type.flags & 64 /* BigInt */) {
|
|
160598
160723
|
return factory.createBigIntLiteral("0n");
|
|
160599
160724
|
}
|
|
160600
|
-
if (type.flags &
|
|
160725
|
+
if (type.flags & 16 /* Boolean */) {
|
|
160601
160726
|
return factory.createFalse();
|
|
160602
160727
|
}
|
|
160603
|
-
if (type.flags &
|
|
160728
|
+
if (type.flags & 1056 /* EnumLike */) {
|
|
160604
160729
|
const enumMember = type.symbol.exports ? firstOrUndefinedIterator(type.symbol.exports.values()) : type.symbol;
|
|
160605
160730
|
const symbol = type.symbol.parent && type.symbol.parent.flags & 256 /* RegularEnum */ ? type.symbol.parent : type.symbol;
|
|
160606
160731
|
const name = checker.symbolToExpression(
|
|
@@ -160613,26 +160738,26 @@ function tryGetValueFromType(context, checker, importAdder, quotePreference, typ
|
|
|
160613
160738
|
);
|
|
160614
160739
|
return enumMember === void 0 || name === void 0 ? factory.createNumericLiteral(0) : factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember));
|
|
160615
160740
|
}
|
|
160616
|
-
if (type.flags &
|
|
160741
|
+
if (type.flags & 256 /* NumberLiteral */) {
|
|
160617
160742
|
return factory.createNumericLiteral(type.value);
|
|
160618
160743
|
}
|
|
160619
|
-
if (type.flags &
|
|
160744
|
+
if (type.flags & 2048 /* BigIntLiteral */) {
|
|
160620
160745
|
return factory.createBigIntLiteral(type.value);
|
|
160621
160746
|
}
|
|
160622
|
-
if (type.flags &
|
|
160747
|
+
if (type.flags & 128 /* StringLiteral */) {
|
|
160623
160748
|
return factory.createStringLiteral(
|
|
160624
160749
|
type.value,
|
|
160625
160750
|
/* isSingleQuote */
|
|
160626
160751
|
quotePreference === 0 /* Single */
|
|
160627
160752
|
);
|
|
160628
160753
|
}
|
|
160629
|
-
if (type.flags &
|
|
160754
|
+
if (type.flags & 512 /* BooleanLiteral */) {
|
|
160630
160755
|
return type === checker.getFalseType() || type === checker.getFalseType(
|
|
160631
160756
|
/*fresh*/
|
|
160632
160757
|
true
|
|
160633
160758
|
) ? factory.createFalse() : factory.createTrue();
|
|
160634
160759
|
}
|
|
160635
|
-
if (type.flags &
|
|
160760
|
+
if (type.flags & 65536 /* Null */) {
|
|
160636
160761
|
return factory.createNull();
|
|
160637
160762
|
}
|
|
160638
160763
|
if (type.flags & 1048576 /* Union */) {
|
|
@@ -162078,7 +162203,7 @@ registerCodeFix({
|
|
|
162078
162203
|
const info = getInfo15(err.file, err.start, checker);
|
|
162079
162204
|
if (!info) return;
|
|
162080
162205
|
const { typeNode, type } = info;
|
|
162081
|
-
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId56 === fixIdNullable ? checker.getNullableType(type,
|
|
162206
|
+
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId56 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
162082
162207
|
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
162083
162208
|
});
|
|
162084
162209
|
}
|
|
@@ -162367,7 +162492,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
162367
162492
|
}
|
|
162368
162493
|
const variableDeclaration = findAncestor(targetNode, isVariableDeclaration);
|
|
162369
162494
|
const type = variableDeclaration && typeChecker.getTypeAtLocation(variableDeclaration);
|
|
162370
|
-
if (type && type.flags &
|
|
162495
|
+
if (type && type.flags & 8192 /* UniqueESSymbol */) {
|
|
162371
162496
|
return void 0;
|
|
162372
162497
|
}
|
|
162373
162498
|
if (!(isExpressionTarget || isShorthandPropertyAssignmentTarget)) return void 0;
|
|
@@ -162848,7 +162973,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
162848
162973
|
mutatedTarget: false
|
|
162849
162974
|
};
|
|
162850
162975
|
function getFlags(type2) {
|
|
162851
|
-
return (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type2.flags &
|
|
162976
|
+
return (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type2.flags & 8192 /* UniqueESSymbol */ ? 1048576 /* AllowUniqueESSymbolType */ : 0 /* None */;
|
|
162852
162977
|
}
|
|
162853
162978
|
}
|
|
162854
162979
|
function createTypeOfFromEntityNameExpression(node) {
|
|
@@ -163822,7 +163947,7 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163822
163947
|
case 32 /* GreaterThanToken */:
|
|
163823
163948
|
case 34 /* GreaterThanEqualsToken */:
|
|
163824
163949
|
const operandType = checker.getTypeAtLocation(parent2.left === node ? parent2.right : parent2.left);
|
|
163825
|
-
if (operandType.flags &
|
|
163950
|
+
if (operandType.flags & 1056 /* EnumLike */) {
|
|
163826
163951
|
addCandidateType(usage, operandType);
|
|
163827
163952
|
} else {
|
|
163828
163953
|
usage.isNumber = true;
|
|
@@ -163831,11 +163956,11 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163831
163956
|
case 65 /* PlusEqualsToken */:
|
|
163832
163957
|
case 40 /* PlusToken */:
|
|
163833
163958
|
const otherOperandType = checker.getTypeAtLocation(parent2.left === node ? parent2.right : parent2.left);
|
|
163834
|
-
if (otherOperandType.flags &
|
|
163959
|
+
if (otherOperandType.flags & 1056 /* EnumLike */) {
|
|
163835
163960
|
addCandidateType(usage, otherOperandType);
|
|
163836
|
-
} else if (otherOperandType.flags &
|
|
163961
|
+
} else if (otherOperandType.flags & 296 /* NumberLike */) {
|
|
163837
163962
|
usage.isNumber = true;
|
|
163838
|
-
} else if (otherOperandType.flags &
|
|
163963
|
+
} else if (otherOperandType.flags & 402653316 /* StringLike */) {
|
|
163839
163964
|
usage.isString = true;
|
|
163840
163965
|
} else if (otherOperandType.flags & 1 /* Any */) {
|
|
163841
163966
|
} else {
|
|
@@ -163912,7 +164037,7 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163912
164037
|
const indexType = checker.getTypeAtLocation(parent2.argumentExpression);
|
|
163913
164038
|
const indexUsage = createEmptyUsage();
|
|
163914
164039
|
calculateUsageOfNode(parent2, indexUsage);
|
|
163915
|
-
if (indexType.flags &
|
|
164040
|
+
if (indexType.flags & 296 /* NumberLike */) {
|
|
163916
164041
|
usage.numberIndex = indexUsage;
|
|
163917
164042
|
} else {
|
|
163918
164043
|
usage.stringIndex = indexUsage;
|
|
@@ -163950,11 +164075,11 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
163950
164075
|
low: (t) => t === stringNumber
|
|
163951
164076
|
},
|
|
163952
164077
|
{
|
|
163953
|
-
high: (t) => !(t.flags & (1 /* Any */ |
|
|
163954
|
-
low: (t) => !!(t.flags & (1 /* Any */ |
|
|
164078
|
+
high: (t) => !(t.flags & (1 /* Any */ | 16384 /* Void */)),
|
|
164079
|
+
low: (t) => !!(t.flags & (1 /* Any */ | 16384 /* Void */))
|
|
163955
164080
|
},
|
|
163956
164081
|
{
|
|
163957
|
-
high: (t) => !(t.flags & (
|
|
164082
|
+
high: (t) => !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(getObjectFlags(t) & 16 /* Anonymous */),
|
|
163958
164083
|
low: (t) => !!(getObjectFlags(t) & 16 /* Anonymous */)
|
|
163959
164084
|
}
|
|
163960
164085
|
];
|
|
@@ -165467,7 +165592,7 @@ function getInitializer(checker, propertyDeclaration) {
|
|
|
165467
165592
|
return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type));
|
|
165468
165593
|
}
|
|
165469
165594
|
function getDefaultValueFromType(checker, type) {
|
|
165470
|
-
if (type.flags &
|
|
165595
|
+
if (type.flags & 512 /* BooleanLiteral */) {
|
|
165471
165596
|
return type === checker.getFalseType() || type === checker.getFalseType(
|
|
165472
165597
|
/*fresh*/
|
|
165473
165598
|
true
|
|
@@ -165476,7 +165601,7 @@ function getDefaultValueFromType(checker, type) {
|
|
|
165476
165601
|
return factory.createStringLiteral(type.value);
|
|
165477
165602
|
} else if (type.isNumberLiteral()) {
|
|
165478
165603
|
return factory.createNumericLiteral(type.value);
|
|
165479
|
-
} else if (type.flags &
|
|
165604
|
+
} else if (type.flags & 2048 /* BigIntLiteral */) {
|
|
165480
165605
|
return factory.createBigIntLiteral(type.value);
|
|
165481
165606
|
} else if (type.isUnion()) {
|
|
165482
165607
|
return firstDefined(type.types, (t) => getDefaultValueFromType(checker, t));
|
|
@@ -166641,7 +166766,7 @@ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, i
|
|
|
166641
166766
|
} else {
|
|
166642
166767
|
if (initializer) {
|
|
166643
166768
|
const inferredType = checker.getTypeAtLocation(initializer.parent);
|
|
166644
|
-
if (!(inferredType.flags & (1 /* Any */ |
|
|
166769
|
+
if (!(inferredType.flags & (1 /* Any */ | 16384 /* Void */))) {
|
|
166645
166770
|
const sourceFile = initializer.getSourceFile();
|
|
166646
166771
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
166647
166772
|
const builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */;
|
|
@@ -166873,7 +166998,7 @@ function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options,
|
|
|
166873
166998
|
const importAdder = ts_codefix_exports.createImportAdder(sourceFile, program, preferences, host);
|
|
166874
166999
|
const elements = [];
|
|
166875
167000
|
for (const type of switchType.types) {
|
|
166876
|
-
if (type.flags &
|
|
167001
|
+
if (type.flags & 1024 /* EnumLiteral */) {
|
|
166877
167002
|
Debug.assert(type.symbol, "An enum member type should have a symbol");
|
|
166878
167003
|
Debug.assert(type.symbol.parent, "An enum member type should have a parent symbol (the enum symbol)");
|
|
166879
167004
|
const enumValue = type.symbol.valueDeclaration && checker.getConstantValue(type.symbol.valueDeclaration);
|
|
@@ -167167,8 +167292,8 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
|
|
|
167167
167292
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none" && !(isJsxAttribute(location.parent) && location.parent.initializer)) {
|
|
167168
167293
|
let useBraces2 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
167169
167294
|
const type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
167170
|
-
if (preferences.jsxAttributeCompletionStyle === "auto" && !(type.flags &
|
|
167171
|
-
if (type.flags &
|
|
167295
|
+
if (preferences.jsxAttributeCompletionStyle === "auto" && !(type.flags & 528 /* BooleanLike */) && !(type.flags & 1048576 /* Union */ && find(type.types, (type2) => !!(type2.flags & 528 /* BooleanLike */)))) {
|
|
167296
|
+
if (type.flags & 402653316 /* StringLike */ || type.flags & 1048576 /* Union */ && every(type.types, (type2) => !!(type2.flags & (402653316 /* StringLike */ | 32768 /* Undefined */) || isStringAndEmptyAnonymousObjectIntersection(type2)))) {
|
|
167172
167297
|
insertText = `${escapeSnippetText(name)}=${quote(sourceFile, preferences, "$1")}`;
|
|
167173
167298
|
isSnippet = true;
|
|
167174
167299
|
} else {
|
|
@@ -168425,7 +168550,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
168425
168550
|
const isLiteralExpected = !tryCast(previousToken, isStringLiteralLike) && !isJsxIdentifierExpected;
|
|
168426
168551
|
const literals = !isLiteralExpected ? [] : mapDefined(
|
|
168427
168552
|
contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]),
|
|
168428
|
-
(t) => t.isLiteral() && !(t.flags &
|
|
168553
|
+
(t) => t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : void 0
|
|
168429
168554
|
);
|
|
168430
168555
|
const recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker);
|
|
168431
168556
|
return {
|
|
@@ -170529,7 +170654,7 @@ function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, check
|
|
|
170529
170654
|
type = propType;
|
|
170530
170655
|
}
|
|
170531
170656
|
}
|
|
170532
|
-
isNewIdentifier = isNewIdentifier || !!(type.flags &
|
|
170657
|
+
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
170533
170658
|
return getStringLiteralTypes(type, uniques);
|
|
170534
170659
|
});
|
|
170535
170660
|
return length(types) ? { kind: 2 /* Types */, types, isNewIdentifier } : void 0;
|
|
@@ -170560,7 +170685,7 @@ function stringLiteralCompletionsForObjectLiteral(checker, objectLiteralExpressi
|
|
|
170560
170685
|
function getStringLiteralTypes(type, uniques = /* @__PURE__ */ new Set()) {
|
|
170561
170686
|
if (!type) return emptyArray;
|
|
170562
170687
|
type = skipConstraint(type);
|
|
170563
|
-
return type.isUnion() ? flatMap(type.types, (t) => getStringLiteralTypes(t, uniques)) : type.isStringLiteral() && !(type.flags &
|
|
170688
|
+
return type.isUnion() ? flatMap(type.types, (t) => getStringLiteralTypes(t, uniques)) : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && addToSeen(uniques, type.value) ? [type] : emptyArray;
|
|
170564
170689
|
}
|
|
170565
170690
|
function nameAndKind(name, kind, extension) {
|
|
170566
170691
|
return { name, kind, extension };
|
|
@@ -174003,7 +174128,7 @@ function getTypeDefinitionAtPosition(typeChecker, sourceFile, position) {
|
|
|
174003
174128
|
return typeDefinitions.length ? [...getFirstTypeArgumentDefinitions(typeChecker, resolvedType, node, failedAliasResolution), ...typeDefinitions] : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, skipAlias(symbol, typeChecker), node, failedAliasResolution) : void 0;
|
|
174004
174129
|
}
|
|
174005
174130
|
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
174006
|
-
return flatMap(type.isUnion() && !(type.flags &
|
|
174131
|
+
return flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], (t) => t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution));
|
|
174007
174132
|
}
|
|
174008
174133
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
174009
174134
|
if (type.symbol === symbol || // At `const f = () => {}`, the symbol is `f` and the type symbol is at `() => {}`
|
|
@@ -176707,7 +176832,7 @@ function getRenameInfoForNode(node, typeChecker, sourceFile, program, preference
|
|
|
176707
176832
|
if (!symbol) {
|
|
176708
176833
|
if (isStringLiteralLike(node)) {
|
|
176709
176834
|
const type = getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker);
|
|
176710
|
-
if (type && (type.flags &
|
|
176835
|
+
if (type && (type.flags & 128 /* StringLiteral */ || type.flags & 1048576 /* Union */ && every(type.types, (type2) => !!(type2.flags & 128 /* StringLiteral */)))) {
|
|
176711
176836
|
return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile);
|
|
176712
176837
|
}
|
|
176713
176838
|
} else if (isLabelName(node)) {
|
|
@@ -182742,7 +182867,6 @@ __export(ts_exports2, {
|
|
|
182742
182867
|
commonOptionsWithBuild: () => commonOptionsWithBuild,
|
|
182743
182868
|
compact: () => compact,
|
|
182744
182869
|
compareBooleans: () => compareBooleans,
|
|
182745
|
-
compareComparableValues: () => compareComparableValues,
|
|
182746
182870
|
compareDataObjects: () => compareDataObjects,
|
|
182747
182871
|
compareDiagnostics: () => compareDiagnostics,
|
|
182748
182872
|
compareEmitHelpers: () => compareEmitHelpers,
|
|
@@ -197496,7 +197620,6 @@ if (typeof console !== "undefined") {
|
|
|
197496
197620
|
commonOptionsWithBuild,
|
|
197497
197621
|
compact,
|
|
197498
197622
|
compareBooleans,
|
|
197499
|
-
compareComparableValues,
|
|
197500
197623
|
compareDataObjects,
|
|
197501
197624
|
compareDiagnostics,
|
|
197502
197625
|
compareEmitHelpers,
|