language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Detect invalid class name when using CSS module

Open Doeke opened this issue 11 months ago • 0 comments

What problem does this feature solve?

It would be nice to see a type error if we make a typo in a class name when using CSS modules. Currently the type for useCssModule() is defined like Record<string, string> & { class1: string, ... }, would it be possible to remove the Record and just have it be of type { class1: string, ... }? Perhaps this could be added with a TS config option to enable it, similar to strictTemplates etc?

What does the proposed solution look like?

<script setup>
const { wrongClass } = useCssModule()
/// ^ Error: Property 'wrongClass' does not exist on type
</script>
<style module>
.class1 { color: red }
</style>

Doeke avatar Feb 04 '25 12:02 Doeke