Skip to content

Commit

Permalink
Add Command.options to TypeScript (#1827)
Browse files Browse the repository at this point in the history
Make options and commands readonly to discourage direct manipulation.


Co-authored-by: Cynthia <cynthia@cynthia.dev>
Co-authored-by: Marcelo Shima <marceloshima@gmail.com>
Co-authored-by: Dmitry Maganov <vonagam@gmail.com>
  • Loading branch information
4 people committed Nov 29, 2022
1 parent e0f6173 commit 04fc0fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion typings/index.d.ts
Expand Up @@ -277,7 +277,8 @@ export interface OptionValues {
export class Command {
args: string[];
processedArgs: any[];
commands: Command[];
readonly commands: readonly Command[];
readonly options: readonly Option[];
parent: Command | null;

constructor(name?: string);
Expand Down
3 changes: 2 additions & 1 deletion typings/index.test-d.ts
Expand Up @@ -28,7 +28,8 @@ expectType<commander.Argument>(commander.createArgument('<foo>'));
expectType<string[]>(program.args);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expectType<any[]>(program.processedArgs);
expectType<commander.Command[]>(program.commands);
expectType<readonly commander.Command[]>(program.commands);
expectType<readonly commander.Option[]>(program.options);
expectType<commander.Command | null>(program.parent);

// version
Expand Down

0 comments on commit 04fc0fd

Please sign in to comment.