TypeScript "TS1205: Re-exporting a type ... isolatedModules" - Fix in CI
With isolatedModules enabled (required by esbuild/SWC/Vite single-file transpilers), each file is compiled in isolation, so the compiler cannot tell whether a re-exported name is a type or a value. Re-exporting a type without export type is an error.
What this error means
tsc (or next build/vite build) fails with TS1205: Re-exporting a type when 'isolatedModules' is enabled requires using 'export type'. naming the re-export line. It appears after enabling isolatedModules or moving to a single-file transpiler.
src/types/index.ts:3:1 - error TS1205: Re-exporting a type when
'isolatedModules' is enabled requires using 'export type'.
3 export { User } from './user'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Common causes
Type re-exported as a value
Under isolatedModules, a per-file transpiler cannot follow ./user to learn that User is a type, so it would emit a runtime re-export of a name that does not exist at runtime. tsc flags it.
Barrel files mixing types and values
A barrel (index.ts) re-exporting both runtime values and types with a single export { ... } mixes the two, which isolatedModules cannot disambiguate.
How to fix it
Use export type for type re-exports
Separate type re-exports with export type.
// barrel index.ts
export type { User } from './user' // type
export { createUser } from './user' // runtime valueEnable verbatim handling consistently
- Audit barrel files for
export {}lines that re-export types. - Convert each type-only re-export to
export type. - Consider
verbatimModuleSyntaxto make the type/value distinction explicit everywhere.
How to prevent it
- Use
export typefor all type-only re-exports. - Keep barrels explicit about types vs values.
- Enable
isolatedModulesearly so single-file-transpiler constraints surface in dev.