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

Typescript #46

Closed
leemhenson opened this issue Feb 20, 2020 · 14 comments
Closed

Typescript #46

leemhenson opened this issue Feb 20, 2020 · 14 comments

Comments

@leemhenson
Copy link

Hi. Do you plan to release Typescript declarations for this library?

@ScopeyNZ
Copy link
Contributor

It's not in our timeline right now, but we're happy to accept contributions!

@ElijahKotyluk
Copy link

I would be willing to work on this. There are a couple options for doing this. You can create a types repo and publish it to TypeScript's @types/ organization on npm or include an index.d.ts file inside the main repo and include types | typings in the package.json which will point to the path of the types file.

@robbieaverill
Copy link
Contributor

Thanks @ElijahKotyluk, that’s be really cool. We would prefer the latter of those options. Let us know if you need any help!

@ElijahKotyluk
Copy link

Sounds good, I'll get a PR going in the next couple days. Thank you!

@robbieaverill
Copy link
Contributor

I've been looking into this a little today, and just wanted to say that while we are hoping to be able to auto-generate types from our Chec API documentation, at this stage I don't believe we have enough structured data to do that. This may mean (at least initially) that we publish types manually.

@robbieaverill
Copy link
Contributor

I've created types for all our response models, and written some basic TS definitions for the "features" of the Commerce.js API - see here: https://github.com/chec/commerce.js/compare/feature/commerce.ts?expand=1

We could tidy these up and publish them as a standalone package via @types/commercejs or similar, or we could release a v3 of Commerce.js which is natively written in TypeScript.

@timnlupo
Copy link

+1 on support for this

@fmendoza
Copy link
Contributor

+1 happy to help if needed.

@PaitoAnderson
Copy link
Contributor

PaitoAnderson commented May 26, 2021

I've submitted this to DefinitelyTyped as suggested, there are still a lot of any types and I'm sure some of the types provided aren't 100%, but it's a start. @types/chec__commerce.js

@robbieaverill
Copy link
Contributor

@PaitoAnderson thanks for taking the time to do this! We'll need to work out the best way to version Commerce.js and the corresponding types library against the date based versioning of the Chec API, but this is something we'll work out internally. It looks like the upstream types library matches the tags from this repo, which makes this easier to maintain going forwards.

@PaitoAnderson
Copy link
Contributor

@robbieaverill No problem, thanks for getting it started. I was thinking about that too, it does seem complicated especially because the Chec-Version can be specified when using the library like you mentioned. Hopefully these types are useful to others just getting started with the library like myself!

@ScopeyNZ
Copy link
Contributor

Just to be as open as possible, we've been thinking about switching our versioning system with Commerce.js so that we can include API date versions in the commerce.js version. This would then set a default Chec-Version header for responses that are consistent with the types (or something like that).

We are considering some pretty major plans for a Commerce.js 3.0 though, so it might be bundled with that. So much to do and so little time!

@robbieaverill
Copy link
Contributor

It's a good point though that if you use a custom version via request headers, your TS definitions are probably not going to match up. We'll need to consider an accessible way for people to install specific versions of the types to match.

@robbieaverill
Copy link
Contributor

For now I'm going to close this issue. You can install Commerce.js types now thanks to @PaitoAnderson (🎉) and we will work on improving them as things change over time, as well as establishing a workable versioning system for both Commerce.js and the types that go with it, as breaking changes in the API happen.

For now types are versioned according to Commerce.js versions, which is nice.

Thanks again for your help here @PaitoAnderson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants