Skip to content

Instantly share code, notes, and snippets.

@robbywashere-zz
Created January 23, 2019 00:18
Show Gist options
  • Save robbywashere-zz/1c3d0a73ae335b6be4343540bd5734a2 to your computer and use it in GitHub Desktop.
Save robbywashere-zz/1c3d0a73ae335b6be4343540bd5734a2 to your computer and use it in GitHub Desktop.
combine functions with varidiac rest parameters types
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