Skip to content

Commit

Permalink
Merge pull request #13712 from micalevisk/fix/forwardref-on-exports
Browse files Browse the repository at this point in the history
fix(core): when using forward references on `exports` array
  • Loading branch information
kamilmysliwiec committed Jul 1, 2024
2 parents ad1e11b + ee37307 commit 970cb48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions .github/ISSUE_TEMPLATE/Bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ body:
required: true
attributes:
label: "Minimum reproduction code"
description: |
An URL to some Git repository/[StackBlitz](https://stackblitz.com/fork/github/nestjs/typescript-starter)/[CodeSandbox](https://codesandbox.io/s/github/nestjs/typescript-starter/tree/master) project that reproduces your issue. [What is a minimum reproduction?](https://jmcdo29.github.io/wtf-is-a-minimum-reproduction)
:warning: **NOTE:** We can close this issue if we don't manage to reproduce your potential bug. [Here](https://antfu.me/posts/why-reproductions-are-required) is why.
placeholder: "https://github.com/..."
description: |
An URL to some Git repository/[StackBlitz](https://stackblitz.com/fork/github/nestjs/typescript-starter)/[CodeSandbox](https://codesandbox.io/s/github/nestjs/typescript-starter/tree/master) project that reproduces your issue. [What is a minimum reproduction?](https://jmcdo29.github.io/wtf-is-a-minimum-reproduction)
> [!WARNING]
> We may close this Issue if we don't manage to reproduce the potential bug. [Read this](https://antfu.me/posts/why-reproductions-are-required) to understand why.
- type: textarea
attributes:
Expand Down
8 changes: 6 additions & 2 deletions packages/core/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,14 @@ export class DependenciesScanner {
}

public insertExportedProvider(
exportedProvider: Type<Injectable>,
// TODO: improve the type definition bellow because it doesn't reflects the real usage of this method
exportedProvider: Type<Injectable> | ForwardReference,
token: string,
) {
this.container.addExportedProvider(exportedProvider, token);
const fulfilledProvider = this.isForwardReference(exportedProvider)
? exportedProvider.forwardRef()
: exportedProvider;
this.container.addExportedProvider(fulfilledProvider, token);
}

public insertController(controller: Type<Controller>, token: string) {
Expand Down

0 comments on commit 970cb48

Please sign in to comment.