@@ -557,11 +557,11 @@ export class CommandService extends Disposable implements ICommandService {
557557
558558 this . _multiCommandDisposables . set ( command . id , disposableCollection ) ;
559559 } else {
560- if ( ( registry [ 0 ] as Record < string , any > ) . multi !== true ) {
561- throw new Error ( 'Command has registered as a single command.' ) ;
562- } else {
563- multiCommand = registry [ 0 ] as MultiCommand ;
560+ const registeredCommand = registry [ 0 ] ;
561+ if ( ! ( registeredCommand instanceof MultiCommand ) ) {
562+ throw new TypeError ( 'Command has registered as a single command.' ) ;
564563 }
564+ multiCommand = registeredCommand ;
565565 }
566566
567567 const implementationDisposable = multiCommand . registerImplementation ( command as IMultiCommand ) ;
@@ -583,11 +583,11 @@ export class CommandService extends Disposable implements ICommandService {
583583 ( item ) => item . type === CommandType . COMMAND
584584 ) ;
585585 if ( triggerCommand ) {
586- Reflect . set ( params , 'trigger' , triggerCommand . id ) ;
586+ this . _setMutationTrigger ( params , triggerCommand . id ) ;
587587 return ;
588588 }
589589
590- if ( Reflect . get ( params , 'trigger' ) !== undefined ) {
590+ if ( 'trigger' in params && params . trigger !== undefined ) {
591591 return ;
592592 }
593593
@@ -596,10 +596,14 @@ export class CommandService extends Disposable implements ICommandService {
596596 ( item ) => item . type === CommandType . OPERATION
597597 ) ;
598598 if ( triggerOperation ) {
599- Reflect . set ( params , 'trigger' , triggerOperation . id ) ;
599+ this . _setMutationTrigger ( params , triggerOperation . id ) ;
600600 }
601601 }
602602
603+ private _setMutationTrigger ( params : object , trigger : string ) : void {
604+ Object . assign ( params , { trigger } satisfies IMutationCommonParams ) ;
605+ }
606+
603607 private async _execute < P extends object , R = boolean > ( command : ICommand < P , R > , params ?: P , options ?: IExecutionOptions ) : Promise < R > {
604608 // If syncOnly is true, skip execution but return true to indicate success for sync purposes
605609 if ( options ?. syncOnly ) {
0 commit comments