
Description
@value
statements (https://github.com/css-modules/css-modules/blob/master/docs/values-variables.md) are missing from the imported types.
There doesn't appear to be any documentation or issue about this (yet).
Is your feature request related to a problem? Please describe.
Here's a minimal example consisting of 3 files:
-
externalValues.module.css
@value externalValue 100px;
-
test.module.css
@value externalValues: "./externalValues.module.css"; @value externalValue from externalValues; @value value 200px; .class { }
-
index.ts
import test from './test.module.css' console.log('test', JSON.stringify(test, undefined, 2))
The type for test
from this plugin is (retrieved with vscode):
(alias) let test: {
class: string;
}
import test
However, the types at runtime (from what I can tell, without explicitly loading postcss-modules-values
):
- vite devserver
test { "externalValues": "\"./externalValues.module.css\"", "externalValue": "100px", "value": "200px", "class": "src-test-test-module__class--svpx1" }
- webpack ('style-loader' → 'css-loader') devserver
test { "externalValues": "\"./externalValues.module.css\"", "externalValue": "100px", "value": "200px", "class": "test-test-module__class--nqRDQ" }
This leads to issues accessing test.value
due to bad typing, despite it existing at runtime.
Describe the solution you'd like
I want the typing to match the actual imported content.
At the very least, I want the @value
to be respected (for "value" and "externalValue"), because our code depends on this.
Describe alternatives you've considered
We'd have to rewrite a lot of code which depends on @value
and move constants from CSS to TS. But this is a bad approach as the CSS might be generated from design tools, so this would mean more work in the future.
If this is is already supported (somehow), then please document how to handle this.