Skip to content

Typings could be tighter for default value parameter for .option() #158

@shadowspawn

Description

@shadowspawn

Consider:

.option(flags, description, defaultValue)

Commander types this to match the possible option value types (tj/commander.js#1721 (comment)), leaving aside coercion:

defaultValue?: string | boolean | string[]

which allow options defined with matching defaults like:

.option('--string <value>', 'description, 'DEFAULT')  // string
.option('--boolean', 'description', false) // boolean
.option('--variadic <value...>, ['DEFAULT']) // string[]

In extra-typings we could restrict the default type to match the flag type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending releaseOn a branch for eventual release, but not yet merged to main.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions