From 695c6d462241b1c8f08bfc1381e45ae3d342197a Mon Sep 17 00:00:00 2001 From: John Gee Date: Tue, 29 Nov 2022 19:21:42 +1300 Subject: [PATCH] Add Command.options to TypeScript Make options and commands readonly to discourage direct manipulation. Co-authored-by: Cynthia Co-authored-by: Marcelo Shima Co-authored-by: Dmitry Maganov --- typings/index.d.ts | 3 ++- typings/index.test-d.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index bdfb2cccb..84c857a59 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -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); diff --git a/typings/index.test-d.ts b/typings/index.test-d.ts index 10740b0be..e5245afb2 100644 --- a/typings/index.test-d.ts +++ b/typings/index.test-d.ts @@ -28,7 +28,8 @@ expectType(commander.createArgument('')); expectType(program.args); // eslint-disable-next-line @typescript-eslint/no-explicit-any expectType(program.processedArgs); -expectType(program.commands); +expectType(program.commands); +expectType(program.options); expectType(program.parent); // version