-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TypeScript's ecosystem of self-bundled typings does not work with npm #8836
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 is a serious problem. But when you say that
it is important to note that the way npm resolves these transitive dependencies is by recursively installing and resolving packages as nested dependencies. Versioning is handled by directory nesting. This is far from ideal and is part of the reason why tools like jspm exist. I'm bringing this up here, in a npm issue, because I think the problem is broader and that a more abstract solution needs to exist. |
if the declaration files are authored correctly as modules, then there are no issues here. if the declaration file is authored as global, then the conflict in the global scope is what i would expect. @DanielRosenwasser what did you have in mind marking this as "community tooling"? |
@mhegazy Indeed, there might be global declarations, such as |
this is not a viable option. wrapping declarations change their shape and origin and leads to more conflicts down the road. it also changes user code, which makes identifying problems and fixing them much harder. |
not sure i understand what you mean by this. |
@mhegazy Something I didn't think about for a long time was that the |
here is the documentation we are adding to the handbook. take a look and let us know if there is something that is missing: microsoft/TypeScript-Handbook#335 |
@mhegazy What I meant is that dependencies or their dependencies might require an older, conflicting version of a given global typing (e.g. node). Will the TypeScript compiler know to distinguish the in their respectable scopes, or will it cause problems, like the OP described? |
no. and that is why packages should not rely on specific versions of an |
@mhegazy @RyanCavanaugh This seems to still be a problem. Has anybody put any thought into how this might work? What TypeScript currently does is not in line with how NPM is meant to work or how it is used in practice. You are able to have multiple versions of a package installed (e.g. We have a situation in which we are writing code within a monorepo. We're writing a library I do not know how I can tell TypeScript to use different Are we meant to use Right now it seems that we need to code our way around this (using |
Coming back to this issue but what I am thinking of doing to solve the problem in the short-term is to use I still think that in the long-term TypeScript should be able to resolve the types of an import depending on what version of a package it refers to (this would be in line with the behaviour of |
Another problem arose: #31148 |
As a response for a label; a proposal to resolve a real problem #31148 caused by this core issue is written in there. |
When npm dependencies have same packages of different versions, tsc throws duplicate identifier errors. TypeScript's ecosystem of packages is weaker than npm, and does not have compatibility with npm. I believe this is a large problem. And this will be a popular problem because npm always install an exact version in resolving dependencies. For example, when depending
a@^0.0.2
anda@^0.0.1
as another package's dependency, its project hasa@0.0.1
anda@0.0.2
. npm can resolve these different versions, but TypeScript cannot.TypeScript Version:
1.9.0-dev.20160526
The text was updated successfully, but these errors were encountered: