Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fast-kings-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/recipes': minor
---

Handle option field that doesn't exist in config
2 changes: 1 addition & 1 deletion packages/recipes/src/createRuntimeFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const createRuntimeFn = <Variants extends VariantGroups>(

const selectionClassName =
// @ts-expect-error
config.variantClassNames[variantName][selection];
config.variantClassNames?.[variantName]?.[selection];

if (selectionClassName) {
className += ' ' + selectionClassName;
Expand Down
7 changes: 7 additions & 0 deletions tests/recipes/recipes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ describe('recipes', () => {
);
});

it('should not fall on arbitrary fields', () => {
// @ts-expect-error Field should be not defined in this test
expect(basic({ notHere: 'arbitrary-prop' })).toMatchInlineSnapshot(
`"recipes_basic__niwegb0 recipes_basic_spaceWithDefault_small__niwegb1"`,
);
});

it('should return requested variants', () => {
expect(
basic({
Expand Down