Skip to content

Commit

Permalink
fix(recipes): Allow undefined for variants (#1443)
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikRusso authored Aug 17, 2024
1 parent e836691 commit 2a7acc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tame-suits-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/recipes': patch
---

Enable passing `undefined` variant values to recipe functions when TypeScript's `exactOptionalPropertyTypes` is enabled.
4 changes: 3 additions & 1 deletion packages/recipes/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ type BooleanMap<T> = T extends 'true' | 'false' ? boolean : T;

export type VariantGroups = Record<string, VariantDefinitions>;
export type VariantSelection<Variants extends VariantGroups> = {
[VariantGroup in keyof Variants]?: BooleanMap<keyof Variants[VariantGroup]>;
[VariantGroup in keyof Variants]?:
| BooleanMap<keyof Variants[VariantGroup]>
| undefined;
};

export type VariantsClassNames<Variants extends VariantGroups> = {
Expand Down

0 comments on commit 2a7acc9

Please sign in to comment.