Skip to content

Commit f076a81

Browse files
committed
fix: prevent detection of CSS objects within style/styled API
1 parent 5227b39 commit f076a81

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/source-matcher.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const getSourceMatchers = (
5353
kind: [SyntaxKind.Identifier, SyntaxKind.StringLiteral],
5454
text: 'base',
5555
},
56+
// Do not match CSS objects: `base: { color: 'blue' }`
5657
initializer: (node: ts.Node) => node.kind != SyntaxKind.ObjectLiteralExpression,
5758
// https://github.com/microsoft/typescript-template-language-service-decorator/blob/main/src/nodes.ts#L62
5859
// TODO styled.button, styled()
@@ -74,6 +75,8 @@ export const getSourceMatchers = (
7475
kind: [SyntaxKind.Identifier, SyntaxKind.StringLiteral],
7576
text: 'use',
7677
},
78+
// Do not match CSS objects: `use: { color: 'blue' }`
79+
initializer: (node: ts.Node) => node.kind !== SyntaxKind.ObjectLiteralExpression,
7780
parent: {
7881
kind: SyntaxKind.ObjectLiteralExpression,
7982
parent: {
@@ -103,6 +106,8 @@ export const getSourceMatchers = (
103106
// style({ variants: { [...]: { [...]: '...' }} })
104107
{
105108
kind: SyntaxKind.PropertyAssignment,
109+
// Do not match CSS objects
110+
initializer: (node: ts.Node) => node.kind != SyntaxKind.ObjectLiteralExpression,
106111
parent: {
107112
kind: SyntaxKind.ObjectLiteralExpression,
108113
parent: {

0 commit comments

Comments
 (0)