Open L2jLiga opened 3 years ago
Here my solution on how I solved this issue while preserving type safety and removing my linting errors.
First of all I extended the existing interface as follows:
interface customSubscriptionListParams extends _subscription.subscription_list_params {
filename?: filter._string;
}
afterwards I just made a cast to this interface like:
this._chargebeeClient.subscription
.list(<customSubscriptionListParams>{
limit: 1,
cf_filename: { is: filename },
})
Hence, the type checks exists for the default variables but also for the additional custom field.
The only draw back I see is that this needs to be adapted per request instead of that there would be a central location which is exactly what @jaska120 asked for in https://github.com/chargebee/chargebee-typescript/issues/28.
Hence, Chargebee, if you have a solution to that, please let us know.
Could do something like this too, alternative, has it's draw backs
declare module 'chargebee-typescript' {
namespace _subscription {
interface subscription_list_params {
cf_filename?: filter._string;
}
}
}
Hi @L2jLiga, I'm sorry for the dealyed response.
Thank you @ced-mos for the solution. I'd also suggest extending the predefined interface to include your custom field. @L2jLiga — were you able to try this and did it help?
In chargebee we used additional fields inside
subscription
likecf_filename
which is impossible with this library and we have to castsubscription
object asany