NestJS · Senior · Question 1 of 75
How does Nest know what to inject into constructor(private users: UsersService)?
- ✓Correct answer: TypeScript emits
design:paramtypesmetadata (withemitDecoratorMetadata), and Nest reads it viareflect-metadatato look up providers by class token - 2Nest parses the source file at runtime
- 3Nest injects by parameter name
Explanation
That's why type-only imports (import type) or interfaces break injection: there is no runtime value to use as a token.