-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat: switch to TypeScript #281
base: master
Are you sure you want to change the base?
Conversation
Disabling this rule with eslint comments wasn't working for a reason so we are using this trick to avoid this linter error without completly disabling the rule.
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.
Code-wise everything looks clean and nice.
- New (usage) documentation is missing
- Version bump to 0.3.0 ? is missing
What I find problematic, though, is the complete absence of the callback based interface. The new version can then be released as e.g. 0.4.0 or 1.0.0 even, with the callback interface completely gone. Also, not having the automatic cleanup (unsafe cleanup, graceful cleanup) might alienate some users and break a lot of applications and tests. So we should first deprecated these options and then remove them. What do you think? |
Thank you! Yes, all of these are missing, because this is still a work in progress version, I've added the |
I am planning to add that back as an optional argument. If somebody passes a callback function then we would not return a
We can definitely discuss the versioning. I don't have a strong opinion about them.
I don't think we can deprecate them in a nice way. Since if we would provide the functionality the same way then we make this type of refactoring and cleanup impossible. I am thinking about alternatives, but I am not sure we can do too much. BTW the cleanup is technically nothing but calling an |
Great.
Same here. Whatever fits the semver scheme works for me.
You could memoize the handed out temporary paths, similar to https://github.com/raszi/node-tmp/blob/refactor/src/internal/GarbageCollector.ts, https://github.com/raszi/node-tmp/blob/refactor/src/internal/GarbageDisposer.ts, and, https://github.com/raszi/node-tmp/blob/refactor/src/internal/GarbagePruner.ts. |
I can memoize them, but when can we delete them? There is no good answer to that, I can provide a function that does the garbage collection on all the items, but is that the right solution? What if they want to do partial removal? |
We had the |
Okay, let me think about this. Thank you for your feedback! |
Coming to think of it, why don't just make this a
where Where And where |
Well, anything but an enum! 😆 Enums cannot be mapped back to JS that was a mistake that the TypeScript developers did there. |
Hm, enums will be transpiled into an object
And they can be used directly from javascript...
|
Loosely transpiled to JS. There are a lot of issues with that with no huge benefits. I would rather use union types with string. |
Is it possible to leverage the use of the interface then to just string literal constants, e.g. KEEP vs. 'KEEP'?
? |
And I am not going into the ADAPT-ADOPT-and-IMPROVE of the information provided in the links you provided. These devs should get their gears straight. 😄 |
With this change we both support Promise usage and callback usage.
@silkentrance I've implemented the optional callback. If that is provided then we don't return a If the optional callback function is not passed then we'll return a In the implementation, I've used function overloadings, and if the callback option is used then the return type is |
@raszi my original PR for this was much more elaborate and also fixed a lot more issues than this one does. |
I am sorry, but I disagree with you @silkentrance. I still believe this is a better approach since this PR creates a better API than the old one and gives a much better TS type definition, it also adds a clear promise interface which is why tmp-promise was born. There are the following reasons why I did not complete this PR:
|
Breaking change
This PR is about switching from JavaScript to TypeScript and changing the API at the same time with re-implementing the whole codebase instead of just "rewriting" the previous old JavaScript code in TypeScript.
The main interface is going to be more or less the same with the following caveats:
FileHandle
just a path of the created file or directoryWith this change, we are also dropping the support for old Node versions which are not maintained anymore according to the Node LTS release schedule: https://nodejs.org/en/about/releases/