Conversation
`DEFAULT_OPTIONS` takes precedence over the user's tsconfig, so forcing `preserveSymlinks: true` made the option unsettable and broke resolution on package managers that reach transitive dependencies through realpath. On pnpm this silently emitted invalid declarations: the failure happens inside a dependency's `.d.ts`, which `skipLibCheck: true` ignores, so `noEmitOnError` has no diagnostic to act on. Dropping the key restores tsconfig as the source of truth and falls back to the TypeScript default (`false`) when unset. Refs Swatinem#405, Swatinem#143
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opened #405 as a question. I think this is the right direction, so here is the change alongside it.
What
DEFAULT_OPTIONSis spread after the user's tsconfig ingetCompilerOptions:So
preserveSymlinks: truewas not a default. It was unsettable from tsconfig.This removes the key rather than setting it to
false. Hardcodingfalsekeeps the same defect mirrored: anyone who needstruefornpm linkwould be silently overridden. Removing it restores tsconfig as the source of truth and falls back to the TypeScript default (false), which fixes pnpm out of the box.The old comment looks backwards
// Ensure TS2742 errors are visibleis the opposite of what happens. Forcing it on hides the failure and emits invalid output. With it unset, TypeScript resolves the package and reports the portability error (TS2883).Test
tests/testcases/externals-pnpm-layoutreproduces pnpm's layout:pkg-ais symlinked into a store directory where its transitivepkg-bsits as a sibling, reachable only through realpath.preserveSymlinks: true(before)declare const value: any;declare const value: number;Nothing is reported in the first case. The resolution failure is inside
pkg-a's.d.ts, whichskipLibCheck: trueskips, sonoEmitOnErrorhas no diagnostic to act on.Full suite passes.
Compatibility
Breaking for symlinked packages. A linked package resolving peer dependencies against its consumer (
npm link) relied on the forcedtrueand now needs it declared:{ "compilerOptions": { "preserveSymlinks": true } }Probably worth a major. Happy to adjust.
Downstream has been working around this for a while. unbuild passes
preserveSymlinks: falseinto this plugin citing #143, and tsup carries a copy ofDEFAULT_OPTIONSwith the flag flipped.Refs #405, and #143 which reported this in 2021.