Sitelet https://web.archive.org/web/20201209134954/https://github.com/developit/microbundle/issues/740
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Modules don't work with Typescript files #740

Open
NickBeeuwsaert opened this issue Oct 15, 2020 · 0 comments
Open

CSS Modules don't work with Typescript files #740

NickBeeuwsaert opened this issue Oct 15, 2020 · 0 comments

Comments

@NickBeeuwsaert
Copy link

@NickBeeuwsaert NickBeeuwsaert commented Oct 15, 2020

when trying to import a CSS module in a typescript file, Typescript will give an error that it can't find the CSS module, whereas a JS module importing a CSS module works just fine. Here's a minimal reproducible example: https://gist.github.com/NickBeeuwsaert/e091e6dd45dc7c639fff91a87ee5fd7e

If you include a css-modules.d.ts file in your tsconfig.json like below, the error will go away:

/// css-modules.d.ts
declare module '*.module.css' {
    const classes: { [key: string]: string };
    export default classes;
}
/// tsconfig.json
{
"include": ["./css-modules.d.ts"]
}

This had me confused for around an hour, it would be nice if this was documented or worked out of the box. I'd be happy to work on a PR for documentation or getting this to work out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.