使用类型别名声明函数

Declare a function using a type alias

我想使用类型别名来声明函数的类型。像这样:

type F = (_: number) => number;

function f:F (a) { return a; }
          ^ Unexpected token :

declare function f:F;
                  ^ Unexpected token :

我想要这个的原因是我有一堆具有相同(相当长)类型声明的函数,我想节省输入并提高清晰度。

是否可以在 Flow 中执行此操作?如果否,是否有为此打开的功能请求?

我使用 declare 找到了满意的答案。只是我不得不使用 declare var 而不是 declare function (这有一定道理):

type F = (_: number) => number;
declare var f:F;
function f(a) { return a; }

使用 :F 内联是理想的,但这已经足够了。