fix(build): resolve type errors in communications + stripe apiVersion
Deploy to route.crispygoat.com / deploy (push) Has been cancelled
Deploy to route.crispygoat.com / deploy (push) Has been cancelled
Two pre-existing type errors that were masking each other in the Gitea build
(Next.js's build worker exits on the first type-check failure):
1. src/app/admin/communications/page.tsx — the no-brand early-return was
passing initialAnalytics={{ success: true, analytics: null }} to a prop
typed as CampaignAnalytics[]. Switched to initialAnalytics={[]}.
2. Six files passed apiVersion: "2026-06-24.dahlia" to new Stripe(...), but
the installed stripe SDK 22.x union type only contains older API
versions. The five files using `as StripeApiVersion` (a local literal
type) didn't bypass the SDK's union check; the sixth had no cast at all.
Changed all to `as any` to pin a forward-dated API version safely.
Build verified locally: npm run build succeeds.
This commit is contained in:
@@ -25,7 +25,7 @@ await getSession(); const stripeKey = process.env.STRIPE_SECRET_KEY;
|
|||||||
if (!stripeKey) return { success: false, error: "Stripe not configured on this server." };
|
if (!stripeKey) return { success: false, error: "Stripe not configured on this server." };
|
||||||
|
|
||||||
const Stripe = (await import("stripe")).default;
|
const Stripe = (await import("stripe")).default;
|
||||||
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as StripeApiVersion });
|
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as any });
|
||||||
|
|
||||||
const lineItems = items.map((item) => ({
|
const lineItems = items.map((item) => ({
|
||||||
price_data: {
|
price_data: {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ await getSession(); const stripeKey = process.env.STRIPE_SECRET_KEY;
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Stripe = (await import("stripe")).default;
|
const Stripe = (await import("stripe")).default;
|
||||||
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as StripeApiVersion });
|
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as any });
|
||||||
|
|
||||||
// Compute the subtotal in cents. We don't compute sales tax here —
|
// Compute the subtotal in cents. We don't compute sales tax here —
|
||||||
// Stripe's `automatic_tax` would be ideal but requires address collection
|
// Stripe's `automatic_tax` would be ideal but requires address collection
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ await getSession();
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Stripe = (await import("stripe")).default;
|
const Stripe = (await import("stripe")).default;
|
||||||
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as StripeApiVersion });
|
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as any });
|
||||||
|
|
||||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:3000";
|
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:3000";
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ await getSession();
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Stripe = (await import("stripe")).default;
|
const Stripe = (await import("stripe")).default;
|
||||||
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as StripeApiVersion });
|
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as any });
|
||||||
|
|
||||||
// Retrieve subscription and find the item for this add-on
|
// Retrieve subscription and find the item for this add-on
|
||||||
const subscription = await stripe.subscriptions.retrieve(subData.stripe_subscription_id);
|
const subscription = await stripe.subscriptions.retrieve(subData.stripe_subscription_id);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ await getSession(); const adminUser = await getAdminUser();
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Stripe = (await import("stripe")).default;
|
const Stripe = (await import("stripe")).default;
|
||||||
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as StripeApiVersion });
|
const stripe = new Stripe(stripeKey, { apiVersion: "2026-06-24.dahlia" as any });
|
||||||
|
|
||||||
const session = await stripe.billingPortal.sessions.create({
|
const session = await stripe.billingPortal.sessions.create({
|
||||||
customer: stripeCustomerId,
|
customer: stripeCustomerId,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export default async function CommunicationsRootPage() {
|
|||||||
templates={[]}
|
templates={[]}
|
||||||
brandId=""
|
brandId=""
|
||||||
initialSegments={[]}
|
initialSegments={[]}
|
||||||
initialAnalytics={{ success: true, analytics: null }}
|
initialAnalytics={[]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ function getStripeClient(): Stripe {
|
|||||||
throw new Error("STRIPE_SECRET_KEY environment variable is not set");
|
throw new Error("STRIPE_SECRET_KEY environment variable is not set");
|
||||||
}
|
}
|
||||||
_stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
|
_stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
|
||||||
apiVersion: "2026-06-24.dahlia",
|
apiVersion: "2026-06-24.dahlia" as any,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return _stripe;
|
return _stripe;
|
||||||
|
|||||||
Reference in New Issue
Block a user