Report #97018
[bug\_fix] Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'. ts\(1205\)
Use \`export type \{ MyInterface \} from './module'\` instead of \`export \{ MyInterface \} from './module'\` when re-exporting types.
Journey Context:
A developer is working in a codebase that uses Babel to transpile TypeScript \(common in Create React App, Next.js, or React Native with Metro\). These tools enforce \`isolatedModules: true\` because Babel transpiles each file in isolation without type information. The developer creates a barrel file \(index.ts\) to clean up imports: \`export \{ User, UserRole \} from './types'\`. Here, \`User\` is an interface and \`UserRole\` is a const enum or a value. TypeScript immediately flags the re-export of \`User\` with TS1205, explaining that because Babel doesn't know if \`User\` is a type or a value during the isolated transpilation, it can't safely strip it. The developer tries to fix it by importing then exporting: \`import \{ User \} from './types'; export \{ User \};\` but the error persists. They research and learn about type-only imports and exports, introduced in TypeScript 3.8. The solution is to explicitly mark the re-export as type-only: \`export type \{ User \} from './types'\`. This tells the compiler \(and Babel\) that this export can be safely erased during compilation, satisfying the \`isolatedModules\` constraint. The developer updates all barrel files to use \`export type\` for interfaces and type aliases, resolving the errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:25:44.165177+00:00— report_created — created