-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Do not require @types/node
to be a dependency
#44777
Comments
In fact, "all our types" do not depend on
There are vast amounts of types packages which do not depend on From a quick look, both of those packages in fact do depend on Node's standard library (both import |
There is a fact if you don't use TypeScript then you don't need the types. |
The node standard library is just like any other, with its own types and used when necessary. A large amount of projects don't make use of it at all. In your case, you decided to depend on two packages which themselves depend on node's standard libraries. How else would you resolve those types? Just like any dependency, the Node stdlib is one too, so its part of your dependency tree along with its types. It is not a dependency every user should have, it just so happens to be one you chose to depend on. Just like the source its self, if you didn't want to pull in node's standard library, you simply wouldn't depend on it would you? |
Every TypeScript project declares https://github.com/yarnpkg/berry/blob/3c25698b5619cfef1450f6e6ef70fa2df7b0e783/package.json#L23
How does this relate to the fact that people who don't use TypeScript don't need the types? All TypeScript projects include |
Every typescript package which depends on node declares that dependency. It is incorrect to state all typescript packages do. If it's a dependency of a given package, just like any other dependency, there will be a reason (such as importing http like in this case). Huge amounts of typescript packages do not use that package, I work on plenty. Your immediate problem isn't that you are shipping typescript types to consumers, it is that you depend on a large package (node stdlib, it may be worth opening a separate issue specifically about the size of that individual dependency. I imagine it's because it has all the different node versions in it. |
Okay, but the thing is that deps that reference Node.js have
Then these projects then are compatible in many environments. I'm talking about Node.js explicitly.
👍 exactly
That's not a solution since all Node.js modules are related with each other. E.g. |
More what I meant was that the
I imagine all those end up in the npm package. Maybe that's why it's so big? |
I feel like I'm repeating myself :| The problem is that |
Oh I fully understood already. But there are two issues here:
For the second point, it isn't an easy problem to solve. It is a tooling problem (npm, tsc) as typescript would have to be aware of some typescript-specific set of dependencies in the package manifest. Unlikely to be a thing anytime soon, if ever, as that would bring its own problems. For the first part, you depend on
your solution here is to either help reduce the size of |
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the |
In Got 10 we switched to TypeScript. This resulted in +600KB overhead in install size, because all your packages define this:
Please note that not all Node.js users use TypeScript, so the increase is really unnecessary.
Currently we use these types:
https://github.com/sindresorhus/got/blob/df333ddbc163e35537a9f49818e722c7aa6803c0/package.json#L48-L49
/cc @BendingBender @paulmelnikow @sindresorhus
The text was updated successfully, but these errors were encountered: