Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This improves three friction points when working with Typescript: 1. `new StripeResource(stripe)` now works. Prior to this change, attempting to construct `StripeResource` with its one required argument would fail a type check. Support for a constructor was added in stripe#1245 and extended in stripe#1249 (never merged). Thanks @rattrayalex! 2. `StripeResource.extend` now returns a class that is properly typed when instantiated. Prior to this change, you could extend `StripeResource` but your extensions wouldn't appear on the object after construction. Now, it does. 3. `StripeResource.method` returns a function that returns `Response<object>`. Prior to this change, extensions created with `StripeResource.method` would have a return type of `object`. Returning `Response<object>` makes it possible to call functions like `lastResponse` without casting the value. 4. `StripeResource.method` now accepts generic type that sets the response object's type. For example, if you're hitting a customer endpoint, you can do this: `StripeResource.method<Customer>(...)`. When you use that extension, it will return `Response<Customer>`. This eliminates the need to cast when calling StripeResource extension methods. # Conflicts: # types/lib.d.ts # types/test/typescriptTest.ts
- Loading branch information