TS error on adding provider to a module
See original GitHub issueI’m submitting a…
[ ] Regression
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
vscode shows an error when adding a provider to a module:
ts]
Argument of type '{ providers: { provide: string; useFactory: () => Promise<any>; }[][]; exports: { provide: string...' is not assignable to parameter of type 'ModuleMetadata'.
Types of property 'providers' are incompatible.
Type '{ provide: string; useFactory: () => Promise<any>; }[][]' is not assignable to type 'Provider[]'.
Type '{ provide: string; useFactory: () => Promise<any>; }[]' is not assignable to type 'Provider'.
Type '{ provide: string; useFactory: () => Promise<any>; }[]' is not assignable to type 'FactoryProvider'.
Property 'provide' is missing in type '{ provide: string; useFactory: () => Promise<any>; }[]'.
The app boots fine when npm start
but vscode tells that something is wrong with TS.
Expected behavior
Import a provider to a module without error
Minimal reproduction of the problem with instructions
I have generated a new app with nest cli and took app.module.ts
, cats
and database
folder from this sample: https://github.com/nestjs/nest/tree/master/sample/14-mongoose-base .
Open cats.module.ts
or database.module.ts
in vscode and you should see the error.
Environment
[System Information]
OS Version : macOS High Sierra
NodeJS Version : v9.10.1
NPM Version : 5.8.0
[Nest Information]
microservices version : 5.0.0-beta.6
websockets version : 5.0.0-beta.6
mongoose version : 3.0.1
testing version : 5.0.0-beta.6
common version : 5.0.0-beta.6
core version : 5.0.0-beta.6
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Error: Provider configuration not present - Hashicorp Support
This occurs when a provider configuration is removed while objects created by that provider still exist in the state. Re-add the provider ...
Read more >angular - 'No provider' error (even though I've added a provider)
- I've added the Service and AppModule code. My index.ts file only contains export * from './app.component'; and export * from './app.
Read more >Add Provider to app.module.ts so is persistent across all ...
I have a DataService provider for connecting to a database. I store some data retrieved in that Provider Service. When I use ionic...
Read more >Common errors - FAQ - A progressive Node.js framework
The most common culprit of the error, is not having the <provider> in the module's providers array. Please make sure that the provider...
Read more >Singleton services - Angular
If a module defines both providers and declarations (components, directives, pipes), then loading the module in multiple feature modules would duplicate the ...
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
Solved on my side. In my case one of providers had
private constructor(...)
. Don’t ask why 😉@matheusdavidson check if by any chance it’s not the case in your code.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.