Skip to content

parseArgs Type Definition #47487

Description

@marcobarrios-fi

Instead of having a type property with either a "string" or "boolean" value, I believe it would be more intuitive to have a boolean property with either true or false value, with the default value being false.

options: {
  verbose: {
    short: "v",
    boolean: true
  }
}

Furthermore, I would prefer the options to be an array of objects, as this would make it easier work with them.

options: [
  {
    long: "output",
    short: "o",
    required: true
  },
  {
    long: "verbose",
    short: "v",
    boolean: true
  }
}

Thank you for including the parseArgs feature in Node!

Activity

  1. benjamingr commented on Apr 9, 2023

    @benjamingr
    Member

    cc @bcoe @RaisinTen @aduh95 (pinging Ben who added it and some people who reviewed that since I'm not sure what team to ping)

  2. added
    utilIssues and PRs related to the built-in util module.
    on Apr 9, 2023
  3. shadowspawn commented on Apr 9, 2023

    @shadowspawn
    Member

    Instead of having a type property with either a "string" or "boolean" value, I believe it would be more intuitive to have a boolean property with either true or false value, with the default value being false.

    This was deliberate in case there was expansion of types in the future or by third parties. The original design had a withValue array and the current naming was first discussed in refactor: pkgjs/parseargs#63 (comment)

  4. shadowspawn commented on Apr 9, 2023

    @shadowspawn
    Member

    Furthermore, I would prefer the options to be an array of objects, as this would make it easier work with them.

    I think implicitly we were thinking of a key/value lookup of the options properties, but an array could work too. I think the difference is probably not compelling enough to change, also with parseArgs moving to stable in #46640

    Proposal for refactor leading to current configuration:
    pkgjs/parseargs#45

    Edit: Also I don't know if it would be possible to do the strong typing of the parse results in TypeScript if the options configuration was a plain array.

  5. shadowspawn commented on Apr 9, 2023

    @shadowspawn
    Member

    (Two good questions @marcobarriosfi )

  6. benjamingr commented on Apr 10, 2023

    @benjamingr
    Member

    (The TS bit is possible to type though I actually personally like the current API better)

  7. github-actions commented on Jun 5, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 210 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  8. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jun 5, 2026
  9. github-actions commented on Jul 6, 2026

    @github-actions
    Contributor

    This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 240 days).
    If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

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

    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions