I am encountering a challenge with a Node.js library that utilizes promises, specifically TypeScript declarations using ES6 Promise
. Interestingly, this library can be adjusted to work with any promise library, such as Bluebird
.
The issue lies in making the Bluebird promise interface accessible at a declarative level without modifying the library itself. Is there a method to communicate to the compiler that a different Promise protocol is being used?
Naturally, altering the library directly would resolve this dilemma effortlessly. However, that option is not viable in this scenario.
To provide insight into the nature of this library, consider the following simplistic interface example:
interface Protocol {
methodName(param1:string, param2:number):Promise<Object[]>
}
This interface complexity is then amplified by a factor of 1000.
Creating a mock protocol in a separate file will not suffice. The key is determining how to specify to the compiler that the default ES6 Promise
should be replaced with the Bluebird TypeScript version.