Skip to content

Commit df6780a

Browse files
authored
fix(language-core): correctly obtain the index of style modules (#4907)
1 parent 6a075c6 commit df6780a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/language-core/lib/codegen/script/styleModulesType.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ export function* generateStyleModulesType(
88
options: ScriptCodegenOptions,
99
ctx: ScriptCodegenContext
1010
): Generator<Code> {
11-
const styles = options.sfc.styles.filter(style => style.module);
11+
const styles = options.sfc.styles.map((style, i) => [style, i] as const).filter(([style]) => style.module);
1212
if (!styles.length) {
1313
return;
1414
}
1515
yield `type __VLS_StyleModules = {${newLine}`;
16-
for (let i = 0; i < styles.length; i++) {
17-
const style = styles[i];
16+
for (const [style, i] of styles) {
1817
const { name, offset } = style.module!;
1918
if (offset) {
2019
yield [
@@ -39,6 +38,5 @@ export function* generateStyleModulesType(
3938
}
4039
yield `>${endOfLine}`;
4140
}
42-
yield `}`;
43-
yield endOfLine;
41+
yield `}${endOfLine}`;
4442
}

0 commit comments

Comments
 (0)