-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
contribution welcomeThis is a good candidate for a community contributionThis is a good candidate for a community contributionenhancementNew feature or requestNew feature or request
Description
Thank you for awesome library!
I found that types has an edge case that is not covered.
There is no way to pass optional injection token.
In nest js there is a syntax for optional injection:
const connectionProvider = {
provide: 'CONNECTION',
useFactory: (optionsProvider: MyOptionsProvider, optionalProvider?: string) => {
const options = optionsProvider.get();
return new DatabaseConnection(options);
},
inject: [MyOptionsProvider, { token: 'SomeOptionalProvider', optional: true }],
// \______________/ \__________________/
// This provider The provider with this token
// is mandatory. can resolve to `undefined`.
};https://docs.nestjs.com/fundamentals/custom-providers
But this syntax is not described in types ClsModule.forFeatureAsync
So in my example:
ClsModule.forFeatureAsync({
provide: getTenantDataSourceToken(moduleName),
strict: true,
inject: [
CLS_REQ,
{ token: getMetricsServiceToken(moduleName), optional: true },
^^^^^
],
....I get an error: Object literal may only specify known properties, and token does not exist in type Function | Type<any> | Abstract<any
Metadata
Metadata
Assignees
Labels
contribution welcomeThis is a good candidate for a community contributionThis is a good candidate for a community contributionenhancementNew feature or requestNew feature or request