Open
Description
Is your feature request related to a problem? Please describe.
I'm often writing the same TypeScript code to narrow the types returned by the API to extract item IDs. Example:
const price = await stripe.prices.retrieve(priceId);
const { product } = price;
// this part
const productId = (typeof product === 'string' ? product : product.id);
Describe the solution you'd like
It would be nice if this library included a helper method for this, e.g.
function getId(stripeObject: { id: string } | string) {
return typeof stripeObject === 'string' ? stripeObject : stripeObject.id;
}
Then I could write
const price = await stripe.prices.retrieve(priceId);
const { product } = price;
const productId = getId(product);
Describe alternatives you've considered
I could just write this function for use in my personal projects, but if this is a common problem/use-case I think including it in the library would be good so others could use it too
Additional context
No response