mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
Fix StripeProvider stripe prop
This commit is contained in:
2
types/react-stripe-elements/index.d.ts
vendored
2
types/react-stripe-elements/index.d.ts
vendored
@@ -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>;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user