我如何注释Flow的这个function

我有这个JS函数在我使用Flow( https://github.com/facebook/flow )

// @flow static promiseWrapper(fn, ...args) { return new Promise( async function(resolve, reject) { try { await fn(...args); resolve(); } catch (e) { reject(e); } } ) } 

我怎么去注释这个?

正如在github项目问题上讨论的,这将是我提出的解决scheme:

 class Foo { // We are using generics <U, T> to define the input type / output type (may be the same... I don't know the use-cases) static promiseWrapper<U, T>(fn: (...args: Array<U>) => Promise<T>, ...args: Array<U>): Promise<T> { return new Promise(async (resolve, reject) => { try { // I felt like handling the return value of this await function const ret = await fn(...args); resolve(ret); } catch (e) { reject(e); } }); } } // Most of the type inference comes from this function function fun(...args: Array<number>): Promise<string> { const ret = args.reduce((result, num) => (result + num), 0); return Promise.resolve(ret.toString()); } const myProm = Foo.promiseWrapper(fun, 1, 2, 3); // Here, total should be inferred as string, since our `fun` function returns a Promise<string> // Generic function definition <T> picks this up correctly :-) myProm.then((total) => { // $ExpectError : total should be inferred as string, hence it should fail on numerical addition const foo: number = total + 1; });