Skip to content
webtype.orgwebtype.orgtsconfig

    ↑↓ move · ⏎ open · esc close

    tsconfig

    isolatedModules

    One file at a time

    Rejects the constructs that cannot be compiled correctly without looking at other files — which is how every fast bundler compiles.

    Since
    TypeScript 1.5
    strict
    Not in strict
    In your tsconfig
    "isolatedModules": true
    Compiled with
    "module": "esnext""moduleResolution": "bundler"

    The same snippet both times. Only the option changed.

    With it off

    "isolatedModules": false

    main.ts

    import { Widget } from './widget'
    
    export { Widget }

    widget.ts

    export type Widget = { id: number }

    Compiles clean

    With it on

    "isolatedModules": true

    main.ts

    import { Widget } from './widget'
    
    export { Widget }

    widget.ts

    export type Widget = { id: number }

    Emits TS1205

    Why the compiler bothers

    esbuild, swc, Babel and every dev server built on them transform one file at a time with no type information at all. Re-exporting a name without knowing whether it is a type or a value is undecidable for them, so they either guess or break. Turning this on means `tsc` refuses exactly the code those tools cannot handle, and the build stops disagreeing with the thing that actually produces your output.

    Takeaway

    If a bundler produces your JavaScript, this flag makes `tsc` agree with it.

    Where to go next

    22 options