vercel / nextjs-subscription-payments

Clone, deploy, and fully customize a SaaS subscription application with Next.js.
https://subscription-payments.vercel.app/
MIT License
5.79k stars 1.19k forks source link

Type error `priceData` #297

Open guylepage3 opened 4 months ago

guylepage3 commented 4 months ago

Nice work on the update. Thank you.

One error that I am sure everyone is getting is a type error seen below. Someone should update this at some point. Thx.

2.217    ▲ Next.js 14.1.0
2.217    - Environments: .env.local
2.218 
2.232    Creating an optimized production build ...
19.52  ✓ Compiled successfully
19.52    Linting and checking validity of types ...
23.87 Failed to compile.
23.87 
23.87 ./utils/supabase/admin.ts:43:9
23.87 Type error: Type '{ id: string; product_id: string; active: boolean; currency: string; type: Type; unit_amount: number | null; interval: Interval | null; interval_count: number | null; trial_period_days: number; }' is missing the following properties from type '{ active: boolean | null; currency: string | null; description: string | null; id: string; interval: "day" | "week" | "month" | "year" | null; interval_count: number | null; metadata: Json; product_id: string | null; trial_period_days: number | null; type: "one_time" | ... 1 more ... | null; unit_amount: number | nu...': description, metadata
23.87 
23.87   41 |   maxRetries = 3
23.87   42 | ) => {
23.87 > 43 |   const priceData: Price = {
23.87      |         ^
23.87   44 |     id: price.id,
23.87   45 |     product_id: typeof price.product === 'string' ? price.product : '',
23.87   46 |     active: price.active,
23.90  ELIFECYCLE  Command failed with exit code 1.
iancuandrei commented 4 months ago

Hi! I'm getting the same error, did you manage to fix it?

guylepage3 commented 4 months ago

@iancuandrei If I remember correctly, I just updated my types.

chriscarrollsmith commented 3 months ago

I had dropped the 'description' and 'metadata' columns from the database schema in a PR and changed the types accordingly, because these are no longer really used by Stripe. The schema changes got rejected, but the types didn't get changed back.

You can run pnpm supabase:generate-types as a workaround to correct the issue until it's fixed.