Last active
March 15, 2021 04:07
-
-
Save mscolnick/b16842ac4492fa4c60d2356565a914e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Plus1<A extends any[]> = [true, ...A]; | |
| type Add<A extends any[], B extends any[]> = [...A, ...B]; | |
| type Minus1<A extends any[]> = A extends readonly [any?, ...infer U] ? U : [...A]; | |
| type Minus2<A extends any[]> = Minus1<Minus1<A>>; | |
| // verify | |
| type D = Plus1<A>; // [true, true, true, true] | |
| type E = Minus1<A>; // [true, true] | |
| type F = Minus2<A>; // [true] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment