Skip to content

Commit

Permalink
revert: re-generate property access when referencing the scoped classes
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Dec 21, 2024
1 parent ea394f1 commit 580a096
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/script/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function* generateStyleScopedClasses(
ctx: TemplateCodegenContext
): Generator<Code> {
const firstClasses = new Set<string>();
yield `type __VLS_StyleScopedClasses = {}`;
yield `let __VLS_styleScopedClasses!: {}`;
for (let i = 0; i < options.sfc.styles.length; i++) {
const style = options.sfc.styles[i];
const option = options.vueCompilerOptions.experimentalResolveStyleCssClasses;
Expand Down
16 changes: 6 additions & 10 deletions packages/language-core/lib/codegen/template/styleScopedClasses.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import type { Code } from '../../types';
import { endOfLine } from '../utils';
import { endOfLine, newLine } from '../utils';
import type { TemplateCodegenContext } from './context';

export function* generateStyleScopedClassReferences(
ctx: TemplateCodegenContext,
withDot = false
): Generator<Code> {
if (!ctx.emptyClassOffsets.length && !ctx.scopedClasses.length) {
return;
}

yield `[`;
for (const offset of ctx.emptyClassOffsets) {
yield `'`;
yield `__VLS_styleScopedClasses['`;
yield [
'',
'template',
offset,
ctx.codeFeatures.additionalCompletion,
];
yield `', `;
yield `']${endOfLine}`;
}
for (const { source, className, offset } of ctx.scopedClasses) {
yield `__VLS_styleScopedClasses[`;
yield [
'',
source,
Expand All @@ -39,9 +35,9 @@ export function* generateStyleScopedClassReferences(
offset + className.length,
ctx.codeFeatures.navigationWithoutRename,
];
yield `, `;
yield `]${endOfLine}`;
}
yield `] as (keyof __VLS_StyleScopedClasses)[]${endOfLine}`;
yield newLine;

function* escapeString(source: string, className: string, offset: number, escapeTargets: string[]): Generator<Code> {
let count = 0;
Expand Down

0 comments on commit 580a096

Please sign in to comment.