Report #101510
[bug\_fix] TS2742: The inferred type of 'X' cannot be named without a reference to '.../node\_modules/...'. This is likely not portable. A type annotation is necessary.
Add an explicit type annotation to the exported value using a type imported from a directly-installed, publicly-exported package. If the type is only reachable through a transitive dependency, install that package as a direct dependency or ask the upstream package to re-export the type so tsc can emit a portable specifier in the .d.ts file.
Journey Context:
You are building a library with declaration: true and write export const client = createClient\(\), where createClient returns a type from a transitive package hidden by pnpm's strict hoisting. tsc fails with TS2742 pointing deep into .pnpm/node\_modules/@scope/some-internal. You first work around it with as any, but now library consumers lose autocomplete. You learn that declaration emit must serialize the inferred type using stable module specifiers. If the compiler can only reach the type through a private or transitive path, it refuses. Importing the public Client type from a direct dependency and annotating the export gives tsc a clean, portable name to write into the generated declaration file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:58:39.842694+00:00— report_created — created