Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Narrower type for stripe.invoices.retrieveUpcoming() #1629

Merged
merged 5 commits into from Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/Invoices.d.ts
Expand Up @@ -40,7 +40,7 @@ declare module 'stripe' {
/**
* Unique identifier for the object. This property is always present unless the invoice is an upcoming invoice. See [Retrieve an upcoming invoice](https://stripe.com/docs/api/invoices/upcoming) for more details.
*/
id?: string;
id: string;

/**
* String representing the object's type. Objects of the same type share the same value.
Expand Down
4 changes: 2 additions & 2 deletions types/InvoicesResource.d.ts
Expand Up @@ -2168,10 +2168,10 @@ declare module 'stripe' {
retrieveUpcoming(
params?: InvoiceRetrieveUpcomingParams,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.Invoice>>;
): Promise<Stripe.Response<Stripe.UpcomingInvoice>>;
retrieveUpcoming(
options?: RequestOptions
): Promise<Stripe.Response<Stripe.Invoice>>;
): Promise<Stripe.Response<Stripe.UpcomingInvoice>>;

/**
* Search for invoices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language).
Expand Down
7 changes: 7 additions & 0 deletions types/UpcomingInvoices.d.ts
@@ -0,0 +1,7 @@
// File generated from our OpenAPI spec
pakrym-stripe marked this conversation as resolved.
Show resolved Hide resolved
richardm-stripe marked this conversation as resolved.
Show resolved Hide resolved

richardm-stripe marked this conversation as resolved.
Show resolved Hide resolved
declare module 'stripe' {
namespace Stripe {
type UpcomingInvoice = Omit<Stripe.Invoice, 'id'>;
}
}
1 change: 1 addition & 0 deletions types/index.d.ts
Expand Up @@ -7,6 +7,7 @@
///<reference path='./Errors.d.ts' />
///<reference path='./OAuth.d.ts' />
///<reference path='./Webhooks.d.ts' />
///<reference path='./UpcomingInvoices.d.ts' />
///<reference path='./AccountsResource.d.ts' />
///<reference path='./AccountLinksResource.d.ts' />
///<reference path='./ApplePayDomainsResource.d.ts' />
Expand Down
4 changes: 4 additions & 0 deletions types/test/typescriptTest.ts
Expand Up @@ -123,6 +123,10 @@ stripe = new Stripe('sk_test_123', {
return undefined;
});

// @ts-expect-error
richardm-stripe marked this conversation as resolved.
Show resolved Hide resolved
(await stripe.invoices.retrieveUpcoming()).id;
(await stripe.invoices.retrieve('')).id;

try {
await stripe.paymentIntents.create({amount: 100, currency: 'USD'});
} catch (err) {
Expand Down