I have something like this:
type Foo<TOut> = ( a: number ) => TOut;
function bar<TOut> ( ...fs: Foo<TOut>[] ): Foo<TOut>;
const fa = ( a: number ) => 1 as const;
const fb = ( a: number ) => 'b' as const;
const fc = ( a: number ) => true as const;
Is it possible to modify the type definition of bar so it would automatically infer ReturnType of the returned function as a union of ReturnTypes of all input functions (unknown in case of 0 input functions)?
Currently I have to provide a hint like this:
const fr = bar(
fa as Foo<1|'b'|true>,
fb,
fc
);