-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Typescript errors when using Stripe with 1.18.0 #6701
Comments
I'm seeing the same issues in v1.18.0. |
Temporary workaround for me: const loaderData = useLoaderData<typeof loader>()
const subscription = loaderData?.subscription as unknown as Stripe.Subscription
const invoices = loaderData?.invoices as unknown as Stripe.Invoice[] | null You just gotta find out what the Stripe type is for the data you're using. |
Unfortunately this doesn't work for my use case, as I'm using the |
Looking into this reveals that TS is actually inferring the correct types. So not sure if this is a false positive. As a workaround, you can use // @ts-expect-error
const loaderData = useLoaderData<typeof loader>() Keeping an eye on this to see if its a TS issue or a Remix issue. |
I've managed to find a workaround it by doing something similar to @piotrkulpinski - just not a very elegant solution, but enough for typechecks to pass as a temporary solution. The only thing I know is that I'm not having any of these issues until it's gone through the Remix loader. I've obviously no idea whether it'd be a TS or Remix issue, but it seems odd that if it were a TS issue there aren't any issues from the stripe API directly when used in the loader or regular typescript, only when consuming it from |
Here's the smallest reproduction I've made so far. For example, using this type: type X = {
x?: X
} ...my mental model so far:
^ so the cycle get's detected by TS, but TS hasn't reduced the problem at all. It's still trying to answer "Is |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
What version of Remix are you using?
1.18.0
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
Here is a typescript playground reproduction
Stripe.InvoiceLineItem
in a loader.Expected Behavior
Everything to work with no issues, like when using the type inside a loader before it's gone through remix's loader data serializing/prettifying process.
Actual Behavior
It produces the following typescript errors:
Presumably due to the potentially cyclic nature of the stripe API if you expand these properties. I receive those errors when I try and directly access the object with the lineItems inside - not on the useLoaderData function call, like in the typescript playground reproduction.
EDIT: Similar to #6693 and #6558 (#6558 was resolved, so hoping this can also be resolved).
The text was updated successfully, but these errors were encountered: