Using Promise as return type in Flow

I'm guessing this was figured some time ago and the correct answer to what was going on was that it was a versions mismatch between local and the on-line flow interpreter.

However, as this question turns up near the top of search results when looking for how to Flow annotate Promises, it's probably worth mentioning that the fix for these types of situations is to specify the Flow type that the Promise resolves to as a Flow angle bracket parameter.

In this case adding a "any" to the Promise annotation silences the error e.g. ...

function process(callback:Function):Promise<any> {
  return new Promise((r,re) => callback)
}

In the docs over here as well for another example


According to the flow changelog there was a change introduced in v0.28.0 which made type arguments explicit. Explicitly setting the return type to Promise<any> should fix your issue.

Alternatively you can set the following flag to false, although this is a temporary flag which will be removed in the future

experimental.strict_type_args=false

https://github.com/facebook/flow/blob/master/Changelog.md#v0280