Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wrap<T extends Function>(fn: T) {
- return (...args) => {
- return fn(...args)
- };
- }
- function foo(a: string, b: number): [string, number] {
- return [a, b];
- }
- const wrappedFoo = wrap(foo);
- function wrap<A, B, C>(fn: (a: A, b: B) => C) {
- return (a: A, b: B): C => {
- return fn(a, b);
- };
- }
- const wrappedFoo = wrap(foo);
- function wrap<In, Out>(fn: (params: In) => Out) {
- return (params: In): Out => {
- return fn(params);
- };
- }
- interface FooParams {
- a: string;
- b: number;
- }
- function foo(params: FooParams): [string, number] {
- return [params.a, params.b];
- }
- const wrappedFoo = wrap(foo);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement