Skip to content

Resolve RecipeVariants type to improve IDE hint#1161

Merged
mattcompiles merged 4 commits intovanilla-extract-css:masterfrom
PrettyCoffee:feat/resolve-recipe-variants
Nov 9, 2023
Merged

Resolve RecipeVariants type to improve IDE hint#1161
mattcompiles merged 4 commits intovanilla-extract-css:masterfrom
PrettyCoffee:feat/resolve-recipe-variants

Conversation

@PrettyCoffee
Copy link
Contributor

Hey, when testing out vanilla-extract, I found that the type hints are currently very verbose with the generic RecipeVariants type and not readable.

For example when having a button that has the variants look, size, pill and square, it currently looks like this in my IDE (VSCode):

image

By using a generic type like this:

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

you can kind of "resolve" the type and only display the actually underlying type:

image

which has much better readability! :)

This is not changing the type itself, it is more like reassigning the attributes to a new type.

Loving the project so far, great work! ♥️

@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2023

🦋 Changeset detected

Latest commit: 3ead769

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

@askoufis
Copy link
Contributor

Thanks for the PR! Love the screenshots.

We've wanted to do this where it made sense in the repo, but never got around to it. It definitely improves the types significantly.

Your PR looks fine, but you'll need to add a changeset in order to get the change released. If you're unfamiliar with changesets, have a look at the links in the changeset bot comment above.

@PrettyCoffee
Copy link
Contributor Author

@askoufis thanks a lot for adding the changeset! Unfortunately, I didn't have a lot of time last week. 😅

@mattcompiles mattcompiles enabled auto-merge (squash) November 9, 2023 02:47
@mattcompiles mattcompiles merged commit d16c22f into vanilla-extract-css:master Nov 9, 2023
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.

3 participants