@@ -1361,35 +1361,85 @@ type Extract<T, U> = T extends U ? T : never;
1361
1361
type NonNullable < T > = T extends null | undefined ? never : T ;
1362
1362
1363
1363
declare namespace TypeFacts {
1364
+ /**
1365
+ * Effectively replaces a `T` with a `T extends string`
1366
+ */
1367
+ export type IsString < T extends string > = T ;
1368
+
1369
+ /**
1370
+ * Effectively replaces a `T` with a `T extends number`
1371
+ */
1372
+ export type IsNumber < T extends number > = T ;
1373
+
1374
+ /**
1375
+ * Effectively replaces a `T` with a `T extends boolean`
1376
+ */
1377
+ export type IsBoolean < T extends boolean > = T ;
1378
+
1379
+ /**
1380
+ * Effectively replaces a `T` with a `T extends symbol`
1381
+ */
1382
+ export type IsSymbol < T extends symbol > = T ;
1383
+
1384
+ /**
1385
+ * Effectively replaces a `T` with a `T extends object`
1386
+ */
1387
+ export type IsObject < T extends object > = T ;
1388
+
1389
+ /**
1390
+ * Effectively replaces a `T` with a `T extends (...args: any[]) => any`
1391
+ */
1392
+ export type IsFunction < T extends ( ...args : any [ ] ) => any > = T ;
1393
+
1394
+ /**
1395
+ * Effectively replaces a `T` with a `T extends undefined | void`
1396
+ */
1397
+ export type IsUndefined < T extends undefined | void > = T ;
1398
+
1399
+ /**
1400
+ * Effectively replaces a `T` with a `T extends null`
1401
+ */
1402
+ export type IsNull < T extends null > = T ;
1403
+
1404
+ /**
1405
+ * Effectively replaces a `T` with a `T extends undefined | null | void`
1406
+ */
1407
+ export type IsUndefinedOrNull < T extends undefined | null | void > = T ;
1408
+
1409
+ /**
1410
+ * Effectively replaces a `T` with a `T extends false | null | undefined | void | 0 | ""`
1411
+ */
1412
+ export type IsFalsy < T extends false | null | undefined | void | 0 | "" > = T ;
1413
+
1364
1414
/**
1365
1415
* Include only string from T
1366
1416
*/
1367
- export type EQString < T > = T extends string ? T : never ;
1417
+ export type EQString < T > = T extends IsString < infer U > ? T & U : never ;
1368
1418
1369
1419
/**
1370
1420
* Include only number from T
1371
1421
*/
1372
- export type EQNumber < T > = T extends number ? T : never ;
1422
+ export type EQNumber < T > = T extends IsNumber < infer U > ? T & U : never ;
1373
1423
1374
1424
/**
1375
1425
* Include only boolean from T
1376
1426
*/
1377
- export type EQBoolean < T > = T extends boolean ? T : never ;
1427
+ export type EQBoolean < T > = T extends IsBoolean < infer U > ? T & U : never ;
1378
1428
1379
1429
/**
1380
1430
* Include only symbol from T
1381
1431
*/
1382
- export type EQSymbol < T > = T extends symbol ? T : never ;
1432
+ export type EQSymbol < T > = T extends IsSymbol < infer U > ? T & U : never ;
1383
1433
1384
1434
/**
1385
1435
* Include only object from T
1386
1436
*/
1387
- export type EQObject < T > = T extends object ? T : never ;
1437
+ export type EQObject < T > = T extends IsObject < infer U > ? T & U : never ;
1388
1438
1389
1439
/**
1390
1440
* Include only functions from T
1391
1441
*/
1392
- export type EQFunction < T > = T extends ( ... args : any [ ] ) => any ? T : never ;
1442
+ export type EQFunction < T > = T extends IsFunction < infer U > ? T & U : never ;
1393
1443
1394
1444
/**
1395
1445
* Exclude only string from T
@@ -1424,17 +1474,17 @@ declare namespace TypeFacts {
1424
1474
/**
1425
1475
* Include only undefined from T
1426
1476
*/
1427
- export type EQUndefined < T > = T extends undefined | void ? T : never ;
1477
+ export type EQUndefined < T > = T extends IsUndefined < infer U > ? T & U : never ;
1428
1478
1429
1479
/**
1430
1480
* Include only null from T
1431
1481
*/
1432
- export type EQNull < T > = T extends null ? T : never ;
1482
+ export type EQNull < T > = T extends IsNull < infer U > ? T & U : never ;
1433
1483
1434
1484
/**
1435
1485
* Include only null and undefined from T
1436
1486
*/
1437
- export type EQUndefinedOrNull < T > = T extends null | undefined | void ? T : never ;
1487
+ export type EQUndefinedOrNull < T > = T extends IsUndefinedOrNull < infer U > ? T & U : never ;
1438
1488
1439
1489
/**
1440
1490
* Exclude only undefined from T
@@ -1459,7 +1509,7 @@ declare namespace TypeFacts {
1459
1509
/**
1460
1510
* Include falsy from T
1461
1511
*/
1462
- export type Falsy < T > = T extends false | null | undefined | void | 0 | "" ? T : never ;
1512
+ export type Falsy < T > = T extends IsFalsy < infer U > ? T & U : never ;
1463
1513
}
1464
1514
1465
1515
/**
0 commit comments