You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there, first of all i'd like to say excellent work on the projects in this repo, the typed cqrs package is awesome!
Is your feature request related to a problem? Please describe.
I've ran into a minor DX issue a few times where i update the class annotation to handle a different command e.g. @CommandHandler(Command1) -> @Commandhandler(OtherCommand).
Because the type-safety of the handler class is currently enforced by the IInferredCommandHandler interface, i'd need to remember to update the implements clause as well.
Describe the solution you'd like
It would be nice if the type-safety for the handler came from the decorator, allowing us to omit the need for the interface, and only needing to reference the target command in one place.
Could maybe be achieved like so:
import{CommandHandlerasBaseCommandHandler}from"@nestjs-architects/typed-cqrs"typeInferredResultType<CommandTypeextendsCommand<unknown>>=CommandTypeextendsCommand<infer R> ? R
: never;interfaceHandler<TextendsCommand<unknown>>{execute(command: T): Promise<InferredResultType<T>>}exportconstCommandHandler=<CextendsCommand<unknown>>(command: Constructor<C>)=>{return(target: Constructor<Handler<C>>)=>{BaseCommandHandler(command)(target)};};
Hey there, first of all i'd like to say excellent work on the projects in this repo, the typed cqrs package is awesome!
Is your feature request related to a problem? Please describe.
I've ran into a minor DX issue a few times where i update the class annotation to handle a different command e.g.
@CommandHandler(Command1)
->@Commandhandler(OtherCommand)
.Because the type-safety of the handler class is currently enforced by the
IInferredCommandHandler
interface, i'd need to remember to update theimplements
clause as well.Describe the solution you'd like
It would be nice if the type-safety for the handler came from the decorator, allowing us to omit the need for the interface, and only needing to reference the target command in one place.
Could maybe be achieved like so:
Allowing the handler to look like so:
The text was updated successfully, but these errors were encountered: