Skip to content

Detect invalid class name when using CSS module #5162

@Doeke

Description

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>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions