Skip to content

Commit

Permalink
add if_required type to PE fields.billingDetails.address (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
graceg-stripe authored Oct 8, 2024
1 parent 5965cef commit 94a07cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions tests/types/src/invalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ elements.create('payment', {
defaultValues: {card: {network: 'invalid_network'}},
});

// invalid value for fields
// @ts-expect-error: No overload matches this call
elements.create('payment', {
fields: {
billingDetails: 'if_required',
},
});

paymentElement.on('change', (e) => {
// @ts-expect-error: `error` is not present on PaymentElement "change" event.
if (e.error) {
Expand Down
2 changes: 1 addition & 1 deletion tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ const paymentElement: StripePaymentElement = elements.create('payment', {
billingDetails: {
email: 'never',
phone: 'auto',
address: 'never',
address: 'if_required',
},
},
terms: {
Expand Down
1 change: 1 addition & 0 deletions types/stripe-js/elements/payment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export interface FieldsOption {
phone?: FieldOption;
address?:
| FieldOption
| 'if_required'
| {
country?: FieldOption;
postalCode?: FieldOption;
Expand Down

0 comments on commit 94a07cf

Please sign in to comment.