-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Can't use typescript with css modules #616
Comments
You probably have to provide a declaration file which specifies what you get when you import a css file. This would be a start:
|
Use Adding |
Are css modules in TypeScript working for anyone in |
@mightyiam CSS modules are working for me with TypeScript and Parcel I'm closing this issue as OP's problem is resolved with the correct module definition. |
@mightyiam I have this issue at the moment. |
Thanks. I didn't know I needed a PostCSS configuration... I've added a
And now the CSS file does get imported but not transpiled, still. And the object is still empty. So, seemingly same result. |
#70 suggests disabling hot module reload. So I used |
I am experiencing the same problem. But this seems to be typescript type error. I use postcss, is working // .postcssrc
"modules": true, But the type error did not find a good solution.
Maybe can give up😔. To use emotion |
I wrote a plugin to generate .d.ts files called parcel-plugin-typed-css-modules. Maybe this can solve your problem. I've kinda neglected it so there are some known bugs but it might get the job done for you |
Thanks @Place1 Great work! |
This will work for parcel v2: https://www.npmjs.com/package/parcel-transformer-ts-css-modules |
I personally had problems with the above mentioned parcel-transformer-ts-css-modules. Maybe I didn't use postcss correctly, but in my case all classes with the same name were merged into one in the dist/main.css. Also, I personally dislike that every *.module.scss file gets a *.d.ts twin. Instead I did the following:
Now it compiles without any warnings. |
Hi, I'm bootstrapping a simple project with react and typescript and I can't seem to import css modules correctly.
This works:
import './styles.css'
This doesn't
import * as classes from './styles.css'
Am I missing something?
The text was updated successfully, but these errors were encountered: