Skip to content

Updating import statements fails if declare module '*.module.css' {...} exists #169

@mizdra

Description

@mizdra

If any of the following file exist in the project, update of the import statement will fail.

// src/global.d.ts
declare module '*.module.css' {
  const classes: { [className: string]: string };
  export default classes;
}

How to reproduce

https://github.com/mizdra/css-modules-kit-example/tree/a44af6d329f2f86c4cd5a885382a2d38bed3a567

First, do the following:

git clone git@github.com:mizdra/css-modules-kit-example.git
git checkout a44af6d329f2f86c4cd5a885382a2d38bed3a567
npm i
code --profile-temp .

Next, install mizdra.css-modules-kit-vscode in VS Code. Then, rename src/a.module.css to src/aa.module.css from VS Code's Explorer panel.

2025-04-12.21.20.44.mov

Workaround

Removing or commenting out the ambient module declaration in *.module.css will avoid the problem.

// src/global.d.ts
// declare module '*.module.css' {
//   const classes: { [className: string]: string };
//   export default classes;
// }
2025-04-12.21.25.41.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions