stripe-node icon indicating copy to clipboard operation
stripe-node copied to clipboard

Refactor event type to string literals

Open itaied246 opened this issue 2 years ago • 1 comments

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

[email protected]

API version

2020-08-27

Additional context

No response

itaied246 avatar Jun 19 '22 10:06 itaied246

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.

dcr-stripe avatar Jul 26 '22 20:07 dcr-stripe

This has been fixed in v13.4.0; event.type is now a union of string literals!

huw avatar Sep 10 '23 08:09 huw