madyankin / madyankin/postcss-modules

Types of CSS modules

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

Nobody has claimed this yet.

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

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?

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.

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.