Skip to content

Commit 252e03d

Browse files
committed
feat(language-core): add strictCssModules option
1 parent a2abd0a commit 252e03d

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

Diff for: packages/language-core/lib/codegen/script/styleModulesType.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ export function* generateStyleModulesType(
2020
name,
2121
'main',
2222
offset + 1,
23-
codeFeatures.all
23+
codeFeatures.navigation
2424
];
2525
}
2626
else {
2727
yield name;
2828
}
29-
yield `: Record<string, string> & ${ctx.localTypes.PrettifyLocal}<{}`;
29+
yield `: `;
30+
if (!options.vueCompilerOptions.strictCssModules) {
31+
yield `Record<string, string> & `;
32+
}
33+
yield `${ctx.localTypes.PrettifyLocal}<{}`;
3034
for (const className of style.classNames) {
3135
yield* generateCssClassProperty(
3236
i,

Diff for: packages/language-core/lib/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface VueCompilerOptions {
3232
checkUnknownProps: boolean;
3333
checkUnknownEvents: boolean;
3434
checkUnknownComponents: boolean;
35+
strictCssModules: boolean;
3536
skipTemplateCodegen: boolean;
3637
fallthroughAttributes: boolean;
3738
dataAttributes: string[];

Diff for: packages/language-core/lib/utils/ts.ts

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ export function getDefaultCompilerOptions(target = 99, lib = 'vue', strictTempla
265265
checkUnknownProps: strictTemplates,
266266
checkUnknownEvents: strictTemplates,
267267
checkUnknownComponents: strictTemplates,
268+
strictCssModules: false,
268269
skipTemplateCodegen: false,
269270
fallthroughAttributes: false,
270271
dataAttributes: [],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- @strictCssModules true -->
2+
3+
<script lang="ts" setup>
4+
import { useCssModule } from 'vue';
5+
import { exactType } from '../../shared';
6+
7+
const style = useCssModule();
8+
exactType(style, {} as {
9+
foo: string;
10+
});
11+
</script>
12+
13+
<style module>
14+
.foo { }
15+
</style>

0 commit comments

Comments
 (0)