stripe-node
stripe-node copied to clipboard
Refactor event type to string literals
Describe the bug
event.type === "payment_intent.created" // correct
event.type === "payment_intent.not_exist_type" // incorrect - should not compile
The Event
interface type
field should be string literals instead of string
:
/**
* Description of the event (e.g., `invoice.created` or `charge.refunded`).
*/
type: string;
To Reproduce
event.type === "payment_intent.not_exist_type"
Expected behavior
Running typescript compilation should fail
Code snippets
You should create the string literals of the events:
type: "payment_intent.created" | "payment_intent.succeeded" ...
OS
Ubuntu
Node version
Node v16.15.0
Library version
API version
2020-08-27
Additional context
No response
Hey @itaied246 - thanks for the report. I'll label this as a feature request - I think this is a really interesting idea and something we'll want to consider in our future roadmap.
This has been fixed in v13.4.0; event.type
is now a union of string literals!