Skip to content

Missing standard properties and methods in URL and URLSearchParams type definitions #54789

@manishbalayan

Description

@manishbalayan

Description

The current URL and URLSearchParams type definitions in globals.d.ts are missing several standard properties and methods that are present in the Web API and supported by the React Native runtime (via whatwg-url polyfill).
For URL, properties like hash, host, hostname, href, origin, password, pathname, port, protocol, search, username are missing.
For URLSearchParams, methods like delete, get, getAll, has, set, sort, forEach, keys, values, entries are missing.

Steps to reproduce

  1. Create a new React Native project with TypeScript.
  2. Try to access new URL('https://example.com').pathname.
  3. Try to use new URLSearchParams().get('key').
  4. Observe TypeScript errors: Property 'pathname' does not exist on type 'URL' and Property 'get' does not exist on type 'URLSearchParams'.

React Native Version

0.82.0

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx @react-native-community/cli info

N/A - Static Analysis Issue (Type Definition Bug)

Stacktrace or Logs

Property 'pathname' does not exist on type 'URL'.
Property 'get' does not exist on type 'URLSearchParams'.

MANDATORY Reproducer

https://snack.expo.dev/@manishbalayan/intelligent-indigo-apples?platform=ios

Screenshots and Videos

Image There is the error shown in Screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.Resolution: PR SubmittedA pull request with a fix has been provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions