Skip to content
Latchkey

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.

tsc output
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.

TypeScript
// barrel index.ts
export type { User } from './user'   // type
export { createUser } from './user'  // runtime value

Enable verbatim handling consistently

  1. Audit barrel files for export {} lines that re-export types.
  2. Convert each type-only re-export to export type.
  3. Consider verbatimModuleSyntax to make the type/value distinction explicit everywhere.

How to prevent it

  • Use export type for all type-only re-exports.
  • Keep barrels explicit about types vs values.
  • Enable isolatedModules early so single-file-transpiler constraints surface in dev.

Frequently asked questions

What causes ""TS1205 (isolatedModules)""?
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.
How do I fix "TS1205 (isolatedModules)"?
Separate type re-exports with export type.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card