Skip to content

Commit 3aa6288

Browse files
authored
feat(openiap): add discriminated union support (#3084)
Add discriminated union support with `ProductOrSubscription`
1 parent 41a1403 commit 3aa6288

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

openiap-versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"apple": "1.2.31",
33
"google": "1.3.4",
4-
"gql": "1.2.4"
4+
"gql": "1.2.5"
55
}

src/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export interface ExternalPurchaseNoticeResultIOS {
166166
result: ExternalPurchaseNoticeAction;
167167
}
168168

169-
export type FetchProductsResult = Product[] | ProductSubscription[] | null;
169+
export type FetchProductsResult = ProductOrSubscription[] | Product[] | ProductSubscription[] | null;
170170

171171
export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios' | 'user-choice-billing-android';
172172

@@ -354,6 +354,8 @@ export interface ProductIOS extends ProductCommon {
354354
typeIOS: ProductTypeIOS;
355355
}
356356

357+
export type ProductOrSubscription = Product | ProductSubscription;
358+
357359
export type ProductQueryType = 'in-app' | 'subs' | 'all';
358360

359361
export interface ProductRequest {
@@ -526,7 +528,7 @@ export interface Query {
526528
/** Get current StoreKit 2 entitlements (iOS 15+) */
527529
currentEntitlementIOS?: Promise<(PurchaseIOS | null)>;
528530
/** Retrieve products or subscriptions from the store */
529-
fetchProducts: Promise<(Product[] | ProductSubscription[] | null)>;
531+
fetchProducts: Promise<(ProductOrSubscription[] | Product[] | ProductSubscription[] | null)>;
530532
/** Get active subscriptions (filters by subscriptionIds when provided) */
531533
getActiveSubscriptions: Promise<ActiveSubscription[]>;
532534
/** Fetch the current app transaction (iOS 16+) */

0 commit comments

Comments
 (0)