Reflect Metadata API cho phép đọc/ghi metadata trên class/method tại runtime.
- TypeScript emit metadata khi emitDecoratorMetadata: true (design:type, design:paramtypes, design:returntype).
- Dùng bởi dependency injection frameworks (Angular, NestJS) để resolve constructor params tự động.
typescript
import 'reflect-metadata';
@Injectable()
class UserService {
constructor(private repo: UserRepository) {}
// NestJS đọc design:paramtypes → tự inject UserRepository
}