-
Notifications
You must be signed in to change notification settings - Fork 140
Description
Description:
We are currently using recurly-js in a TypeScript project, and we've noticed a lack of comprehensive TypeScript type definitions for functionalities related to coupons. This makes it challenging to integrate coupon-related operations seamlessly and safely within our TypeScript codebase, as we lose the benefits of type checking and auto-completion.
Specifically, we are looking for types that cover:
Coupon objects: The structure of a coupon returned by the API. Examples of the types we'd find beneficial include:
export type RecurlyCouponFrequencyUnit = "day" | "week" | "month" | "year"
export type RecurlyCouponType = "dollars" | "percent" | "free_trial"
export type RecurlyCouponDuration = "single_use" | "temporal" | "forever"
export type MonetaryAmount = { [currency: string]: number }
export type RecurlyCouponTrial = {
unit?: RecurlyCouponFrequencyUnit
amount: number
}
export type RecurlyCouponDiscount = {
type: RecurlyCouponType
amount?: MonetaryAmount
trial: RecurlyCouponTrial
rate?: number | null
}
export type RecurlyCouponResult = {
discount: RecurlyCouponDiscount
plans: string[]
applies_to_all_plans: boolean
code: string
temporal_unit?: RecurlyCouponFrequencyUnit
temporal_amount: number
duration: RecurlyCouponDuration
}
export type RecurlyCouponError = {
code: string
}
Coupon lists/arrays: Types for collections of coupons.
Methods related to coupons: For example, if there are methods to fetch, apply, or validate coupons, their parameters and return types would be highly beneficial.
Impact:
Without these types, developers working with recurly-js in TypeScript projects have to resort to any types or manually define interfaces, which can lead to runtime errors and a less robust development experience. Adding these types would significantly improve developer experience and code quality for TypeScript users of recurly-js.
Proposed Solution:
We kindly request that you consider adding official TypeScript type definitions for all relevant coupon-related objects and methods directly within the recurly-js package. This would ensure that the types are always up-to-date with the library's functionality.
Thank you for considering this request!