Skip to content

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

Description

@JoeDailey

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions