Skip to content

Improve URLSearchParams constructor type definition #2070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rossrobino
Copy link

@rossrobino rossrobino commented Jul 16, 2025

Overrides the type of URLSearchParams init to accept a Iterable<[string, string]> instead of string[][].

MDN Reference

For example:

new URLSearchParams(new Set([["name", "ross"]]));

is valid, but currently shows an error.

There was an added type of URLSearchParams which I figured I should remove, the Iterable<[string, string]> type covers this case as well.

@rossrobino
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Contributor

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

@jakebailey
Copy link
Member

I can't seem to get it to generate, I'm getting a ENOENT error. I don't have files in /inputfiles/mdn/

You need to have cloned the submodule as well.

git submodule update --init

@saschanaz
Copy link
Contributor

This is blocked by #222 because vars can't be split by separate type declarations. We cannot just override the constructor because it'll break ES5 compatibility.

microsoft/TypeScript#3538 could greatly help without all those separate libs but I don't see that coming anytime soon.

@jakebailey
Copy link
Member

ES5 is going to be deprecated, so maybe there's a future where it'd work out.

@rossrobino
Copy link
Author

Thanks @jakebailey, got it to generate and committed the changes.

I am seeing the Cannot find name 'Iterable' error now during the test run, I assume this is the ES5 issue. Let me know if not!

@jakebailey
Copy link
Member

Correct, but we're likely making DOM imply ES6 and DOM.Iterable in 6.0

@saschanaz
Copy link
Contributor

But will 6.0 remove ES5 completely?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants