Skip to content

Add TypeScript declaration for the queueMicrotask global - #59007

Open
BilalWalker wants to merge 1 commit into
react:mainfrom
BilalWalker:add-queuemicrotask-ts-declaration
Open

BilalWalker wants to merge 1 commit into
react:mainfrom
BilalWalker:add-queuemicrotask-ts-declaration

Conversation

@BilalWalker

@BilalWalker BilalWalker commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary:

React Native installs a queueMicrotask global on every app (Libraries/Core/setUpTimers.js, backed by Libraries/Core/Timers/queueMicrotask.js), but src/types/globals.d.ts never declared it. The shipped TypeScript config (@react-native/typescript-config) uses pure ES libs, so TypeScript users without lib: ["dom"] hit:

Cannot find name 'queueMicrotask'.

This is the same gap as requestIdleCallback (#58565, fixed in #57545), performance (#58610, #58831) and TextEncoder/TextDecoder (#56325, #56326). queueMicrotask was called out as missing in #58610 (comment) (by @johnnycheng0210) and has no PR yet.

This declares queueMicrotask(callback: () => void): void next to the other timer globals, matching the runtime implementation, and adds a type test.

Changelog:

[GENERAL] [ADDED] - Add TypeScript declaration for the queueMicrotask global

Test Plan:

yarn test-typescript-legacy      # passes (includes __typetests__/globals.tsx)
npx eslint --max-warnings 0 packages/react-native/src/types/globals.d.ts packages/react-native/__typetests__/globals.tsx   # clean
prettier --check on both files   # clean

The new testQueueMicrotask type test covers the valid call shape and uses @ts-expect-error for a missing argument, a non-function argument and an extra argument.

yarn build-types + yarn test-generated-typescript could not be run locally: build-types fails on Windows before reaching this change (Failed to build packages\react-native\index.js.flow path handling), so I am relying on the build_js_types CI job for that check.

React Native installs queueMicrotask on every app (setUpTimers.js), but
src/types/globals.d.ts never declared it. TypeScript users without the DOM
lib hit "Cannot find name 'queueMicrotask'".

Declare it next to the other timer globals and cover it in the globals
type test.
@meta-cla

meta-cla Bot commented Oct 12, 2026

Copy link
Copy Markdown

Hi @BilalWalker!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@BilalWalker
BilalWalker marked this pull request as draft October 12, 2026 10:32
@BilalWalker
BilalWalker marked this pull request as ready for review October 12, 2026 13:16
@meta-cla

meta-cla Bot commented Oct 12, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 12, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant