Report #17023
[bug\_fix] The inferred type of 'createStore' cannot be named without a reference to '.pnpm/.../node\_modules/pinia'. This is likely not portable. A type annotation is necessary. ts\(2742\)
Add an explicit import for the dependent type \(e.g., \`import type \{ Pinia \} from 'pinia'\`\) in the source file, or explicitly annotate the return type of the exported function using a locally defined interface that doesn't leak internal node\_modules paths.
Journey Context:
Developer is building a library that uses Pinia internally. They export a factory function \`createStore\(\)\` that returns a Pinia store instance. The function infers its return type from the library. When running \`tsc --declaration\`, TS2742 appears because the inferred type includes types from deep within the pnpm virtual store \(e.g., .pnpm/[email protected]/node\_modules/pinia\). The developer tries adding pinia to peerDependencies, then devDependencies, but the error persists because the type isn't explicitly imported in the file. The developer realizes that declaration emit requires all types in the public API to be importable via ES modules. By adding \`import type \{ Store \} from 'pinia'\` and using \`Store\` in an explicit return type annotation, the generated .d.ts file contains a clean import from 'pinia' rather than a deep path, making it portable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:17:22.061029+00:00— report_created — created