Repository navigation
Add TypeScript declaration for the queueMicrotask global - #59007
BilalWalker wants to merge 1 commit into
Conversation
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.
|
Hi @BilalWalker! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
React Native installs a
queueMicrotaskglobal on every app (Libraries/Core/setUpTimers.js, backed byLibraries/Core/Timers/queueMicrotask.js), butsrc/types/globals.d.tsnever declared it. The shipped TypeScript config (@react-native/typescript-config) uses pure ESlibs, so TypeScript users withoutlib: ["dom"]hit:This is the same gap as
requestIdleCallback(#58565, fixed in #57545),performance(#58610, #58831) andTextEncoder/TextDecoder(#56325, #56326).queueMicrotaskwas called out as missing in #58610 (comment) (by @johnnycheng0210) and has no PR yet.This declares
queueMicrotask(callback: () => void): voidnext to the other timer globals, matching the runtime implementation, and adds a type test.Changelog:
[GENERAL] [ADDED] - Add TypeScript declaration for the
queueMicrotaskglobalTest Plan:
The new
testQueueMicrotasktype test covers the valid call shape and uses@ts-expect-errorfor a missing argument, a non-function argument and an extra argument.yarn build-types+yarn test-generated-typescriptcould not be run locally:build-typesfails on Windows before reaching this change (Failed to build packages\react-native\index.js.flowpath handling), so I am relying on thebuild_js_typesCI job for that check.