Repository navigation
fix(ts): ReadonlyURLSearchParams should extend URLSearchParams - #61419
Conversation
Tests Passed |
Stats from current PRDefault BuildGeneral
Client Bundles (main, webpack)
Legacy Client Bundles (polyfills)
Client Pages
Client Build Manifests
Rendered Page Sizes
Edge SSR bundle Size
Middleware size
Next Runtimes
Diff detailsDiff for page.jsDiff too large to display Diff for 68-HASH.jsDiff too large to display Diff for app-page-exp..ntime.dev.jsDiff too large to display Diff for app-page.runtime.dev.jsDiff too large to display |
| [Symbol.iterator]() { | ||
| return this[INTERNAL_URLSEARCHPARAMS_INSTANCE][Symbol.iterator]() | ||
| /** @internal */ | ||
| class ReadonlyURLSearchParamsError extends Error { |
There was a problem hiding this comment.
This results in more code output right? The internal methods can't be minified whereas the function version can be minified
There was a problem hiding this comment.
I believe this should be an acceptable size change.
Generally, we should start using proper Errors everywhere to improve the codebase readability/type safety, etc.
There was a problem hiding this comment.
I'm with @balazsorban44 here in that improving the hygiene around error management, creation, is a huge area within the codebase that we could use some more rigid structure around. While we might have some minification losses, cases where we're creating error classes are few and far between.
What?
Let the developer check the instance of
ReadonlyURLSearchParamsto match againstURLSearchParamsWhy?
useSearchParams()'s return type isReadonlyURLSearchParamswhich implements all the methods ofURLSearchParams, therefore its type should be extended fromURLSearchParamsas well. Deprecated methods are also implemented to throw an error, so no runtime behavior is being changedHow?
Mark the unavailable methods as
@deprecatedwhich will visually mark them in IDEs:This is similar how
ReadonlyHeadersextendsHeaders, added in: #49075Slack thread
Closes NEXT-2305