Closed sangrepura closed 8 months ago
Also there is another minor mismatch for the apiVersion
:
src/lib/stripe/index.ts:4:3 - error TS2322: Type '"2023-08-16"' is not assignable to type '"2023-10-16"'.
4 apiVersion: "2023-08-16",
fix:
--- a/src/lib/stripe/index.ts
+++ b/src/lib/stripe/index.ts
- apiVersion: "2023-08-16",
+ apiVersion: "2023-10-16",
Hey @sangrepura - thanks for flagging! This has been resolved with 3508b58 and will be pushed as part of the next update (later today). Cheers!
Summary
name: Typescript Error about: Mismatch between the shape of objects labels: bug
Bug Description
When selecting Stripe the generated code has the following Typescript errors:
Steps To Reproduce
Steps to reproduce the behavior:
npx create-next-app@latest myProject
tsc --project ./tsconfig.json
Expected behavior No Typescript Errors
Proposed Solution
The error is due to a mismatch between the shape of the object returned by
getUserSubscriptionPlan
and the expected properties of thePlanSettingsProps
interface.Use null Instead of undefined:
Since the
PlanSettingsProps
interface expects properties to be string | null, not undefined, return null instead of undefined fromgetUserSubscriptionPlan()
for properties that don't have values:stripeSubscriptionId: [-undefined,-]{+null,+}
stripeCurrentPeriodEnd: [-undefined,-]{+null,+}
stripeCustomerId: [-undefined,-]{+null,+}
Handle Types in the
getUserSubscriptionPlan
function:When returning an object from
getUserSubscriptionPlan
, ensure that we are returning an object that fits thePlanSettingsProps
type. This can be done using type assertion.Here's the full diff that fixes it: