uni-types 1.1.0 → 1.2.0
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/README.md +45 -0
- package/dist/index.d.cts +1868 -236
- package/dist/index.d.mts +1868 -236
- package/package.json +31 -1
package/dist/index.d.mts
CHANGED
|
@@ -428,367 +428,1132 @@ type DeepReadonly<T> = T extends BuiltIn ? T : T extends Map<infer K, infer V> ?
|
|
|
428
428
|
*/
|
|
429
429
|
type DeepMutable<T> = T extends BuiltIn ? T : T extends Map<infer K, infer V> ? Map<DeepMutable<K>, DeepMutable<V>> : T extends Set<infer V> ? Set<DeepMutable<V>> : T extends readonly (infer E)[] ? DeepMutable<E>[] : T extends object ? { -readonly [P in keyof T]: DeepMutable<T[P]> } : T;
|
|
430
430
|
//#endregion
|
|
431
|
-
//#region src/
|
|
431
|
+
//#region src/ecosystem/prisma.d.ts
|
|
432
432
|
/**
|
|
433
|
-
*
|
|
433
|
+
* Prisma ORM integration types
|
|
434
|
+
*
|
|
435
|
+
* These types help work with Prisma models and operations.
|
|
436
|
+
* Note: Prisma is an optional peer dependency.
|
|
434
437
|
*/
|
|
435
438
|
/**
|
|
436
|
-
*
|
|
439
|
+
* Prisma model type helper
|
|
437
440
|
*
|
|
438
441
|
* @example
|
|
439
442
|
* ```ts
|
|
440
|
-
*
|
|
441
|
-
*
|
|
443
|
+
* // Assuming you have a User model in Prisma
|
|
444
|
+
* type UserModel = PrismaModel<User>
|
|
442
445
|
* ```
|
|
443
446
|
*/
|
|
444
|
-
type
|
|
447
|
+
type PrismaModel<T> = T;
|
|
445
448
|
/**
|
|
446
|
-
*
|
|
449
|
+
* Prisma create input type
|
|
447
450
|
*
|
|
448
451
|
* @example
|
|
449
452
|
* ```ts
|
|
450
|
-
* type
|
|
451
|
-
*
|
|
453
|
+
* type CreateInput = PrismaCreateInput<User>
|
|
454
|
+
* // { name: string; email: string; age?: number }
|
|
452
455
|
* ```
|
|
453
456
|
*/
|
|
454
|
-
type
|
|
457
|
+
type PrismaCreateInput<T> = { [K in keyof T as undefined extends T[K] ? never : K]: T[K] } & { [K in keyof T as undefined extends T[K] ? K : never]?: T[K] };
|
|
455
458
|
/**
|
|
456
|
-
*
|
|
459
|
+
* Prisma update input type
|
|
457
460
|
*
|
|
458
461
|
* @example
|
|
459
462
|
* ```ts
|
|
460
|
-
* type
|
|
461
|
-
*
|
|
462
|
-
* NthParameter<Fn, 1> // number
|
|
463
|
-
* NthParameter<Fn, 2> // boolean
|
|
463
|
+
* type UpdateInput = PrismaUpdateInput<User>
|
|
464
|
+
* // { name?: string; email?: string; age?: number }
|
|
464
465
|
* ```
|
|
465
466
|
*/
|
|
466
|
-
type
|
|
467
|
+
type PrismaUpdateInput<T> = { [K in keyof T]?: T[K] | null };
|
|
467
468
|
/**
|
|
468
|
-
*
|
|
469
|
+
* Prisma where input type for unique lookup
|
|
469
470
|
*
|
|
470
471
|
* @example
|
|
471
472
|
* ```ts
|
|
472
|
-
* type
|
|
473
|
-
*
|
|
473
|
+
* type UniqueWhere = PrismaUniqueWhere<User, 'id' | 'email'>
|
|
474
|
+
* // { id: string } | { email: string }
|
|
474
475
|
* ```
|
|
475
476
|
*/
|
|
476
|
-
type
|
|
477
|
+
type PrismaUniqueWhere<T, UniqueFields extends keyof T> = { [K in UniqueFields]: { [P in K]: T[P] } }[UniqueFields];
|
|
477
478
|
/**
|
|
478
|
-
*
|
|
479
|
+
* Prisma where input type
|
|
479
480
|
*
|
|
480
481
|
* @example
|
|
481
482
|
* ```ts
|
|
482
|
-
* type
|
|
483
|
-
*
|
|
483
|
+
* type WhereInput = PrismaWhereInput<User>
|
|
484
|
+
* // { id?: string; name?: string; AND?: WhereInput[]; OR?: WhereInput[] }
|
|
484
485
|
* ```
|
|
485
486
|
*/
|
|
486
|
-
type
|
|
487
|
+
type PrismaWhereInput<T> = Partial<T> & {
|
|
488
|
+
AND?: PrismaWhereInput<T>[];
|
|
489
|
+
OR?: PrismaWhereInput<T>[];
|
|
490
|
+
NOT?: PrismaWhereInput<T>[];
|
|
491
|
+
};
|
|
487
492
|
/**
|
|
488
|
-
*
|
|
493
|
+
* Prisma order by input type
|
|
489
494
|
*
|
|
490
495
|
* @example
|
|
491
496
|
* ```ts
|
|
492
|
-
* type
|
|
493
|
-
*
|
|
497
|
+
* type OrderBy = PrismaOrderByInput<User>
|
|
498
|
+
* // { name?: 'asc' | 'desc'; createdAt?: 'asc' | 'desc' }
|
|
494
499
|
* ```
|
|
495
500
|
*/
|
|
496
|
-
type
|
|
501
|
+
type PrismaOrderByInput<T> = { [K in keyof T]?: 'asc' | 'desc' };
|
|
497
502
|
/**
|
|
498
|
-
*
|
|
503
|
+
* Prisma select type
|
|
499
504
|
*
|
|
500
505
|
* @example
|
|
501
506
|
* ```ts
|
|
502
|
-
*
|
|
503
|
-
*
|
|
507
|
+
* type Select = PrismaSelect<User, 'name' | 'email'>
|
|
508
|
+
* // { name: true; email: true }
|
|
504
509
|
* ```
|
|
505
510
|
*/
|
|
506
|
-
type
|
|
511
|
+
type PrismaSelect<T, Keys extends keyof T = keyof T> = { [K in Keys]?: true };
|
|
507
512
|
/**
|
|
508
|
-
*
|
|
513
|
+
* Prisma include type (for relations)
|
|
509
514
|
*
|
|
510
515
|
* @example
|
|
511
516
|
* ```ts
|
|
512
|
-
*
|
|
513
|
-
*
|
|
517
|
+
* type Include = PrismaInclude<User, 'posts'>
|
|
518
|
+
* // { posts: true }
|
|
514
519
|
* ```
|
|
515
520
|
*/
|
|
516
|
-
type
|
|
521
|
+
type PrismaInclude<T, Keys extends keyof T = keyof T> = { [K in Keys]?: true | {
|
|
522
|
+
select?: Partial<T>;
|
|
523
|
+
} };
|
|
517
524
|
/**
|
|
518
|
-
*
|
|
525
|
+
* Extract scalar (non-relation) fields from a Prisma model
|
|
519
526
|
*
|
|
520
527
|
* @example
|
|
521
528
|
* ```ts
|
|
522
|
-
* type
|
|
523
|
-
*
|
|
529
|
+
* type Scalars = PrismaScalarFields<User>
|
|
530
|
+
* // 'id' | 'name' | 'email' | 'createdAt'
|
|
524
531
|
* ```
|
|
525
532
|
*/
|
|
526
|
-
type
|
|
533
|
+
type PrismaScalarFields<T> = { [K in keyof T]: T[K] extends Date | string | number | boolean | bigint | Buffer ? K : T[K] extends Date | string | number | boolean | bigint | Buffer | null ? K : never }[keyof T];
|
|
527
534
|
/**
|
|
528
|
-
*
|
|
535
|
+
* Extract relation fields from a Prisma model
|
|
529
536
|
*
|
|
530
537
|
* @example
|
|
531
538
|
* ```ts
|
|
532
|
-
* type
|
|
533
|
-
*
|
|
539
|
+
* type Relations = PrismaRelationFields<User>
|
|
540
|
+
* // 'posts' | 'comments'
|
|
534
541
|
* ```
|
|
535
542
|
*/
|
|
536
|
-
type
|
|
543
|
+
type PrismaRelationFields<T> = Exclude<keyof T, PrismaScalarFields<T>>;
|
|
537
544
|
/**
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
* @example
|
|
541
|
-
* ```ts
|
|
542
|
-
* type Fn = (a: string) => void
|
|
543
|
-
* PrependParameter<Fn, number> // (a: number, b: string) => void
|
|
544
|
-
* ```
|
|
545
|
+
* Prisma pagination args
|
|
545
546
|
*/
|
|
546
|
-
|
|
547
|
+
interface PrismaPagination {
|
|
548
|
+
skip?: number;
|
|
549
|
+
take?: number;
|
|
550
|
+
cursor?: Record<string, unknown>;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Prisma find many args
|
|
554
|
+
*/
|
|
555
|
+
interface PrismaFindManyArgs<T> {
|
|
556
|
+
where?: PrismaWhereInput<T>;
|
|
557
|
+
orderBy?: PrismaOrderByInput<T> | PrismaOrderByInput<T>[];
|
|
558
|
+
skip?: number;
|
|
559
|
+
take?: number;
|
|
560
|
+
cursor?: PrismaUniqueWhere<T, keyof T>;
|
|
561
|
+
select?: Partial<Record<keyof T, true>>;
|
|
562
|
+
include?: Partial<Record<keyof T, true | object>>;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Prisma find first args
|
|
566
|
+
*/
|
|
567
|
+
interface PrismaFindFirstArgs<T> {
|
|
568
|
+
where?: PrismaWhereInput<T>;
|
|
569
|
+
orderBy?: PrismaOrderByInput<T> | PrismaOrderByInput<T>[];
|
|
570
|
+
cursor?: PrismaUniqueWhere<T, keyof T>;
|
|
571
|
+
select?: Partial<Record<keyof T, true>>;
|
|
572
|
+
include?: Partial<Record<keyof T, true | object>>;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Prisma find unique args
|
|
576
|
+
*/
|
|
577
|
+
interface PrismaFindUniqueArgs<T, UniqueFields extends keyof T> {
|
|
578
|
+
where: PrismaUniqueWhere<T, UniqueFields>;
|
|
579
|
+
select?: Partial<Record<keyof T, true>>;
|
|
580
|
+
include?: Partial<Record<keyof T, true | object>>;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Prisma create args
|
|
584
|
+
*/
|
|
585
|
+
interface PrismaCreateArgs<T> {
|
|
586
|
+
data: PrismaCreateInput<T>;
|
|
587
|
+
select?: Partial<Record<keyof T, true>>;
|
|
588
|
+
include?: Partial<Record<keyof T, true | object>>;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Prisma update args
|
|
592
|
+
*/
|
|
593
|
+
interface PrismaUpdateArgs<T, UniqueFields extends keyof T> {
|
|
594
|
+
where: PrismaUniqueWhere<T, UniqueFields>;
|
|
595
|
+
data: PrismaUpdateInput<T>;
|
|
596
|
+
select?: Partial<Record<keyof T, true>>;
|
|
597
|
+
include?: Partial<Record<keyof T, true | object>>;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Prisma delete args
|
|
601
|
+
*/
|
|
602
|
+
interface PrismaDeleteArgs<T, UniqueFields extends keyof T> {
|
|
603
|
+
where: PrismaUniqueWhere<T, UniqueFields>;
|
|
604
|
+
select?: Partial<Record<keyof T, true>>;
|
|
605
|
+
include?: Partial<Record<keyof T, true | object>>;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Prisma upsert args
|
|
609
|
+
*/
|
|
610
|
+
interface PrismaUpsertArgs<T, UniqueFields extends keyof T> {
|
|
611
|
+
where: PrismaUniqueWhere<T, UniqueFields>;
|
|
612
|
+
create: PrismaCreateInput<T>;
|
|
613
|
+
update: PrismaUpdateInput<T>;
|
|
614
|
+
select?: Partial<Record<keyof T, true>>;
|
|
615
|
+
include?: Partial<Record<keyof T, true | object>>;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Prisma count args
|
|
619
|
+
*/
|
|
620
|
+
interface PrismaCountArgs<T> {
|
|
621
|
+
where?: PrismaWhereInput<T>;
|
|
622
|
+
select?: Partial<Record<keyof T, true>>;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Prisma aggregate args
|
|
626
|
+
*/
|
|
627
|
+
interface PrismaAggregateArgs<T> {
|
|
628
|
+
where?: PrismaWhereInput<T>;
|
|
629
|
+
orderBy?: PrismaOrderByInput<T> | PrismaOrderByInput<T>[];
|
|
630
|
+
skip?: number;
|
|
631
|
+
take?: number;
|
|
632
|
+
_count?: true | {
|
|
633
|
+
_all?: true;
|
|
634
|
+
} | Partial<Record<keyof T, true>>;
|
|
635
|
+
_avg?: Partial<Record<keyof T, true>>;
|
|
636
|
+
_sum?: Partial<Record<keyof T, true>>;
|
|
637
|
+
_min?: Partial<Record<keyof T, true>>;
|
|
638
|
+
_max?: Partial<Record<keyof T, true>>;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Prisma group by args
|
|
642
|
+
*/
|
|
643
|
+
interface PrismaGroupByArgs<T> {
|
|
644
|
+
where?: PrismaWhereInput<T>;
|
|
645
|
+
orderBy?: PrismaOrderByInput<T> | PrismaOrderByInput<T>[];
|
|
646
|
+
by: (keyof T)[];
|
|
647
|
+
having?: PrismaWhereInput<T>;
|
|
648
|
+
take?: number;
|
|
649
|
+
skip?: number;
|
|
650
|
+
_count?: true | {
|
|
651
|
+
_all?: true;
|
|
652
|
+
} | Partial<Record<keyof T, true>>;
|
|
653
|
+
_avg?: Partial<Record<keyof T, true>>;
|
|
654
|
+
_sum?: Partial<Record<keyof T, true>>;
|
|
655
|
+
_min?: Partial<Record<keyof T, true>>;
|
|
656
|
+
_max?: Partial<Record<keyof T, true>>;
|
|
657
|
+
}
|
|
547
658
|
//#endregion
|
|
548
|
-
//#region src/
|
|
659
|
+
//#region src/ecosystem/react.d.ts
|
|
549
660
|
/**
|
|
550
|
-
*
|
|
661
|
+
* React component props utilities
|
|
551
662
|
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
* IsArray<string[]> // true
|
|
555
|
-
* IsArray<string> // false
|
|
556
|
-
* ```
|
|
663
|
+
* These types help work with React component props.
|
|
664
|
+
* Note: React is an optional peer dependency.
|
|
557
665
|
*/
|
|
558
|
-
type IsArray<T> = T extends readonly unknown[] ? T extends readonly [...unknown[]] ? true : false : false;
|
|
559
666
|
/**
|
|
560
|
-
*
|
|
667
|
+
* Extract props from a React component
|
|
561
668
|
*
|
|
562
669
|
* @example
|
|
563
|
-
* ```
|
|
564
|
-
*
|
|
565
|
-
*
|
|
670
|
+
* ```tsx
|
|
671
|
+
* import type { ComponentProps } from 'uni-types'
|
|
672
|
+
*
|
|
673
|
+
* type ButtonProps = ComponentProps<'button'>
|
|
674
|
+
* type InputProps = ComponentProps<'input'>
|
|
566
675
|
* ```
|
|
567
676
|
*/
|
|
568
|
-
type
|
|
677
|
+
type ComponentProps<T> = T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : T extends ReactComponentType<infer P> ? P : never;
|
|
569
678
|
/**
|
|
570
|
-
*
|
|
679
|
+
* Get props with ref included
|
|
571
680
|
*
|
|
572
681
|
* @example
|
|
573
|
-
* ```
|
|
574
|
-
*
|
|
575
|
-
* IsEqual<string, number> // false
|
|
682
|
+
* ```tsx
|
|
683
|
+
* type ButtonPropsWithRef = ComponentPropsWithRef<'button'>
|
|
576
684
|
* ```
|
|
577
685
|
*/
|
|
578
|
-
type
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
686
|
+
type ComponentPropsWithRef<T> = T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] & {
|
|
687
|
+
ref?: unknown;
|
|
688
|
+
} : T extends ReactComponentType<infer P> ? P & {
|
|
689
|
+
ref?: unknown;
|
|
690
|
+
} : never;
|
|
583
691
|
/**
|
|
584
|
-
*
|
|
692
|
+
* Add children to props
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* ```tsx
|
|
696
|
+
* type Props = PropsWithChildren<{ name: string }>
|
|
697
|
+
* // { name: string; children?: React.ReactNode }
|
|
698
|
+
* ```
|
|
585
699
|
*/
|
|
586
|
-
type
|
|
700
|
+
type PropsWithChildren<P = unknown> = P & {
|
|
701
|
+
children?: ReactNode;
|
|
702
|
+
};
|
|
587
703
|
/**
|
|
588
|
-
*
|
|
704
|
+
* Remove children from props
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* ```tsx
|
|
708
|
+
* type Props = PropsWithoutChildren<{ name: string; children: ReactNode }>
|
|
709
|
+
* // { name: string }
|
|
710
|
+
* ```
|
|
589
711
|
*/
|
|
590
|
-
type
|
|
591
|
-
//#endregion
|
|
592
|
-
//#region src/infer/index.d.ts
|
|
712
|
+
type PropsWithoutChildren<P> = Omit<P, 'children'>;
|
|
593
713
|
/**
|
|
594
|
-
*
|
|
714
|
+
* Extract the prop types from a component
|
|
595
715
|
*
|
|
596
716
|
* @example
|
|
597
|
-
* ```
|
|
598
|
-
*
|
|
599
|
-
*
|
|
717
|
+
* ```tsx
|
|
718
|
+
* const MyComponent = (props: { name: string; age: number }) => null
|
|
719
|
+
* type Props = ExtractPropTypes<typeof MyComponent>
|
|
720
|
+
* // { name: string; age: number }
|
|
600
721
|
* ```
|
|
601
722
|
*/
|
|
602
|
-
type
|
|
723
|
+
type ExtractPropTypes<T> = T extends ReactComponentType<infer P> ? P : never;
|
|
603
724
|
/**
|
|
604
|
-
* Get
|
|
725
|
+
* Get required props from a component
|
|
605
726
|
*
|
|
606
727
|
* @example
|
|
607
|
-
* ```
|
|
608
|
-
*
|
|
609
|
-
*
|
|
728
|
+
* ```tsx
|
|
729
|
+
* interface Props {
|
|
730
|
+
* name: string // required
|
|
731
|
+
* age?: number // optional
|
|
732
|
+
* onChange?: () => void
|
|
733
|
+
* }
|
|
734
|
+
*
|
|
735
|
+
* type Required = RequiredProps<Props>
|
|
736
|
+
* // 'name'
|
|
610
737
|
* ```
|
|
611
738
|
*/
|
|
612
|
-
type
|
|
739
|
+
type RequiredProps<P> = { [K in keyof P]-?: {} extends Pick<P, K> ? never : K }[keyof P];
|
|
613
740
|
/**
|
|
614
|
-
* Get
|
|
741
|
+
* Get optional props from a component
|
|
615
742
|
*
|
|
616
743
|
* @example
|
|
617
|
-
* ```
|
|
618
|
-
*
|
|
744
|
+
* ```tsx
|
|
745
|
+
* interface Props {
|
|
746
|
+
* name: string // required
|
|
747
|
+
* age?: number // optional
|
|
748
|
+
* onChange?: () => void
|
|
749
|
+
* }
|
|
750
|
+
*
|
|
751
|
+
* type Optional = OptionalProps<Props>
|
|
752
|
+
* // 'age' | 'onChange'
|
|
619
753
|
* ```
|
|
620
754
|
*/
|
|
621
|
-
type
|
|
755
|
+
type OptionalProps<P> = { [K in keyof P]-?: {} extends Pick<P, K> ? K : never }[keyof P];
|
|
622
756
|
/**
|
|
623
|
-
*
|
|
757
|
+
* Props for forward ref components
|
|
624
758
|
*
|
|
625
759
|
* @example
|
|
626
|
-
* ```
|
|
627
|
-
*
|
|
628
|
-
* name: string
|
|
629
|
-
* onClick: () => void
|
|
630
|
-
* onChange: (v: string) => void
|
|
631
|
-
* }
|
|
632
|
-
* FunctionKeys<Obj> // 'onClick' | 'onChange'
|
|
760
|
+
* ```tsx
|
|
761
|
+
* type InputProps = ForwardRefProps<'input'>
|
|
633
762
|
* ```
|
|
634
763
|
*/
|
|
635
|
-
type
|
|
764
|
+
type ForwardRefProps<T extends keyof JSX.IntrinsicElements> = ComponentProps<T> & {
|
|
765
|
+
ref?: unknown;
|
|
766
|
+
};
|
|
636
767
|
/**
|
|
637
|
-
*
|
|
768
|
+
* Merge props with default props
|
|
638
769
|
*
|
|
639
770
|
* @example
|
|
640
|
-
* ```
|
|
641
|
-
* interface
|
|
642
|
-
*
|
|
643
|
-
*
|
|
771
|
+
* ```tsx
|
|
772
|
+
* interface Props {
|
|
773
|
+
* size?: 'sm' | 'md' | 'lg'
|
|
774
|
+
* variant?: 'primary' | 'secondary'
|
|
644
775
|
* }
|
|
645
|
-
*
|
|
776
|
+
*
|
|
777
|
+
* type WithDefaults = MergeDefaultProps<Props, { size: 'md' }>
|
|
778
|
+
* // size becomes optional with default 'md'
|
|
646
779
|
* ```
|
|
647
780
|
*/
|
|
648
|
-
type
|
|
781
|
+
type MergeDefaultProps<P, D extends Partial<P>> = Omit<P, keyof D> & { [K in keyof D]?: P extends Record<K, infer V> ? V : D[K] };
|
|
649
782
|
/**
|
|
650
|
-
*
|
|
783
|
+
* Props with style
|
|
651
784
|
*/
|
|
652
|
-
type
|
|
785
|
+
type PropsWithStyle<P = unknown> = P & {
|
|
786
|
+
style?: CSSProperties;
|
|
787
|
+
};
|
|
653
788
|
/**
|
|
654
|
-
*
|
|
789
|
+
* Props with className
|
|
655
790
|
*/
|
|
656
|
-
type
|
|
791
|
+
type PropsWithClassName<P = unknown> = P & {
|
|
792
|
+
className?: string;
|
|
793
|
+
};
|
|
657
794
|
/**
|
|
658
|
-
*
|
|
795
|
+
* Props with style and className
|
|
659
796
|
*/
|
|
660
|
-
type
|
|
797
|
+
type PropsWithStyleAndClassName<P = unknown> = P & {
|
|
798
|
+
style?: CSSProperties;
|
|
799
|
+
className?: string;
|
|
800
|
+
};
|
|
801
|
+
/**
|
|
802
|
+
* Event handler type
|
|
803
|
+
*/
|
|
804
|
+
type EventHandler<E = SyntheticEvent> = (event: E) => void;
|
|
805
|
+
/**
|
|
806
|
+
* Change event handler
|
|
807
|
+
*/
|
|
808
|
+
type ChangeEventHandler = (event: SyntheticEvent) => void;
|
|
809
|
+
/**
|
|
810
|
+
* Mouse event handler
|
|
811
|
+
*/
|
|
812
|
+
type MouseEventHandler = (event: SyntheticEvent) => void;
|
|
813
|
+
/**
|
|
814
|
+
* Keyboard event handler
|
|
815
|
+
*/
|
|
816
|
+
type KeyboardEventHandler = (event: SyntheticEvent) => void;
|
|
817
|
+
/**
|
|
818
|
+
* Focus event handler
|
|
819
|
+
*/
|
|
820
|
+
type FocusEventHandler = (event: SyntheticEvent) => void;
|
|
821
|
+
/**
|
|
822
|
+
* Form event handler
|
|
823
|
+
*/
|
|
824
|
+
type FormEventHandler = (event: SyntheticEvent) => void;
|
|
825
|
+
type ReactComponentType<P = unknown> = (props: P) => unknown;
|
|
826
|
+
type ReactNode = unknown;
|
|
827
|
+
interface SyntheticEvent {
|
|
828
|
+
type: string;
|
|
829
|
+
nativeEvent: unknown;
|
|
830
|
+
currentTarget: unknown;
|
|
831
|
+
target: unknown;
|
|
832
|
+
}
|
|
833
|
+
type CSSProperties = Record<string, string | number | undefined>;
|
|
834
|
+
declare namespace JSX {
|
|
835
|
+
type IntrinsicElements = Record<string, unknown>;
|
|
836
|
+
}
|
|
661
837
|
//#endregion
|
|
662
|
-
//#region src/
|
|
838
|
+
//#region src/ecosystem/trpc.d.ts
|
|
663
839
|
/**
|
|
664
|
-
*
|
|
840
|
+
* tRPC integration types
|
|
841
|
+
*
|
|
842
|
+
* These types help work with tRPC routers and procedures.
|
|
843
|
+
* Note: tRPC is an optional peer dependency.
|
|
844
|
+
*/
|
|
845
|
+
/**
|
|
846
|
+
* tRPC router shape
|
|
665
847
|
*
|
|
666
848
|
* @example
|
|
667
849
|
* ```ts
|
|
668
|
-
*
|
|
669
|
-
*
|
|
850
|
+
* import { initTRPC } from '@trpc/server'
|
|
851
|
+
*
|
|
852
|
+
* const t = initTRPC.create()
|
|
853
|
+
*
|
|
854
|
+
* const router = t.router({
|
|
855
|
+
* user: t.procedure.query(() => ({ name: 'John' })),
|
|
856
|
+
* post: t.procedure.query(() => ({ title: 'Hello' }))
|
|
857
|
+
* })
|
|
858
|
+
*
|
|
859
|
+
* type RouterShape = TRPCRouterShape<typeof router>
|
|
670
860
|
* ```
|
|
671
861
|
*/
|
|
672
|
-
type
|
|
862
|
+
type TRPCRouterShape<T> = T extends {
|
|
863
|
+
_def: {
|
|
864
|
+
router: infer R;
|
|
865
|
+
};
|
|
866
|
+
} ? R : T;
|
|
673
867
|
/**
|
|
674
|
-
*
|
|
868
|
+
* Extract input type from tRPC procedure
|
|
675
869
|
*
|
|
676
870
|
* @example
|
|
677
871
|
* ```ts
|
|
678
|
-
*
|
|
872
|
+
* const procedure = t.procedure.input(z.object({ name: z.string() }))
|
|
873
|
+
*
|
|
874
|
+
* type Input = TRPCProcedureInput<typeof procedure>
|
|
875
|
+
* // { name: string }
|
|
679
876
|
* ```
|
|
680
877
|
*/
|
|
681
|
-
type
|
|
878
|
+
type TRPCProcedureInput<T> = T extends {
|
|
879
|
+
_def: {
|
|
880
|
+
inputs: infer I;
|
|
881
|
+
};
|
|
882
|
+
} ? I extends [infer First, ...unknown[]] ? First : I : T extends {
|
|
883
|
+
_def: {
|
|
884
|
+
input: infer I;
|
|
885
|
+
};
|
|
886
|
+
} ? I : never;
|
|
682
887
|
/**
|
|
683
|
-
*
|
|
888
|
+
* Extract output type from tRPC procedure
|
|
684
889
|
*
|
|
685
890
|
* @example
|
|
686
891
|
* ```ts
|
|
687
|
-
*
|
|
688
|
-
*
|
|
892
|
+
* const procedure = t.procedure.output(z.object({ name: z.string() }))
|
|
893
|
+
*
|
|
894
|
+
* type Output = TRPCProcedureOutput<typeof procedure>
|
|
895
|
+
* // { name: string }
|
|
689
896
|
* ```
|
|
690
897
|
*/
|
|
691
|
-
type
|
|
898
|
+
type TRPCProcedureOutput<T> = T extends {
|
|
899
|
+
_def: {
|
|
900
|
+
output: infer O;
|
|
901
|
+
};
|
|
902
|
+
} ? O : never;
|
|
692
903
|
/**
|
|
693
|
-
*
|
|
904
|
+
* tRPC procedure type
|
|
694
905
|
*/
|
|
695
|
-
type
|
|
906
|
+
type TRPCProcedureType = 'query' | 'mutation' | 'subscription';
|
|
696
907
|
/**
|
|
697
|
-
*
|
|
908
|
+
* Extract procedure type from tRPC procedure
|
|
698
909
|
*/
|
|
699
|
-
type
|
|
910
|
+
type TRPCExtractProcedureType<T> = T extends {
|
|
911
|
+
_def: {
|
|
912
|
+
type: infer P;
|
|
913
|
+
};
|
|
914
|
+
} ? P extends TRPCProcedureType ? P : never : never;
|
|
700
915
|
/**
|
|
701
|
-
*
|
|
916
|
+
* tRPC error shape
|
|
917
|
+
*
|
|
918
|
+
* @example
|
|
919
|
+
* ```ts
|
|
920
|
+
* type Error = TRPCErrorShape<{ message: string }>
|
|
921
|
+
* ```
|
|
702
922
|
*/
|
|
703
|
-
|
|
923
|
+
interface TRPCErrorShape<T = unknown> {
|
|
924
|
+
message: string;
|
|
925
|
+
code: string;
|
|
926
|
+
data?: T;
|
|
927
|
+
}
|
|
704
928
|
/**
|
|
705
|
-
*
|
|
929
|
+
* tRPC context type
|
|
930
|
+
*
|
|
931
|
+
* @example
|
|
932
|
+
* ```ts
|
|
933
|
+
* interface Context {
|
|
934
|
+
* user?: { id: string }
|
|
935
|
+
* session: Session
|
|
936
|
+
* }
|
|
937
|
+
*
|
|
938
|
+
* type AppContext = TRPCContext<Context>
|
|
939
|
+
* ```
|
|
706
940
|
*/
|
|
707
|
-
type
|
|
708
|
-
type LiteralNumber<T extends number> = T;
|
|
709
|
-
type LiteralBoolean<T extends boolean> = T;
|
|
941
|
+
type TRPCContext<T> = T;
|
|
710
942
|
/**
|
|
711
|
-
*
|
|
943
|
+
* tRPC middleware type
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```ts
|
|
947
|
+
* type Middleware = TRPCMiddleware<{ user: User }>
|
|
948
|
+
* ```
|
|
712
949
|
*/
|
|
713
|
-
type
|
|
950
|
+
type TRPCMiddleware<T = unknown> = (opts: {
|
|
951
|
+
ctx: T;
|
|
952
|
+
next: () => Promise<void>;
|
|
953
|
+
}) => Promise<void>;
|
|
714
954
|
/**
|
|
715
|
-
*
|
|
955
|
+
* tRPC router record
|
|
716
956
|
*/
|
|
717
|
-
type
|
|
957
|
+
type TRPCRouterRecord = Record<string, unknown>;
|
|
718
958
|
/**
|
|
719
|
-
*
|
|
959
|
+
* Merge multiple tRPC routers
|
|
720
960
|
*/
|
|
721
|
-
type
|
|
961
|
+
type TRPCMergeRouters<T extends TRPCRouterRecord[]> = T extends [infer First extends TRPCRouterRecord, ...infer Rest extends TRPCRouterRecord[]] ? Rest extends [] ? First : First & TRPCMergeRouters<Rest> : Record<string, never>;
|
|
722
962
|
/**
|
|
723
|
-
*
|
|
963
|
+
* tRPC procedure builder
|
|
724
964
|
*/
|
|
725
|
-
|
|
965
|
+
interface TRPCProcedureBuilder<T = unknown> {
|
|
966
|
+
_def: {
|
|
967
|
+
input: T;
|
|
968
|
+
output: unknown;
|
|
969
|
+
type: TRPCProcedureType;
|
|
970
|
+
};
|
|
971
|
+
}
|
|
726
972
|
/**
|
|
727
|
-
*
|
|
973
|
+
* Get all query procedures from router
|
|
728
974
|
*/
|
|
729
|
-
type
|
|
975
|
+
type TRPCQueries<T> = T extends object ? { [K in keyof T]: T[K] extends {
|
|
976
|
+
_def: {
|
|
977
|
+
type: 'query';
|
|
978
|
+
};
|
|
979
|
+
} ? K : never }[keyof T] : never;
|
|
730
980
|
/**
|
|
731
|
-
*
|
|
732
|
-
* Handles consecutive uppercase letters correctly (e.g., XMLParser -> xml_parser)
|
|
981
|
+
* Get all mutation procedures from router
|
|
733
982
|
*/
|
|
734
|
-
type
|
|
983
|
+
type TRPCMutations<T> = T extends object ? { [K in keyof T]: T[K] extends {
|
|
984
|
+
_def: {
|
|
985
|
+
type: 'mutation';
|
|
986
|
+
};
|
|
987
|
+
} ? K : never }[keyof T] : never;
|
|
735
988
|
/**
|
|
736
|
-
*
|
|
989
|
+
* Get all subscription procedures from router
|
|
737
990
|
*/
|
|
738
|
-
type
|
|
991
|
+
type TRPCSubscriptions<T> = T extends object ? { [K in keyof T]: T[K] extends {
|
|
992
|
+
_def: {
|
|
993
|
+
type: 'subscription';
|
|
994
|
+
};
|
|
995
|
+
} ? K : never }[keyof T] : never;
|
|
739
996
|
/**
|
|
740
|
-
*
|
|
997
|
+
* tRPC client type
|
|
741
998
|
*/
|
|
742
|
-
|
|
999
|
+
interface TRPCClient<T> {
|
|
1000
|
+
query: <K extends keyof T>(procedure: K, input?: unknown) => Promise<TRPCProcedureOutput<T[K]>>;
|
|
1001
|
+
mutate: <K extends keyof T>(procedure: K, input?: unknown) => Promise<TRPCProcedureOutput<T[K]>>;
|
|
1002
|
+
subscribe: <K extends keyof T>(procedure: K, input?: unknown) => Promise<void>;
|
|
1003
|
+
}
|
|
743
1004
|
/**
|
|
744
|
-
*
|
|
1005
|
+
* tRPC caller type
|
|
745
1006
|
*/
|
|
746
|
-
type
|
|
1007
|
+
type TRPSCaller<T, Context = unknown> = (ctx: Context) => TRPCCallerRouter<T>;
|
|
747
1008
|
/**
|
|
748
|
-
*
|
|
1009
|
+
* tRPC caller router type
|
|
749
1010
|
*/
|
|
750
|
-
type
|
|
1011
|
+
type TRPCCallerRouter<T> = { [K in keyof T]: TRPCProcedureCaller<T[K]> };
|
|
751
1012
|
/**
|
|
752
|
-
*
|
|
1013
|
+
* tRPC procedure caller type
|
|
753
1014
|
*/
|
|
754
|
-
type
|
|
1015
|
+
type TRPCProcedureCaller<T> = (input: TRPCProcedureInput<T>) => Promise<TRPCProcedureOutput<T>>;
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region src/ecosystem/vue.d.ts
|
|
755
1018
|
/**
|
|
756
|
-
*
|
|
1019
|
+
* Vue component props utilities
|
|
1020
|
+
*
|
|
1021
|
+
* These types help work with Vue component props.
|
|
1022
|
+
* Note: Vue is an optional peer dependency.
|
|
757
1023
|
*/
|
|
758
|
-
type UnionToTuple<T> = UnionToIntersection<T extends unknown ? (t: T) => T : never> extends ((_: any) => infer W) ? [...UnionToTuple<Exclude<T, W>>, W] : [];
|
|
759
1024
|
/**
|
|
760
|
-
*
|
|
1025
|
+
* Vue prop type definition
|
|
761
1026
|
*
|
|
762
1027
|
* @example
|
|
763
|
-
* ```
|
|
764
|
-
*
|
|
1028
|
+
* ```vue
|
|
1029
|
+
* <script setup lang="ts">
|
|
1030
|
+
* const props = defineProps<{
|
|
765
1031
|
* name: string
|
|
766
1032
|
* age?: number
|
|
767
|
-
* }
|
|
768
|
-
*
|
|
1033
|
+
* }>()
|
|
1034
|
+
* </script>
|
|
769
1035
|
* ```
|
|
770
1036
|
*/
|
|
771
|
-
|
|
1037
|
+
interface VuePropType<T> {
|
|
1038
|
+
type: VuePropConstructor<T>;
|
|
1039
|
+
required?: boolean;
|
|
1040
|
+
default?: T | (() => T);
|
|
1041
|
+
}
|
|
772
1042
|
/**
|
|
773
|
-
*
|
|
1043
|
+
* Vue prop constructor types
|
|
1044
|
+
*/
|
|
1045
|
+
type VuePropConstructor<T> = (abstract new (...args: any[]) => T & object) | {
|
|
1046
|
+
(): T;
|
|
1047
|
+
} | {
|
|
1048
|
+
new (...args: any[]): T & object;
|
|
1049
|
+
};
|
|
1050
|
+
/**
|
|
1051
|
+
* Extract props from Vue component options
|
|
774
1052
|
*
|
|
775
1053
|
* @example
|
|
776
1054
|
* ```ts
|
|
777
|
-
* interface
|
|
778
|
-
*
|
|
779
|
-
*
|
|
1055
|
+
* interface Props {
|
|
1056
|
+
* title: string
|
|
1057
|
+
* count?: number
|
|
780
1058
|
* }
|
|
781
|
-
*
|
|
1059
|
+
*
|
|
1060
|
+
* type Props = ExtractVueProps<Props>
|
|
782
1061
|
* ```
|
|
783
1062
|
*/
|
|
784
|
-
type
|
|
1063
|
+
type ExtractVueProps<T> = T extends {
|
|
1064
|
+
props: infer P;
|
|
1065
|
+
} ? P : T;
|
|
785
1066
|
/**
|
|
786
|
-
*
|
|
1067
|
+
* Vue component raw props (before normalization)
|
|
1068
|
+
*/
|
|
1069
|
+
type VueRawProps = Record<string, VuePropConstructor<unknown> | VuePropType<unknown>>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Normalize Vue props to TypeScript types
|
|
787
1072
|
*
|
|
788
1073
|
* @example
|
|
789
1074
|
* ```ts
|
|
790
|
-
*
|
|
791
|
-
* name:
|
|
1075
|
+
* const props = {
|
|
1076
|
+
* name: String,
|
|
1077
|
+
* age: { type: Number, required: false }
|
|
1078
|
+
* }
|
|
1079
|
+
*
|
|
1080
|
+
* type Normalized = NormalizeVueProps<typeof props>
|
|
1081
|
+
* // { name: string; age?: number }
|
|
1082
|
+
* ```
|
|
1083
|
+
*/
|
|
1084
|
+
type NormalizeVueProps<T extends VueRawProps> = { [K in keyof T]: T[K] extends VuePropType<infer V> ? T[K] extends {
|
|
1085
|
+
required: true;
|
|
1086
|
+
} ? V : V | undefined : T[K] extends VuePropConstructor<infer V> ? V | undefined : never };
|
|
1087
|
+
/**
|
|
1088
|
+
* Vue emit function type
|
|
1089
|
+
*
|
|
1090
|
+
* @example
|
|
1091
|
+
* ```vue
|
|
1092
|
+
* <script setup lang="ts">
|
|
1093
|
+
* const emit = defineEmits<{
|
|
1094
|
+
* change: [value: string]
|
|
1095
|
+
* submit: []
|
|
1096
|
+
* }>()
|
|
1097
|
+
* </script>
|
|
1098
|
+
* ```
|
|
1099
|
+
*/
|
|
1100
|
+
type VueEmitType<T extends Record<string, unknown[]>> = { [K in keyof T]: (...args: T[K]) => void };
|
|
1101
|
+
/**
|
|
1102
|
+
* Vue model props (for v-model)
|
|
1103
|
+
*
|
|
1104
|
+
* @example
|
|
1105
|
+
* ```ts
|
|
1106
|
+
* interface Props {
|
|
1107
|
+
* modelValue: string
|
|
1108
|
+
* 'onUpdate:modelValue'?: (value: string) => void
|
|
1109
|
+
* }
|
|
1110
|
+
*
|
|
1111
|
+
* type Model = VueModelProps<'modelValue', string>
|
|
1112
|
+
* ```
|
|
1113
|
+
*/
|
|
1114
|
+
type VueModelProps<K extends string, T> = { [P in K]: T } & { [P in `onUpdate:${K}`]?: (value: T) => void };
|
|
1115
|
+
/**
|
|
1116
|
+
* Vue prop with default value
|
|
1117
|
+
*/
|
|
1118
|
+
interface VuePropWithDefault<T, D extends T> {
|
|
1119
|
+
type: VuePropConstructor<T>;
|
|
1120
|
+
required: false;
|
|
1121
|
+
default: D;
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Required Vue prop
|
|
1125
|
+
*/
|
|
1126
|
+
interface RequiredVueProp<T> {
|
|
1127
|
+
type: VuePropConstructor<T>;
|
|
1128
|
+
required: true;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Optional Vue prop
|
|
1132
|
+
*/
|
|
1133
|
+
interface OptionalVueProp<T> {
|
|
1134
|
+
type: VuePropConstructor<T>;
|
|
1135
|
+
required: false;
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Vue slot type
|
|
1139
|
+
*/
|
|
1140
|
+
type VueSlot<T = Record<string, unknown>> = (props: T) => unknown;
|
|
1141
|
+
/**
|
|
1142
|
+
* Vue slots type
|
|
1143
|
+
*/
|
|
1144
|
+
type VueSlots<T extends Record<string, Record<string, unknown> | undefined>> = { [K in keyof T]: VueSlot<NonNullable<T[K]>> };
|
|
1145
|
+
/**
|
|
1146
|
+
* Vue expose type
|
|
1147
|
+
*/
|
|
1148
|
+
type VueExpose<T extends Record<string, (...args: any[]) => any>> = T;
|
|
1149
|
+
/**
|
|
1150
|
+
* Vue injection key type
|
|
1151
|
+
*/
|
|
1152
|
+
type VueInjectionKey<_T> = symbol | string;
|
|
1153
|
+
/**
|
|
1154
|
+
* Vue provide/inject type pair
|
|
1155
|
+
*/
|
|
1156
|
+
interface VueProvideInjectPair<T> {
|
|
1157
|
+
key: VueInjectionKey<T>;
|
|
1158
|
+
defaultValue?: T;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Vue computed property type
|
|
1162
|
+
*/
|
|
1163
|
+
interface VueComputed<T> {
|
|
1164
|
+
get: () => T;
|
|
1165
|
+
set?: (value: T) => void;
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Vue ref type
|
|
1169
|
+
*/
|
|
1170
|
+
interface VueRef<T = unknown> {
|
|
1171
|
+
value: T;
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Vue reactive type
|
|
1175
|
+
*/
|
|
1176
|
+
type VueReactive<T extends object> = T;
|
|
1177
|
+
/**
|
|
1178
|
+
* Convert Vue props options to TypeScript type
|
|
1179
|
+
*/
|
|
1180
|
+
type VuePropsToType<T extends VueRawProps> = { [K in keyof T]: T[K] extends {
|
|
1181
|
+
type: infer C;
|
|
1182
|
+
required: true;
|
|
1183
|
+
} ? C extends VuePropConstructor<infer V> ? V : never : T[K] extends {
|
|
1184
|
+
type: infer C;
|
|
1185
|
+
default: unknown;
|
|
1186
|
+
} ? C extends VuePropConstructor<infer V> ? V : never : T[K] extends VuePropConstructor<infer V> ? V | undefined : T[K] extends VuePropType<infer V> ? V | undefined : never };
|
|
1187
|
+
/**
|
|
1188
|
+
* Vue component instance type
|
|
1189
|
+
*/
|
|
1190
|
+
interface VueComponentInstance<P = unknown, S = unknown> {
|
|
1191
|
+
$props: P;
|
|
1192
|
+
$slots: S;
|
|
1193
|
+
$emit: (event: string, ...args: unknown[]) => void;
|
|
1194
|
+
}
|
|
1195
|
+
//#endregion
|
|
1196
|
+
//#region src/functions/index.d.ts
|
|
1197
|
+
/**
|
|
1198
|
+
* Function type utilities
|
|
1199
|
+
*/
|
|
1200
|
+
/**
|
|
1201
|
+
* Get function parameters as tuple
|
|
1202
|
+
*
|
|
1203
|
+
* @example
|
|
1204
|
+
* ```ts
|
|
1205
|
+
* type Fn = (a: string, b: number) => boolean
|
|
1206
|
+
* Parameters<Fn> // [string, number]
|
|
1207
|
+
* ```
|
|
1208
|
+
*/
|
|
1209
|
+
type Parameters<T> = T extends ((...args: infer P) => any) ? P : never;
|
|
1210
|
+
/**
|
|
1211
|
+
* Get function return type
|
|
1212
|
+
*
|
|
1213
|
+
* @example
|
|
1214
|
+
* ```ts
|
|
1215
|
+
* type Fn = (a: string) => number
|
|
1216
|
+
* ReturnType<Fn> // number
|
|
1217
|
+
* ```
|
|
1218
|
+
*/
|
|
1219
|
+
type ReturnType$1<T> = T extends ((...args: any[]) => infer R) ? R : any;
|
|
1220
|
+
/**
|
|
1221
|
+
* Get Nth parameter type (0-indexed)
|
|
1222
|
+
*
|
|
1223
|
+
* @example
|
|
1224
|
+
* ```ts
|
|
1225
|
+
* type Fn = (a: string, b: number, c: boolean) => void
|
|
1226
|
+
* NthParameter<Fn, 0> // string
|
|
1227
|
+
* NthParameter<Fn, 1> // number
|
|
1228
|
+
* NthParameter<Fn, 2> // boolean
|
|
1229
|
+
* ```
|
|
1230
|
+
*/
|
|
1231
|
+
type NthParameter<T, N extends number> = T extends ((...args: infer P) => any) ? P[N] : never;
|
|
1232
|
+
/**
|
|
1233
|
+
* Extract async function return type (unwraps Promise)
|
|
1234
|
+
*
|
|
1235
|
+
* @example
|
|
1236
|
+
* ```ts
|
|
1237
|
+
* type AsyncFn = () => Promise<string>
|
|
1238
|
+
* AsyncReturnType<AsyncFn> // string
|
|
1239
|
+
* ```
|
|
1240
|
+
*/
|
|
1241
|
+
type AsyncReturnType<T> = T extends ((...args: any[]) => Promise<infer R>) ? R : T extends ((...args: any[]) => infer R) ? R : never;
|
|
1242
|
+
/**
|
|
1243
|
+
* Get function this parameter type
|
|
1244
|
+
*
|
|
1245
|
+
* @example
|
|
1246
|
+
* ```ts
|
|
1247
|
+
* type Fn = (this: { x: number }) => void
|
|
1248
|
+
* ThisParameterType<Fn> // { x: number }
|
|
1249
|
+
* ```
|
|
1250
|
+
*/
|
|
1251
|
+
type ThisParameterType<T> = T extends ((this: infer U, ...args: any[]) => any) ? U : unknown;
|
|
1252
|
+
/**
|
|
1253
|
+
* Omit this parameter from function type
|
|
1254
|
+
*
|
|
1255
|
+
* @example
|
|
1256
|
+
* ```ts
|
|
1257
|
+
* type Fn = (this: { x: number }, a: string) => void
|
|
1258
|
+
* OmitThisParameter<Fn> // (a: string) => void
|
|
1259
|
+
* ```
|
|
1260
|
+
*/
|
|
1261
|
+
type OmitThisParameter<T> = T extends ((this: any, ...args: infer A) => infer R) ? (...args: A) => R : T;
|
|
1262
|
+
/**
|
|
1263
|
+
* Check if type is a function
|
|
1264
|
+
*
|
|
1265
|
+
* @example
|
|
1266
|
+
* ```ts
|
|
1267
|
+
* IsFunction<() => void> // true
|
|
1268
|
+
* IsFunction<string> // false
|
|
1269
|
+
* ```
|
|
1270
|
+
*/
|
|
1271
|
+
type IsFunction<T> = T extends ((...args: any[]) => any) ? true : false;
|
|
1272
|
+
/**
|
|
1273
|
+
* Check if type is an async function
|
|
1274
|
+
*
|
|
1275
|
+
* @example
|
|
1276
|
+
* ```ts
|
|
1277
|
+
* IsAsyncFunction<() => Promise<string>> // true
|
|
1278
|
+
* IsAsyncFunction<() => string> // false
|
|
1279
|
+
* ```
|
|
1280
|
+
*/
|
|
1281
|
+
type IsAsyncFunction<T> = T extends ((...args: any[]) => Promise<any>) ? true : false;
|
|
1282
|
+
/**
|
|
1283
|
+
* Make function parameters optional
|
|
1284
|
+
*
|
|
1285
|
+
* @example
|
|
1286
|
+
* ```ts
|
|
1287
|
+
* type Fn = (a: string, b: number) => void
|
|
1288
|
+
* OptionalParameters<Fn> // (a?: string, b?: number) => void
|
|
1289
|
+
* ```
|
|
1290
|
+
*/
|
|
1291
|
+
type OptionalParameters<T> = T extends ((...args: any[]) => infer R) ? (...args: Partial<Parameters<T>>) => R : never;
|
|
1292
|
+
/**
|
|
1293
|
+
* Append a parameter to a function
|
|
1294
|
+
*
|
|
1295
|
+
* @example
|
|
1296
|
+
* ```ts
|
|
1297
|
+
* type Fn = (a: string) => void
|
|
1298
|
+
* AppendParameter<Fn, number> // (a: string, b: number) => void
|
|
1299
|
+
* ```
|
|
1300
|
+
*/
|
|
1301
|
+
type AppendParameter<T, P> = T extends ((...args: infer A) => infer R) ? (...args: [...A, P]) => R : never;
|
|
1302
|
+
/**
|
|
1303
|
+
* Prepend a parameter to a function
|
|
1304
|
+
*
|
|
1305
|
+
* @example
|
|
1306
|
+
* ```ts
|
|
1307
|
+
* type Fn = (a: string) => void
|
|
1308
|
+
* PrependParameter<Fn, number> // (a: number, b: string) => void
|
|
1309
|
+
* ```
|
|
1310
|
+
*/
|
|
1311
|
+
type PrependParameter<T, P> = T extends ((...args: infer A) => infer R) ? (...args: [P, ...A]) => R : never;
|
|
1312
|
+
//#endregion
|
|
1313
|
+
//#region src/guards/index.d.ts
|
|
1314
|
+
/**
|
|
1315
|
+
* Check if type is an array
|
|
1316
|
+
*
|
|
1317
|
+
* @example
|
|
1318
|
+
* ```ts
|
|
1319
|
+
* IsArray<string[]> // true
|
|
1320
|
+
* IsArray<string> // false
|
|
1321
|
+
* ```
|
|
1322
|
+
*/
|
|
1323
|
+
type IsArray<T> = T extends readonly unknown[] ? T extends readonly [...unknown[]] ? true : false : false;
|
|
1324
|
+
/**
|
|
1325
|
+
* Check if type is a tuple
|
|
1326
|
+
*
|
|
1327
|
+
* @example
|
|
1328
|
+
* ```ts
|
|
1329
|
+
* IsTuple<[string, number]> // true
|
|
1330
|
+
* IsTuple<string[]> // false
|
|
1331
|
+
* ```
|
|
1332
|
+
*/
|
|
1333
|
+
type IsTuple<T> = T extends readonly [unknown, ...unknown[]] ? T extends readonly unknown[] ? number extends T['length'] ? false : true : false : false;
|
|
1334
|
+
/**
|
|
1335
|
+
* Check if two types are equal
|
|
1336
|
+
*
|
|
1337
|
+
* @example
|
|
1338
|
+
* ```ts
|
|
1339
|
+
* IsEqual<string, string> // true
|
|
1340
|
+
* IsEqual<string, number> // false
|
|
1341
|
+
* ```
|
|
1342
|
+
*/
|
|
1343
|
+
type IsEqual<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
1344
|
+
/**
|
|
1345
|
+
* Check if type is any
|
|
1346
|
+
*/
|
|
1347
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1348
|
+
/**
|
|
1349
|
+
* Check if type is never
|
|
1350
|
+
*/
|
|
1351
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
1352
|
+
/**
|
|
1353
|
+
* Check if type is unknown
|
|
1354
|
+
*/
|
|
1355
|
+
type IsUnknown<T> = IsEqual<T, unknown> extends true ? IsAny<T> extends true ? false : true : false;
|
|
1356
|
+
//#endregion
|
|
1357
|
+
//#region src/infer/index.d.ts
|
|
1358
|
+
/**
|
|
1359
|
+
* Get Promise value type (recursive unwrapping)
|
|
1360
|
+
*
|
|
1361
|
+
* @example
|
|
1362
|
+
* ```ts
|
|
1363
|
+
* Awaited<Promise<string>> // string
|
|
1364
|
+
* Awaited<Promise<Promise<number>>> // number
|
|
1365
|
+
* ```
|
|
1366
|
+
*/
|
|
1367
|
+
type Awaited<T> = T extends Promise<infer U> ? Awaited<U> : T;
|
|
1368
|
+
/**
|
|
1369
|
+
* Get array element type
|
|
1370
|
+
*
|
|
1371
|
+
* @example
|
|
1372
|
+
* ```ts
|
|
1373
|
+
* ArrayElement<string[]> // string
|
|
1374
|
+
* ArrayElement<(number | boolean)[]> // number | boolean
|
|
1375
|
+
* ```
|
|
1376
|
+
*/
|
|
1377
|
+
type ArrayElement<T> = T extends readonly (infer E)[] ? E : never;
|
|
1378
|
+
/**
|
|
1379
|
+
* Get object value type
|
|
1380
|
+
*
|
|
1381
|
+
* @example
|
|
1382
|
+
* ```ts
|
|
1383
|
+
* ValueOf<{ a: string; b: number }> // string | number
|
|
1384
|
+
* ```
|
|
1385
|
+
*/
|
|
1386
|
+
type ValueOf<T> = T[keyof T];
|
|
1387
|
+
/**
|
|
1388
|
+
* Get function type keys
|
|
1389
|
+
*
|
|
1390
|
+
* @example
|
|
1391
|
+
* ```ts
|
|
1392
|
+
* interface Obj {
|
|
1393
|
+
* name: string
|
|
1394
|
+
* onClick: () => void
|
|
1395
|
+
* onChange: (v: string) => void
|
|
1396
|
+
* }
|
|
1397
|
+
* FunctionKeys<Obj> // 'onClick' | 'onChange'
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
type FunctionKeys<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? K : never }[keyof T];
|
|
1401
|
+
/**
|
|
1402
|
+
* Get non-function type keys
|
|
1403
|
+
*
|
|
1404
|
+
* @example
|
|
1405
|
+
* ```ts
|
|
1406
|
+
* interface Obj {
|
|
1407
|
+
* name: string
|
|
1408
|
+
* onClick: () => void
|
|
1409
|
+
* }
|
|
1410
|
+
* NonFunctionKeys<Obj> // 'name'
|
|
1411
|
+
* ```
|
|
1412
|
+
*/
|
|
1413
|
+
type NonFunctionKeys<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? never : K }[keyof T];
|
|
1414
|
+
/**
|
|
1415
|
+
* Get function's first parameter type
|
|
1416
|
+
*/
|
|
1417
|
+
type FirstParameter<T> = T extends ((first: infer F, ...rest: any[]) => any) ? F : never;
|
|
1418
|
+
/**
|
|
1419
|
+
* Extract function properties
|
|
1420
|
+
*/
|
|
1421
|
+
type FunctionOnly<T> = Pick<T, FunctionKeys<T>>;
|
|
1422
|
+
/**
|
|
1423
|
+
* Extract non-function properties
|
|
1424
|
+
*/
|
|
1425
|
+
type DataOnly<T> = Pick<T, NonFunctionKeys<T>>;
|
|
1426
|
+
//#endregion
|
|
1427
|
+
//#region src/utils/index.d.ts
|
|
1428
|
+
/**
|
|
1429
|
+
* Merge two types (latter overrides former)
|
|
1430
|
+
*
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```ts
|
|
1433
|
+
* Merge<{ a: string; b: number }, { b: boolean; c: string }>
|
|
1434
|
+
* // { a: string; b: boolean; c: string }
|
|
1435
|
+
* ```
|
|
1436
|
+
*/
|
|
1437
|
+
type Merge<T, U> = Omit<T, keyof U> & U;
|
|
1438
|
+
/**
|
|
1439
|
+
* Non null/undefined
|
|
1440
|
+
*
|
|
1441
|
+
* @example
|
|
1442
|
+
* ```ts
|
|
1443
|
+
* NonNullable<string | null | undefined> // string
|
|
1444
|
+
* ```
|
|
1445
|
+
*/
|
|
1446
|
+
type NonNullable$1<T> = T & {};
|
|
1447
|
+
/**
|
|
1448
|
+
* Exclusive properties (only one can be selected)
|
|
1449
|
+
*
|
|
1450
|
+
* @example
|
|
1451
|
+
* ```ts
|
|
1452
|
+
* type Result = Exclusive<{ type: 'a'; valueA: string } | { type: 'b'; valueB: number }, 'type'>
|
|
1453
|
+
* // Only type: 'a' or type: 'b' can be selected
|
|
1454
|
+
* ```
|
|
1455
|
+
*/
|
|
1456
|
+
type Exclusive<T, K extends keyof T> = T extends unknown ? Omit<T, K> & { [P in K]?: never } : never;
|
|
1457
|
+
/**
|
|
1458
|
+
* Remove null and undefined from all properties
|
|
1459
|
+
*/
|
|
1460
|
+
type NoNullish<T> = { [K in keyof T]: NonNullable$1<T[K]> };
|
|
1461
|
+
/**
|
|
1462
|
+
* Make all properties optional while preserving undefined/null values
|
|
1463
|
+
*/
|
|
1464
|
+
type LoosePartial<T> = { [P in keyof T]?: T[P] };
|
|
1465
|
+
/**
|
|
1466
|
+
* Literal types
|
|
1467
|
+
*/
|
|
1468
|
+
type Literal = string | number | boolean | undefined | null | void | bigint;
|
|
1469
|
+
/**
|
|
1470
|
+
* Exact literal types
|
|
1471
|
+
*/
|
|
1472
|
+
type LiteralString<T extends string> = T;
|
|
1473
|
+
type LiteralNumber<T extends number> = T;
|
|
1474
|
+
type LiteralBoolean<T extends boolean> = T;
|
|
1475
|
+
/**
|
|
1476
|
+
* Nullable type
|
|
1477
|
+
*/
|
|
1478
|
+
type Nullable<T> = T | null;
|
|
1479
|
+
/**
|
|
1480
|
+
* Optional type
|
|
1481
|
+
*/
|
|
1482
|
+
type Optional<T> = T | undefined;
|
|
1483
|
+
/**
|
|
1484
|
+
* Maybe type (nullable and optional)
|
|
1485
|
+
*/
|
|
1486
|
+
type Maybe<T> = T | null | undefined;
|
|
1487
|
+
/**
|
|
1488
|
+
* Convert string to camelCase
|
|
1489
|
+
*/
|
|
1490
|
+
type CamelCase<S extends string> = S extends `${infer P}_${infer Q}` ? `${P}${Capitalize<CamelCase<Q>>}` : S extends `${infer P}-${infer Q}` ? `${P}${Capitalize<CamelCase<Q>>}` : S;
|
|
1491
|
+
/**
|
|
1492
|
+
* Convert object keys to camelCase
|
|
1493
|
+
*/
|
|
1494
|
+
type CamelCaseKeys<T> = { [K in keyof T as CamelCase<string & K>]: T[K] };
|
|
1495
|
+
/**
|
|
1496
|
+
* Convert string to snake_case
|
|
1497
|
+
* Handles consecutive uppercase letters correctly (e.g., XMLParser -> xml_parser)
|
|
1498
|
+
*/
|
|
1499
|
+
type SnakeCase<S extends string> = S extends `${infer C0}${infer C1}${infer Rest}` ? C0 extends Uppercase<C0> ? C0 extends Lowercase<C0> ? `${C0}${SnakeCase<`${C1}${Rest}`>}` : C1 extends Uppercase<C1> ? C1 extends Lowercase<C1> ? `_${Lowercase<C0>}${SnakeCase<`${C1}${Rest}`>}` : `${Lowercase<C0>}${SnakeCase<`${C1}${Rest}`>}` : `_${Lowercase<C0>}${SnakeCase<`${C1}${Rest}`>}` : `${C0}${SnakeCase<`${C1}${Rest}`>}` : S extends `${infer C}` ? C extends Uppercase<C> ? C extends Lowercase<C> ? `${C}` : `_${Lowercase<C>}` : `${C}` : S;
|
|
1500
|
+
/**
|
|
1501
|
+
* Convert object keys to snake_case
|
|
1502
|
+
*/
|
|
1503
|
+
type SnakeCaseKeys<T> = { [K in keyof T as SnakeCase<string & K>]: T[K] };
|
|
1504
|
+
/**
|
|
1505
|
+
* Require at least one property
|
|
1506
|
+
*/
|
|
1507
|
+
type AtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & { [K in Keys]: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>> }[Keys];
|
|
1508
|
+
/**
|
|
1509
|
+
* Strict extract
|
|
1510
|
+
*/
|
|
1511
|
+
type StrictExtract<T, U extends keyof any> = T extends Record<U, any> ? T : never;
|
|
1512
|
+
/**
|
|
1513
|
+
* Strict exclude
|
|
1514
|
+
*/
|
|
1515
|
+
type StrictExclude<T, U extends T> = T extends U ? never : T;
|
|
1516
|
+
/**
|
|
1517
|
+
* Convert union type to intersection type
|
|
1518
|
+
*/
|
|
1519
|
+
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
1520
|
+
/**
|
|
1521
|
+
* Convert union type to tuple
|
|
1522
|
+
*/
|
|
1523
|
+
type UnionToTuple<T> = UnionToIntersection<T extends unknown ? (t: T) => T : never> extends ((_: any) => infer W) ? [...UnionToTuple<Exclude<T, W>>, W] : [];
|
|
1524
|
+
/**
|
|
1525
|
+
* Get all required keys of a type
|
|
1526
|
+
*
|
|
1527
|
+
* @example
|
|
1528
|
+
* ```ts
|
|
1529
|
+
* interface User {
|
|
1530
|
+
* name: string
|
|
1531
|
+
* age?: number
|
|
1532
|
+
* }
|
|
1533
|
+
* RequiredKeys<User> // 'name'
|
|
1534
|
+
* ```
|
|
1535
|
+
*/
|
|
1536
|
+
type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T];
|
|
1537
|
+
/**
|
|
1538
|
+
* Get all optional keys of a type
|
|
1539
|
+
*
|
|
1540
|
+
* @example
|
|
1541
|
+
* ```ts
|
|
1542
|
+
* interface User {
|
|
1543
|
+
* name: string
|
|
1544
|
+
* age?: number
|
|
1545
|
+
* }
|
|
1546
|
+
* OptionalKeys<User> // 'age'
|
|
1547
|
+
* ```
|
|
1548
|
+
*/
|
|
1549
|
+
type OptionalKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never }[keyof T];
|
|
1550
|
+
/**
|
|
1551
|
+
* Get all writable (non-readonly) keys of a type
|
|
1552
|
+
*
|
|
1553
|
+
* @example
|
|
1554
|
+
* ```ts
|
|
1555
|
+
* interface User {
|
|
1556
|
+
* name: string
|
|
792
1557
|
* readonly age: number
|
|
793
1558
|
* }
|
|
794
1559
|
* WritableKeys<User> // 'name'
|
|
@@ -950,127 +1715,431 @@ type Subtract<A extends number, B extends number> = NumberToArray<B> extends [..
|
|
|
950
1715
|
*/
|
|
951
1716
|
type Range<From extends number, To extends number, Acc extends number = From> = From extends To ? Acc : From extends To ? Acc : never;
|
|
952
1717
|
/**
|
|
953
|
-
* Check if A is greater than B
|
|
1718
|
+
* Check if A is greater than B
|
|
1719
|
+
*
|
|
1720
|
+
* @example
|
|
1721
|
+
* ```ts
|
|
1722
|
+
* GreaterThan<5, 3> // true
|
|
1723
|
+
* GreaterThan<3, 5> // false
|
|
1724
|
+
* ```
|
|
1725
|
+
*/
|
|
1726
|
+
type GreaterThan<A extends number, B extends number> = Subtract<A, B> extends 0 ? false : true;
|
|
1727
|
+
/**
|
|
1728
|
+
* Check if A is less than B
|
|
1729
|
+
*
|
|
1730
|
+
* @example
|
|
1731
|
+
* ```ts
|
|
1732
|
+
* LessThan<3, 5> // true
|
|
1733
|
+
* LessThan<5, 3> // false
|
|
1734
|
+
* ```
|
|
1735
|
+
*/
|
|
1736
|
+
type LessThan<A extends number, B extends number> = Subtract<B, A> extends 0 ? false : true;
|
|
1737
|
+
/**
|
|
1738
|
+
* Maximum of two numbers
|
|
1739
|
+
*
|
|
1740
|
+
* @example
|
|
1741
|
+
* ```ts
|
|
1742
|
+
* Max<3, 5> // 5
|
|
1743
|
+
* Max<5, 3> // 5
|
|
1744
|
+
* ```
|
|
1745
|
+
*/
|
|
1746
|
+
type Max<A extends number, B extends number> = GreaterThan<A, B> extends true ? A : B;
|
|
1747
|
+
/**
|
|
1748
|
+
* Minimum of two numbers
|
|
1749
|
+
*
|
|
1750
|
+
* @example
|
|
1751
|
+
* ```ts
|
|
1752
|
+
* Min<3, 5> // 3
|
|
1753
|
+
* Min<5, 3> // 3
|
|
1754
|
+
* ```
|
|
1755
|
+
*/
|
|
1756
|
+
type Min<A extends number, B extends number> = LessThan<A, B> extends true ? A : B;
|
|
1757
|
+
//#endregion
|
|
1758
|
+
//#region src/path/index.d.ts
|
|
1759
|
+
/**
|
|
1760
|
+
* Enhanced path utilities with validation and array support
|
|
1761
|
+
*/
|
|
1762
|
+
type Primitive = string | number | boolean | null | undefined | symbol | bigint | Date | RegExp;
|
|
1763
|
+
type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
|
|
1764
|
+
/**
|
|
1765
|
+
* Check if a path exists in type T
|
|
1766
|
+
*
|
|
1767
|
+
* @example
|
|
1768
|
+
* ```ts
|
|
1769
|
+
* interface Obj {
|
|
1770
|
+
* a: {
|
|
1771
|
+
* b: string
|
|
1772
|
+
* }
|
|
1773
|
+
* }
|
|
1774
|
+
*
|
|
1775
|
+
* ValidPath<Obj, 'a.b'> // true
|
|
1776
|
+
* ValidPath<Obj, 'a.c'> // false
|
|
1777
|
+
* ```
|
|
1778
|
+
*/
|
|
1779
|
+
type ValidPath<T, P extends string> = T extends Primitive ? P extends '' ? true : false : P extends '' ? true : P extends `${infer K}.${infer Rest}` ? K extends keyof T ? ValidPath<T[K], Rest> : false : P extends keyof T ? true : false;
|
|
1780
|
+
/**
|
|
1781
|
+
* Get all paths including array indices
|
|
1782
|
+
*
|
|
1783
|
+
* @example
|
|
1784
|
+
* ```ts
|
|
1785
|
+
* interface Users {
|
|
1786
|
+
* users: { name: string }[]
|
|
1787
|
+
* }
|
|
1788
|
+
*
|
|
1789
|
+
* ArrayPaths<Users>
|
|
1790
|
+
* // 'users' | `users.${number}` | `users.${number}.name`
|
|
1791
|
+
* ```
|
|
1792
|
+
*/
|
|
1793
|
+
type ArrayPaths<T, D extends number = 10> = [D] extends [never] ? never : T extends Primitive ? never : T extends readonly (infer E)[] ? ArrayPaths<E, Prev[D]> extends infer P ? P extends string ? `${number}` | `${number}.${P}` : `${number}` : `${number}` : { [K in keyof T]: T[K] extends readonly unknown[] ? `${K & string}` | `${K & string}.${ArrayPaths<T[K], Prev[D]>}` : T[K] extends Primitive ? `${K & string}` : `${K & string}` | `${K & string}.${ArrayPaths<T[K], Prev[D]>}` }[keyof T];
|
|
1794
|
+
/**
|
|
1795
|
+
* Get leaf node paths only (paths to primitive values)
|
|
1796
|
+
*
|
|
1797
|
+
* @example
|
|
1798
|
+
* ```ts
|
|
1799
|
+
* interface Users {
|
|
1800
|
+
* users: { name: string, age: number }[]
|
|
1801
|
+
* }
|
|
1802
|
+
*
|
|
1803
|
+
* LeafPaths<Users>
|
|
1804
|
+
* // `users.${number}.name` | `users.${number}.age`
|
|
1805
|
+
* ```
|
|
1806
|
+
*/
|
|
1807
|
+
type LeafPaths<T, D extends number = 10> = [D] extends [never] ? never : T extends Primitive ? never : T extends readonly (infer E)[] ? LeafPaths<E, Prev[D]> extends infer P ? P extends string ? `${number}.${P}` : never : never : { [K in keyof T]: T[K] extends Primitive ? `${K & string}` : LeafPaths<T[K], Prev[D]> extends never ? never : `${K & string}.${LeafPaths<T[K], Prev[D]>}` }[keyof T];
|
|
1808
|
+
/**
|
|
1809
|
+
* Get the length of a path (number of segments)
|
|
1810
|
+
*
|
|
1811
|
+
* @example
|
|
1812
|
+
* ```ts
|
|
1813
|
+
* PathLength<'a.b.c'> // 3
|
|
1814
|
+
* PathLength<'single'> // 1
|
|
1815
|
+
* ```
|
|
1816
|
+
*/
|
|
1817
|
+
type PathLength<P extends string> = P extends '' ? 0 : P extends `${string}.${infer Rest}` ? Increment<PathLength<Rest>> : 1;
|
|
1818
|
+
type Increment<N extends number, Arr extends 0[] = []> = N extends Arr['length'] ? [...Arr, 0]['length'] : Increment<N, [...Arr, 0]>;
|
|
1819
|
+
/**
|
|
1820
|
+
* Get the parent path of a given path
|
|
1821
|
+
*
|
|
1822
|
+
* @example
|
|
1823
|
+
* ```ts
|
|
1824
|
+
* ParentPath<'a.b.c'> // 'a.b'
|
|
1825
|
+
* ParentPath<'a'> // ''
|
|
1826
|
+
* ```
|
|
1827
|
+
*/
|
|
1828
|
+
type ParentPath<P extends string> = P extends `${infer Head}.${infer _}` ? Head : '';
|
|
1829
|
+
/**
|
|
1830
|
+
* Get the last segment of a path
|
|
1831
|
+
*
|
|
1832
|
+
* @example
|
|
1833
|
+
* ```ts
|
|
1834
|
+
* PathLeaf<'a.b.c'> // 'c'
|
|
1835
|
+
* PathLeaf<'a'> // 'a'
|
|
1836
|
+
* ```
|
|
1837
|
+
*/
|
|
1838
|
+
type PathLeaf<P extends string> = P extends `${string}.${infer Tail}` ? PathLeaf<Tail> : P;
|
|
1839
|
+
//#endregion
|
|
1840
|
+
//#region src/perf/cache.d.ts
|
|
1841
|
+
/**
|
|
1842
|
+
* Type caching utilities
|
|
1843
|
+
*
|
|
1844
|
+
* These types help cache and memoize type computations.
|
|
1845
|
+
*/
|
|
1846
|
+
/**
|
|
1847
|
+
* Cached type - prevents re-computation
|
|
1848
|
+
*
|
|
1849
|
+
* @example
|
|
1850
|
+
* ```ts
|
|
1851
|
+
* type CachedResult = Cached<ComplexComputation>
|
|
1852
|
+
* ```
|
|
1853
|
+
*/
|
|
1854
|
+
type Cached<T> = T extends infer U ? {
|
|
1855
|
+
__cached: U;
|
|
1856
|
+
} : never;
|
|
1857
|
+
/**
|
|
1858
|
+
* Extract cached value
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* ```ts
|
|
1862
|
+
* type Value = CachedValue<Cached<string>> // string
|
|
1863
|
+
* ```
|
|
1864
|
+
*/
|
|
1865
|
+
type CachedValue<T> = T extends {
|
|
1866
|
+
__cached: infer U;
|
|
1867
|
+
} ? U : never;
|
|
1868
|
+
/**
|
|
1869
|
+
* Memoized type - remembers computation
|
|
1870
|
+
*
|
|
1871
|
+
* @example
|
|
1872
|
+
* ```ts
|
|
1873
|
+
* type Memo = Memoized<{ a: string } & { b: number }>
|
|
1874
|
+
* ```
|
|
1875
|
+
*/
|
|
1876
|
+
type Memoized<T> = T extends infer U ? U : never;
|
|
1877
|
+
/**
|
|
1878
|
+
* Type identity - prevents structural typing
|
|
1879
|
+
*/
|
|
1880
|
+
interface TypeIdentity<T> {
|
|
1881
|
+
__brand: T;
|
|
1882
|
+
}
|
|
1883
|
+
/**
|
|
1884
|
+
* Brand cache for memoization
|
|
1885
|
+
*/
|
|
1886
|
+
type BrandCache<T, B extends string> = T & {
|
|
1887
|
+
__brandCache: B;
|
|
1888
|
+
};
|
|
1889
|
+
/**
|
|
1890
|
+
* Resolve brand cache
|
|
1891
|
+
*/
|
|
1892
|
+
type ResolveBrandCache<T> = T extends {
|
|
1893
|
+
__brandCache: infer _;
|
|
1894
|
+
} ? Omit<T, '__brandCache'> : T;
|
|
1895
|
+
/**
|
|
1896
|
+
* Cached intersection
|
|
1897
|
+
*/
|
|
1898
|
+
type CachedIntersection<A, B> = Cached<A & B>;
|
|
1899
|
+
/**
|
|
1900
|
+
* Cached union
|
|
1901
|
+
*/
|
|
1902
|
+
type CachedUnion<A, B> = Cached<A | B>;
|
|
1903
|
+
/**
|
|
1904
|
+
* Cached keyof
|
|
1905
|
+
*/
|
|
1906
|
+
type CachedKeyOf<T> = Cached<keyof T>;
|
|
1907
|
+
/**
|
|
1908
|
+
* Cached property access
|
|
1909
|
+
*/
|
|
1910
|
+
type CachedProperty<T, K extends keyof T> = Cached<T[K]>;
|
|
1911
|
+
/**
|
|
1912
|
+
* Type computation cache key
|
|
1913
|
+
*/
|
|
1914
|
+
type CacheKey<T> = symbol & {
|
|
1915
|
+
__cacheKey: T;
|
|
1916
|
+
};
|
|
1917
|
+
/**
|
|
1918
|
+
* Cache entry
|
|
1919
|
+
*/
|
|
1920
|
+
interface CacheEntry<K, V> {
|
|
1921
|
+
key: K;
|
|
1922
|
+
value: V;
|
|
1923
|
+
timestamp: number;
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* Type cache structure
|
|
1927
|
+
*/
|
|
1928
|
+
type TypeCache<T extends Record<string, unknown>> = { [K in keyof T]: Cached<T[K]> };
|
|
1929
|
+
/**
|
|
1930
|
+
* Flush cache - force re-computation
|
|
1931
|
+
*/
|
|
1932
|
+
type FlushCache<T> = T extends Cached<infer U> ? U : T;
|
|
1933
|
+
//#endregion
|
|
1934
|
+
//#region src/perf/lazy.d.ts
|
|
1935
|
+
/**
|
|
1936
|
+
* Lazy type evaluation utilities
|
|
1937
|
+
*
|
|
1938
|
+
* These types help defer type evaluation for better compilation performance.
|
|
1939
|
+
*/
|
|
1940
|
+
/**
|
|
1941
|
+
* Lazy type wrapper - defers type evaluation
|
|
1942
|
+
*
|
|
1943
|
+
* @example
|
|
1944
|
+
* ```ts
|
|
1945
|
+
* // Instead of complex immediate evaluation
|
|
1946
|
+
* type Result = Lazy<ComplexUnion>
|
|
1947
|
+
* ```
|
|
1948
|
+
*/
|
|
1949
|
+
type Lazy<T> = () => T;
|
|
1950
|
+
/**
|
|
1951
|
+
* Force evaluate a lazy type
|
|
1952
|
+
*
|
|
1953
|
+
* @example
|
|
1954
|
+
* ```ts
|
|
1955
|
+
* type Deferred = Lazy<string>
|
|
1956
|
+
* type Evaluated = ForceEvaluate<Deferred> // string
|
|
1957
|
+
* ```
|
|
1958
|
+
*/
|
|
1959
|
+
type ForceEvaluate<T> = T extends (() => infer R) ? R : T;
|
|
1960
|
+
/**
|
|
1961
|
+
* Deferred type - prevents immediate expansion
|
|
954
1962
|
*
|
|
955
1963
|
* @example
|
|
956
1964
|
* ```ts
|
|
957
|
-
*
|
|
958
|
-
* GreaterThan<3, 5> // false
|
|
1965
|
+
* type Complex = Deferred<{ a: string } & { b: number }>
|
|
959
1966
|
* ```
|
|
960
1967
|
*/
|
|
961
|
-
type
|
|
1968
|
+
type Deferred<T> = T extends infer U ? U : never;
|
|
962
1969
|
/**
|
|
963
|
-
*
|
|
1970
|
+
* Thunk type - zero-argument function returning a type
|
|
964
1971
|
*
|
|
965
1972
|
* @example
|
|
966
1973
|
* ```ts
|
|
967
|
-
*
|
|
968
|
-
*
|
|
1974
|
+
* type StringThunk = Thunk<string>
|
|
1975
|
+
* // () => string
|
|
969
1976
|
* ```
|
|
970
1977
|
*/
|
|
971
|
-
type
|
|
1978
|
+
type Thunk<T> = () => T;
|
|
972
1979
|
/**
|
|
973
|
-
*
|
|
1980
|
+
* Lazy property access
|
|
974
1981
|
*
|
|
975
1982
|
* @example
|
|
976
1983
|
* ```ts
|
|
977
|
-
*
|
|
978
|
-
*
|
|
1984
|
+
* type Props = { a: string; b: number; c: boolean }
|
|
1985
|
+
* type LazyA = LazyKey<Props, 'a'> // () => Props['a']
|
|
979
1986
|
* ```
|
|
980
1987
|
*/
|
|
981
|
-
type
|
|
1988
|
+
type LazyKey<T, K extends keyof T> = () => T[K];
|
|
982
1989
|
/**
|
|
983
|
-
*
|
|
1990
|
+
* Lazy conditional - defers conditional evaluation
|
|
984
1991
|
*
|
|
985
1992
|
* @example
|
|
986
1993
|
* ```ts
|
|
987
|
-
*
|
|
988
|
-
*
|
|
1994
|
+
* type Cond = LazyConditional<true, string, number>
|
|
1995
|
+
* // () => string
|
|
989
1996
|
* ```
|
|
990
1997
|
*/
|
|
991
|
-
type
|
|
1998
|
+
type LazyConditional<C extends boolean, T, F> = C extends true ? () => T : () => F;
|
|
1999
|
+
/**
|
|
2000
|
+
* Lazy array element
|
|
2001
|
+
*/
|
|
2002
|
+
type LazyArrayElement<T> = T extends readonly (infer E)[] ? () => E : never;
|
|
2003
|
+
/**
|
|
2004
|
+
* Lazy promise unwrap
|
|
2005
|
+
*/
|
|
2006
|
+
type LazyAwaited<T> = T extends PromiseLike<infer U> ? () => U : () => T;
|
|
2007
|
+
/**
|
|
2008
|
+
* Lazy function return
|
|
2009
|
+
*/
|
|
2010
|
+
type LazyReturnType<T> = T extends ((...args: any[]) => infer R) ? () => R : never;
|
|
2011
|
+
/**
|
|
2012
|
+
* Lazy function parameters
|
|
2013
|
+
*/
|
|
2014
|
+
type LazyParameters<T> = T extends ((...args: infer P) => any) ? () => P : never;
|
|
2015
|
+
/**
|
|
2016
|
+
* Chain lazy evaluations
|
|
2017
|
+
*/
|
|
2018
|
+
type LazyChain<T, F extends (value: T) => unknown> = () => ReturnType<F>;
|
|
2019
|
+
/**
|
|
2020
|
+
* Lazy map over array type
|
|
2021
|
+
*/
|
|
2022
|
+
type LazyMap<T extends readonly unknown[], F extends (value: T[number]) => unknown> = { [K in keyof T]: () => ReturnType<F> };
|
|
992
2023
|
//#endregion
|
|
993
|
-
//#region src/
|
|
2024
|
+
//#region src/perf/optimize.d.ts
|
|
994
2025
|
/**
|
|
995
|
-
*
|
|
2026
|
+
* Type optimization utilities
|
|
2027
|
+
*
|
|
2028
|
+
* These types help simplify and optimize complex types for better compilation.
|
|
996
2029
|
*/
|
|
997
|
-
type Primitive = string | number | boolean | null | undefined | symbol | bigint | Date | RegExp;
|
|
998
|
-
type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
|
|
999
2030
|
/**
|
|
1000
|
-
*
|
|
2031
|
+
* Simplify complex types - flatten intersections
|
|
1001
2032
|
*
|
|
1002
2033
|
* @example
|
|
1003
2034
|
* ```ts
|
|
1004
|
-
*
|
|
1005
|
-
*
|
|
1006
|
-
*
|
|
1007
|
-
* }
|
|
1008
|
-
* }
|
|
1009
|
-
*
|
|
1010
|
-
* ValidPath<Obj, 'a.b'> // true
|
|
1011
|
-
* ValidPath<Obj, 'a.c'> // false
|
|
2035
|
+
* type Complex = { a: string } & { b: number }
|
|
2036
|
+
* type Simple = Simplify<Complex>
|
|
2037
|
+
* // { a: string; b: number }
|
|
1012
2038
|
* ```
|
|
1013
2039
|
*/
|
|
1014
|
-
type
|
|
2040
|
+
type Simplify<T> = { [K in keyof T]: T[K] } & unknown;
|
|
1015
2041
|
/**
|
|
1016
|
-
*
|
|
2042
|
+
* Deep simplify - recursively flatten types
|
|
1017
2043
|
*
|
|
1018
2044
|
* @example
|
|
1019
2045
|
* ```ts
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1022
|
-
*
|
|
2046
|
+
* type Nested = { a: { b: string } & { c: number } }
|
|
2047
|
+
* type Deep = DeepSimplify<Nested>
|
|
2048
|
+
* ```
|
|
2049
|
+
*/
|
|
2050
|
+
type DeepSimplify<T> = T extends object ? T extends ((...args: any[]) => any) ? T : T extends Array<infer E> ? DeepSimplify<E>[] : { [K in keyof T]: DeepSimplify<T[K]> } : T;
|
|
2051
|
+
/**
|
|
2052
|
+
* Flatten type - remove extra intersections
|
|
1023
2053
|
*
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
2054
|
+
* @example
|
|
2055
|
+
* ```ts
|
|
2056
|
+
* type Flat = FlattenType<{ a: string } & { b: number } & { c: boolean }>
|
|
2057
|
+
* // { a: string; b: number; c: boolean }
|
|
1026
2058
|
* ```
|
|
1027
2059
|
*/
|
|
1028
|
-
type
|
|
2060
|
+
type FlattenType<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
|
|
1029
2061
|
/**
|
|
1030
|
-
*
|
|
2062
|
+
* Reduce intersection - simplify intersection types
|
|
1031
2063
|
*
|
|
1032
2064
|
* @example
|
|
1033
2065
|
* ```ts
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1036
|
-
*
|
|
2066
|
+
* type Reduced = ReduceIntersection<{ a: string } & { a: string; b: number }>
|
|
2067
|
+
* // { a: string; b: number }
|
|
2068
|
+
* ```
|
|
2069
|
+
*/
|
|
2070
|
+
type ReduceIntersection<T> = T extends infer U ? Simplify<U> : never;
|
|
2071
|
+
/**
|
|
2072
|
+
* Reduce union - remove duplicate union members
|
|
1037
2073
|
*
|
|
1038
|
-
*
|
|
1039
|
-
*
|
|
2074
|
+
* @example
|
|
2075
|
+
* ```ts
|
|
2076
|
+
* type Reduced = ReduceUnion<string | number | string>
|
|
2077
|
+
* // string | number
|
|
1040
2078
|
* ```
|
|
1041
2079
|
*/
|
|
1042
|
-
type
|
|
2080
|
+
type ReduceUnion<T> = T extends infer U ? U : never;
|
|
1043
2081
|
/**
|
|
1044
|
-
*
|
|
2082
|
+
* Compact type - remove never and undefined from objects
|
|
1045
2083
|
*
|
|
1046
2084
|
* @example
|
|
1047
2085
|
* ```ts
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
2086
|
+
* type Compacted = Compact<{ a: string; b: never; c?: undefined }>
|
|
2087
|
+
* // { a: string }
|
|
1050
2088
|
* ```
|
|
1051
2089
|
*/
|
|
1052
|
-
type
|
|
1053
|
-
type Increment<N extends number, Arr extends 0[] = []> = N extends Arr['length'] ? [...Arr, 0]['length'] : Increment<N, [...Arr, 0]>;
|
|
2090
|
+
type Compact<T> = { [K in keyof T as T[K] extends never ? never : undefined extends T[K] ? never : K]: T[K] };
|
|
1054
2091
|
/**
|
|
1055
|
-
*
|
|
2092
|
+
* Strip never from object
|
|
1056
2093
|
*
|
|
1057
2094
|
* @example
|
|
1058
2095
|
* ```ts
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
2096
|
+
* type Stripped = StripNever<{ a: string; b: never; c: number }>
|
|
2097
|
+
* // { a: string; c: number }
|
|
1061
2098
|
* ```
|
|
1062
2099
|
*/
|
|
1063
|
-
type
|
|
2100
|
+
type StripNever<T> = { [K in keyof T as T[K] extends never ? never : K]: T[K] };
|
|
1064
2101
|
/**
|
|
1065
|
-
*
|
|
2102
|
+
* Strip undefined from object
|
|
1066
2103
|
*
|
|
1067
2104
|
* @example
|
|
1068
2105
|
* ```ts
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
2106
|
+
* type Stripped = StripUndefined<{ a: string; b?: undefined; c: number }>
|
|
2107
|
+
* // { a: string; c: number }
|
|
1071
2108
|
* ```
|
|
1072
2109
|
*/
|
|
1073
|
-
type
|
|
2110
|
+
type StripUndefined<T> = { [K in keyof T as undefined extends T[K] ? never : K]: T[K] };
|
|
2111
|
+
/**
|
|
2112
|
+
* Strip null from object
|
|
2113
|
+
*/
|
|
2114
|
+
type StripNull<T> = { [K in keyof T as null extends T[K] ? never : K]: T[K] };
|
|
2115
|
+
/**
|
|
2116
|
+
* Merge all - deeply merge object types
|
|
2117
|
+
*/
|
|
2118
|
+
type MergeAll<T extends object[]> = T extends [infer First extends object, ...infer Rest extends object[]] ? Rest extends [] ? Simplify<First> : Simplify<First & MergeAll<Rest>> : Record<string, never>;
|
|
2119
|
+
/**
|
|
2120
|
+
* Pick non-nullable - pick only non-nullable properties
|
|
2121
|
+
*/
|
|
2122
|
+
type PickNonNullable<T> = { [K in keyof T as null | undefined extends T[K] ? never : K]: T[K] };
|
|
2123
|
+
/**
|
|
2124
|
+
* Pick nullable - pick only nullable properties
|
|
2125
|
+
*/
|
|
2126
|
+
type PickNullable<T> = { [K in keyof T as null | undefined extends T[K] ? K : never]: T[K] };
|
|
2127
|
+
/**
|
|
2128
|
+
* Type equivalence check (optimized)
|
|
2129
|
+
*/
|
|
2130
|
+
type TypeEq<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
|
|
2131
|
+
/**
|
|
2132
|
+
* Exact type - ensure exact shape match
|
|
2133
|
+
*/
|
|
2134
|
+
type ExactType<T, Shape> = T extends Shape ? Exclude<keyof T, keyof Shape> extends never ? T : never : never;
|
|
2135
|
+
/**
|
|
2136
|
+
* Normalize - remove optional markers while preserving types
|
|
2137
|
+
*/
|
|
2138
|
+
type Normalize<T> = { [K in keyof T]-?: T[K] };
|
|
2139
|
+
/**
|
|
2140
|
+
* Optionalize - make all properties optional
|
|
2141
|
+
*/
|
|
2142
|
+
type Optionalize<T> = { [K in keyof T]?: T[K] };
|
|
1074
2143
|
//#endregion
|
|
1075
2144
|
//#region src/record/index.d.ts
|
|
1076
2145
|
/**
|
|
@@ -1181,6 +2250,569 @@ type HasKeys<T, K extends keyof any> = K extends keyof T ? T : never;
|
|
|
1181
2250
|
*/
|
|
1182
2251
|
type HasExactKeys<T, K extends keyof any> = keyof T extends K ? K extends keyof T ? true : false : false;
|
|
1183
2252
|
//#endregion
|
|
2253
|
+
//#region src/schema/runtime.d.ts
|
|
2254
|
+
/**
|
|
2255
|
+
* Runtime type checking utilities
|
|
2256
|
+
*/
|
|
2257
|
+
/**
|
|
2258
|
+
* Runtime type guard function type
|
|
2259
|
+
*
|
|
2260
|
+
* @example
|
|
2261
|
+
* ```ts
|
|
2262
|
+
* const isString: RuntimeGuard<string> = (value): value is string =>
|
|
2263
|
+
* typeof value === 'string'
|
|
2264
|
+
* ```
|
|
2265
|
+
*/
|
|
2266
|
+
type RuntimeGuard<T> = (value: unknown) => value is T;
|
|
2267
|
+
/**
|
|
2268
|
+
* Extract the guarded type from a type guard function
|
|
2269
|
+
*
|
|
2270
|
+
* @example
|
|
2271
|
+
* ```ts
|
|
2272
|
+
* const isNumber = (value: unknown): value is number => typeof value === 'number'
|
|
2273
|
+
* type Num = GuardedType<typeof isNumber> // number
|
|
2274
|
+
* ```
|
|
2275
|
+
*/
|
|
2276
|
+
type GuardedType<G> = G extends ((value: unknown) => value is infer T) ? T : never;
|
|
2277
|
+
/**
|
|
2278
|
+
* Check if a type has a runtime check function
|
|
2279
|
+
*
|
|
2280
|
+
* @example
|
|
2281
|
+
* ```ts
|
|
2282
|
+
* type A = HasRuntimeCheck<string> // true (typeof check)
|
|
2283
|
+
* type B = HasRuntimeCheck<object> // false (no direct check)
|
|
2284
|
+
* ```
|
|
2285
|
+
*/
|
|
2286
|
+
type HasRuntimeCheck<T> = T extends string | number | boolean | symbol | bigint | null | undefined ? true : T extends Array<infer _> ? true : T extends Map<infer _, infer _> ? true : T extends Set<infer _> ? true : T extends Date ? true : false;
|
|
2287
|
+
/**
|
|
2288
|
+
* Primitive type guard mapping
|
|
2289
|
+
*/
|
|
2290
|
+
interface PrimitiveGuardMap {
|
|
2291
|
+
string: (value: unknown) => value is string;
|
|
2292
|
+
number: (value: unknown) => value is number;
|
|
2293
|
+
boolean: (value: unknown) => value is boolean;
|
|
2294
|
+
symbol: (value: unknown) => value is symbol;
|
|
2295
|
+
bigint: (value: unknown) => value is bigint;
|
|
2296
|
+
null: (value: unknown) => value is null;
|
|
2297
|
+
undefined: (value: unknown) => value is undefined;
|
|
2298
|
+
}
|
|
2299
|
+
/**
|
|
2300
|
+
* Get primitive guard type
|
|
2301
|
+
*/
|
|
2302
|
+
type PrimitiveGuard<T extends keyof PrimitiveGuardMap> = PrimitiveGuardMap[T];
|
|
2303
|
+
/**
|
|
2304
|
+
* Composite type guard for objects
|
|
2305
|
+
*
|
|
2306
|
+
* @example
|
|
2307
|
+
* ```ts
|
|
2308
|
+
* interface User {
|
|
2309
|
+
* name: string
|
|
2310
|
+
* age: number
|
|
2311
|
+
* }
|
|
2312
|
+
*
|
|
2313
|
+
* const isUser: CompositeGuard<User> = (value): value is User => {
|
|
2314
|
+
* return typeof value === 'object' && value !== null &&
|
|
2315
|
+
* 'name' in value && 'age' in value
|
|
2316
|
+
* }
|
|
2317
|
+
* ```
|
|
2318
|
+
*/
|
|
2319
|
+
type CompositeGuard<T extends object> = (value: unknown) => value is T;
|
|
2320
|
+
/**
|
|
2321
|
+
* Array element guard
|
|
2322
|
+
*/
|
|
2323
|
+
type ArrayElementGuard<T> = (value: unknown) => value is T[];
|
|
2324
|
+
/**
|
|
2325
|
+
* Create a type guard that checks for null
|
|
2326
|
+
*/
|
|
2327
|
+
type NullGuard = RuntimeGuard<null>;
|
|
2328
|
+
/**
|
|
2329
|
+
* Create a type guard that checks for undefined
|
|
2330
|
+
*/
|
|
2331
|
+
type UndefinedGuard = RuntimeGuard<undefined>;
|
|
2332
|
+
/**
|
|
2333
|
+
* Create a type guard that checks for null or undefined
|
|
2334
|
+
*/
|
|
2335
|
+
type NullishGuard = RuntimeGuard<null | undefined>;
|
|
2336
|
+
/**
|
|
2337
|
+
* Negate a type guard
|
|
2338
|
+
*
|
|
2339
|
+
* @example
|
|
2340
|
+
* ```ts
|
|
2341
|
+
* const isNotString: NegateGuard<string> = (value): value is Exclude<unknown, string> =>
|
|
2342
|
+
* typeof value !== 'string'
|
|
2343
|
+
* ```
|
|
2344
|
+
*/
|
|
2345
|
+
type NegateGuard<T> = (value: unknown) => value is Exclude<unknown, T>;
|
|
2346
|
+
/**
|
|
2347
|
+
* Combine multiple type guards (AND)
|
|
2348
|
+
*/
|
|
2349
|
+
type CombinedGuard<T, U> = (value: unknown) => value is T & U;
|
|
2350
|
+
/**
|
|
2351
|
+
* Union type guard (OR)
|
|
2352
|
+
*/
|
|
2353
|
+
type UnionGuard<T, U> = (value: unknown) => value is T | U;
|
|
2354
|
+
/**
|
|
2355
|
+
* Type predicate helper
|
|
2356
|
+
*/
|
|
2357
|
+
type TypePredicate = (value: unknown) => boolean;
|
|
2358
|
+
/**
|
|
2359
|
+
* Assertion function type
|
|
2360
|
+
*/
|
|
2361
|
+
type AssertionFunction<T> = (value: unknown) => asserts value is T;
|
|
2362
|
+
/**
|
|
2363
|
+
* Convert type to guard name mapping
|
|
2364
|
+
*/
|
|
2365
|
+
type TypeToGuardKey<T> = T extends string ? 'string' : T extends number ? 'number' : T extends boolean ? 'boolean' : T extends symbol ? 'symbol' : T extends bigint ? 'bigint' : T extends null ? 'null' : T extends undefined ? 'undefined' : never;
|
|
2366
|
+
/**
|
|
2367
|
+
* Type guard for any value
|
|
2368
|
+
*/
|
|
2369
|
+
type AnyGuard = RuntimeGuard<unknown>;
|
|
2370
|
+
//#endregion
|
|
2371
|
+
//#region src/schema/yup.d.ts
|
|
2372
|
+
/**
|
|
2373
|
+
* Yup schema integration types
|
|
2374
|
+
*
|
|
2375
|
+
* These types work with Yup schemas to provide type extraction and manipulation.
|
|
2376
|
+
* Note: Yup is an optional peer dependency.
|
|
2377
|
+
*/
|
|
2378
|
+
declare const YupTypeSymbol: unique symbol;
|
|
2379
|
+
/**
|
|
2380
|
+
* Base Yup schema type stub
|
|
2381
|
+
*/
|
|
2382
|
+
interface YupSchemaStub<T = unknown> {
|
|
2383
|
+
[YupTypeSymbol]?: T;
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Extract the output type from a Yup schema
|
|
2387
|
+
*
|
|
2388
|
+
* @example
|
|
2389
|
+
* ```ts
|
|
2390
|
+
* import * as yup from 'yup'
|
|
2391
|
+
*
|
|
2392
|
+
* const UserSchema = yup.object({
|
|
2393
|
+
* name: yup.string().required(),
|
|
2394
|
+
* age: yup.number()
|
|
2395
|
+
* })
|
|
2396
|
+
*
|
|
2397
|
+
* type User = YupOutput<typeof UserSchema>
|
|
2398
|
+
* // { name: string; age?: number | undefined }
|
|
2399
|
+
* ```
|
|
2400
|
+
*/
|
|
2401
|
+
type YupOutput<T> = T extends {
|
|
2402
|
+
__outputType: infer O;
|
|
2403
|
+
} ? O : T extends {
|
|
2404
|
+
spec: object;
|
|
2405
|
+
} ? T : never;
|
|
2406
|
+
/**
|
|
2407
|
+
* Extract the input type from a Yup schema
|
|
2408
|
+
*
|
|
2409
|
+
* @example
|
|
2410
|
+
* ```ts
|
|
2411
|
+
* import * as yup from 'yup'
|
|
2412
|
+
*
|
|
2413
|
+
* const UserSchema = yup.object({
|
|
2414
|
+
* name: yup.string().required(),
|
|
2415
|
+
* age: yup.number()
|
|
2416
|
+
* })
|
|
2417
|
+
*
|
|
2418
|
+
* type UserInput = YupInput<typeof UserSchema>
|
|
2419
|
+
* // { name: string; age?: number | undefined }
|
|
2420
|
+
* ```
|
|
2421
|
+
*/
|
|
2422
|
+
type YupInput<T> = T extends {
|
|
2423
|
+
__inputType: infer I;
|
|
2424
|
+
} ? I : T extends {
|
|
2425
|
+
spec: object;
|
|
2426
|
+
} ? T : never;
|
|
2427
|
+
/**
|
|
2428
|
+
* Check if a type is a Yup schema
|
|
2429
|
+
*
|
|
2430
|
+
* @example
|
|
2431
|
+
* ```ts
|
|
2432
|
+
* import * as yup from 'yup'
|
|
2433
|
+
*
|
|
2434
|
+
* type A = IsYupSchema<yup.StringSchema> // true
|
|
2435
|
+
* type B = IsYupSchema<string> // false
|
|
2436
|
+
* ```
|
|
2437
|
+
*/
|
|
2438
|
+
type IsYupSchema<T> = T extends {
|
|
2439
|
+
spec: object;
|
|
2440
|
+
} ? true : T extends {
|
|
2441
|
+
__isYupSchema: true;
|
|
2442
|
+
} ? true : false;
|
|
2443
|
+
/**
|
|
2444
|
+
* Extract the inner type from Yup optional schema
|
|
2445
|
+
*/
|
|
2446
|
+
type YupUnwrapOptional<T> = T extends {
|
|
2447
|
+
_innerType: infer I;
|
|
2448
|
+
} ? I : T;
|
|
2449
|
+
/**
|
|
2450
|
+
* Check if Yup schema is optional
|
|
2451
|
+
*/
|
|
2452
|
+
type IsYupOptional<T> = T extends {
|
|
2453
|
+
spec: {
|
|
2454
|
+
optional: true;
|
|
2455
|
+
};
|
|
2456
|
+
} ? true : T extends {
|
|
2457
|
+
_nullable: true;
|
|
2458
|
+
} ? true : false;
|
|
2459
|
+
/**
|
|
2460
|
+
* Check if Yup schema is nullable
|
|
2461
|
+
*/
|
|
2462
|
+
type IsYupNullable<T> = T extends {
|
|
2463
|
+
spec: {
|
|
2464
|
+
nullable: true;
|
|
2465
|
+
};
|
|
2466
|
+
} ? true : T extends {
|
|
2467
|
+
_nullable: true;
|
|
2468
|
+
} ? true : false;
|
|
2469
|
+
/**
|
|
2470
|
+
* Get the element type from Yup array schema
|
|
2471
|
+
*/
|
|
2472
|
+
type YupArrayElement<T> = T extends {
|
|
2473
|
+
_subType: infer E;
|
|
2474
|
+
} ? E : T extends {
|
|
2475
|
+
innerType: infer E;
|
|
2476
|
+
} ? E : never;
|
|
2477
|
+
/**
|
|
2478
|
+
* Convert Yup schema to TypeScript type (alias for YupOutput)
|
|
2479
|
+
*/
|
|
2480
|
+
type YupToType<T> = YupOutput<T>;
|
|
2481
|
+
/**
|
|
2482
|
+
* Get Yup schema fields from object schema
|
|
2483
|
+
*/
|
|
2484
|
+
type YupFields<T> = T extends {
|
|
2485
|
+
fields: infer F;
|
|
2486
|
+
} ? F : T extends {
|
|
2487
|
+
_subFields: infer F;
|
|
2488
|
+
} ? F : never;
|
|
2489
|
+
/**
|
|
2490
|
+
* Required keys from Yup object schema
|
|
2491
|
+
*/
|
|
2492
|
+
type YupRequiredKeys<T> = T extends {
|
|
2493
|
+
fields: infer F;
|
|
2494
|
+
} ? { [K in keyof F]: F[K] extends {
|
|
2495
|
+
spec: {
|
|
2496
|
+
optional: true;
|
|
2497
|
+
};
|
|
2498
|
+
} ? never : F[K] extends {
|
|
2499
|
+
_optional: true;
|
|
2500
|
+
} ? never : K }[keyof F] : never;
|
|
2501
|
+
/**
|
|
2502
|
+
* Optional keys from Yup object schema
|
|
2503
|
+
*/
|
|
2504
|
+
type YupOptionalKeys<T> = T extends {
|
|
2505
|
+
fields: infer F;
|
|
2506
|
+
} ? { [K in keyof F]: F[K] extends {
|
|
2507
|
+
spec: {
|
|
2508
|
+
optional: true;
|
|
2509
|
+
};
|
|
2510
|
+
} ? K : F[K] extends {
|
|
2511
|
+
_optional: true;
|
|
2512
|
+
} ? K : never }[keyof F] : never;
|
|
2513
|
+
/**
|
|
2514
|
+
* Yup schema type names
|
|
2515
|
+
*/
|
|
2516
|
+
type YupTypeNames = 'StringSchema' | 'NumberSchema' | 'BooleanSchema' | 'DateSchema' | 'ArraySchema' | 'ObjectSchema' | 'MixedSchema' | 'TupleSchema' | 'Lazy';
|
|
2517
|
+
/**
|
|
2518
|
+
* Yup validation error type
|
|
2519
|
+
*/
|
|
2520
|
+
interface YupErrorType {
|
|
2521
|
+
name: 'ValidationError';
|
|
2522
|
+
value: unknown;
|
|
2523
|
+
path: string;
|
|
2524
|
+
type: string | undefined;
|
|
2525
|
+
errors: string[];
|
|
2526
|
+
inner: Array<{
|
|
2527
|
+
name: 'ValidationError';
|
|
2528
|
+
path: string;
|
|
2529
|
+
message: string;
|
|
2530
|
+
type: string | undefined;
|
|
2531
|
+
}>;
|
|
2532
|
+
}
|
|
2533
|
+
/**
|
|
2534
|
+
* Yup test config type
|
|
2535
|
+
*/
|
|
2536
|
+
interface YupTestConfig<T = unknown> {
|
|
2537
|
+
name: string;
|
|
2538
|
+
message: string | ((params: {
|
|
2539
|
+
value: unknown;
|
|
2540
|
+
path: string;
|
|
2541
|
+
}) => string);
|
|
2542
|
+
test: (value: T) => boolean | Promise<boolean>;
|
|
2543
|
+
}
|
|
2544
|
+
/**
|
|
2545
|
+
* Yup transform function type
|
|
2546
|
+
*/
|
|
2547
|
+
type YupTransform<T = unknown, R = unknown> = (value: T, originalValue: T) => R;
|
|
2548
|
+
//#endregion
|
|
2549
|
+
//#region src/schema/zod.d.ts
|
|
2550
|
+
/**
|
|
2551
|
+
* Zod schema integration types
|
|
2552
|
+
*
|
|
2553
|
+
* These types work with Zod schemas to provide type extraction and manipulation.
|
|
2554
|
+
* Note: Zod is an optional peer dependency.
|
|
2555
|
+
*/
|
|
2556
|
+
declare const ZodTypeSymbol: unique symbol;
|
|
2557
|
+
/**
|
|
2558
|
+
* Base Zod schema type stub
|
|
2559
|
+
*/
|
|
2560
|
+
interface ZodTypeStub<T = unknown> {
|
|
2561
|
+
[ZodTypeSymbol]?: T;
|
|
2562
|
+
}
|
|
2563
|
+
/**
|
|
2564
|
+
* ZodObject shape stub
|
|
2565
|
+
*/
|
|
2566
|
+
type ZodObjectShapeStub = Record<string, ZodTypeStub>;
|
|
2567
|
+
/**
|
|
2568
|
+
* Extract the output type from a Zod schema
|
|
2569
|
+
*
|
|
2570
|
+
* @example
|
|
2571
|
+
* ```ts
|
|
2572
|
+
* import { z } from 'zod'
|
|
2573
|
+
*
|
|
2574
|
+
* const UserSchema = z.object({
|
|
2575
|
+
* name: z.string(),
|
|
2576
|
+
* age: z.number()
|
|
2577
|
+
* })
|
|
2578
|
+
*
|
|
2579
|
+
* type User = ZodOutput<typeof UserSchema>
|
|
2580
|
+
* // { name: string; age: number }
|
|
2581
|
+
* ```
|
|
2582
|
+
*/
|
|
2583
|
+
type ZodOutput<T> = T extends {
|
|
2584
|
+
_output: infer O;
|
|
2585
|
+
} ? O : T extends {
|
|
2586
|
+
_def: {
|
|
2587
|
+
type: string;
|
|
2588
|
+
};
|
|
2589
|
+
} ? T : never;
|
|
2590
|
+
/**
|
|
2591
|
+
* Extract the input type from a Zod schema
|
|
2592
|
+
*
|
|
2593
|
+
* @example
|
|
2594
|
+
* ```ts
|
|
2595
|
+
* import { z } from 'zod'
|
|
2596
|
+
*
|
|
2597
|
+
* const UserSchema = z.object({
|
|
2598
|
+
* name: z.string(),
|
|
2599
|
+
* age: z.number().optional()
|
|
2600
|
+
* })
|
|
2601
|
+
*
|
|
2602
|
+
* type UserInput = ZodInput<typeof UserSchema>
|
|
2603
|
+
* // { name: string; age?: number | undefined }
|
|
2604
|
+
* ```
|
|
2605
|
+
*/
|
|
2606
|
+
type ZodInput<T> = T extends {
|
|
2607
|
+
_input: infer I;
|
|
2608
|
+
} ? I : T extends {
|
|
2609
|
+
_def: {
|
|
2610
|
+
type: string;
|
|
2611
|
+
};
|
|
2612
|
+
} ? T : never;
|
|
2613
|
+
/**
|
|
2614
|
+
* Check if a type is a Zod schema
|
|
2615
|
+
*
|
|
2616
|
+
* @example
|
|
2617
|
+
* ```ts
|
|
2618
|
+
* import { z } from 'zod'
|
|
2619
|
+
*
|
|
2620
|
+
* type A = IsZodSchema<z.ZodString> // true
|
|
2621
|
+
* type B = IsZodSchema<string> // false
|
|
2622
|
+
* ```
|
|
2623
|
+
*/
|
|
2624
|
+
type IsZodSchema<T> = T extends {
|
|
2625
|
+
_def: object;
|
|
2626
|
+
} ? true : false;
|
|
2627
|
+
/**
|
|
2628
|
+
* Extract shape from ZodObject
|
|
2629
|
+
*
|
|
2630
|
+
* @example
|
|
2631
|
+
* ```ts
|
|
2632
|
+
* import { z } from 'zod'
|
|
2633
|
+
*
|
|
2634
|
+
* const UserSchema = z.object({
|
|
2635
|
+
* name: z.string(),
|
|
2636
|
+
* age: z.number()
|
|
2637
|
+
* })
|
|
2638
|
+
*
|
|
2639
|
+
* type Shape = ZodShape<typeof UserSchema>
|
|
2640
|
+
* // { name: ZodString; age: ZodNumber }
|
|
2641
|
+
* ```
|
|
2642
|
+
*/
|
|
2643
|
+
type ZodShape<T> = T extends {
|
|
2644
|
+
_def: {
|
|
2645
|
+
shape: () => infer S;
|
|
2646
|
+
};
|
|
2647
|
+
} ? S : T extends {
|
|
2648
|
+
shape: infer S;
|
|
2649
|
+
} ? S : never;
|
|
2650
|
+
/**
|
|
2651
|
+
* Extract the inner type from ZodOptional
|
|
2652
|
+
*/
|
|
2653
|
+
type ZodUnwrapOptional<T> = T extends {
|
|
2654
|
+
_def: {
|
|
2655
|
+
innerType: infer I;
|
|
2656
|
+
};
|
|
2657
|
+
} ? I : T;
|
|
2658
|
+
/**
|
|
2659
|
+
* Extract the inner type from ZodNullable
|
|
2660
|
+
*/
|
|
2661
|
+
type ZodUnwrapNullable<T> = T extends {
|
|
2662
|
+
_def: {
|
|
2663
|
+
innerType: infer I;
|
|
2664
|
+
};
|
|
2665
|
+
} ? I : T;
|
|
2666
|
+
/**
|
|
2667
|
+
* Check if Zod schema is optional
|
|
2668
|
+
*/
|
|
2669
|
+
type IsZodOptional<T> = T extends {
|
|
2670
|
+
_def: {
|
|
2671
|
+
typeName: 'ZodOptional';
|
|
2672
|
+
};
|
|
2673
|
+
} ? true : false;
|
|
2674
|
+
/**
|
|
2675
|
+
* Check if Zod schema is nullable
|
|
2676
|
+
*/
|
|
2677
|
+
type IsZodNullable<T> = T extends {
|
|
2678
|
+
_def: {
|
|
2679
|
+
typeName: 'ZodNullable';
|
|
2680
|
+
};
|
|
2681
|
+
} ? true : false;
|
|
2682
|
+
/**
|
|
2683
|
+
* Get the element type from ZodArray
|
|
2684
|
+
*/
|
|
2685
|
+
type ZodArrayElement<T> = T extends {
|
|
2686
|
+
_def: {
|
|
2687
|
+
type: 'array';
|
|
2688
|
+
elementType: infer E;
|
|
2689
|
+
};
|
|
2690
|
+
} ? E : T extends {
|
|
2691
|
+
element: infer E;
|
|
2692
|
+
} ? E : never;
|
|
2693
|
+
/**
|
|
2694
|
+
* Get value type from ZodRecord
|
|
2695
|
+
*/
|
|
2696
|
+
type ZodRecordValue<T> = T extends {
|
|
2697
|
+
_def: {
|
|
2698
|
+
valueType: infer V;
|
|
2699
|
+
};
|
|
2700
|
+
} ? V : never;
|
|
2701
|
+
/**
|
|
2702
|
+
* Get key and value types from ZodMap
|
|
2703
|
+
*/
|
|
2704
|
+
type ZodMapEntry<T> = T extends {
|
|
2705
|
+
_def: {
|
|
2706
|
+
keyType: infer K;
|
|
2707
|
+
valueType: infer V;
|
|
2708
|
+
};
|
|
2709
|
+
} ? {
|
|
2710
|
+
key: K;
|
|
2711
|
+
value: V;
|
|
2712
|
+
} : never;
|
|
2713
|
+
/**
|
|
2714
|
+
* Convert Zod schema to TypeScript type (alias for ZodOutput)
|
|
2715
|
+
*/
|
|
2716
|
+
type ZodToType<T> = ZodOutput<T>;
|
|
2717
|
+
/**
|
|
2718
|
+
* Deep partial input for Zod schemas
|
|
2719
|
+
*/
|
|
2720
|
+
type ZodDeepPartialInput<T> = T extends {
|
|
2721
|
+
_def: {
|
|
2722
|
+
typeName: 'ZodObject';
|
|
2723
|
+
shape: () => infer S;
|
|
2724
|
+
};
|
|
2725
|
+
} ? { [K in keyof S]?: ZodDeepPartialInput<S[K]> } : T extends {
|
|
2726
|
+
_def: {
|
|
2727
|
+
typeName: 'ZodArray';
|
|
2728
|
+
elementType: infer E;
|
|
2729
|
+
};
|
|
2730
|
+
} ? ZodDeepPartialInput<E>[] : T extends {
|
|
2731
|
+
_def: {
|
|
2732
|
+
typeName: 'ZodOptional';
|
|
2733
|
+
innerType: infer I;
|
|
2734
|
+
};
|
|
2735
|
+
} ? ZodDeepPartialInput<I> | undefined : T extends {
|
|
2736
|
+
_def: {
|
|
2737
|
+
typeName: 'ZodNullable';
|
|
2738
|
+
innerType: infer I;
|
|
2739
|
+
};
|
|
2740
|
+
} ? ZodDeepPartialInput<I> | null : T;
|
|
2741
|
+
/**
|
|
2742
|
+
* Required keys from ZodObject schema
|
|
2743
|
+
*/
|
|
2744
|
+
type ZodRequiredKeys<T> = T extends {
|
|
2745
|
+
_def: {
|
|
2746
|
+
shape: () => infer S;
|
|
2747
|
+
};
|
|
2748
|
+
} ? { [K in keyof S]: S[K] extends {
|
|
2749
|
+
_def: {
|
|
2750
|
+
typeName: 'ZodOptional';
|
|
2751
|
+
};
|
|
2752
|
+
} ? never : S[K] extends {
|
|
2753
|
+
_def: {
|
|
2754
|
+
typeName: 'ZodDefault';
|
|
2755
|
+
};
|
|
2756
|
+
} ? never : K }[keyof S] : never;
|
|
2757
|
+
/**
|
|
2758
|
+
* Optional keys from ZodObject schema
|
|
2759
|
+
*/
|
|
2760
|
+
type ZodOptionalKeys<T> = T extends {
|
|
2761
|
+
_def: {
|
|
2762
|
+
shape: () => infer S;
|
|
2763
|
+
};
|
|
2764
|
+
} ? { [K in keyof S]: S[K] extends {
|
|
2765
|
+
_def: {
|
|
2766
|
+
typeName: 'ZodOptional';
|
|
2767
|
+
};
|
|
2768
|
+
} ? K : S[K] extends {
|
|
2769
|
+
_def: {
|
|
2770
|
+
typeName: 'ZodDefault';
|
|
2771
|
+
};
|
|
2772
|
+
} ? K : never }[keyof S] : never;
|
|
2773
|
+
/**
|
|
2774
|
+
* Pick properties from ZodObject schema
|
|
2775
|
+
*/
|
|
2776
|
+
type ZodPick<T, K extends keyof ZodShape<T>> = T extends {
|
|
2777
|
+
_def: {
|
|
2778
|
+
shape: () => infer S;
|
|
2779
|
+
};
|
|
2780
|
+
} ? {
|
|
2781
|
+
_def: {
|
|
2782
|
+
shape: () => Pick<S, K & keyof S>;
|
|
2783
|
+
typeName: 'ZodObject';
|
|
2784
|
+
};
|
|
2785
|
+
} : never;
|
|
2786
|
+
/**
|
|
2787
|
+
* Omit properties from ZodObject schema
|
|
2788
|
+
*/
|
|
2789
|
+
type ZodOmit<T, K extends keyof ZodShape<T>> = T extends {
|
|
2790
|
+
_def: {
|
|
2791
|
+
shape: () => infer S;
|
|
2792
|
+
};
|
|
2793
|
+
} ? {
|
|
2794
|
+
_def: {
|
|
2795
|
+
shape: () => Omit<S, K & keyof S>;
|
|
2796
|
+
typeName: 'ZodObject';
|
|
2797
|
+
};
|
|
2798
|
+
} : never;
|
|
2799
|
+
/**
|
|
2800
|
+
* Get the error type from ZodError
|
|
2801
|
+
*/
|
|
2802
|
+
interface ZodErrorType {
|
|
2803
|
+
issues: Array<{
|
|
2804
|
+
code: string;
|
|
2805
|
+
message: string;
|
|
2806
|
+
path: (string | number)[];
|
|
2807
|
+
expected?: string;
|
|
2808
|
+
received?: string;
|
|
2809
|
+
}>;
|
|
2810
|
+
}
|
|
2811
|
+
/**
|
|
2812
|
+
* Zod schema type name mapping
|
|
2813
|
+
*/
|
|
2814
|
+
type ZodTypeNames = 'ZodString' | 'ZodNumber' | 'ZodBoolean' | 'ZodNull' | 'ZodUndefined' | 'ZodAny' | 'ZodUnknown' | 'ZodNever' | 'ZodVoid' | 'ZodArray' | 'ZodObject' | 'ZodUnion' | 'ZodIntersection' | 'ZodTuple' | 'ZodRecord' | 'ZodMap' | 'ZodSet' | 'ZodDate' | 'ZodFunction' | 'ZodLazy' | 'ZodLiteral' | 'ZodEnum' | 'ZodNativeEnum' | 'ZodPromise' | 'ZodBranded' | 'ZodOptional' | 'ZodNullable' | 'ZodDefault' | 'ZodCatch';
|
|
2815
|
+
//#endregion
|
|
1184
2816
|
//#region src/template/index.d.ts
|
|
1185
2817
|
/**
|
|
1186
2818
|
* Template literal type utilities for string manipulation
|
|
@@ -1317,4 +2949,4 @@ type PadStart<S extends string, N extends number, P extends string = ' '> = Stri
|
|
|
1317
2949
|
type PadEnd<S extends string, N extends number, P extends string = ' '> = StringLength<S> extends N ? S : N extends number ? `${PadEnd<S, Decrement<N>, P>}${P}` : S;
|
|
1318
2950
|
type Decrement<N extends number, Acc extends 0[] = []> = N extends 0 ? 0 : [...Acc, 0]['length'] extends N ? Acc['length'] : Decrement<N, [...Acc, 0]>;
|
|
1319
2951
|
//#endregion
|
|
1320
|
-
export { Add, And, AppendParameter, ArrayElement, ArrayPaths, Assert, AsyncReturnType, AtLeastOne, Awaited, Brand, BrandedNumber, BrandedString, CamelCase, CamelCaseKeys, CapitalizeAll, DataOnly, Dec, DeepMutable, DeepNonNullable, DeepNullable, DeepOmit, DeepOmitPaths, DeepOptional, DeepPartial, DeepPick, DeepPickPaths, DeepReadonly, DeepRequired, DeepRequiredProperties, EndsWith, Exact, Exclusive, FilterKeys, FirstParameter, Flatten, FunctionKeys, FunctionOnly, GreaterThan, HasExactKeys, HasKeys, Head, If, Immutable, Inc, Init, IsAny, IsArray, IsAsyncFunction, IsEmptyTuple, IsEqual, IsFunction, IsNever, IsTuple, IsUnknown, Keys, KeysByValueType, Last, LeafPaths, LessThan, Literal, LiteralBoolean, LiteralNumber, LiteralString, LoosePartial, Max, Maybe, Merge, Min, Mutable, NoNullish, NonFunctionKeys, NonNullable$1 as NonNullable, Not, NthParameter, Nullable, OmitPartial, OmitRequired, OmitThisParameter, Optional, OptionalKeys, OptionalParameters, Or, PadEnd, PadStart, Parameters, ParentPath, PascalCaseKeys, PathLeaf, PathLength, PathValue, Paths, PickPartial, PickRequired, PrefixKeys, PrependParameter, Range, ReadonlyKeys, RenameKeys, Repeat, Replace, ReplaceAll, Required$1 as Required, RequiredKeys, ReturnType, Reverse, SnakeCase, SnakeCaseKeys, SplitPath, StartsWith, StrictExclude, StrictExtract, StringLength, StringToArray, Subtract, SuffixKeys, Tail$1 as Tail, ThisParameterType, Trim, TrimLeft, TrimRight, TupleLength, Unbrand, UncapitalizeAll, UnionToIntersection, UnionToTuple, ValidPath, ValueOf, WritableKeys };
|
|
2952
|
+
export { Add, And, AnyGuard, AppendParameter, ArrayElement, ArrayElementGuard, ArrayPaths, Assert, AssertionFunction, AsyncReturnType, AtLeastOne, Awaited, Brand, BrandCache, BrandedNumber, BrandedString, CacheEntry, CacheKey, Cached, CachedIntersection, CachedKeyOf, CachedProperty, CachedUnion, CachedValue, CamelCase, CamelCaseKeys, CapitalizeAll, ChangeEventHandler, CombinedGuard, Compact, ComponentProps, ComponentPropsWithRef, CompositeGuard, DataOnly, Dec, DeepMutable, DeepNonNullable, DeepNullable, DeepOmit, DeepOmitPaths, DeepOptional, DeepPartial, DeepPick, DeepPickPaths, DeepReadonly, DeepRequired, DeepRequiredProperties, DeepSimplify, Deferred, EndsWith, EventHandler, Exact, ExactType, Exclusive, ExtractPropTypes, ExtractVueProps, FilterKeys, FirstParameter, Flatten, FlattenType, FlushCache, FocusEventHandler, ForceEvaluate, FormEventHandler, ForwardRefProps, FunctionKeys, FunctionOnly, GreaterThan, GuardedType, HasExactKeys, HasKeys, HasRuntimeCheck, Head, If, Immutable, Inc, Init, IsAny, IsArray, IsAsyncFunction, IsEmptyTuple, IsEqual, IsFunction, IsNever, IsTuple, IsUnknown, IsYupNullable, IsYupOptional, IsYupSchema, IsZodNullable, IsZodOptional, IsZodSchema, KeyboardEventHandler, Keys, KeysByValueType, Last, Lazy, LazyArrayElement, LazyAwaited, LazyChain, LazyConditional, LazyKey, LazyMap, LazyParameters, LazyReturnType, LeafPaths, LessThan, Literal, LiteralBoolean, LiteralNumber, LiteralString, LoosePartial, Max, Maybe, Memoized, Merge, MergeAll, MergeDefaultProps, Min, MouseEventHandler, Mutable, NegateGuard, NoNullish, NonFunctionKeys, NonNullable$1 as NonNullable, Normalize, NormalizeVueProps, Not, NthParameter, NullGuard, Nullable, NullishGuard, OmitPartial, OmitRequired, OmitThisParameter, Optional, OptionalKeys, OptionalParameters, OptionalProps, OptionalVueProp, Optionalize, Or, PadEnd, PadStart, Parameters, ParentPath, PascalCaseKeys, PathLeaf, PathLength, PathValue, Paths, PickNonNullable, PickNullable, PickPartial, PickRequired, PrefixKeys, PrependParameter, PrimitiveGuard, PrimitiveGuardMap, PrismaAggregateArgs, PrismaCountArgs, PrismaCreateArgs, PrismaCreateInput, PrismaDeleteArgs, PrismaFindFirstArgs, PrismaFindManyArgs, PrismaFindUniqueArgs, PrismaGroupByArgs, PrismaInclude, PrismaModel, PrismaOrderByInput, PrismaPagination, PrismaRelationFields, PrismaScalarFields, PrismaSelect, PrismaUniqueWhere, PrismaUpdateArgs, PrismaUpdateInput, PrismaUpsertArgs, PrismaWhereInput, PropsWithChildren, PropsWithClassName, PropsWithStyle, PropsWithStyleAndClassName, PropsWithoutChildren, Range, ReadonlyKeys, ReduceIntersection, ReduceUnion, RenameKeys, Repeat, Replace, ReplaceAll, Required$1 as Required, RequiredKeys, RequiredProps, RequiredVueProp, ResolveBrandCache, ReturnType$1 as ReturnType, Reverse, RuntimeGuard, Simplify, SnakeCase, SnakeCaseKeys, SplitPath, StartsWith, StrictExclude, StrictExtract, StringLength, StringToArray, StripNever, StripNull, StripUndefined, Subtract, SuffixKeys, TRPCCallerRouter, TRPCClient, TRPCContext, TRPCErrorShape, TRPCExtractProcedureType, TRPCMergeRouters, TRPCMiddleware, TRPCMutations, TRPCProcedureBuilder, TRPCProcedureCaller, TRPCProcedureInput, TRPCProcedureOutput, TRPCProcedureType, TRPCQueries, TRPCRouterRecord, TRPCRouterShape, TRPCSubscriptions, TRPSCaller, Tail$1 as Tail, ThisParameterType, Thunk, Trim, TrimLeft, TrimRight, TupleLength, TypeCache, TypeEq, TypeIdentity, TypePredicate, TypeToGuardKey, Unbrand, UncapitalizeAll, UndefinedGuard, UnionGuard, UnionToIntersection, UnionToTuple, ValidPath, ValueOf, VueComponentInstance, VueComputed, VueEmitType, VueExpose, VueInjectionKey, VueModelProps, VuePropConstructor, VuePropType, VuePropWithDefault, VuePropsToType, VueProvideInjectPair, VueRawProps, VueReactive, VueRef, VueSlot, VueSlots, WritableKeys, YupArrayElement, YupErrorType, YupFields, YupInput, YupOptionalKeys, YupOutput, YupRequiredKeys, YupSchemaStub, YupTestConfig, YupToType, YupTransform, YupTypeNames, YupUnwrapOptional, ZodArrayElement, ZodDeepPartialInput, ZodErrorType, ZodInput, ZodMapEntry, ZodObjectShapeStub, ZodOmit, ZodOptionalKeys, ZodOutput, ZodPick, ZodRecordValue, ZodRequiredKeys, ZodShape, ZodToType, ZodTypeNames, ZodTypeStub, ZodUnwrapNullable, ZodUnwrapOptional };
|