flow javascript 类型检查器中的函数类型是什么?

What is the type of function in flow javascript type checker?

在函数作为参数传入的上下文中,您如何定义流中函数的类型?例如,下面的 afterDoneSomething 是正在传递的回调函数 - 我不确定我是如何定义它的类型的。

function doSomething(path:string, afterDoneSomething:<What is the Type>)

根据文档:http://flowtype.org/docs/functions.html,您需要提供函数参数的类型和 returned 值:(P1: T1, .., Pn: Tn) => U

所以假设你的 afterDoneSomething 取一个数字和 return 一个数字,它应该被注释为

function doSomething(path:string, afterDoneSomething: (x: number) => number)