Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export VariantGroups and PatternOptions types from @vanilla-extract/recipes #1204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HorusGoul
Copy link

@HorusGoul HorusGoul commented Oct 26, 2023

Like in #694, I need to create a wrapper for the recipe() function. The solution provided in that issue doesn't solve the actual problem.

#694 (comment)
You could always pull the types out with TS, for example:

import { recipe } from '@vanilla-extract/recipes';

type VariantGroups = NonNullable<Parameters<typeof recipe>[0]['variants']>;
type PatternOptions = Parameters<typeof recipe>[0];

Does this help?

In my case, something else is needed. The proper type is the same type recipe uses:

function recipe<Variants extends VariantGroups>(
  options: PatternOptions<Variants>,
  debugId?: string,
): RuntimeFn<Variants>

I need to be able to do precisely that, process the options parameter, and pass it to recipe. Not doing it this way would make the API for the consumer of my wrappedRecipe function not configurable with a type parameter like recipe.

In that same issue, someone mentions the reason behind not exposing these types:

michaletaranto: As a general rule, we try to minimise the API footprint as it makes us less vulnerable to breaking changes in the future

Good, this makes sense, but this is part of the public API; I should be able to generate the PatternOptions in any way I like, with complete type safety, which I won't have unless I can do PatternOptions<MyVariants>

PatternOptions and VariableGroups are already public but not exported. If the format for PatternOption changes at some point or we remove something, it will be a breaking change and will require a major bump for the recipes package.


So, in the hopes of reopening this discussion and making it easy to fix the problem, I've opened this PR 馃槃

@changeset-bot
Copy link

changeset-bot bot commented Oct 26, 2023

馃 Changeset detected

Latest commit: 429bae7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vanilla-extract/recipes Patch
@fixtures/recipes Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant