polyfills: sets Promise.prototype

This commit is contained in:
thislight 2024-12-21 15:49:44 +08:00
parent fe350532ec
commit 994edfa22c
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E

View file

@ -22,7 +22,7 @@ if (typeof Promise.withResolvers === "undefined") {
// Promise.withResolvers is generic and works with subclasses - the typescript built-in decl
// could not handle the subclassing case.
Promise.withResolvers = function <T>(this: AnyPromiseConstructor<T>) {
(Promise.prototype as any).withResolvers = function <T>(this: AnyPromiseConstructor<T>) {
let resolve!: PromiseWithResolvers<T>["resolve"], reject!: PromiseWithResolvers<T>["reject"];
// These variables are expected to be set after `new this()`