Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type True = {b};
- type False = {a};
- type NOT<X> = X extends True ? False : True;
- type AND<X,Y> = X extends True ? (Y extends True ? True : False) : False;
- type OR<X,Y> = X extends False ? (Y extends False ? False : True) : True;
- let x: NOT<OR<NOT<True>,False>>; // x : True
- type Num = any[];
- type Eval<T extends Num> = T['length'];
- type Zero = [];
- type Succ<N extends Num> = Prepend<1,N>;
- type Prepend<E, T extends any[]> = ((head: E, ...args: T) => any) extends ((...args: infer U) => any) ? U : T;
- let y: Eval<Succ<Succ<Zero>>>; // y : 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement