-
Notifications
You must be signed in to change notification settings - Fork 74
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
@value
is missing from imported type
#261
Comments
Looks like the However, to get this in the typings we'd have to create a postcss configuration, which is not something we need for any other tooling (and might even cause issues with webpack or vite, as their defaults would be modified). For vite, it also appears here: https://github.com/madyankin/postcss-modules/blob/325f0b33f1b746eae7aa827504a5efd0949022ef/src/scoping.js#L6 |
Hi @JannikGM, I can take a look soon - I'm away right now - but if you could create a reproduction in the meantime, that'll enable me to track down the issue much faster. It's obviously very hard for this plugin to be zero-config for everyone, because there are (near) infinite ways people can write and build their CSS, but where possible we want to be zero-config. |
I've attached a zip with a project for reproducing the issue: typescript-plugin-css-modules-repro-master.zip It shows a red box with the result of I haven't tried to create webpack/vite builds yet, but the watch-mode of vite and webpack seems to work (or rather: shows the problem). |
@mrmckeb any updates on this? |
Sorry, I haven't had a chance to look into this recently. PRs are always welcome though if anyone wants to take a look! I'll hopefully have some time in the near future. |
Hi @JannikGM, sorry for the delay. I changed jobs and moved cities over the last six months and haven't had much time to work on open source. It looks like your issue is - as you pointed out - that you need to have the plugin installed.
(Source: https://github.com/css-modules/css-modules/blob/master/docs/values-variables.md) This plugin will load any PostCSS plugins you have installed, but expects them to be in a PostCSS config. As this is in Webpack's CSS loader, I think it's fair to add it here. Would you be open to creating a PR? If not, I can take a look as it's a very small change either way :) |
Thanks for getting back to it. I'll be leaving the company that had this issue in the next days. Would be nice if you can still fix it. |
@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
index.ts
The type for
test
from this plugin is (retrieved with vscode):However, the types at runtime (from what I can tell, without explicitly loading
postcss-modules-values
):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.
The text was updated successfully, but these errors were encountered: