#gabor
1 messages · Page 1 of 1 (latest)
Hi, this is the TS error:
Type 'import("stripe").Stripe.SubscriptionSchedule.Phase' is not assignable to type 'import("stripe").Stripe.SubscriptionScheduleUpdateParams.Phase'.
Types of property 'add_invoice_items' are incompatible.
Type 'import("stripe").Stripe.SubscriptionSchedule.Phase.AddInvoiceItem[]' is not assignable to type 'import("stripe").Stripe.SubscriptionScheduleUpdateParams.Phase.AddInvoiceItem[]'.
Type 'import("stripe").Stripe.SubscriptionSchedule.Phase.AddInvoiceItem' is not assignable to type 'import("stripe").Stripe.SubscriptionScheduleUpdateParams.Phase.AddInvoiceItem'.
Types of property 'price' are incompatible.
Type 'string | Price | DeletedPrice' is not assignable to type 'string | undefined'.
Type 'Price' is not assignable to type 'string'.ts(2322)
As far as I understand there is a conflict between the schedule.phases I'm trying to include with the spread operator and what stripe.subscriptionSchedules.update expects.
subscription is a result of a query with stripe.subscriptions.retrieve(), expanded with the schedule object.
We suspect that the schedule returned is just raw JSON so you would need to cast each parameter to it's corresponding type.
Oh, that makes sense! Thank you!
Although TS says subscription.schedule is string | Stripe.SubscriptionSchedule
and schedule.phases is Stripe.SubscriptionSchedule.Phase[]
You can review the types specified in our Node.js SDK here: https://github.com/stripe/stripe-node/blob/master/types/SubscriptionSchedulesResource.d.ts
Thanks. Apart from types, is my base concept of including the existing phases and adding new ones like that correct?
It appears so.. but I'd recommend that you review some of the example codes here for different use cases: https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases