next.js
df74a02f - fix(ts): `ReadonlyURLSearchParams` should extend `URLSearchParams` (#61419)

Commit
1 year ago
fix(ts): `ReadonlyURLSearchParams` should extend `URLSearchParams` (#61419) ### What? Let the developer check the instance of `ReadonlyURLSearchParams` to match against `URLSearchParams` ### Why? `useSearchParams()`'s return type is `ReadonlyURLSearchParams` which implements all the methods of `URLSearchParams`, therefore its type should be extended from `URLSearchParams` as well. Deprecated methods are also implemented to throw an error, so no runtime behavior is being changed ### How? Mark the unavailable methods as `@deprecated` which will visually mark them in IDEs: ![image](https://github.com/vercel/next.js/assets/18369201/f3de2858-14ac-4021-981d-b0267610faa7) This is similar how `ReadonlyHeaders` extends `Headers`, added in: #49075 [Slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1706628877916779) Closes NEXT-2305
Author
Parents
Loading