Created
February 26, 2024 01:59
-
-
Save so1ve/6e4d306ef8237f12bd34b0c2601b998d to your computer and use it in GitHub Desktop.
chain (buggy)
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
const LastSymbol = Symbol(); | |
type InitialLastType = typeof LastSymbol; | |
type GenerateChainArray<T extends any[], Last = InitialLastType> = T extends [] | |
? [] | |
: T extends [infer Head, ...infer Rest] | |
? [ | |
Last extends InitialLastType ? () => Head : (arg: Last) => Head, | |
...GenerateChainArray<Rest, Head>, | |
] | |
: []; | |
declare function chain<T extends any[]>(fns: GenerateChainArray<T>): boolean; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment