Sitelet https://github.com/angular/angular/pull/69739
Skip to content

refactor(core): use native Promise.withResolvers() in tests - #69739

Merged
mattrbeck merged 1 commit into
angular:mainfrom
MeAkib:use-native-Promise.withResolvers
Sep 1, 2026
Merged

mattrbeck merged 1 commit into
angular:mainfrom
MeAkib:use-native-Promise.withResolvers

Conversation

@MeAkib

@MeAkib MeAkib commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Based on #69686 (comment)

Since Promise.withResolvers() is available natively now, we should use that instead of introducing a new utility.

Replaces the temporary promiseWithResolvers polyfill with the native Promise.withResolvers() API now that it is supported by both the runtime and TypeScript.

Also removes the polyfill and its exports, and updates the TypeScript configuration to include the es2024 library.

@pullapprove
pullapprove Bot requested review from JeanMeche and josephperrott July 11, 2026 01:46
@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Jul 11, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jul 11, 2026
@JeanMeche

Copy link
Copy Markdown
Member

We cannot use Promise.withResolvers outside of our test files. Its not "widely available" yet: https://web-platform-dx.github.io/web-features-explorer/features/promise-withresolvers/

@JeanMeche JeanMeche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please only replace it in the test files.

@MeAkib
MeAkib force-pushed the use-native-Promise.withResolvers branch from 70f2a94 to ec3ede4 Compare July 11, 2026 02:09
@MeAkib MeAkib changed the title refactor(core): use native Promise.withResolvers() refactor(core): use native Promise.withResolvers() in tests Jul 11, 2026
@MeAkib
MeAkib marked this pull request as draft July 11, 2026 02:39
@josephperrott

Copy link
Copy Markdown
Member

As mentioned this is not widely available yet. As such we do not want to replace it in our tests yet either to allow for our tests to be run in real browser environments which may not have support yet.

@JeanMeche

Copy link
Copy Markdown
Member

I do think our browser testing set supports it but we're still missing some type definitions..

@MeAkib
MeAkib force-pushed the use-native-Promise.withResolvers branch from ec3ede4 to 3090768 Compare July 20, 2026 19:43
Comment thread packages/tsconfig.json Outdated
@@ -28,7 +28,7 @@
},
"rootDir": ".",
"inlineSourceMap": true,
"lib": ["es2022", "dom", "dom.iterable"],
"lib": ["es2022", "dom", "dom.iterable", "es2024.promise"],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can drop this change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After drop, something like this

Untitled

Comment thread packages/tsconfig-build.json Resolved
Replaces the temporary `promiseWithResolvers` polyfill with the
native `Promise.withResolvers()` API in test files and Updates the TypeScript configuration to include the `es2024.promise`.
@JeanMeche
JeanMeche force-pushed the use-native-Promise.withResolvers branch from 79d9626 to 0511142 Compare July 21, 2026 07:13
@JeanMeche
JeanMeche marked this pull request as ready for review July 21, 2026 07:23
@angular angular deleted a comment from aalonso777777 Jul 22, 2026
@JeanMeche
JeanMeche requested review from alan-agius4 and removed request for josephperrott August 17, 2026 20:05
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker area: testing Issues related to Angular testing features, such as TestBed target: patch This PR is targeted for the next patch release and removed area: core Issues related to the framework runtime labels Sep 1, 2026
@JeanMeche JeanMeche removed the area: testing Issues related to Angular testing features, such as TestBed label Sep 1, 2026
@ngbot ngbot Bot removed this from the Backlog milestone Sep 1, 2026
@mattrbeck
mattrbeck merged commit b5ce15c into angular:main Sep 1, 2026
28 of 30 checks passed
@mattrbeck

Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

MeAkib added a commit to MeAkib/angular that referenced this pull request Sep 6, 2026
Follow-up to angular#69739, applying the same change to the test suites that still hand-roll the
deferred promise idiom: declaring an outer `resolve`/`reject` binding and capturing the
executor arguments into it.

Also drops the last two stand-ins for the native API — the `promiseWithResolvers` import in
`resource_spec.ts` and the local `createPromise()` helper in the router's `bootstrap.spec.ts`.

No configuration change is needed here: `packages/tsconfig-build.json` already lists
`es2024.promise`, and zone.js implements `withResolvers()` on `ZoneAwarePromise`, so both the
node and browser test targets pick the native API up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MeAkib added a commit to MeAkib/angular that referenced this pull request Sep 6, 2026
Replaces the remaining hand-rolled deferred promise implementations
with the native `Promise.withResolvers()` API and removes the now
unused helper and import.

Follow-up to angular#69739.
MeAkib added a commit to MeAkib/angular that referenced this pull request Sep 6, 2026
Replaces the remaining hand-rolled deferred promise implementations
with the native `Promise.withResolvers()` API and removes the now
unused helper and import.

Follow-up to angular#69739.
crisbeto pushed a commit that referenced this pull request Sep 9, 2026
Replaces the remaining hand-rolled deferred promise implementations
with the native `Promise.withResolvers()` API and removes the now
unused helper and import.

Follow-up to #69739.
crisbeto pushed a commit that referenced this pull request Sep 9, 2026
Replaces the remaining hand-rolled deferred promise implementations
with the native `Promise.withResolvers()` API and removes the now
unused helper and import.

Follow-up to #69739.

(cherry picked from commit 1bc7e3c)
MeAkib added a commit to MeAkib/angular that referenced this pull request Sep 28, 2026
…t files

Replaces the remaining hand-rolled deferred promises in test-only files
with the native `Promise.withResolvers()` API.

Follow-up to angular#69739.
atscott pushed a commit that referenced this pull request Sep 28, 2026
…t files

Replaces the remaining hand-rolled deferred promises in test-only files
with the native `Promise.withResolvers()` API.

Follow-up to #69739.
atscott pushed a commit that referenced this pull request Sep 28, 2026
…t files

Replaces the remaining hand-rolled deferred promises in test-only files
with the native `Promise.withResolvers()` API.

Follow-up to #69739.

(cherry picked from commit c8d6971)
@MeAkib
MeAkib deleted the use-native-Promise.withResolvers branch October 22, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants