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
"The inferred type of X cannot be named without a reference to Y" (TS2742) occurs when multiple modules with the same package ID are resolved #47663
Comments
|
same problem |
|
So, aside from finding a solution to this problem, is my assumption correct that having multiple packages with typings that have the same version should not cause any problems? I'd also appreciate any hints on where to look at the source code to solve this problem. |
|
same problem! |
|
@renke i have a repro where everything has the same version here : https://github.com/quadristan/ts-indirect-type-reference-bug |
|
same problem :( have you solved it? |
|
I haven't solved it yet, but there is also a similar issue #48212 with a milestone of TypeScript 4.8.0. Let's hope it will be solved soon. |
|
same problem |
|
I got this issue because the mentioned dependency had this code in its and the file it was complaining in was using |
|
Same problem :( |
|
Same Problem for me too :( |
|
is there any expected timeline for a fix for this problem? |
|
same here |
|
Same problem :( |
|
same here |
1 similar comment
|
same here |
|
What's worse is that neither |
|
This bug occurs pretty readily when using pnpm since the node_modules directory layout is different under pnpm than npm/yarn. Any npm package whose types reference another npm package's type will generate the error I've made a minimal reproduction here: https://github.com/mrmeku/portable_types_repro |
renke commentedJan 30, 2022
•
edited
Bug Report
Problems occurs with 4.5.x and 4.6.x and most likely earlier versions (I've tried a few other versions). It stills occurs on
4.7.0-dev.20220321.I've created minimal repository that shows the problem: https://github.com/renke/typescript-package-id-merge-repro
The problem occurs when using pnpm (due to the modules layout it uses). No problems occur when using npm/yarn.
To reproduce the problem run
pnpm installand thenpnpm checkpnpx tsc -b.I don't think the code itself matters to much except from the fact that it in fact does not have explicit type annotations (which is kind of the idea when using zod and by extension @renke/vommer).
The following error occurs when trying to build a composite TypeScript project (same happens when just using
declaration: true).The dependency tree of
@renke/vommerLooking at the resolution trace TypeScript tries to resolve
@renke/votwo times the first time from@renke/vommerand the second time from@renke/vod. Both end up having the package ID@renke/vo/dist/index.d.ts@0.2.0.Using
"preserveSymlinks": truedoesn't solve the problem in so far that the error disappears but the type is inferred as any, because the dependencies of@renke/vommerare not found. Also I don't actually want to use it.The error should not occur when there are two (or more) modules that have the same resolved package ID. It would make sense for the error to occur when they have different versions.
The text was updated successfully, but these errors were encountered: