Fix StripeProvider stripe prop

This commit is contained in:
Jonathan Ingram
2018-06-16 13:06:41 +10:00
parent ebf0b6ada7
commit c37b9bf467
2 changed files with 16 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ export namespace ReactStripeElements {
interface StripeProviderOptions {
stripeAccount?: string;
}
type StripeProviderProps = { apiKey: string; stripe?: never; } & StripeProviderOptions | { apiKey?: never; stripe: StripeProps | null; } & StripeProviderOptions;
type StripeProviderProps = { apiKey: string; stripe?: never; } & StripeProviderOptions | { apiKey?: never; stripe: stripe.Stripe | null | null; } & StripeProviderOptions;
interface StripeProps {
createSource(sourceData?: SourceOptions): Promise<SourceResponse>;

View File

@@ -16,7 +16,6 @@ import ElementChangeResponse = stripe.elements.ElementChangeResponse;
import ElementsOptions = stripe.elements.ElementsOptions;
import ElementsCreateOptions = stripe.elements.ElementsCreateOptions;
import PatchedTokenResponse = ReactStripeElements.PatchedTokenResponse;
import StripeProps = ReactStripeElements.StripeProps;
const cardElementProps: ElementsOptions = {
iconStyle: 'solid',
@@ -185,7 +184,7 @@ const ElementsDefaultPropsTest: React.SFC = () => (
const TestStripeProviderProps1: React.SFC = () => <StripeProvider apiKey="" />;
const TestStripeProviderProps2: React.SFC<{
stripe: StripeProps;
stripe: stripe.Stripe;
}> = props => <StripeProvider stripe={props.stripe} />;
/**
@@ -193,9 +192,22 @@ const TestStripeProviderProps2: React.SFC<{
* See: https://github.com/stripe/react-stripe-elements#props-shape
*/
const TestStripeProviderProps3: React.SFC<{
stripe: StripeProps;
stripe: stripe.Stripe;
}> = props => <StripeProvider stripe={null} />;
/**
* End-to-end usage of loading stripe.js asynchronously.
* See: https://github.com/stripe/react-stripe-elements#loading-stripejs-asynchronously
*/
const TestStripeProviderProps4: React.SFC<{
stripe: null | stripe.Stripe
}> = props =>
<StripeProvider stripe={props.stripe}>
<Elements>
<div />
</Elements>
</StripeProvider>;
/**
* StripeProvider should be able to accept options.
* See: https://stripe.com/docs/stripe-js/reference#stripe-function for options.