An import with nothing to bind, import "./setup.js", runs a file for its side effects. TypeScript used to skip such imports entirely, so a misspelled path passed the check and failed only when the code ran. With noUncheckedSideEffectImports, an unresolved side-effect import is reported like any other missing module (TS2307).
It arrived with TypeScript 5.6, is not part of strict, and is on by default from TypeScript 6.0.
At a glance
| Write | "noUncheckedSideEffectImports": true; tsc --init in TypeScript 5.9 writes it, and 6.0 turns it on by default |
|---|---|
| On the command line | --noUncheckedSideEffectImports |
| Type | boolean |
| Default in TypeScript 5.9 | false |
| Default from TypeScript 6.0 | true (TypeScript 6.0) |
| TypeScript's description | Check side effect imports. |
The description is quoted from TypeScript's own option list (Apache-2.0); see the notices.
Examples
import "./polyfils.js";error TS2307: Cannot find module './polyfils.js' or its corresponding type declarations.
import "./setup.js";
console.log("ready");jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": [],
"noUncheckedSideEffectImports": true
},
"include": [
"*.js"
]
} import "./polyfils.js";
import "./setup.js";
console.log("ready");jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": [
"*.js"
]
} Side-effect imports of CSS and other files
Bundler projects often write import "./styles.css". With the option on, TypeScript needs to know that such a module exists. TypeScript's 5.6 release notes suggest a declaration file with declare module "*.css" {}, which covers every CSS import at once.
Under TypeScript 6.0 and 7.0
Every example on this page also runs under TypeScript 6.0.3 and 7.0.2 when this site is built. Two of them report something different from 5.9.3, the version the page describes; the ✗ on their badges link to their entries below.
Side-effect imports are checked by default
The pattern: import "./polyfils.js";, a side-effect import of a file that does not exist, in a config that does not set noUncheckedSideEffectImports.
Why: Only the 6.0 default causes this: noUncheckedSideEffectImports is now on unless the config turns it off, so the misspelled path is reported (TS2882) where 5.9 said nothing. Source: TypeScript 6.0 release notes: Simple default changes.
noUncheckedSideEffectImports off: the typo passes, and the import fails at run time main.js
- TypeScript 5.9.3
No errors.
- TypeScript 6.0.3differs from 5.9.3
main.js(1,8): error TS2882: Cannot find module or type declarations for side-effect import of './polyfils.js'.
- TypeScript 7.0.2differs from 5.9.3
main.js(1,8): error TS2882: Cannot find module or type declarations for side-effect import of './polyfils.js'. setup.js(1,12): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
What works in every version: Fix the path. Keep "noUncheckedSideEffectImports": false only for imports that tsc cannot resolve on purpose.
An unresolved side-effect import has its own code
The pattern: A side-effect import of a missing file with noUncheckedSideEffectImports on.
Why: 5.9 reports it as TS2307 ("Cannot find module"); TypeScript 6.0.3 and 7.0.2 report TS2882 ("Cannot find module or type declarations for side-effect import") on the same line. The release notes do not list the new code. Code that is right is unaffected; a script that filters tsc's output for TS2307 needs both codes. Source: TypeScript 6.0 release notes: Simple default changes.
noUncheckedSideEffectImports on: a misspelled side-effect import main.js
- TypeScript 5.9.3
main.js(2,8): error TS2307: Cannot find module './polyfils.js' or its corresponding type declarations.
- TypeScript 6.0.3differs from 5.9.3
main.js(2,8): error TS2882: Cannot find module or type declarations for side-effect import of './polyfils.js'.
- TypeScript 7.0.2differs from 5.9.3
main.js(2,8): error TS2882: Cannot find module or type declarations for side-effect import of './polyfils.js'. setup.js(1,12): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
What works in every version: Nothing to rewrite: the same broken import, reported under a new code.
Assigning to globalThis does not declare a global
The pattern: globalThis.appReady = true; in a .js file, with nothing declaring appReady.
Why: 5.9 read the assignment as a declaration of the global, as it reads other expando assignments in .js files. TypeScript 7.0.2 does not, so under strict the assignment is TS7017. The port's list of changes narrows expando declarations without naming globalThis. Source: CHANGES.md: Expando declarations.
noUncheckedSideEffectImports on: a misspelled side-effect import main.js
- TypeScript 5.9.3
main.js(2,8): error TS2307: Cannot find module './polyfils.js' or its corresponding type declarations.
- TypeScript 6.0.3differs from 5.9.3
main.js(2,8): error TS2882: Cannot find module or type declarations for side-effect import of './polyfils.js'.
- TypeScript 7.0.2differs from 5.9.3
main.js(2,8): error TS2882: Cannot find module or type declarations for side-effect import of './polyfils.js'. setup.js(1,12): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
noUncheckedSideEffectImports off: the typo passes, and the import fails at run time main.js
- TypeScript 5.9.3
No errors.
- TypeScript 6.0.3differs from 5.9.3
main.js(1,8): error TS2882: Cannot find module or type declarations for side-effect import of './polyfils.js'.
- TypeScript 7.0.2differs from 5.9.3
main.js(1,8): error TS2882: Cannot find module or type declarations for side-effect import of './polyfils.js'. setup.js(1,12): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
What works in every version: Declare the global with var in a .d.ts file.
/** @param {string} message */
export function debug(message) {
if (globalThis.DEBUG) console.log(message);
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js", "*.d.ts"]
} Gotchas
- TypeScript 6.0 turns it on by default, so after an upgrade a side-effect import that passed before can report TS2307.
Sources
- TSConfig Reference: noUncheckedSideEffectImports · TypeScript
- TypeScript 5.6 release notes · TypeScript handbook
- TypeScript 6.0 release notes · TypeScript handbook
Last reviewed 20 October 2026.