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
Update TypeScript types, check types against JavaScript tests/examples #307
base: master
Are you sure you want to change the base?
Conversation
Converted some support functions to TypeScript
input, confirm, numberal, password, invisible, toggle, basicauth
Ok, I cleaned up a few more issues – there are still places we need to improve, but I think we're in a good spot to make smaller, iterative changes now. (Especially now that we're testing against the actual JS examples.) @jonschlinkert would you be willing to merge these TypeScript changes? Is there anything else you'd like me change? |
@@ -9,3 +9,5 @@ node_js: | |||
- '11' | |||
- '10' | |||
- '8' | |||
before_script: | |||
- cd examples && npm install && cd ../guide && npm install && cd .. |
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.
Some of the examples use external dependencies which aren't in the top-level package.json
, so we have to install them before running tsc
in Travis. (Otherwise TypeScript throws errors for missing dependencies.)
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.
thanks!
(I force-pushed to retry CI. Tests on Node.js 8 fail randomly – not related to this PR, which doesn't touch any JS.) |
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.
the code is breaking some SOLID principles
Yeah, there are tradeoffs. If you've seen any of my other libraries, I'm a big fan of SOLID principles, I tend to favor responsibility libraries. IMHO, in Enquirer the benefits of inheritance far outweigh the advantages of SOLID, from the standpoints of both maintenance and implementation. It's just too much work to redefine everything on every class, and repeated code everywhere lends itself to inconsistencies when minor improvements or tweaks are made.
(I force-pushed to retry CI. Tests on Node.js 8 fail randomly – not related to this PR, which doesn't touch any JS.)
I think it's related to a dev dependency (time-require I think). Don't worry about it, I'll get that fixed. If that is indeed what's causing it, I'll either fix the node version inconsistency or just remove that unnecessary dev dep.
I'm still looking through, but I'd love to get this merged. I'm getting caught up. Please let me know if you think it's ready. I just #307 (comment) but missed that earlier. Sounds good!
@@ -9,3 +9,5 @@ node_js: | |||
- '11' | |||
- '10' | |||
- '8' | |||
before_script: | |||
- cd examples && npm install && cd ../guide && npm install && cd .. |
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.
thanks!
@jonschlinkert thanks for taking a look! Please let me know if there's anything else you'd like me to change before merging this. 🚀 I'm current using a version of this PR in my development branch of Bitauth CLI, where I'm continuing to improve the types as needed. After this PR is merged, future PRs should have much smaller diffs and only increase "TypeScript coverage". (In this PR, only a few examples are "covered", but we can slowly expand that list until it includes everything in the |
@bitjson I'm amazed at the amount of effort that you, @unional and others have put into adding typescript support. You are very much appreciated! @doowb and I have both looked over the code, neither of us had any issues at all running the code. One of us will try to get these changes merged in ASAP. Thanks! |
^ any update on this 😬 |
@jonschlinkert / @doowb 🙏 💖 🙏 Getting this in would be very much appreciated 🙏 💖 🙏 |
👍 Just confirming that these changes work great in a CLI project I'm writing in TS, would really appreciate if these changes made in in soon! |
Hey @jonschlinkert and @doowb, I think this has been well-reviewed by some of the above commenters, and the changes are contained to only TypeScript-related parts of the project. (It also resolves/closes 11 other issues and PRs! 😄) I think merging is pretty low-risk now: would it be possible to get this released soon? |
as a workaround till this lands, you can update your {
"compilerOptions": {
"paths": {
"enquirer": ["./types/enquirer.d.ts"]
}
}
} |
Thanks @eleith for the workaround! In case someone runs into issues with the solution you also need to set {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"enquirer": ["./types/enquirer.d.ts"]
}
} } |
Any updates on this? Thanks :) |
I've tested this as well, seems to work flawlessly so far. Can this be merged @jonschlinkert and @doowb? |
Using TypeScript, would really appreciate for this to be merged. |
Options & | ||
types.Initializer<string | number, string> & | ||
types.Formatter<string, string>; | ||
export type MultipleOptions = { multiple: true } & Type & |
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.
This Type &
seems superfluous, it resolves to nothing in my local setup. Similar on SingleOptions
in this namespace.
A couple enhancements that would be nice to have (for a V2): https://gist.github.com/ProdigySim/73913e526d12719476582238a3fce2aa Supports:
Missing:
|
Hi! We are seeing that the type definition for enquirer/lib/prompts/confirm.js Line 8 in 70bdb0f
I think we need to change Thankssss |
Still a work in progress – I'm just trying to get @unional's fantastic work on #261 over the finish line.
This PR builds on #261 – I've removed the duplicated set of tests (which were being used to develop the types), and instead I'm checking the rest of the repo (
guide
,examples
,lib
,recipes
,test
) with the new types. I also reverted some formatting changes to keep this PR as thin as possible.There are ~500 TS issues remaining (many of which were already marked as
TODO
by @unional), but once these issues are fixed, the types should be very complete, and much easier to maintain (npm test
now validates them). If you're interested in helping, please send PRs to this branch, and I'll merge them to add them to this PR.Closes #82
Closes #135
Closes #202
Closes #204
Closes #212
Closes #252
Closes #258
Closes #261
Closes #262
Closes #263
Closes #286