-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Forced to pass undefined
when a method accepts void
or undefined
#19259
Comments
I think I think there is merit in general in allowing parameters that accept |
I think you expressed it perfectly; that's it: |
undefined
when a method accepts void
undefined
when a method accepts void
or undefined
No just T|undefined. Null has a different value. |
Well, you are the expert :) |
looks like a duplicate of #12400 |
So it seems indeed. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
If a method accepts
void
as the type of one of its arguments, passingundefined
to it should not be explicitly required, in my opinion, as the method will receiveundefined
anyway if no argument is provided.My use case is as follows:
Might be an uncommon case, but what I would like to effectively indicate from the the user of class
C
is the need or not to provide the argumenta
. In other words, the methodf()
ofC
should force you to send an argument to it if the type is different thanvoid
(so an optional argument doesn't work, unless there is a way to condition this to the argument type), but also allow you to say "I don't need an argument inf()
" (and using a default type, e.g.any
wouldn't be very type-safe, of course, so I would like to avoid this option).What is the best possible way to achieve this for the time being? If none, does my proposal make sense?
The text was updated successfully, but these errors were encountered: