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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve RecipeVariants type to improve IDE hint #1161

Merged
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/grumpy-suns-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vanilla-extract/recipes": patch
---

Improve IDE hover of `RecipeVariants` type by explicitly resolving its output
9 changes: 7 additions & 2 deletions packages/recipes/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { ComplexStyleRule } from '@vanilla-extract/css';

type Resolve<T> = {
[Key in keyof T]: T[Key];
} & {};

type RecipeStyleRule = ComplexStyleRule | string;

export type VariantDefinitions = Record<string, RecipeStyleRule>;
Expand Down Expand Up @@ -48,5 +52,6 @@ export type RuntimeFn<Variants extends VariantGroups> = ((
classNames: RecipeClassNames<Variants>;
};

export type RecipeVariants<RecipeFn extends RuntimeFn<VariantGroups>> =
Parameters<RecipeFn>[0];
export type RecipeVariants<RecipeFn extends RuntimeFn<VariantGroups>> = Resolve<
Parameters<RecipeFn>[0]
>;