DefinitelyTyped/types/braintree
Simon Garner 5706c529a4
[braintree] Use discriminated union for WebhookNotifications (#42030)
* Use discriminated union for WebhookNotifications

Change the WebhookNotification types to know their own values for the `kind` property, so that the compiler can automatically infer types from it.

This also requires changing the notification types to be interfaces instead of classes, and changing `WebhookNotification` to be a union type instead of an abstract class.

Ref: https://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions

The result of all this is that a guard on the returned `notification.kind` will have the effect of narrowing the type of `notification` itself, so that explicit casts aren’t always necessary.

* Update test

* Revert kind to still be WebhookNotificationKind

* Group types for WebhookNotificationKind

* fix: missing semicolon
2020-02-03 10:19:53 -08:00
..
braintree-tests.ts [braintree] Use discriminated union for WebhookNotifications (#42030) 2020-02-03 10:19:53 -08:00
index.d.ts [braintree] Use discriminated union for WebhookNotifications (#42030) 2020-02-03 10:19:53 -08:00
tsconfig.json
tslint.json