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

Should undefined be allowed in API request parameters? #48

Open
jwbth opened this issue Jul 21, 2024 · 1 comment
Open

Should undefined be allowed in API request parameters? #48

jwbth opened this issue Jul 21, 2024 · 1 comment

Comments

@jwbth
Copy link

jwbth commented Jul 21, 2024

While converting https://en.wikipedia.org/wiki/User:BrandonXLF/QuickEdit.js to TypeScript, I came across this:

					minor: minor.isSelected() ? true : undefined,
					notminor: minor.isSelected() ? undefined : true,

This is currently disallowed by

type UnknownApiParams = Record<string, string | string[] | boolean | number | number[]>;

image

But mediawiki.api just removes all undefined paramters (just as false ones) in https://github.com/wikimedia/mediawiki/blob/d84806614aed6d99f7e6a64243b8c4f8812a70c8/resources/src/mediawiki.api/index.js#L191.

I have to admit, I use "syntactic sugar" like this in my code as well. Should this be perhaps allowed?

@siddharthvp
Copy link
Member

Makes sense to me.

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