Skip to content

polyfill for Promise.withResolvers#67

Merged
dgreif merged 3 commits into
mainfrom
polyfill-with-resolvers
Oct 17, 2024
Merged

polyfill for Promise.withResolvers#67
dgreif merged 3 commits into
mainfrom
polyfill-with-resolvers

Conversation

@mattcosta7

@mattcosta7 mattcosta7 commented Oct 17, 2024

Copy link
Copy Markdown
Member
@mattcosta7 mattcosta7 self-assigned this Oct 17, 2024
@mattcosta7 mattcosta7 marked this pull request as ready for review October 17, 2024 13:11
@mattcosta7 mattcosta7 requested a review from a team as a code owner October 17, 2024 13:11
@mattcosta7 mattcosta7 requested a review from dgreif October 17, 2024 13:11
// eslint-disable-next-line @typescript-eslint/no-explicit-any
reject: (reason?: any) => void
}
out.promise = new Promise<T>((resolve, reject) => {

Copy link
Copy Markdown
Member Author

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})

Copy link
Copy Markdown
Member Author

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

@dgreif dgreif enabled auto-merge October 17, 2024 13:13
Comment thread src/promise-withResolvers.ts Outdated
@dgreif dgreif merged commit ed36174 into main Oct 17, 2024
@dgreif dgreif deleted the polyfill-with-resolvers branch October 17, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants