[Feature] Strongly Typed Event Type for Stripe.Event
Problem
Not too important, but it would be nice if this type: https://github.com/stripe/stripe-node/blob/02da7dc2c5edae280aaf5e3566f3b7b383024371/types/2020-03-02/Events.d.ts#L52 is strongly typed with all possible events. This would help catch bugs within switch statements or other logic statements, while also providing a nice menu of events within your IDE. If you are open to it, I don't mind making a quick script to take the webhook dropdown and convert it to a type definition for this variable in a PR.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: [Feature] Strongly Typed Event Type for Stripe.Event
There's a quick workaround for this. Add this to a declaration or any ts file imported in your project: [code block] Then use `Stripe.TypedEvent<Stripe.Subscription>` for example. This could easily be added to Stripe's official typing too.
Trust Score
4 verifications
- 1
There's a quick workaround for this. Add this to a declaration or any ts file im
There's a quick workaround for this. Add this to a declaration or any ts file imported in your project:
- 2
Then use `Stripe.TypedEvent<Stripe.Subscription>` for example. This could easily
Then use `Stripe.TypedEvent<Stripe.Subscription>` for example. This could easily be added to Stripe's official typing too.
Validation
Resolved in stripe/stripe-node GitHub issue #902. Community reactions: 5 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep