Existence of ‘number’ Key in `Options.arrays` Changes Parsing
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 519
- Forks
- 129
- Avg merge
- 1h 34m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the option-array parsing behavior described in the issue and compare it with the parser options documentation. Reproduce the examples for array.number and array.boolean, then trace how the presence of those keys is interpreted. Done means false or undefined no longer enables the corresponding type conversion, with the documented behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100