-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
polyfill for Promise.withResolvers #67
Conversation
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
reject: (reason?: any) => void | ||
} | ||
out.promise = new Promise<T>((resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - I would new this
here, but we call this in tests directly, so haven't done so
|
||
export function apply(): void { | ||
if (!('withResolvers' in Promise)) { | ||
Object.assign(Promise, {withResolvers}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using Object.assign
to avoid type errors from defining withResolvers
on Promise
Adds a polyfill for
Promise.withResolvers
which is baseline 2024see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
see: https://github.com/tc39/proposal-promise-with-resolvers/blob/main/polyfills.js