-
Notifications
You must be signed in to change notification settings - Fork 52
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
Use named imports #4
Comments
What if we export a In order not to break API, we can export both the function and a |
I'm actually not sure if that would fix it. Additionally I actually brought it up because named imports are more declarative and easier to understand and extend. And API breakage would simply mean a new major release which would not impact current users of version 1.x. |
Debatable because it's subjective :)
Agreed, but then we make a major bump.
If you are interested in testing this out, one easy test you could do in your end (please) before I change things here is to update your locally installed diff --git a/dist/node.js b/dist/node.js
index 050965d..58a53d0 100644
--- a/dist/node.js
+++ b/dist/node.js
@@ -8,3 +8,4 @@ if (semver.satisfies(process.version, "<8")) {
}
module.exports = exports;
+module.exports.default = exports; |
With this change I had to change the definition to export = asyncPool;
declare function asyncPool(/* ... *) {
/* ... */
} It results in the following import: import asyncPool from 'tiny-async-pool'; |
Let's do that update? I understood it looks better for you on TypeScript, although it's not exactly what you wanted (named exports). Do you want to submit a PR? Thanks |
If you'd like it that way - sure! |
Fixed by #6 |
Would you reconsider this after checking out the related discucssion at DefinitelyTyped? |
@krlwlfrt thanks for the TypeScript integration work you're doing. It seems like in TypeScript you always have to use It's not clear to me what could be reconsidered? Even if using a named export such as That being said, what do you think about this... Currently, package.json |
No. The section that you're referring to only describes what happens with Named export would result in a TypeScript definition with This would enable an import like As far as I know, there is no option do override the main file in Node.js since TypeScript does support different module systems but no other specifics of the platforms it runs on. |
@rxaviers, I'd open a PR with the appropriate changes if you'd like. |
First of all: thank you very much for the concise and easy to use implementation. In my opionion it's much better than comparable solutions.
I added TypeScript definitions to DefinitelyTyped to be able to use your async pool better and more easily in my TypeScript projects. It was a little tricky because you are not using a named import but are exporting the function directly. This leads to rather weird imports in TypeScript modules.
If you would use named exports the import would be the normal and standard way:
The text was updated successfully, but these errors were encountered: