Created
October 4, 2018 03:32
-
-
Save babakness/9deb5eb317fc4436eecc4c39b3e8cbae to your computer and use it in GitHub Desktop.
Sample pipe function using overloads in TypeScript
This file contains 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
// Example taken from @type/ramda at the time of this writing. | |
pipe<T1>(fn0: () => T1): () => T1; | |
pipe<V0, T1>(fn0: (x0: V0) => T1): (x0: V0) => T1; | |
pipe<V0, V1, T1>(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1; | |
pipe<V0, V1, V2, T1>(fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T1; | |
pipe<T1, T2>(fn0: () => T1, fn1: (x: T1) => T2): () => T2; | |
pipe<V0, T1, T2>(fn0: (x0: V0) => T1, fn1: (x: T1) => T2): (x0: V0) => T2; | |
pipe<V0, V1, T1, T2>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1) => T2; | |
pipe<V0, V1, V2, T1, T2>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1, x2: V2) => T2; | |
//.. and so on... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment