cqrs
cqrs copied to clipboard
fix: type inference of type
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
- [x] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:
What is the current behavior?
When using ofType with more than one type it would try to collapse those down into a single type, ie A | B would become A if B was essentially the same as A but with a few extra properties. And if the types couldn't be collapsed because they were incompatible then you would just get an error requiring the generics to be manually filled int
Issue Number: N/A
What is the new behavior?
The ofType() can now property infer types of unions wether they are similar or disparate
Does this PR introduce a breaking change?
[x] Yes
[ ] No
Technically the generics of ofType() are changing so that the second parameter is an array rather than a union.
I think this is relatively low risk as most people would be inferring the type and if someone is providing the generic it is probably because it couldn't be inferred which this should fix