From 46c0de15c8741e5ee937fff43ac6acd9526dd71b Mon Sep 17 00:00:00 2001 From: andjsrk Date: Thu, 13 Mar 2025 15:49:25 +0900 Subject: [PATCH 1/3] Match runtime behavior to the type definition --- packages/css/src/style.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/css/src/style.ts b/packages/css/src/style.ts index d2c417a1f..be0c46f75 100644 --- a/packages/css/src/style.ts +++ b/packages/css/src/style.ts @@ -27,7 +27,11 @@ function composedStyle(rules: Array, debugId?: string) { const classList = []; const styleRules = []; - for (const rule of rules) { + // `flat(Infinity)` fails to compile because of TS2589 + const flattenedRules = rules.flat(Infinity as 20) as Array< + StyleRule | string + >; + for (const rule of flattenedRules) { if (typeof rule === 'string') { classList.push(rule); } else { From 51826cac03e8968aedfc6d80ce573702c8ebfeb5 Mon Sep 17 00:00:00 2001 From: andjsrk Date: Thu, 13 Mar 2025 16:10:57 +0900 Subject: [PATCH 2/3] Add changeset --- .changeset/dry-rabbits-grow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/dry-rabbits-grow.md diff --git a/.changeset/dry-rabbits-grow.md b/.changeset/dry-rabbits-grow.md new file mode 100644 index 000000000..4c0b204fb --- /dev/null +++ b/.changeset/dry-rabbits-grow.md @@ -0,0 +1,5 @@ +--- +'@vanilla-extract/css': patch +--- + +Fix runtime behavior to match the type definition From a95d74bd76cefcab723e48b9c39f9e3ae0b952bc Mon Sep 17 00:00:00 2001 From: andjsrk Date: Thu, 13 Mar 2025 16:34:45 +0900 Subject: [PATCH 3/3] Fix code more appropriately `dudupeAndJoinClassList(classList)` is on below and will handle `ClassNames` --- packages/css/src/style.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/css/src/style.ts b/packages/css/src/style.ts index be0c46f75..39a4bc2ea 100644 --- a/packages/css/src/style.ts +++ b/packages/css/src/style.ts @@ -27,15 +27,11 @@ function composedStyle(rules: Array, debugId?: string) { const classList = []; const styleRules = []; - // `flat(Infinity)` fails to compile because of TS2589 - const flattenedRules = rules.flat(Infinity as 20) as Array< - StyleRule | string - >; - for (const rule of flattenedRules) { - if (typeof rule === 'string') { - classList.push(rule); - } else { + for (const rule of rules) { + if (typeof rule !== 'string' && !Array.isArray(rule)) { styleRules.push(rule); + } else { + classList.push(rule); } }