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

Module $style doesn't contain mixins classes or "&name" classes #157

Closed
sheremet-va opened this issue Apr 25, 2021 · 3 comments
Closed

Module $style doesn't contain mixins classes or "&name" classes #157

sheremet-va opened this issue Apr 25, 2021 · 3 comments

Comments

@sheremet-va
Copy link

For example if I have this code in my style tag (scss, module):

.chevron {
   color: red;

   &Up {
      color: green;
   }
}

Type checking for $style fails because it doesn't contain the class chevronUp.

Снимок экрана 2021-04-25 в 13 14 49

This also applies to global mixins and mixins in general. We have @import "@/styles/_imports.scss" in our additionalData for scss inside Vite config and import them like:

.input {
    @include input;
}

If mixing contains a class or classes, they don't appear inside $style variable. Right now I use useCssStyle in my setup method to bypass that, but that's not ideal.

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Apr 25, 2021

This is a design limitation. If we need to calculate all valid class names, this will be a compiler level job for each style language. (css, scss, less)

And class name renaming feature can't not working on this case.

I suggest you use a single style block to shims the css module types.

<style module>
// you original styles
</style>

<style module>
.chevronUp { }
.chevronDown { }
// ...
</style>

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Apr 25, 2021

I found that useCssModule() type is Record<string, string>, maybe I should change $style types to Record<string, string> & { chevron: string, ... }, that allow all class name from $style in template, but we can't get error report if we have some typing mistake with $style.xxx.

@johnsoncodehk
Copy link
Member

Fixed in 0.24.2.

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

No branches or pull requests

2 participants