-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Module "..." cannot be named without a reference to "..." error when decl emitting references to nested modules #48212
Comments
This seems to be related to the issue I've opened earlier here: #47663 |
Althought I don't know why , |
I think |
This error is also not suppressible through |
Thanks for scheduling this for 4.8! I'm looking forward to tracking the fix. Would it be possible to get some insight from language designers on what this is trying to protect us from[1]? Understanding this or having some clue about the recommended mitigation while we await upstream fix would be helpful. Here's a dump of what I've found so far. A note, the problem I'm seeing might not be representative of the full presentation of this error. To provide some context, our use case similar to pnpm's where the real path of For reference, the type definition of
Our code looks like:
And
Using traditional
To begin, this seems like problematic behavior because only
In fact, around 50% of exported types already look like this, but not all, for reasons I don't understand yet:
I have so far found 2 partial workarounds that sometimes work:
Between the two, the first option seems better, even if it's technically different behavior, but I'd obviously like to make sure I'm not shooting myself in the foot somehow. Thanks! [1] - My guess looking at the behavior and some past analysis is that it's trying to avoid unnamed deps that are technically resolveable at build time but are not distributed in a proper way that would be available to downstream users e.g. from |
You get this error any time the declaration emitter can't synthesize a workable specifier for a module which it needs to name a type from. For example, if it appears that the only legal path is The logic to synthesize these specifiers starts with the easy route of "Has this already been imported?", in which case re-use is easy and fine. Immediately past that lie many dragons and it's easy to get into a novel corner case where there is a speakable name to a module but TS just can't figure it out. Adding the import yourself is the easiest way to resolve the situation.
Note that if this isn't possible, then the error is correct and working around it by manually adding an import you know to be invalid is, well, invalid. |
Same problem |
We're also running into this with saiichihashimoto/sanity-typed-schema-builder#155. It's unclear what should happen here, considering transitive type dependencies should work. |
I've made a smaller reproduction here: #47663 (comment) Hope its helpful |
@RyanCavanaugh does this problem occur due to TS thinking the resolved transitive dependency is being resolved "outside" of the project? Or is it just multiple module specifiers being synthesised to the same id as @renke mentioned in #47663? If TS think it is the former, i.e. deps being resolved outside the project. I'm interested to know if outside just means parent or sibling directory relative to your project directory? |
I got this when upgrading from 4.9.5 to 5.0.2 with no other changes. using |
I started seeing this after upgrading from 4.9 to 5.0, but only for one dependency, and only when building everything at once (rather than using project references), and only when using |
Same problem |
Bug Report
π Search Terms
cannot be named without a reference to symlink
π Version & Regression Information
β― Playground Link
N/A
π» Code
https://github.com/jcreamer898/monorepo-examples/tree/main/pnpm-example
TL;DR file layout:
@fluentui/react
is nested in/monorepo-examples/pnpm-example/node_modules/.pnpm/@fluentui+react
Adding a blank import to
@fluentui/merge-styles
inindex.ts
makes the problem go awayπ Actual behavior
π Expected behavior
No error
The text was updated successfully, but these errors were encountered: