-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
change option default value type to unknown #1725
Conversation
See also: #1721 |
You are right the default argumentment can technically be anything, but the The current definitions (after #1721) are:
Example calls are:
|
What is your use case that currently causes a type warning? |
Thanks for pointing out. That make since. Cuurent I'm using a default value of number. I'm not sure if we need add the number type to default values, i think it depends on the uasge of uesrs.
warning: Argument type number is not assignable to parameter type string | boolean | undefined Type number is not assignable to type string | boolean Type number is not assignable to type boolean |
maybe use custom processing is a better way...
|
Yes. (I was typing up a longer answer when you suggested it yourself! 😄 ) Without custom processing, you would need to deal with mixed types in your code. cards # number 5 from default
cards --deep=5 # string '5' from CLI With the custom processing function, Commander can warn you if the default value does not match the return type of the coerce function. Note: You can not use When you digest all this, was the warning actually useful in this case? |
Yes! The warning is useful. Sorry I just glanced at the readme and missed its best practices. Thank you so much 😄 |
Good. Thanks for confirming. 😄 |
Problem
current the type of option default value is
string | boolean
, which will cause warning in IDE since it can be number or other.Solution
this PR change the type from
string | boolean
tounknown
to make sure default value can accpet other types.ChangeLog
change option default value type to unknown