@@ -91,8 +91,8 @@ export function collectStyleScopedClassReferences(
9191 && prop . exp ?. type === CompilerDOM . NodeTypes . SIMPLE_EXPRESSION
9292 && prop . arg . content === 'class'
9393 ) {
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 ;
9696
9797 const { ts } = options ;
9898 const ast = ts . createSourceFile ( '' , content , 99 satisfies ts . ScriptTarget . Latest ) ;
@@ -101,22 +101,19 @@ export function collectStyleScopedClassReferences(
101101 ts . forEachChild ( ast , node => {
102102 if (
103103 ! ts . isExpressionStatement ( node )
104- || ! isTemplateExpression ( node . expression )
104+ || ! ts . isParenthesizedExpression ( node . expression )
105105 ) {
106106 return ;
107107 }
108-
109- const expression = node . expression . templateSpans [ 0 ] . expression ;
108+ const { expression } = node . expression ;
110109
111110 if ( ts . isStringLiteralLike ( expression ) ) {
112111 literals . push ( expression ) ;
113112 }
114-
115- if ( ts . isArrayLiteralExpression ( expression ) ) {
113+ else if ( ts . isArrayLiteralExpression ( expression ) ) {
116114 walkArrayLiteral ( expression ) ;
117115 }
118-
119- if ( ts . isObjectLiteralExpression ( expression ) ) {
116+ else if ( ts . isObjectLiteralExpression ( expression ) ) {
120117 walkObjectLiteral ( expression ) ;
121118 }
122119 } ) ;
@@ -210,8 +207,3 @@ function collectClasses(content: string, startOffset = 0) {
210207 }
211208 return classes ;
212209}
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