Open
Conversation
jabooth
commented
Dec 12, 2016
| }, | ||
| "homepage": "https://github.com/alanhoff/node-portastic#readme", | ||
| "dependencies": { | ||
| "@types/node": "0.0.2", |
Author
There was a problem hiding this comment.
Note that you expose an object that subclasses EventEmitter from node - a consumer of your API therefore needs the node typing information to fully understand your public API, hence the addition of the node types as dependency and not a devDependency (see Packaging dependent declarations)
IchHabRecht
added a commit
to IchHabRecht/node-portastic
that referenced
this pull request
Mar 31, 2022
Add typescript declarations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 portasticas 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.tsdeclaration 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:
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!