Repository navigation
Description
🔎 Search Terms
TS2883, likely not portable, deduplicated package, duplicate package, subpath export, declaration emit
🕗 Version & Regression Information
- This changed between versions 7.1.0-dev.20261012.1 and 7.1.0-dev.20261013.1, the day after Check package reachability before using exports in declarations #64599 closed Declaration emit writes an import the file cannot resolve when the package has
exports; no TS2883 #64590. - It works on 6.0.3 and 7.0.2. It still fails on 7.1.0-dev.20261120.1.
⏯ Playground Link
https://github.com/elevatebart/repro-with-package-installed-twice
💻 Code
app/node_modules/pkg/ identical copy of pkg@1.0.0
app/src/index.ts export type { Rules } from "pkg"; export { first } from "../../lib/src/first";
app/tsconfig.json declaration: true, rootDir: "..", moduleResolution: bundler
lib/node_modules/pkg/ identical copy of pkg@1.0.0
lib/src/first.ts import type { Rules } from "pkg"; export function first(rules: Rules) { return Object.values(rules)[0]; }
pkg exports "." and "./utils/arrayable"; Rules is Record<string, Arrayable<number>>, with Arrayable from pkg/utils/arrayable.
🙁 Actual behavior
When checking types,
lib/src/first.ts(3,17): error TS2883: The inferred type of 'first' cannot be named without a reference to 'Arrayable' from '../../app/node_modules/pkg/utils/arrayable'. This is likely not portable. A type annotation is necessary.
🙂 Expected behavior
As in 6.0.3 and 7.0.2, first.d.ts declares first(rules: Rules): import("pkg/utils/arrayable").Arrayable<number>. From lib, pkg/utils/arrayable resolves to lib's copy, which is the same package and version as the deduplicated file in app.
Additional information about the issue
Context
I realize this setup with two different projects with two different node_modules folders is unusual.
It's the best way we managed to resolve the Open core (compared to Open Source) paradigm at kestra and it has bitten us before.
I would understand if this was dismissed. I thought it would be useful to know the change of behavior.
More info to solve it
- With the two copies at different versions, 7.1 emits fine, so it looks tied to the redirect that deduplicates identical packages.
- Workarounds that avoid it: a
pathsentry that mapspkgto one copy, installingpkgonce (symlinked or in a shared parent folder), or annotating the return type. - We hit it in a project that type-checks sources from a sibling checkout, where
@popperjs/core(pulled in by element-plus) is installed in both checkouts.
Activity
mrginglymus commentedon Nov 23, 2026
I have a similar reproduction here https://github.com/mrginglymus/ts2883-regression (thanks to my toaster) - this time found because of a peer dependency on storybook, using yarn's
pnpmlinker.