Skip to content
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

Existence of ‘number’ Key in Options.arrays Changes Parsing #415

Open
JoeDailey opened this issue Oct 3, 2021 · 1 comment
Open
Labels

Comments

@JoeDailey
Copy link

JoeDailey commented Oct 3, 2021

The documentation says to set numbers: true to parse option-array values as numbers. However, this value can be anything other than true and yargs will still use number parsing. This is particularly confusing when trying to set numbers: false or numbers: undefined.

> const parser = require('yargs-parser')
undefined
> parser('--foo dog cat', {array: {key: 'foo'}})
{ _: [], foo: [ 'dog', 'cat' ] }
> parser('--foo dog cat', {array: {key: 'foo', number: false}})
{ _: [], foo: [ NaN, NaN ] }
> parser('--foo dog cat', {array: {key: 'foo', number: undefined}})
{ _: [], foo: [ NaN, NaN ] } 

This applies to boolean as well.

@bcoe
Copy link
Member

bcoe commented Oct 4, 2021

@JoeDailey thank you for bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants