In nestjs, I understand that
imports: [
TypeOrmModule.forFeature([TaskRepository]),
],
creates some kind of provider token so then I can inject the repository in my service (in same module) with this token.
What I don't understand is how @InjectRepository() works internally, for example:
constructor(
@InjectRepository(TaskRepository)
private taskRepository: TaskRepository,
) {}
How is InjectRepository custom decorator (which should have been created with createParamDecorator) able to inject a provider registered in a module? I researched and found out that createParamDecorator doesn't have ability to use DI. If createParamDecorator just creates a new TaskRepository instance and returns it, then why do I need to import TypeOrmModule.forFeature in module? Can someone explain how this works internally? Thanks!