返回函数的函数的流类型

Fer*_*rry 4 javascript flowtype

流程的函数类型docs,返回的函数primitive type是这样的

const a = aFunc = (id: number): number => id + 1

但是,如何为返回函数的函数创建流类型?

const aFunc = (id: number): <what type?> => {
  return bFunc(a): void => console.log(a)
}
Run Code Online (Sandbox Code Playgroud)

Mic*_*oey 6

您可以创建单独的类型,也可以内联。
或者,您可以选择根本不指定返回类型,因为flow知道的返回类型bFunc

const bFunc = (a): void => console.log(a);
Run Code Online (Sandbox Code Playgroud)

分隔类型:

type aFuncReturnType = () => void;
const aFunc = (id: number): aFuncReturnType => () => bFunc(id);
Run Code Online (Sandbox Code Playgroud)

排队:

const aFunc = (id: number): (() => void) => () => bFunc(id);
Run Code Online (Sandbox Code Playgroud)

您也可以在flow.org/try上看到它