上QQ阅读APP看书,第一时间看更新
Defining types for arrow functions
Finally, let's see how types would be defined for arrow functions. We can have a couple more implementations of the toString() function we saw earlier in the Basic types in Flow section:
// Source file: src/types_basic.js
const toString2 = (x: number): string => {
return x + "";
};
type numberToString = number => string;
const toString3: numberToString = (x: number) => String(x);