TypeScript Compiler Options
preserveValueImports — Removed compiler option
Historically kept value imports that looked unused to TypeScript. Use verbatimModuleSyntax with the module format expected by the host; mark erased type imports explicitly. Retaining an import is not the same as guaranteeing that a bundler will retain it. Deprecated in 5.0; no longer functional from 5.5. On the tested 5.8.3 compiler, enabling this option reports TS5102 even with ignoreDeprecations set to "5.0". Remove the entry rather than suppressing the error. The first example is intentionally invalid; the second is a separate migration project. Baseline: TypeScript 5.8.3. File labels are explanatory, not source text.
Formal Syntax & Structure
typescript syntaxtypescript
"preserveValueImports": true (historical, invalid on 5.8.3)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| preserveValueImports | boolean | Historical setting only; do not set in new projects. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "skipLibCheck": true, "outDir": "dist", "noEmitOnError": true, "preserveValueImports": true }, "files": [ "index.ts" ]}// File: index.ts (omit this label)export const count: number = 7;// Run in a temporary project:// tsc -p . --pretty false// Expected: TS5102. The following separate project demonstrates migration.// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "ESNext", "strict": true, "types": [], "skipLibCheck": true, "outDir": "dist", "noEmitOnError": true, "verbatimModuleSyntax": true }, "files": [ "index.ts" ]}// File: index.ts (omit this label)import { value } from "./dep";export const count = 7;// File: dep.ts (omit this label)export const value = 1;// Run: tsc -p . --pretty false