Skip to content

Commit

Permalink
Resolve RecipeVariants type to improve IDE hint (#1161)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Skoufis <[email protected]>
  • Loading branch information
PrettyCoffee and askoufis authored Nov 9, 2023
1 parent 7961d16 commit d16c22f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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]
>;

0 comments on commit d16c22f

Please sign in to comment.