change option default value type to unknown#1725
change option default value type to unknown#1725wwwenjie wants to merge 2 commits intotj:developfrom
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 CLIWith 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 | booleantounknownto make sure default value can accpet other types.ChangeLog
change option default value type to unknown