Skip to content

Commit

Permalink
fix(language-core): correctly obtain the index of style modules (#4907)
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX authored Oct 24, 2024
1 parent 6a075c6 commit df6780a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/language-core/lib/codegen/script/styleModulesType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ export function* generateStyleModulesType(
options: ScriptCodegenOptions,
ctx: ScriptCodegenContext
): Generator<Code> {
const styles = options.sfc.styles.filter(style => style.module);
const styles = options.sfc.styles.map((style, i) => [style, i] as const).filter(([style]) => style.module);
if (!styles.length) {
return;
}
yield `type __VLS_StyleModules = {${newLine}`;
for (let i = 0; i < styles.length; i++) {
const style = styles[i];
for (const [style, i] of styles) {
const { name, offset } = style.module!;
if (offset) {
yield [
Expand All @@ -39,6 +38,5 @@ export function* generateStyleModulesType(
}
yield `>${endOfLine}`;
}
yield `}`;
yield endOfLine;
yield `}${endOfLine}`;
}

0 comments on commit df6780a

Please sign in to comment.