Skip to content

Commit a292e9a

Browse files
committed
fix(codegen): global var key
1 parent 398ce8e commit a292e9a

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

.changeset/selfish-emus-own.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@pandacss/generator': patch
3+
---
4+
5+
Fix issue where generated type for `CssVarKeys` was incorrect resulting in partial autocompletion

packages/generator/__tests__/generate-style-props.test.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ describe('generate property types', () => {
1414
type CssVars = \`var(--\${string})\`
1515
type CssVarValue = ConditionalValue<Token | AnyString | (number & {})>
1616

17-
type CssVarName = | AnyString
18-
type CssVarKeys = \`--\${CssVarName}\`
17+
type CssVarKeys = \`--\${string}\` & {}
1918

2019
export type CssVarProperties = {
2120
[key in CssVarKeys]?: CssVarValue
@@ -7510,8 +7509,7 @@ describe('generate property types', () => {
75107509
type CssVars = \`var(--\${string})\`
75117510
type CssVarValue = ConditionalValue<Token | AnyString | (number & {})>
75127511

7513-
type CssVarName = | AnyString
7514-
type CssVarKeys = \`--\${CssVarName}\`
7512+
type CssVarKeys = \`--\${string}\` & {}
75157513

75167514
export type CssVarProperties = {
75177515
[key in CssVarKeys]?: CssVarValue
@@ -15024,8 +15022,7 @@ describe('generate property types', () => {
1502415022
type CssVars = "var(--random-color)" | "var(--button-color)"
1502515023
type CssVarValue = ConditionalValue<Token | CssVars | AnyString | (number & {})>
1502615024

15027-
type CssVarName = "random-color" | "button-color" | AnyString
15028-
type CssVarKeys = \`--\${CssVarName}\`
15025+
type CssVarKeys = "--random-color" | "--button-color" | \`--\${string}\` & {}
1502915026

1503015027
export type CssVarProperties = {
1503115028
[key in CssVarKeys]?: CssVarValue

packages/generator/src/artifacts/types/style-props.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ export function generateStyleProps(ctx: Context) {
2222
type CssVars = ${[cssVars || '`var(--${string})`'].filter(Boolean).join(' | ')}
2323
type CssVarValue = ConditionalValue<Token${ctx.globalVars.isEmpty() ? '' : ' | CssVars'} | AnyString | (number & {})>
2424
25-
type CssVarName = ${unionType(ctx.globalVars.names)} | AnyString
26-
type CssVarKeys = \`--\${CssVarName}\`
25+
type CssVarKeys = ${[...ctx.globalVars.names.map((name) => `"--${name}"`), '`--${string}` & {}'].filter(Boolean).join(' | ')}
2726
2827
export type CssVarProperties = {
2928
[key in CssVarKeys]?: CssVarValue

packages/studio/styled-system/types/style-props.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ type AnyString = (string & {})
88
type CssVars = `var(--${string})`
99
type CssVarValue = ConditionalValue<Token | AnyString | (number & {})>
1010

11-
type CssVarName = | AnyString
12-
type CssVarKeys = `--${CssVarName}`
11+
type CssVarKeys = `--${string}` & {}
1312

1413
export type CssVarProperties = {
1514
[key in CssVarKeys]?: CssVarValue

0 commit comments

Comments
 (0)