Skip to content

Conversation

@sneas
Copy link

@sneas sneas commented Apr 3, 2020

Current situation

The below valid CSS

// scss
.classname {
    color: Red;
}

.something-and-something-else {
    color: Red;
}

.надписьКириллицей {
    color: Red;
}

.🐸 {
    color: Green;
}

Produces the following DTS file (namedExport on):

// This file is generated automatically
export const classname: string;
export const something-and-something-else: string; // Invalid ES6 identifier
export const somethingAndSomethingElse: string;
export const надписьКириллицей: string;
export const надписькириллицей: string;
export const 🐸: string; // Invalid ES6 identifier

The above DTS file contains invalid ES6 identifiers and wouldn't be compiled by TS.

Solution

The solution would be to filter out invalid ES6 identifiers from the named exports:

// This file is generated automatically
export const classname: string;
export const somethingAndSomethingElse: string;
export const надписьКириллицей: string;
export const надписькириллицей: string;

@c0gnize
Copy link
Contributor

c0gnize commented Apr 3, 2020

Thank you for your PR but I think it's a little bit redundant. The current loader takes all as-is from css-loader and did not modify variables. If you want to use dashes you can just not use the namedExport option. Or use localsConvention: 'camelCaseOnly' of css-loader.

@sneas
Copy link
Author

sneas commented Apr 3, 2020

Oh yes, you're right. Thank you. Closing the PR.

@sneas sneas closed this Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants