Globhy
AllBusinessHealthMarketingTechnologyTravelUncategorized
HAHartanto3 views
Posted on 03 Sep 2026Edited on 03 Sep 2026

Share:

How to Fix "Cannot Find Module or Type Declarations for Side-Effect Import" in TypeScript

How to Fix "Cannot Find Module or Type Declarations for Side-Effect Import" in TypeScript

Learn how to fix the TypeScript TS2882 error for CSS imports, understand noUncheckedSideEffectImports, and use declare module '*.css' in Next.js.

javascript
import styles from './styles.css'

Instead, the purpose is simply to load the stylesheet.

The same applies to third-party CSS:

javascript
import 'mapbox-gl/dist/mapbox-gl.css'

The CSS is imported for its side effect—loading and applying the stylesheet.

This pattern is extremely common in React, Next.js, Vite, and other frontend applications.

Why Does TypeScript Check Side-Effect Imports?

Historically, TypeScript was relatively permissive with side-effect imports.

For example:

javascript
import './non-existent-file.css'

could sometimes go unnoticed by TypeScript.

This wasn't always desirable because a typo in an asset path could silently make it into the codebase.

Share:

More in Technology

View category