dnsimple / dnsimple-node

The DNSimple API client for Node.js.
https://developer.dnsimple.com/
MIT License
47 stars 19 forks source link

.d.ts support #153

Closed softmarshmallow closed 1 year ago

softmarshmallow commented 1 year ago

Hey any plans for adding index.d.ts for typescript users?

dallasread commented 1 year ago

Thanks for the request, @softmarshmallow.

At this time, there are no plans for Typescript support. That being said, I'll raise this with the team!

ghost commented 1 year ago

Hi @softmarshmallow, we've just released version 7.0.0 which migrated the library to TypeScript, so type definitions are now available for the library. It's a major version so check out the migration guide if you're currently using an older version. Let us know how it goes for you!

mlafeldt commented 1 year ago

@wilson-dnsimple Thanks!

I tried updating my Raycast extension for DNSimple to the latest version of the package:

https://github.com/mlafeldt/dnsimple-raycast/compare/typescript

As you can see, there's some awkward code required to get hold of the actual types. I think the lib would be much more useful if those were exported as well.

Speaking of types, there's still room for improvement, e.g. with domains:

- state: string
+ state: "hosted" | "registered" | "expired"

(A domain type could even use a discriminating union.)

Anyway, it's a great start. 👍

ghost commented 1 year ago

Thanks for the feedback @mlafeldt. Version 7.1.0 has just been released, which adds explicit types that can be imported and uses unions of constant values as enum types. For example:

import { Certificate } from "dnsimple";

const certificates: Array<Certificate> = await client.certificates.listCertificates.collectAll(1010, "domain.com", { sort: "id:asc" });

Let us know any feedback you have on these changes.