dnsimple-node icon indicating copy to clipboard operation
dnsimple-node copied to clipboard

.d.ts support

Open softmarshmallow opened this issue 2 years ago • 1 comments

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

softmarshmallow avatar Sep 27 '22 10:09 softmarshmallow

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!

dallasread avatar Sep 28 '22 13:09 dallasread

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!

ghost avatar Mar 22 '23 02:03 ghost

@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. 👍

mlafeldt avatar Mar 22 '23 20:03 mlafeldt

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.

ghost avatar Mar 30 '23 05:03 ghost