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

Access properties like styles['test'] #61

Closed
PodaruDragos opened this issue Jan 14, 2022 · 5 comments
Closed

Access properties like styles['test'] #61

PodaruDragos opened this issue Jan 14, 2022 · 5 comments

Comments

@PodaruDragos
Copy link

Is there any plan to support accessing styles like styles['test'] ?

styles.test;
string | undefined
Property 'test' comes from an index signature, so it must be accessed with ['test'].ts(4111)

this check is coming from "noPropertyAccessFromIndexSignature": true in tsconfig.

@iChenLei
Copy link
Collaborator

Any idea for this feature ? @clinyong

@iChenLei
Copy link
Collaborator

@PodaruDragos Hello, I think there isn't a easy solution for your issue. Because vscode-css-modules is not a typechecker, We don't known whenever to auto complete .test or ['test'] . We only check if property is kebab-case or not and then auto complete your code like styles['kebab-case'] pr styles.camelCase (#48) , because styles.kebab-case is invalid javascript, we must check it and this case is simple(only need check if it is kebab-case).

@clinyong
Copy link
Owner

@iChenLei is right. When you are typing styles['], vscode doesn't trigger our CompletionProvider. It's hard to do this ourself.

@PodaruDragos
Copy link
Author

Ok, thanks for clearing this out

@Viijay-Kr
Copy link

Viijay-Kr commented Jan 26, 2023

React CSS Modules Addresses this problem .

My project has only non camel case selectors and this feature was so needed so I built my own extension with lots of other features too.
I hope it helps

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

4 participants