Report #43094
[bug\_fix] TS1205: Re-exporting a type when '--isolatedModules' is enabled requires using 'export type'.
When \`isolatedModules\` is enabled \(required by Babel, ts-jest, or esbuild to transpile files independently\), TypeScript forbids re-exporting a type from another file using the standard \`export \{ MyType \} from './module'\` syntax because the transpiler cannot determine if \`MyType\` is a value or a type without analyzing the other file, which violates the 'isolated' constraint. The fix is to explicitly mark the re-export as type-only using \`export type \{ MyType \} from './module'\`, which signals to the transpiler that this export can be safely erased.
Journey Context:
You are migrating your project to use Vite or configuring Jest with ts-jest, which requires \`isolatedModules: true\` in your \`tsconfig.json\`. You have a central \`types.ts\` file that aggregates and re-exports interfaces from feature modules using \`export \{ User, Post \} from './user'\` and \`export \{ Comment \} from './post'\`. Upon compiling, TypeScript throws \`TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'\`. You investigate and learn that because each file is transpiled in isolation, the compiler cannot look into \`./user\` to see if \`User\` is a class \(value\) or an interface \(type\). It errs on the side of caution. You refactor your barrel file to use \`export type \{ User \} from './user'\` for all type-only exports. The error disappears, and your build succeeds, confirming that explicit type annotations resolve the ambiguity for isolated transpilation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:48:27.749775+00:00— report_created — created