Created
January 23, 2019 00:18
-
-
Save robbywashere-zz/1c3d0a73ae335b6be4343540bd5734a2 to your computer and use it in GitHub Desktop.
combine functions with varidiac rest parameters types
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
function combine<T extends any[]>(...args: ((...fnArgs: T) => void)[]) { | |
return (...a: T) => args.forEach(fn => fn(...a)); | |
} | |
function foo(n: number, o: string){ | |
console.log(`string ${n} ${o}`); | |
} | |
function bar(n: number, o: string){ | |
console.log(`string ${n} ${o}`); | |
} | |
combine(foo, bar)(11,"this is very cool :P ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment