vendredi 31 mars 2017

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

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 somewhat like this:

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

Aucun commentaire:

Enregistrer un commentaire