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/calm-impalas-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/recipes': patch
---

Applying recipes now ignores unknown options instead of throwing a runtime TypeError.
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 ignore unknown variants', () => {
const props = { other: 'unknown-option' } as Parameters<typeof basic>[0];
expect(basic(props)).toMatchInlineSnapshot(
`"recipes_basic__niwegb0 recipes_basic_spaceWithDefault_small__niwegb1"`,
);
});

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