Skip to content

Conversation

@EnThib
Copy link

@EnThib EnThib commented Jul 27, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Docs
  • Other... Please describe:

What is the current behavior?

In the CQRS documentation, the KillDragonCommand class is shown extending the Command<{ actionId: string }> class, with a custom constructor:

export class KillDragonCommand extends Command<{ actionId: string }> {
  constructor(
    public readonly heroId: string,
    public readonly dragonId: string,
  ) {}
}

However, this constructor does not include a super() call.

This works only because the Command class from @nestjs/cqrs has no constructor. But if a developer defines their own custom Command class with a constructor, TypeScript will throw error TS2377:

Constructors for derived classes must contain a 'super' call.

This can lead to confusion.

Issue Number: N/A

What is the new behavior?

To improve clarity and prevent confusion, I suggest:

Adding a super() call in the constructor of the example.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@kamilmysliwiec kamilmysliwiec merged commit f88c923 into nestjs:master Jul 28, 2025
4 checks passed
@kamilmysliwiec
Copy link
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants