-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add TypeScript type declaration file #37
base: master
Are you sure you want to change the base?
Conversation
lib/dashdash.d.ts
Outdated
* Note that reflow is just done on whitespace so a long token in the option help can overflow maxCol. | ||
* Default: 80 | ||
*/ | ||
maxCo?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should that be maxCol?
? Ditto for some other vars that seem to be missing some characters: helpCol?
, minHelpCol?
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good news is I know the stupid mistake that caused this and it will be isolated to that interface. Bad new is that it was a stupid mistake in the RegEx find/replace that I used to add the question mark that I didn't catch; I am glad you did.
@adamvoss Thanks. I'm pretty ignorant about TypeScript, so a couple Qs:
|
d51d5b6
to
0a9f304
Compare
This provides completion information for users of both JavaScript and TypeScript with supported editors. This also allows TypeScript users to have type checking and be able to use the library when strict checking is enabled (which is the default for new TS projects).
0a9f304
to
372a44a
Compare
A less complete version (recognizes the methods and number of parameters, but not their specific types) was generated by
Not in any meaningful way I know of. To test this, I copied all the examples from the README into a TypeScript and confirmed they type-checked. Of course that only works to the extent the examples are correct. I could probably automate this test as part of the CI, but the examples would need to be kept up-to-date. With respect to maintenance, I would be happy to update this when you know there are changes. However, I probably do not use There may be something I do not know, but the best general solution I would have for trying to ensure correctness/completeness of external typings for a JS library would be having automated tests written in TypeScript. The test executing would confirm behavior and the TypeScript complier would confirm the type definitions and since tests usually only consume code there is usually little difference between a test written in TypeScript and one written in JavaScript. I am mentioning this only to provide what I know about how validation could be done, and not as advocation it should be done.
Thanks! I responded in-line and pushed a fix. |
There is https://www.npmjs.com/package/tsd which is used by https://github.com/sindresorhus/meow to check it's type definition. But there are also multiple ways to auto generate types from javascript source, one of them just needs typescript, jsdoc comments with some enhancements and the right config. There are also some libraries to help with the task, but I haven't tried any. |
Definition types for node-dashdash package: - definition file - types Shout to original author @adamvoss https://github.com/trentm/node-dashdash https://github.com/trentm/node-dashdash#usage Thanks! Closes: trentm/node-dashdash#37
Definition types for node-dashdash package: - definition file - types Shout to original author @adamvoss https://github.com/trentm/node-dashdash https://github.com/trentm/node-dashdash#usage Thanks! Closes: trentm/node-dashdash#37
Definition types for node-dashdash package: - definition file - types Shout to original author @adamvoss https://github.com/trentm/node-dashdash https://github.com/trentm/node-dashdash#usage Thanks! Closes: trentm/node-dashdash#37
Definition types for node-dashdash package: - definition file - types Shout to original author @adamvoss https://github.com/trentm/node-dashdash https://github.com/trentm/node-dashdash#usage Thanks! Closes: trentm/node-dashdash#37
This provides completion information for users of both JavaScript and TypeScript with supported editors. This also allows TypeScript users to have type checking and be able to use the library when strict checking is enabled (which is the default for new TS projects).