What is the type of function in the javascript stream validation method of the stream?

How would you define a type for functions in a stream, in the context of passing a function as an argument? For example, afterDoneSomething below is a callback function that is passed in - I'm not sure how I determine its type with a stream.

function doSomething(path:string, afterDoneSomething:<What is the Type>) 
+5
source share
1 answer

According to the document http://flowtype.org/docs/functions.html you need to specify the type of function parameters and the return value: (P1: T1, .., Pn: Tn) => U

So, suppose your afterDoneSomething takes a number and returns a number, it should be annotated as

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

Source: https://habr.com/ru/post/1235875/


All Articles