goshippo / shippo-javascript-sdk

MIT License
5 stars 0 forks source link

Export of shippo types #16

Closed alsoscotland closed 2 months ago

alsoscotland commented 2 months ago

I am currently in the process of upgrading from 1.71->2.1.2 and I really appreciate that you are moving to support typescript types. I have been rolling my own approximate types for some time now.

I am curious if you have any advice on importing and leveraging your types directly in node, or if making them more explicit exports would be something you would potentially consider doing in a future release.

As an example I see that

Shippo.addresses.create()

// has a return type at components.Address
// https://github.com/goshippo/shippo-javascript-sdk/blob/main/docs/models/components/address.md

Since this type is not explicitly exported, I do not see a way to import type { Address } from 'shippo' in my node code. This would be very useful if it would be something you could offer in a future release.

shippo-lueders commented 2 months ago

the return types are actually exported from a subdirectory. Try this import {Address} from "shippo/models/components";

Usually, an IDE would autocomplete this information - can you share any details about your environment/IDE?

We don't explicitly state this in the docs anywhere, I'll speak with the team about making this more clear.

alsoscotland commented 2 months ago

Interesting. I use VSCode. It may be more intuitive to be able to import them from the top level of the package.

In looking more at the package, the node_modules install has the types exported at both shippo/models/components and shippo/src/models/components

the IDE may have trouble with resolving due to the redundancy

shippo-lueders commented 2 months ago

It may be more intuitive to be able to import them from the top level of the package.

that's a fair point. should have an update pushed later today, thanks for the feedback!

shippo-lueders commented 2 months ago

just published https://www.npmjs.com/package/shippo/v/2.2.0 which should address this, if not please re-open