-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Prevent dependency hell: export dependencies from DefinitelyTyped as peerDependencies #11671
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
Comments
This wouldn't be a very good long-term fix and only ever works if every single dependency uses the same version of peer dependency which is difficult in production. If this is a occurring, it seems like the better solution would be to improve how TypeScript is resolving dependent typings instead. For example, you're only considering the use-case of one location (DefinitelyTyped) which is centralised and can somewhat achieve this (in fact, it's relied on this poor behaviour for a very long time). What about other people that want to publish types outside of DT? What about module authors too? This would rely on every module author also using Edit: For more reference, the behaviour you propose is everything we tried to stop when I deprecated TSD in favour of Typings. Relying on behaviour like this results in tight coupling of every definition, and it becomes impossible for a development team to work properly as every dependency needs to be updated in unison and it assumes that every module will always be at the latest version. I ran into this myself numerous times when I first started using TypeScript, hence I wrote Typings 😄 |
@blakeembrey I think you're absolutely right. peerDependencies is the opposite of the direction that we should be going in. What we need is, as I believe you hinted at, is for TypeScript to better understand and support multiple versions relative to transitive dependencies. |
If that fixes every usecase, i'm all for it 👍. For the time being i would either like to see peerDependencies, or no dependencies at all. Some more clarification: I feel like The way i see it, peerDependency would come close to
This is why library authors should only depend on
Well, for the
Correct. I would be in control. That's what i like about them :)
Well... i was never a big fan of that decision ;). |
BTW, this issue might be a duplicate of #8836 |
@nicojs That sounds absolutely terrible for an end-user. How do you expect any library author to publish a module if you're telling them "well, figure out the dependencies yourself". There's a reason we use If your gripe is with globals like As for your issues with Typings, I only ever saw one comment from you saying you wouldn't use it because I didn't name it TSD. The model and the need for it is really what pushes for native TypeScript support. If you're only ever developing a single application with few dependencies or a toolchain you completely control, it's easy to say the everything should be "the latest version" and it doesn't matter that it's tightly coupled. But this is the very first problem I run into using TypeScript, and that's what I knew I could fix and I'm trying to help suggest a better way to fix this too before you the proposal is just TSD over NPM. |
Let me clarify: I think its better than having a dependency on
Isn't it true that TypeScript right now only supports one version per module? In that case i would like my transient dependencies to be flat and let me figure out more myself. |
I don't think Typings was the right solution but I think it was heading in the right direction. Requiring that the use your figure it out for themselves is equivalent to saying we're back to square one.
This is where things completely break down your proposal doesn't do anything to help with this.
Java is not a good model to base any kind of dependency management system on. Need to run two versions of the Java Collections API side by side within your application to support your dependencies? Have fun doing that with weak names. |
Sooo, how can I solve problems mentioned above? I need to use package that has "/// " in one of its .d.ts files. I am targeting ES6 so I cannot import that shim into my project as I will get myriads of duplicates. what would be the suggested way of dealing with these clashes? |
@tomitrescak @aluanhaddad I guess i wasn't thinking about such advanced scenario's as i haven't needed them in practice. (dep A needs B@1.0, dep C needs B@2.0). In that case, i guess there needs a change in TypeScript. @blakeembrey happy to see you agree on environmental dependencies. That would solve i think 90% of my issues. Do i keep this issue open in hope of a better TypeScript type resolution? |
@nicojs The mentioned The problematic file has a following line:
|
@tomitrescak none of the three files (node\index.d.ts, chai\index.d.ts and react\index.d.ts) reference also definitions in your file are not only included from |
I should add that this line ( |
@mhegazy the file that references es6-shim is the package file (reducer_extensions.d.ts) with following content: /// <reference types="es6-shim" />
export declare function isQuery(action: any, name: String): boolean;
... Yes, it is the (/// <reference types="es6-shim") that makes problems. And if removed all works as expected. So for now, I am manually removing it from the .d.ts file. I have noticed that the "/// " is added automatically by typescript during compilation. |
where can i find the sources? |
I've made a module called
Let If The resolution is ambiguous:
This ambiguity leads to a ton of errors like I found the only workaround for now to be starting Refs #8836 |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
Not sure where i can post issues on the current export of DefinitelyTyped repo to the @types npm space, please point me to the correct place.
Right now, the @types are populated using the content in the
types-2.0
branche on DefinitelyTyped. An excellent choice! Open source is awesome 😄The problem is that all dependencies marked with
/// <reference types="..." />
are exported asdependencies
of the package. This becomes a problem when you have multiple dependencies on one single module.Say for example: i want type definitions for
@types/express-serve-static-core
and@types/glob
. Both right now mark@types/node
as a dependency. When using npm 2.x i immediately get these duplicate identifier errors:error TS2300: Duplicate identifier 'BufferEncoding'.
When i use npm 3.x, i get some more leeway, because of the flat folder structure, but when one of the modules would require a different version of@types/node
, i would again get this error. Effectively: dependency hell.The problem would be fixed if dependencies would be marked as
peerDependencies
. I understand that it can be some more work for the developer who wants to use the typings, but it would effectively solve this issue. At least i would want it for modules that define variables on the global scope.See for example of a failing build see https://travis-ci.org/stryker-mutator/stryker/jobs/168113675
The text was updated successfully, but these errors were encountered: