Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add string[] to options defaultValue type
option and requiredOption's defaultValue parameter was `string | boolean` but the default for a variadic option should be an array. ``` program.option('--var <args...>', 'variadic arguments', ['1']) program.parse([]) > { var: ['1'] } program.parse(['--var', '1', '2']) > { var: ['1', '2'] } ``` If you use a string default you have to handle opts that are strings ``` // with a string arg the default value is a string. program.option('--var <args...>', 'variadic arguments', '1') program.parse([]) > { var: '1' } program.parse(['--var', '1', '2']) > { var: ['1', '2'] } ``` `unknown` matches the jsdoc comment and the typings for argument(name: string, description?: string, defaultValue?: unknown): this` but conflicts with other `option` overloads. commander will pass thru any defaultValue to parse opts so `any` or `unknown` are good choices, but `string | boolean | string[]` reflects the values that commander will return when it parses arguments without a coerce function.
- Loading branch information