#DeathByPorkChop
1 messages · Page 1 of 1 (latest)
hello! what doesn't work? Are you getting an error?
Hello, yeah I get a Typescript error that no overloads match this call
Unfortunately the error isn't showing up in the console, but I can send the typescript error
No overload matches this call.
Overload 1 of 2, '(options?: StripeElementsOptionsClientSecret): StripeElements', gave the following error.
Argument of type 'StripeElementsOptions' is not assignable to parameter of type 'StripeElementsOptionsClientSecret'.
Type 'StripeElementsOptionsMode' is not assignable to type 'StripeElementsOptionsClientSecret'.
Types of property 'mode' are incompatible.
Type 'string' is not assignable to type 'never'.
Type 'string' is not assignable to type 'never'.
Overload 2 of 2, '(options?: StripeElementsOptionsMode): StripeElements', gave the following error.
Argument of type 'StripeElementsOptions' is not assignable to parameter of type 'StripeElementsOptionsMode'.
Type 'StripeElementsOptionsClientSecret' is not assignable to type 'StripeElementsOptionsMode'.
Types of property 'clientSecret' are incompatible.
Type 'string' is not assignable to type 'never'.ts(2769)
are you using the TypeScript definitions included in the stripe-node SDK?
Is it an independent package? I have /stripe-js in my package.json
ah no, it's not an independent package. It slipped my mind that this is client-side
Sorry I also forgot to mention this is client side
What I find strange is that this error only showed up in the last week/10 days, though the code hasn't changed in 3 months
So I need to install the stripe-node sdk?
Hi @brisk hearth can you share the relevant code that you wrote?
function setupElements(stripeElementsOptions: StripeElementsOptions) {
return state.stripe?.elements(stripeElementsOptions);
}
No you don't need to install stripe-node sdk, that's for backend
And are you using the latest version of stripe-js ?https://www.npmjs.com/package/@stripe/stripe-js
I just upgraded it earlier today
How do you import StripeElementsOptions ?
Can you share with me the complete so that I can try to reproduce at my end?
import type { StripeElementsOptions } from "@ stripe/stripe-js";
I mean the complete source code, not just the import statement
ahh okay, one sec
interface State {
stripe: Stripe | null;
elements: StripeElements | undefined;
elementOptions: StripeElementsOptions;
}
const state = {
stripe: null,
elements: undefined,
elementOptions: {},
}
async function setupStripe() {
state.stripe = await loadStripe(publishableKey.value as string);
state.elements = setupElements(state.elementOptions);
}
function setupElements(stripeElementsOptions: StripeElementsOptions) {
return state.stripe?.elements(stripeElementsOptions);
}
First you need to set the type for state variable
const state: State = {
stripe: null,
elements: undefined,
elementOptions: {},
}
Second, the type that stripe.elements() accept is either StripeElementsOptionsClientSecret, or StripeElementsOptionsMode, not StripeElementsOptions
So you might want to decide which type (StripeElementsOptionsClientSecret, or StripeElementsOptionsMode) to use, and use that type for elementOptions