Report #24473
[bug\_fix] Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'. \(TS1205\)
Change the re-export statement to explicitly use the \`type\` keyword: \`export type \{ User \} from './user';\`, or use \`export type \* from './user';\` for star exports.
Journey Context:
You are migrating a large codebase to use Vite for faster builds, which enforces \`isolatedModules: true\`. You have a central \`types.ts\` file that aggregates and re-exports types from various feature folders: \`export \{ User \} from './user'; export \{ Product \} from './product';\`. Suddenly, TypeScript complains with TS1205 on every line. You check \`User\` and see it's an interface, clearly a type, not a value. You try changing it to \`export type \{ User \} from './user';\` \(TypeScript 3.8\+ syntax\), and the error disappears. You wonder why this is necessary. The root cause is that with \`isolatedModules\`, each file is transpiled independently without cross-file type information. The compiler cannot determine if \`User\` is a type or a value during the single-file transformation phase because it only sees the export statement, not the definition in the other file. Therefore, it requires an explicit \`type\` keyword to strip the export during the JavaScript emit phase safely. The fix works because it provides the compiler with the unambiguous signal that this export is type-only and can be erased during JS emit, preventing potential runtime errors if \`User\` were actually a value that wasn't imported correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:29:25.895197+00:00— report_created — created