Does Flow or TypeScript have a way to use the return type of a function as a separate type

123 Views Asked by At

C++ has the decltype keyword that allows getting the return type of a function without evaluating it, and I was wondering if the typed dialects of JS had something similar. I would imagine it working something like this:

let foo = () => 'bar'
let baz: typeof foo() // uses the inferred return type of foo()
0

There are 0 best solutions below