Open SteRoy opened 5 months ago
most tooling handles this gracefully
What tooling specifically? You'll need to provide a repro that shows a tool resolving differently from tsc. The repro you provided only shows what tsc itself is doing, and doesn't make it easy to see what anything else does for comparison. I made a few small changes to make the resolution visible with Node.js, and tsc is matching it exactly (and you're using --moduleResolution node
, so everything is working as expected):
~/Developer/microsoft/eg/ts-pnpm-resolution-repro/packages/tsc-me (main)
❯ node index.js
From tsc-me: 29.0.0
From lib-with-peers: 31.0.0
Demo Repo
https://github.com/SteRoy/ts-pnpm-resolution-repro
Which of the following problems are you reporting?
The module specifier resolves at runtime, but not at build time
Demonstrate the defect described above with a code sample.
Run
tsc --showConfig
and paste its output hereRun
tsc --traceResolution
and paste its output hereOutput is way too long
This is the erroneous section though I believe
Paste the
package.json
of the importing module, if it existsPaste the
package.json
of the target module, if it existsAny other comments can go here
Hey, apologies if this is out of scope but as far as I can tell this is a homogenous feature across pnpm, npm, and yarn.
The basic premise is that workspaces exist and they allow symlinking from node_modules of some 'consumer' (
tsc-me
in repro) to some 'producer' (lib-with-peers
in repro). This works perfectly fine and most tooling handles this gracefully, the symlinks offer a very pleasant DX and are desirable.Unfortunately, if our 'producer' has peerDependencies (and thus also devDependencies for those peers to make type checking possible from within the 'producer' itself) then tsc will resolve those peers relative to the symlinked folder and disregard the fact that they are peer dependencies entirely.
Please flag if any detail is missing or if repro is unclear
I believe this has previously been reported without clear repro: https://github.com/microsoft/TypeScript/issues/42441#issue-791319315