From 1ef17d04ddd82775956dc9173a02e69c9d15dcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=B1=E5=90=B9=E8=89=B2=E5=BE=A1=E5=AE=88?= <85992002+KazariEX@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:18:21 +0800 Subject: [PATCH] fix(language-core): generate style modules type as needed (#4953) --- .../language-core/lib/codegen/script/styleModulesType.ts | 2 +- test-workspace/tsc/passedFixtures/vue3/cssModule/empty.vue | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test-workspace/tsc/passedFixtures/vue3/cssModule/empty.vue diff --git a/packages/language-core/lib/codegen/script/styleModulesType.ts b/packages/language-core/lib/codegen/script/styleModulesType.ts index 8ddd9b89fb..f23a7addfa 100644 --- a/packages/language-core/lib/codegen/script/styleModulesType.ts +++ b/packages/language-core/lib/codegen/script/styleModulesType.ts @@ -9,7 +9,7 @@ export function* generateStyleModulesType( ctx: ScriptCodegenContext ): Generator { const styles = options.sfc.styles.map((style, i) => [style, i] as const).filter(([style]) => style.module); - if (!styles.length) { + if (!styles.length && !options.scriptSetupRanges?.cssModules.length) { return; } yield `type __VLS_StyleModules = {${newLine}`; diff --git a/test-workspace/tsc/passedFixtures/vue3/cssModule/empty.vue b/test-workspace/tsc/passedFixtures/vue3/cssModule/empty.vue new file mode 100644 index 0000000000..cd1d21d462 --- /dev/null +++ b/test-workspace/tsc/passedFixtures/vue3/cssModule/empty.vue @@ -0,0 +1,6 @@ + \ No newline at end of file