[x] Regression
[ ] 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
It is not possible to create a custom provider use (providers: {provide: 'Interface', useClass: implements this interface''}).
There is an interface that describes the functions
import { User } from './user';
export interface UserCommandRepository {
/**
* @param {number} id
* @returns {Promise}
*/
byId(id: number): Promise
/**
* @param {User} user
*/
store(user: User): Promise;
}
Next, I created a class that implements this interface
TS2345: Argument of type '{ imports: (typeof CQRSModule)[]; controllers: (typeof AuthorizationController)[]; providers: { p...' is not assignable to parameter of type 'ModuleMetadata'. Types of property 'providers' are incompatible. Type '{ provide: string; useClass: typeof TypeOrmUserCommandRepository; }[]' is not assignable to type 'Provider[]'. Type '{ provide: string; useClass: typeof TypeOrmUserCommandRepository; }' is not assignable to type 'Provider'. Type '{ provide: string; useClass: typeof TypeOrmUserCommandRepository; }' is not assignable to type 'FactoryProvider'. Property 'useFactory' is missing in type '{ provide: string; useClass: typeof TypeOrmUserCommandRepository; }'
Expected behavior
The provider must associate the interface and implementations for further use of the interface.
Example:
I'm submitting a...
Current behavior
It is not possible to create a custom provider use (providers: {provide: 'Interface', useClass: implements this interface''}). There is an interface that describes the functions
Next, I created a class that implements this interface
Then I created the provider in the module
And i have error
Expected behavior
The provider must associate the interface and implementations for further use of the interface. Example:
Minimal reproduction of the problem with instructions
In the repository (https://github.com/santaz1995/nestjs-cqrs-starter) , you can look at any module that is on the path 'src/http/modules/'
Environment