I have a literal type as a constructor parameter on my service:
export type MyType = 'val1' | 'val2';
@Injectable()
export class MyService {
myType: MyType;
constructor(private appService: AppService, private myType: MyType = 'val2') {
this.myType = myType;
}
}
I have an error on build time
Nest can't resolve dependencies of the MyService (AppService, ?). Please make sure that the argument String at index [1] is available in the AppModule context.
Potential solutions:
- If String is a provider, is it part of the current AppModule?
- If String is exported from a separate @Module, is that module imported within AppModule?
@Module({
imports: [ /* the Module containing String */ ]
})
How would you fix that?
that is my AppModule:
@Module({
imports: [HttpModule],
controllers: [AppController],
providers: [AppService, MyService, HttpClient],
})
export class AppModule {}