You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I explicitly marked it as boolean: true, it seems to work as expected. However, the problem is if the option/yargs-parser configuration had boolean replaced with narg to allow the flag value to be of multiple types (falling back to a boolean if no value given), then setting it solely as boolean will break the functionality of the other values it could be.
Admittedly, parsedArgs.b would be undefined if it weren't defaulted which is still falsey, but this still came as a surprise to me since narg: { blah: 0 } should be enough to mark it as a boolean. It's not the end of the world but would be nice to not have this gotcha present in the parser that breaks if the user happens to add a default value of false.
Thank you! It's much appreciated, especially now that nullish coalescing is supported natively in all NodeJS LTS >=14.5.x (haven't tried anything earlier than that so can't speak for them).
yargs-parser
doesn't seem to work when a boolean flag is defaulted tofalse
and then activated from the args string. For example:If I explicitly marked it as
boolean: true
, it seems to work as expected. However, the problem is if the option/yargs-parser configuration hadboolean
replaced withnarg
to allow the flag value to be of multiple types (falling back to a boolean if no value given), then setting it solely as boolean will break the functionality of the other values it could be.Admittedly,
parsedArgs.b
would beundefined
if it weren't defaulted which is still falsey, but this still came as a surprise to me sincenarg: { blah: 0 }
should be enough to mark it as a boolean. It's not the end of the world but would be nice to not have this gotcha present in the parser that breaks if the user happens to add a default value offalse
.Related
The text was updated successfully, but these errors were encountered: