-
Notifications
You must be signed in to change notification settings - Fork 65
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
Don't generate export for @keyframes #190
Comments
Interesting, I think it makes sense to remove keyframes from generation since there's no use case I can think of where you'd want to import them in TS/JS. The relevant line of code to change for this would be here:
We're relying on this package: https://www.npmjs.com/package/css-modules-loader-core It looks to allow plugins but haven't investigated further. Hopefully we can alter the functionality to filter out keyframes otherwise would need custom logic or consider switching to another package. |
Hello, @skovy, thank you for your response I created a test Pull Request where I use css-tree package for parsing css. May you please have a look? |
After doing some more research, this is actually intentional and supported behavior. Since someone could be using this and relying on it I don't think this is a bug, but intended functionality. Example of how this can be used: @keyframes animate {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
} import styles from "./style.css";
<div style={{ animation: styles.animate, }} /> This allows importing animations by name and applying them dynamically. |
@skovy There is an issue in your example above. To use it like this you'll need to configure But regardless, behaviour of typed-scss-module about generating types for keyframes is correct, because it fully matches to how css-modules work. |
Introduction
Hello, everyone 👋
Thank you for supporting such a great tool 🙏
Expected Behavior
We have the following
.scss
file:I expect tsm not to generate named export for
@keyframes
declarationDesired output:
Current Behavior
Actual output:
Possible Solution
@keyframes
declaration--excludeKeyframes
Context
namedExport
option incss-loader
webpack pluginimport/no-unused-modules
eslint rule for.scss.d.ts
files.scss
files, where I have@keyframes
declaration, animation name get's generated in.scss.d.ts
files and I get an error fromimport/no-unused-modules
, because this variable is not used in my react componentsYour Environment
7.0.2
macOS Monterey, 12.6.1
The text was updated successfully, but these errors were encountered: