Report #65615
[bug\_fix] Cannot re-export a type when the '--isolatedModules' flag is provided.
Use explicit type-only re-exports: change \`export \{ MyType \} from './module'\` to \`export type \{ MyType \} from './module'\`, or use \`export type \* from './types'\` for star exports. If the re-export mixes values and types, separate them into two export statements. The root cause is that \`isolatedModules\` requires each file to be compilable independently without cross-file type information; when re-exporting, the compiler cannot determine if \`MyType\` is a type or value without analyzing the source file, which violates the isolation constraint.
Journey Context:
Developer migrates a large codebase to Vite or updates ts-loader to use \`transpileOnly: true\` for faster build times. The build tool implicitly forces \`isolatedModules: true\` \(as Vite's esbuild-based compiler does\). The developer has a central \`index.ts\` barrel file that re-exports both components and types from subdirectories: \`export \{ Button, ButtonProps \} from './components/Button';\`. The build fails with "Cannot re-export a type when '--isolatedModules' is provided". The developer checks \`tsconfig.json\` and sees \`isolatedModules: true\`. They try setting it to \`false\`, but Vite/esbuild ignores this and fails anyway with a different error about inability to compile. The developer searches the error message and finds the TypeScript 3.8 release notes. They realize that \`ButtonProps\` is an interface \(a type\), and in isolated modules mode, the compiler cannot know if \`ButtonProps\` is a type or value when re-exporting it from another file without parsing that file \(which isolated mode forbids\). They change the export to \`export type \{ ButtonProps \} from './components/Button';\` while keeping \`export \{ Button \}\` as a separate statement. The build succeeds. The fix works because the \`type\` keyword explicitly marks the export as compile-time-only, telling the transpiler \(esbuild/Babel\) that this export can be erased and does not need to be emitted as a runtime module export, thus satisfying the isolated modules constraint.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:37:13.052873+00:00— report_created — created