From flow's function type docs, function that return primitive type is like this
const a = aFunc = (id: number): number => id + 1.
But, how to create flow type for a function that return a function?
const aFunc = (id: number): <what type?> => {
  return bFunc(a): void => console.log(a)
}
                You can either create a separate type, or you can do it inline.
Or you can choose to don't specify a return-type at all, because flow knows the return type of bFunc.
const bFunc = (a): void => console.log(a);
Separate type:
type aFuncReturnType = () => void;
const aFunc = (id: number): aFuncReturnType => () => bFunc(id);
Inline:
const aFunc = (id: number): (() => void) => () => bFunc(id);
You can also see this on flow.org/try 🙂
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With