useValue bugged in latest version
See original GitHub issueBug Report
Current behavior
I try to write a dynamic module. Check the gist from 🙏 @evolkmann. I get a compiler error:
Returned expression type ... is not assigneable to DynamicModule
If you switch to useClass
it seamlessly works. What am I doing wrong or is it a bug?
Input Code
https://gist.github.com/evolkmann/1019721d46304df3d8ff7adbca87d8ec
Expected behavior
No compiler error since this should work acc. to official docs and I assume gist worked once.
Possible Solution
It works with
{
provide: MyLibService,
useFactory: () => {
return new MyLibService(type);
},
}
But it should accept a value too…?
Environment
"@nestjs/common": "^6.7.2",
"@nestjs/core": "^6.7.2",
For Tooling issues:
- Node version:
"node": "10.16.2"
"npm": "6.10.3"
- Platform: Mac
Others:
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Bug of ValueProvider · Issue #2732 · nestjs/nest
Bug Report Current behavior When 'useValue' is undefined, ... Nest version: 6.5.3 For Tooling issues: - Node version: 10.15.0 - Platform: ...
Read more >Value annotation not working in Junit test - java
Following works for me. It picks up value from the application.properties file.
Read more >Known issues
Known issues. The following issues have been identified in version 7.2.3. To inquire about a particular bug or report a bug, please contact...
Read more >Angular Providers: useClass, useValue, useFactory & ...
Configuring the Angular Provider. To Provide an instance of the dependency, we need to register it in the Providers metadata. In our last...
Read more >Dependency injection in action
The useValue key lets you associate a fixed value with a DI token. Use this technique to provide runtime configuration constants such as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
🎺 Turns out,
rm -rf .idea
does not completely invalidate all caches, weird! I also deleted cachesFile > Invalidate caches / Restart
and now it works. Sorry everyone to bother.@angelov-todor @dboskovic just fixed in
@nestjs/graphql@6.5.3
. Thanks for reporting!