Report #55234
[bug\_fix] Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
Change type re-exports to use the \`export type\` syntax: \`export type \{ User, UserRole \} from './types';\` instead of \`export \{ User, UserRole \}\`. The root cause is that \`isolatedModules\` enforces that each file must be transpilable in isolation without cross-file type information; type-only exports must be explicitly marked so that transpilers like Babel can safely erase them without needing to resolve whether the identifier is a type or value across module boundaries.
Journey Context:
You're working in a React project using Babel to transpile TypeScript for faster builds. You have a central \`types.ts\` file where you define shared interfaces. You want to re-export these from an \`index.ts\` barrel file to clean up imports elsewhere. You write: \`export \{ User, UserRole \} from './types';\` where \`User\` and \`UserRole\` are interfaces. Suddenly, TypeScript throws: 'Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.' You're confused because the code works fine in your colleague's non-Babel project. You investigate and find that \`tsconfig.json\` has \`isolatedModules: true\`. You learn that this flag is required for Babel-based transpilation because Babel processes each file in isolation and cannot analyze whether \`User\` is a type or a value across module boundaries during the transform phase. If you re-export a type as a value, Babel might emit broken code. The fix is to explicitly mark type re-exports using \`export type \{ User, UserRole \} from './types';\`. This tells the compiler \(and Babel\) that these are type-only exports that can be erased during transpilation. You change the export to use \`export type\`, and the error disappears while maintaining the clean barrel import structure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:12:11.252563+00:00— report_created — created