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

Add typescript declarations

Open jabooth opened this issue 9 years ago • 1 comments

Hi @alanhoff,

I'm using your library with Typescript, so I thought I would take a bash at writing a Typescript declaration file for portastic.

If you'd like, you could take this PR, and future TS users of portastic (who just npm install portastic as normal) will get to use the typing information provided here without any extra effort. Some tools/IDE's (like VSCode) will even provide typing assistance to normal JS users of the library based on this definition file.

Of course, the downside is that ideally the index.d.ts declaration needs to be kept up to date as you change your library, otherwise you will have some very confused TS users ;). I hope you feel the maintenance burden is acceptable - even if you don't know TS at all I imagine you can glance over the definition and not be too surprised about what is going on!

If that sounds like too much trouble, I can submit these definitions to DefinitelyTyped, which is a seperate repository of typing information. TS users will still be able to get types by doing:

npm install @types/portastic

The beauty of taking this PR instead is that the types can be versioned and kept in sync with the project.

You can read more about this whole thing from the official TS guide here.

Cheers!

jabooth avatar Dec 12 '16 18:12 jabooth

Coverage Status

Coverage remained the same at 86.555% when pulling adeaa6a0144d64ebf78a052ad1c14831d3524022 on jabooth:ts-declaration into d27c7d4d5c2eee620aff5e5f7804c28c78848ff0 on alanhoff:master.

coveralls avatar Dec 12 '16 18:12 coveralls