When implementing the dependency injection pattern in NestJS, such as shown in this example from the official documentation:
import { Controller, Get, Post, Body } from '@nestjs/common';
import { CreateCatDto } from './dto/create-cat.dto';
import { CatsService } from './cats.service';
import { Cat } from './interfaces/cat.interface';
@Controller('cats')
export class CatsController {
constructor(private catsService: CatsService) {}
// Other methods...
}
How does this mechanism function? It seems that TypeScript is transpiled into plain JavaScript, potentially losing the type information for the CatsService
class. How does NestJS manage to correctly inject the appropriate class in this scenario?