Add support for Partial in the command manager
The command manager types didn't fully support commands defined with `Partial` because it deduced that the command function was `undefined` when the function was not defined. However, if the command is not present, the command registration will not be called. This fixes the types by specifying that the command definition will never be `undefined`.
This commit is contained in:
@@ -30,7 +30,7 @@ export class CommandManager<
|
||||
constructor(
|
||||
private readonly commandRegister: <T extends CommandName>(
|
||||
commandName: T,
|
||||
fn: Commands[T],
|
||||
fn: NonNullable<Commands[T]>,
|
||||
) => Disposable,
|
||||
private readonly commandExecute: <T extends CommandName>(
|
||||
commandName: T,
|
||||
@@ -43,7 +43,7 @@ export class CommandManager<
|
||||
*/
|
||||
register<T extends CommandName>(
|
||||
commandName: T,
|
||||
definition: Commands[T],
|
||||
definition: NonNullable<Commands[T]>,
|
||||
): void {
|
||||
this.commands.push(this.commandRegister(commandName, definition));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user