Next.js Discord

Discord Forum

URLSearchParams: has() with second argument

Unanswered
Stony gall posted this in #help-forum
Open in Discord
Stony gallOP
I'm using the UrlSearchParams: has() method with the second argument value but when I build the Nextjs 13 latest app I get this error.

Expected 1 arguments, but got 2

The app runs fine though, it seems the linter just complains but only during build. Is my tsconfig.js or eslint misconfigured somehow?

8 Replies

Toyger
second parameter only supported by firefox
Is there some sort of polyfill ?
@Stony gall Is there some sort of polyfill ?
Toyger
why polyfill
just use your function like that
it's basicaly one line
function checkSearchParams(urlSearchParams, key, value) {
  return urlSearchParams.has(key) ? urlSearchParams.get(key) === value : false;
}
Stony gallOP
@Toyger if I ignore the TS error the build succeeds and the app works using the second parameters - I believe Nextjs uses corejs polyfill https://github.com/zloirock/core-js#url-and-urlsearchparams - my question now is why I still get the error during build
I just read Nextjs replaces the url package with the one from Nodejs https://nodejs.org/api/url.html#urlsearchparamshasname-value