#1198·yargs

Throw an error if the yargs.Options type is invalid

Author: cnishinaCreated Aug 12, 2018Updated Aug 2, 2026
Labelstriaged

Should yargs throw an error if type is not a valid type identified by yargs? Here is an example:

yargs.option('foo', {
  describe: 'should not work',
  type: 'strings' // invalid since it should be of type string
})

Running the command:

<cli> --foo=2.20

Yargs assumes quietly assumes that it is a number value, not a string, and changes the value to 2.2. Should yargs throw a runtime error to show that this is invalid and there is an issue?

If this sounds reasonable, I'll try to come up with a fix.