Home > OS >  How to describe return type of function which is result of call passed generic function
How to describe return type of function which is result of call passed generic function

Time:01-10

The question is how to describe the return type of function bar which should be the result of execution of generic function fn.

function foo(fn<T>) /*return →*/ function bar<B> /*return →*/ call fn<B>()

Example:

function foo<T extends <X>(...args: any) => any>(fn: T) {
    return function bar<B>(): ReturnType<typeof fn> /**           
  •  Tags:  
  • Related