TypeScript Compiler Options
preserveSymlinks — TypeScript compiler option
Keeps symlink paths in module resolution rather than using physical realpaths. Can affect dependency lookup and identity; coordinate with runtime and bundler. Before compiling this example create node_modules/demo as a directory symlink to ../packages/demo. Tests assert resolved paths, not runtime identity. Default in 5.8.3: false. Create the labeled files in an isolated project and run tsc -p tsconfig.json. Expected diagnostics: []. Expected emitted files: none. Local project fixture, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "preserveSymlinks": true }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| preserveSymlinks | boolean | Set in compilerOptions; default in 5.8.3: false. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "outDir": "dist", "preserveSymlinks": true, "noEmit": true, "moduleResolution": "Node10" }, "files": [ "main.ts" ]}// File: main.tsimport { value } from "demo";const checked: number = value;// File: packages/demo/package.json{"name":"demo","version":"1.0.0","types":"index.d.ts"}// File: packages/demo/index.d.tsexport declare const value: number;