Types of CSS modules

Open
#121 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
css, typescript
Domain
frontend

Research direction

Start with the reported named import and the existing index.d.ts declaration, then reproduce the Gatsby v3 and TypeScript error described in the issue. Compare the declaration with the CSS module export behavior and determine whether the supported approach needs documentation or a project change; done when the correct declaration pattern is clear and verified.

Written by the indexing model from the issue text.

Description

It's not clear to me how currently should types be declared for CSS modules.
For the context, I'm using Gatsby v3 with TypeScript and an example import would be:

import { Header } from './header.module.css';

However, the old style index.d.ts I had won't be suitable anymore since default exports were replaced with tree-shakeable variables:

declare module '*.module.css' {
  const value: { [className: string]: string };
  export default value;
}

That pretty much now ends up in this error:

 Module '"*.module.css"' has no exported member 'Header'. Did you mean to use 'import Header from "*.module.css"' instead?

I'm not sure how this can be handled in the latest version?

Dominant language
JavaScript
Stars
1.6k
Forks
88
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from madyankin/postcss-modules

All issues in madyankin/postcss-modules

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.