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

feat!: Require type to be specified for each supplied option #95

Merged
merged 5 commits into from
Apr 10, 2022

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Apr 10, 2022

Currently the type property is optional and defaults to boolean, but this is a bit opaque.

Closes: #94

Make it an error to leave out the type:

parseArgs({
  options: {
    foo: { },
  },
});
ERR_INVALID_ARG_TYPE [TypeError]: options.foo.type must be ('string|boolean') got undefined

Correct:

parseArgs({
  options: {
    foo: { type: 'boolean' },
  },
});

@shadowspawn shadowspawn marked this pull request as draft April 10, 2022 07:53
@shadowspawn shadowspawn marked this pull request as ready for review April 10, 2022 08:13
@bcoe bcoe merged commit 02cd018 into pkgjs:main Apr 10, 2022
@shadowspawn shadowspawn deleted the feature/require-option-type branch April 10, 2022 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make type mandatory for configured options
2 participants