SCSS - Importing SCSS variables globally breaks exported TS type to `{}`.
See original GitHub issueThanks for the awesome TS plugin! 💪
Describe the bug
There’s certain cases when using SASS where you need the value of a variable and need to wrap it in #{}
in order to get the variable output and not the variable name.
When adding #{}
to a *.module.scss
, the file’s classNames etc are no longer exported and only shows {}
in the TS file.
To Reproduce
Add the following to any *.module.scss
file, and try and import it to a TS
file.
container.module.scss
@use "variables" as *; // Which includes $breakpoint
.container {
@media (min-width: #{$breakpoint}) {
color: red;
}
}
Expected behavior
Using the #{}
functionality shouldn’t remove the classNames.
Desktop (please complete the following information):
- OS: iOS
- Browser: Chrome
- Version: 96.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:16
- Comments:13 (1 by maintainers)
Top Results From Across the Web
How to infer types from modular scss exports? - Stack Overflow
Basically the approach is: Create a modular scss file containing your scss variables, or import them from the original files using @use ....
Read more >Use Sass Variables In Typescript & Javascript | Matt Ferderer
I was using "require" module to import the scss variables like static variables: any = require('../scss/_variables.scss'); It was perfectly ...
Read more >Sass: @import
@import makes all variables, mixins, and functions globally accessible. This makes it very difficult for people (or tools) to tell where anything is...
Read more >Content Types - ESBuild
#Import from JavaScript ... Note that esbuild doesn't yet support CSS modules, so the set of JavaScript export names from a CSS file...
Read more >Standard Styling with Global CSS Files - Gatsby
Importing CSS files into components. It is also possible to break up your CSS styles into separate files so that team members can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
me too, we have a lot of media query global variables on a project, but when we are using them, it’s always showing empty type
{}
With custom media global variables
@media #{$new-tablet-only} {
Without custom media global variables
@mrmckeb please help us to fix this issue
I think it’s related to https://github.com/mrmckeb/typescript-plugin-css-modules/issues/146.
Trying to add the variable directly to the
scss
fixed the error. I have a SCSS configuration in myNextJS
app which includes all my resources, and I think that needs to be set in the same way for the plugin.I will try and update the
tsconfig
plugin settings, and see if I can get it to work 😃