Skip to content
webtype.orgwebtype.orgtsconfig

    ↑↓ move · ⏎ open · esc close

    tsconfig

    noUncheckedSideEffectImports

    Side-effect imports get checked too

    `import "./styles.css"` was never checked to resolve at all, so a typo in one was invisible.

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

    The same snippet both times. Only the option changed.

    With it off

    "noUncheckedSideEffectImports": false
    import './styles.css'
    
    export const ok = 1

    Compiles clean

    With it on

    "noUncheckedSideEffectImports": true
    import './styles.css'
    
    export const ok = 1

    Emits TS2882

    Why the compiler bothers

    The exemption existed because these imports usually name something the compiler has no business understanding — a stylesheet, an image, a polyfill — and erroring on all of them would be useless. The cost was that a renamed or deleted file behind a side-effect import failed at runtime, in the one import form with no binding to catch the mistake. The flag turns the check on, and a wildcard declaration is how you exempt the file types you genuinely want it to skip.

    Takeaway

    Declare `*.css` once and the check stops being noise and starts being useful.

    Where to go next

    22 options