(I have read this post but it is from August and it does not answer my question for the current typescript version.)
I'm currently using Typescript 1.8 in my project and this works fine:
import * as Promise from "bluebird";
async function f() : Promise<void> {
return Promise.delay(200);
}
But if I try to compile with Typescript 2.1:
index.ts(2,16): error TS1059: Return expression in async function does not have a valid callable 'then' member.
Googling the issue of using Bluebird Promises in Typscript, I have also found many github discussions, comments and PRs, but they are all very hard to grasp and while discussing interesting points, I can't find anywhere that says how I'm supposed to get this to work now.
So, how am I supposed to be able to use Bluebird for Promises in Typescript 2.1?
Consider using @types/bluebird-global
as follows.
npm install --save-dev @types/bluebird-global
Import this once in your main entrypoint.
// The same Promise API, everywhere.
import * as Promise from 'bluebird'
global.Promise = Promise
See DefinitelyTyped issue #11027 for further context.