Closed snigdha920 closed 6 months ago
authorEnabled
is not an option of the BookModule
, but rather an extra of it. It lives at the same level as useFactory
or useClass
when using registerAsync
, but looks like it lives at the same level as the options when using regular register
. This is not a bug, but the way the system is designed.
authorEnabled
is not an option of theBookModule
, but rather an extra of it. It lives at the same level asuseFactory
oruseClass
when usingregisterAsync
, but looks like it lives at the same level as the options when using regularregister
. This is not a bug, but the way the system is designed.
Clear, thx! I think we should add an example in the documentation, or a note, because from the documentation it looks like it's an option we can pass from registerAsync
too. If you agree, I can open a PR.
Is there an existing issue for this?
Current behavior
For a dynamic module built using the configurable module builder:
When configured using
registerAsync
, extra-options are set to the default value, not the value being providedWhen configured using
register
, the extra options are set to the value being providedMinimum reproduction code
https://github.com/snigdha920/nestjs-extra-options-bug
Steps to reproduce
Steps to reproduce
pnpm i
pnpm start:dev
in the rootAuthorModule
is not initialised, even though we passauthorEnabled
totrue
in theBookModule.registerAsync
configuration:registerAsync
configuration, and uncomment theregister
configuration inapp.module.ts
, then we see that theAuthorModule
is initialised:Expected behavior
The
AuthorModule
should be initialised when we passauthorEnabled
totrue
in theBookModule.registerAsync
configurationWhat I'm trying to do is import modules depending on config passed in. So in practice I use a ConfigService to pass the right config to the module:
But the extra options are not being set correctly when using registerAsync, and I can only use registerAsync because I want to use my ConfigService.
Package
Other package
No response
NestJS version
10.3.7
Packages versions
Node.js version
20.11.1
In which operating systems have you tested?
Other
No response