Skip to content
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

ParserQuery should not have "undefined" in the type #273

Closed
mortoray opened this issue Sep 10, 2020 · 3 comments
Closed

ParserQuery should not have "undefined" in the type #273

mortoray opened this issue Sep 10, 2020 · 3 comments

Comments

@mortoray
Copy link

The ParserQuery type allows a key to have an "undefined" value. This appears to be an error, as there is no way for a query-string to specify an "undefined" value. It could be a "null", or an empty string, but undefined doesn't make sense.

export interface ParsedQuery<T = string> {
	[key: string]: T | T[] | null | undefined;
}

This is causing me trouble now as we're trying to interop with JSON types which cannot contain an undefined value.

@cdeutsch
Copy link
Contributor

cdeutsch commented Sep 14, 2020

FWIW, I'm in the opposite boat (relying on undefined support), and 16.3.2 breaks my code.

Probably should have been a major version bump for this.

I shouldn't have "reused" ParsedQuery the way I did, but still

@mortoray
Copy link
Author

I guess stringifyUrl should still allow a type that allows undefined. Is that what is causing the trouble? The input type can be more lenient than the output type.

@cdeutsch
Copy link
Contributor

I guess stringifyUrl should still allow a type that allows undefined. Is that what is causing the trouble?

Yeah. Building up an object to pass to it.

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

No branches or pull requests

2 participants