Skip to content
webtype.orgwebtype.orgtsconfig

    ↑↓ move · ⏎ open · esc close

    tsconfig

    erasableSyntaxOnly

    Only the parts that erase

    Bans the TypeScript constructs that emit runtime code — enums, namespaces, parameter properties, `declare` class fields.

    Since
    TypeScript 5.8
    strict
    Not in strict
    In your tsconfig
    "erasableSyntaxOnly": true

    The same snippet both times. Only the option changed.

    With it off

    "erasableSyntaxOnly": false
    export enum Level {
      Low,
      High,
    }

    Compiles clean

    With it on

    "erasableSyntaxOnly": true
    export enum Level {
      Low,
      High,
    }

    Emits TS1294

    Why the compiler bothers

    Most of TypeScript is annotation: delete it and you have the JavaScript. A handful of features are not, and they are the reason a file cannot simply have its types stripped. Node, Deno and browsers running TypeScript directly all take the stripping route, so this flag is what tells you, at compile time, whether your source can go through it — rather than at the moment somebody tries.

    Takeaway

    A union of string literals does what an enum did, and erases.

    Where to go next

    22 options