@@ -91,8 +91,8 @@ export function collectStyleScopedClassReferences(
91
91
&& prop . exp ?. type === CompilerDOM . NodeTypes . SIMPLE_EXPRESSION
92
92
&& prop . arg . content === 'class'
93
93
) {
94
- const content = '`${ ' + prop . exp . content + '}` ' ;
95
- const startOffset = prop . exp . loc . start . offset - 3 ;
94
+ const content = '( ' + prop . exp . content + ') ' ;
95
+ const startOffset = prop . exp . loc . start . offset - 1 ;
96
96
97
97
const { ts } = options ;
98
98
const ast = ts . createSourceFile ( '' , content , 99 satisfies ts . ScriptTarget . Latest ) ;
@@ -101,22 +101,19 @@ export function collectStyleScopedClassReferences(
101
101
ts . forEachChild ( ast , node => {
102
102
if (
103
103
! ts . isExpressionStatement ( node )
104
- || ! isTemplateExpression ( node . expression )
104
+ || ! ts . isParenthesizedExpression ( node . expression )
105
105
) {
106
106
return ;
107
107
}
108
-
109
- const expression = node . expression . templateSpans [ 0 ] . expression ;
108
+ const { expression } = node . expression ;
110
109
111
110
if ( ts . isStringLiteralLike ( expression ) ) {
112
111
literals . push ( expression ) ;
113
112
}
114
-
115
- if ( ts . isArrayLiteralExpression ( expression ) ) {
113
+ else if ( ts . isArrayLiteralExpression ( expression ) ) {
116
114
walkArrayLiteral ( expression ) ;
117
115
}
118
-
119
- if ( ts . isObjectLiteralExpression ( expression ) ) {
116
+ else if ( ts . isObjectLiteralExpression ( expression ) ) {
120
117
walkObjectLiteral ( expression ) ;
121
118
}
122
119
} ) ;
@@ -210,8 +207,3 @@ function collectClasses(content: string, startOffset = 0) {
210
207
}
211
208
return classes ;
212
209
}
213
-
214
- // isTemplateExpression is missing in tsc
215
- function isTemplateExpression ( node : ts . Node ) : node is ts . TemplateExpression {
216
- return node . kind === 228 satisfies ts . SyntaxKind . TemplateExpression ;
217
- }
0 commit comments