yargs / yargs/yargs-parser

Incorrect `default` type should not be allowed

Open
#143 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
JavaScript
Stars
519
Forks
129
Avg merge
1h 34m
Merged PRs (30d)
1

Description

The parser should not allow setting the incorrect type for default.

yargs([], {number: ['foo'], default: {foo: 'x'}});
//=> { _: [], foo: 'x' }

The above should not be allowed as we defined foo as a number, but the default is set to a string. This should throw an error to prevent mistakes.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the parser handles the number declaration together with the default object shown in the issue. Add coverage for the mismatched string default and verify that it throws an error, while a correctly typed default remains accepted.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.