I'm currently working on a nodejs/typescript 2 project that utilizes the es6-promise package from GitHub. However, I've decided to eliminate this dependency and target ES6 directly in typescript.
After removing the es6-promise package, I updated my tsconfig.json file to set the target as es6.
{
"compilerOptions": {
"target": "es6",
// ...
}
}
Some third-party packages rely on Bluebird promises, which are not compatible with the default ES6 promise. This issue has been documented on various GitHub posts:
- bluebird 3.0 definition is not assignable to ES6 Promises
- Provide a way to load Bluebird globally in es6 compilation target.
- Add Symbol.toStringTag to promise instance
This inconsistency is causing the following error:
TS2322: Type 'Bluebird' is not assignable to type 'Promise'. Property '[Symbol.toStringTag]' is missing in type 'Bluebird'.
There is another types package available on npm called @types/bluebird-global. In a blog post, it was recommended to use this package instead of @types/bluebird, but certain third-party packages (e.g., sequelize typings) reference bluebird and not bluebird-global, resulting in another error for the missing typings of bluebird.
What would be an effective solution to resolve this issue?