nest
nest copied to clipboard
fix(core): when using forward references on `exports` array
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
- [ ] 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?
the following code triggers the error because of the forwardRef on exports array
import { Module, forwardRef } from '@nestjs/common';
@Module({})
export class FooModule {}
@Module({
imports: [
forwardRef(() => FooModule),
],
exports: [forwardRef(() => FooModule)],
})
export class AppModule {}
Which breaks the ConditionModule from @nestjs/config when we use a forward reference.
Do note that the same error happens when we supply a promise to exports:
but I didn't address this error in this PR because I'm not sure about the error handling for rejected promises and about the right place to resolve such promise.
What is the new behavior?
we can now use forwardRef on exports, as its type definition tell us so.
I also made a tiny change to the issue template of bug reports. It will look like this:
Does this PR introduce a breaking change?
- [ ] Yes
- [x] No
Other information
I guess such usage was supposed to be supported since this commit: https://github.com/nestjs/nest/commit/0fcdf4ee2c0ffa5f42b4399a11b942dc2dff4803
Pull Request Test Coverage Report for Build ae758b3c-61b4-4091-ac37-30a901dce476
Details
- 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage increased (+0.001%) to 92.208%
| Totals | |
|---|---|
| Change from base Build 0f9b0016-1853-4775-8f4d-a4d89fc35f0f: | 0.001% |
| Covered Lines: | 6745 |
| Relevant Lines: | 7315 |
💛 - Coveralls
lgtm