Report #48289
[bug\_fix] Cannot re-export a type when --isolatedModules is enabled.ts\(1205\)
Use 'export type \{ MyType \}' instead of 'export \{ MyType \}', or 'export type \* from './module'' for star exports.
Journey Context:
Developer is building a shared UI library using esbuild or Babel for fast compilation, which requires 'isolatedModules': true in tsconfig.json. They create an index.ts barrel file to centralize exports: 'export \{ Button \} from './Button'' and 'export \{ ButtonProps \} from './Button''. TypeScript errors on the second export: 'Cannot re-export a type when --isolatedModules is enabled'. This happens because ButtonProps is an interface/type, and with isolatedModules, the compiler processes each file in isolation and cannot determine if ButtonProps is a type or value that needs to be preserved at runtime. The developer searches and finds that TypeScript 3.8 introduced type-only imports/exports. They change the line to 'export type \{ ButtonProps \} from './Button''. For star exports, they use 'export type \* from './types''. The error disappears and the build succeeds because the compiler knows to erase these exports during compilation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T11:32:04.084236+00:00— report_created — created