@nestjs-architects/typed-cqrs
February 17, 2025 · View on GitHub
Tired of hand-typing types for NestJS CQRS package? We got you covered!
⚠️ This library is now deprecated!
All features provided by @nestjs-architects/typed-cqrs are now available natively in @nestjs/cqrs starting from NestJS 11.
This library will no longer be maintained or developed, but it will still work with NestJS@11 and old versions.
Migration Guide
Migrating to @nestjs/cqrs is simple:
- Replace imports from
@nestjs-architects/typed-cqrsto@nestjs/cqrs. - Drop
InferredfromIInferredQueryHandlerandIInferredCommandHandler–IQueryHandlerandICommandHandlernow support its extensions. - Command, Query, CommandResult, and QueryResult are already included in @nestjs/cqrs.
- A quick find & replace in your codebase is all you need!
Usage (before NestJS@11)
First install base @nestjs/cqrs package.
$ npm i @nestjs/cqrs
All you need to do, is to extend your query with type of expected response.
import { Query } from '@nestjs-architects/typed-cqrs';
export class GetProfileQuery extends Query<ResultType> {}
Profit
Now, when implementing handler, you get all type completion & safety!

import { IInferredQueryHandler, QueryHandler } from '@nestjs/cqrs';
@QueryHandler(GetProfileQuery)
export class GetProfileHandler implements IInferredQueryHandler<GetProfileQuery> {}
As well as, results are correctly typed as well!
