From f97b9a521d6a1cd6141c39253267d26f4d0b359f Mon Sep 17 00:00:00 2001 From: Manish Balayan Date: Mon, 8 Dec 2025 15:48:03 -0800 Subject: [PATCH] fix(types): add missing standard properties to URL and URLSearchParams (#54787) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This PR related to issue https://github.com/facebook/react-native/issues/54789 updates the `URL` and `URLSearchParams` definitions in `globals.d.ts` to include missing standard properties and methods that are already supported by the runtime implementation. **Motivation:** I noticed that while the runtime supports standard URL operations (backed by `whatwg-url`), the TypeScript definitions were incomplete, causing unnecessary type errors when using standard Web APIs. ## Changelog: [GENERAL] [FIXED] - Added missing standard properties to `URL` (hash, host, pathname, etc.) and methods to `URLSearchParams` (get, set, delete, etc.). Pull Request resolved: https://github.com/facebook/react-native/pull/54787 Test Plan: 1. Open `globals.d.ts`. 2. Verify that `URL` interface now includes all standard properties. 3. Verify that `URLSearchParams` interface now includes all standard methods. 4. Verify that no new TypeScript errors are introduced. Screenshot: Before making changes Screenshot 2025-12-04 at 11 38 58 PM After making changes ![Uploading Screenshot 2025-12-04 at 11.39.42 PM.png…]() Reviewed By: javache Differential Revision: D88517037 Pulled By: alanleedev fbshipit-source-id: 9225b86e134be27dac7b135370de5266d414afb4 --- packages/react-native/src/types/globals.d.ts | 31 +++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/react-native/src/types/globals.d.ts b/packages/react-native/src/types/globals.d.ts index a8f6b20e618..34d46cc3fec 100644 --- a/packages/react-native/src/types/globals.d.ts +++ b/packages/react-native/src/types/globals.d.ts @@ -461,8 +461,18 @@ declare global { | 'text'; interface URL { - href: string; + readonly hash: string; + readonly host: string; + readonly hostname: string; + readonly href: string; + readonly origin: string; + readonly password: string; + readonly pathname: string; + readonly port: string; + readonly protocol: string; + search: string; readonly searchParams: URLSearchParams; + readonly username: string; toJSON(): string; toString(): string; @@ -479,8 +489,27 @@ declare global { * Based on definitions of lib.dom and lib.dom.iterable */ interface URLSearchParams { + /** + * Returns the number of search parameter entries. + */ + readonly size: number; + append(key: string, value: string): void; + delete(name: string): void; + get(name: string): string | null; + getAll(name: string): string[]; + has(name: string): boolean; + set(name: string, value: string): void; + sort(): void; toString(): string; + forEach( + callbackfn: (value: string, key: string, parent: URLSearchParams) => void, + thisArg?: any, + ): void; + + keys(): IterableIterator; + values(): IterableIterator; + entries(): IterableIterator<[string, string]>; [Symbol.iterator](): IterableIterator<[string, string]>; }