How would you define type for functions in flow, in the context of function getting passed in as argument? For eg, afterDoneSomething below is callback function that's getting passed - I'm not sure how I define it's type with flow.
function doSomething(path:string, afterDoneSomething:<What is the Type>)
According to the doc: http://flowtype.org/docs/functions.html, you need to supply the type of the function's parameters and returned value: (P1: T1, .., Pn: Tn) => U
So suppose your afterDoneSomething
takes a number and return a number, it should be annotated as
function doSomething(path:string, afterDoneSomething: (x: number) => number)
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