TypeScript Compiler Diagnostics
TS1205: Re-exporting a type requires export type
Under isolatedModules, a re-export of a type must be marked explicitly because a single-file transpiler cannot infer whether the exported name is a runtime value. Separate the type re-export from the value import. This does not turn off whole-program type checking. Baseline: TypeScript 5.8.3 with the shown configuration. Reproduce in one directory and create the corrected project in another. The diagnostic can have other causes; inspect its location and message before choosing a correction. Both projects keep strict checking enabled.
Formal Syntax & Structure
typescript syntaxtypescript
TS1205 (compiler diagnostic code, not TypeScript syntax)Working Example
Example Snippettypescript
// INTENTIONALLY INVALID — reproduce// File: tsconfig.json (omit this label){ "compilerOptions": { "strict": true, "target": "ES2022", "module": "CommonJS", "types": [], "lib": [ "ES2022", "DOM" ], "noEmitOnError": true, "outDir": "dist", "isolatedModules": true }, "files": [ "main.ts" ]}
// File: main.ts (omit this label)export { Item } from "./dep";import { value } from "./dep";console.log(value);
// File: dep.ts (omit this label)export interface Item { count: number }export const value = 8;
// Run: tsc -p . --pretty false// Expected: TS1205; no output emitted.
// CORRECTED PROJECT — separate directory// File: tsconfig.json (omit this label){ "compilerOptions": { "strict": true, "target": "ES2022", "module": "CommonJS", "types": [], "lib": [ "ES2022", "DOM" ], "noEmitOnError": true, "outDir": "dist", "isolatedModules": true }, "files": [ "main.ts" ]}
// File: main.ts (omit this label)export type { Item } from "./dep";import { value } from "./dep";console.log(value);
// File: dep.ts (omit this label)export interface Item { count: number }export const value = 8;
// Run: tsc -p . --pretty false// Expected: no diagnostics.// Run: node dist/main.js// Expected stdout: 8