Currently, the return type of the methods in class Command is Command:
public command(name: string, desc?: string, opts?: commander.CommandOptions): Command;
I cannot extend Command to add more methods, like this:
class MyCommandWithUtilities extends Command {
public util1(): this {
// ...
return this;
}
}
const cmd = new MyCommandWithUtilities();
cmd
.command('foo')
.util1() // Syntax error, because `command` returns `Command`, not `MyCommandWithUtilities`
.option(...);
So, please change the return type of the methods in Command to this.
public command(name: string, desc?: string, opts?: commander.CommandOptions): this;
It seems that simply changing the definitions in index.d.ts is not enough. The main source code must also be changed.
See:
microsoft/TypeScript#4910
Currently, the return type of the methods in class
CommandisCommand:I cannot extend
Commandto add more methods, like this:So, please change the return type of the methods in
Commandtothis.It seems that simply changing the definitions in index.d.ts is not enough. The main source code must also be changed.
See:
microsoft/TypeScript#4910