Description
So the types surrounding promises has changed quite a bit over time and I've struggled to properly maintain my own promise lib and have it work happily with async/await and typing.
Since Promise<T>
is an actual type in the lib, it apparently can't be used as an alias to represent a promise that is not the built in ES6 promise no?
I recently ran into:
TS2420: Class 'PromiseBase<T>' incorrectly implements interface 'Promise<T>'.
Property '[Symbol.toStringTag]' is missing in type 'PromiseBase<T>'
Where PromiseBase<T>
is my base class for a variety of different promise types.
I can resolve this issue by simply adding the following to PromiseBase<T>
:
readonly [Symbol.toStringTag]: "Promise"; // Must be "Promise" and cannot be "PromiseBase".
Which I don't mind, but I feel it's not correct.
Any thoughts on the right thing to do here? I think I have a solid promise lib, and want to keep using it. But I have to name it something other than Promise
for the compiler to be happy.