question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module "..." cannot be named without a reference to "..." error when decl emitting references to nested modules

See original GitHub issue

Bug Report

🔎 Search Terms

cannot be named without a reference to symlink

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

N/A

💻 Code

https://github.com/jcreamer898/monorepo-examples/tree/main/pnpm-example

TL;DR file layout:

// monorepo-examples\pnpm-example\packages\pkg-a\index.ts
import { FontSizes, FontWeights, ITheme, IStyle } from "@fluentui/react";

// This expression's inferred type depends on @fluentui/merge-styles
export const something = { ... 

@fluentui/react is nested in /monorepo-examples/pnpm-example/node_modules/.pnpm/@fluentui+react

Adding a blank import to @fluentui/merge-styles in index.ts makes the problem go away

🙁 Actual behavior

src/index.ts:28:14 - error TS2742: The inferred type of 'personScopeListItemOverrides' cannot be named without a reference to '.pnpm/@fluentui+merge-styles@8.3.0/node_modules/@fluentui/merge-styles'. This is likely not portable. A type annotation is necessary.

🙂 Expected behavior

No error

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:20
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
AkonXIcommented, Apr 26, 2022

Althought I don’t know why , "preserveSymlinks": true resolved my problems

2reactions
saiichihashimotocommented, Sep 2, 2022

We’re also running into this with https://github.com/saiichihashimoto/sanity-typed-schema-builder/issues/155. It’s unclear what should happen here, considering transitive type dependencies should work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TS4023: Exported Variable <x> has or is using name <y> from ...
When trying to emit [the module], the compiler needs to write an object type ... so the type "cannot be named" and there's...
Read more >
Modules · The Julia Language
Within a module, a variable name can be “reserved” without assigning to it ... Here, Julia cannot decide which f you are referring...
Read more >
7. Simple statements — Python 3.11.1 documentation
If the name does not occur in a global or nonlocal statement in the current code ... If the target is an attribute...
Read more >
Strict mode - JavaScript - MDN Web Docs
Browsers not supporting strict mode will run strict mode code with ... every name not referring to an argument or local variable must...
Read more >
Announcing TypeScript 4.7 - Microsoft Developer Blogs
This code works in CommonJS modules, but will fail in ES modules because relative import paths need to use extensions. As a result,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found