-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export object interfaces from Typescript definitions #1502
Comments
Hi @volkanunsal! Thank you for your report. We are going to investigate exporting interface definitions from the d.ts files. To unblock you, could you try prefixing the interface names with const stripe = new Stripe("sk_123");
const subscriptions: Stripe.ApiList<Stripe.Subscription> = await stripe.subscriptions.list();
const subscription: Stripe.Subscription = subscriptions.data[0];
console.log(subscription.id); |
Strange. I tried that but it didn’t work for me. |
Are you using some compiler magic? Do I need to add something to tsconfig.json to make that work? |
Some updates. I thought it wasn't working because the types aren't populated when I start typing the type name, but I can actually use them by reference, even though intellisense doesn't know they're there. That's good enough for me. |
No compiler magic. When I tested I used this tsconfig.json. I think {
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "node"
},
"include": ["index.ts"],
"exclude": [
"node_modules"
]
} |
I can't seem to use the types either. Exporting the interfaces directly seems like a no-brainer and it was most libraries do. Also, VSCode has major issues when trying to work with the entire Stripe namespace. It grinds to a halt. |
Thanks for writing in @ryantbrown and continuing to write in @volkanunsal. This is an active area of work for the team right now. in 2023. We're working on a fairly major redesign of how the library is exported/imported and as part of that we will look at this specifically and I'm re-opening the ticket accordingly. |
The readme says don't use import * as StripeAPI from 'stripe'
const Stripe = Context.Tag<StripeAPI.Stripe>('stripe')
const makeStripeLayer = (stripeAPIKey: string) =>
Layer.succeed(
Stripe,
new StripeAPI.Stripe(stripeAPIKey, {
apiVersion: '2022-11-15',
typescript: true, // "Optionally indicate that you are using TypeScript. This currently has no runtime effect other than adding "TypeScript" to your user-agent."
})
)
const listPayouts = (args: StripeAPI.Stripe.PayoutListParams) =>
Effect.flatMap(Stripe, (stripe) =>
Effect.tryPromise(() => stripe.payouts.list(args))
) |
Is this still in the works? |
Is your feature request related to a problem? Please describe.
I need to be able to reference object interfaces defined inside the Stripe namespace, but I'm unable to because these interfaces aren't exported.
Describe the solution you'd like
Please modify your generator to add
export
in front of interface declarations.Describe alternatives you've considered
I currently have to copy and paste the interfaces into my app.
Additional context
No response
The text was updated successfully, but these errors were encountered: