Skip to content

Commit

Permalink
fix(class references): experimentalResolveStyleCssClasses regression (#…
Browse files Browse the repository at this point in the history
…3689)

Co-authored-by: Johnson Chu <[email protected]>
  • Loading branch information
Ilanaya and johnsoncodehk authored Oct 26, 2023
1 parent 50d10c1 commit 7844683
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/language-core/src/generators/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
for (let i = 0; i < styles.length; i++) {
const style = styles[i];
const option = vueCompilerOptions.experimentalResolveStyleCssClasses;
if ((option === 'always' || option === 'scoped') && style.scoped) {
if (option === 'always' || (option === 'scoped' && style.scoped)) {
for (const className of style.classNames) {
generateCssClassProperty(
i,
Expand Down
2 changes: 1 addition & 1 deletion packages/language-core/src/plugins/vue-tsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function createTsx(fileName: string, _sfc: Sfc, { vueCompilerOptions, compilerOp

for (const style of _sfc.styles) {
const option = vueCompilerOptions.experimentalResolveStyleCssClasses;
if ((option === 'always' || option === 'scoped') && style.scoped) {
if (option === 'always' || (option === 'scoped' && style.scoped)) {
for (const className of style.classNames) {
classes.add(className.text.substring(1));
}
Expand Down
17 changes: 17 additions & 0 deletions test-workspace/tsc/#3688/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
{{ () => {
if (Array.isArray(__VLS_styleScopedClasses)) {
exactType(__VLS_styleScopedClasses, {} as 'foo'[]);
}
} }}
</template>

<script setup lang="ts">
import { exactType } from '../shared';
</script>

<style>
.foo {
color: red;
}
</style>
7 changes: 7 additions & 0 deletions test-workspace/tsc/#3688/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"include": [ "**/*" ],
"vueCompilerOptions": {
"experimentalResolveStyleCssClasses": "always",
},
}

0 comments on commit 7844683

Please sign in to comment.