The issue here is that NestJS does not automatically inject dependencies into a parent class constructor. When you extend a class, the super() constructor is called before the configService is available, leading to undefined.
Further explanation: NestJS automatically resolves dependencies without needing @Inject() because of TypeScript's metadata reflection (enabled by emitDecoratorMetadata and reflect-metadata).
When you extend the class PassportStrategy, TypeScript loses the type metadata for ConfigService in the subclass constructor.
NestJS can't infer ConfigService from readonly configService: ConfigService because the super() call is required first.
Since ConfigService is injected before the call to super(), the metadata isn't available at that point.
@Inject(ConfigService) explicitly tells NestJS:
Ignore the missing metadata, manually provide the correct dependency and force NestJS to resolve ConfigService properly.