Skip to content

Conversation

@alexgrozav
Copy link
Contributor

This pull request refactors how the RecipeRuntime type is used throughout the codebase, improving type inference and developer ergonomics when working with recipes. The main change is to use type inference and the as const satisfies RecipeRuntime pattern instead of explicit type annotations, and to introduce a new utility type for extracting variant prop types from a recipe definition. This makes recipe usage more type-safe and flexible, especially in test and consumer code.

Type inference and type safety improvements:

  • Updated all test and consumer code to define recipe objects using const runtime = { ... } as const satisfies RecipeRuntime instead of explicit : RecipeRuntime type annotations. This enables TypeScript to infer literal types for variants and improves type safety. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35]

  • Updated the createRecipe function to be generic over the recipe type, allowing it to infer the correct variant prop types from the recipe definition. The function now accepts a generic parameter and uses the new RecipeVariantProps<R> utility type for its props argument.

Type utility additions:

  • Added a new RecipeVariantProps<R> utility type to types.ts that extracts the correct variant prop types from a given recipe definition. This enables better type inference for recipe props, ensuring that only valid variant keys and values are accepted.

Imports and type usage cleanup:

  • Updated imports in runtime.ts to include the new RecipeVariantProps type and to reorder imports for clarity.

@alexgrozav alexgrozav requested a review from Copilot December 30, 2025 08:55
@alexgrozav alexgrozav self-assigned this Dec 30, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 30, 2025

⚠️ No Changeset found

Latest commit: e47488b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link

vercel bot commented Dec 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
app-styleframe-dev-production Ready Ready Preview, Comment Dec 30, 2025 8:57am
styleframe-dev-production Ready Ready Preview, Comment Dec 30, 2025 8:57am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the RecipeRuntime type usage to leverage TypeScript's type inference through the as const satisfies RecipeRuntime pattern instead of explicit type annotations. This enables better type safety by preserving literal types for variant values while still ensuring structural conformance to the RecipeRuntime interface.

Key changes:

  • Added a new RecipeVariantProps<R> utility type that extracts precise variant prop types from recipe definitions
  • Updated createRecipe to be generic over the recipe type, improving type inference for consumer code
  • Migrated all recipe definitions from : RecipeRuntime annotations to as const satisfies RecipeRuntime pattern

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
engine/runtime/src/types.ts Added RecipeVariantProps<R> utility type with comprehensive JSDoc documentation for extracting variant props from recipe definitions
engine/runtime/src/runtime.ts Updated imports to include new type utility and made createRecipe generic to support improved type inference
engine/runtime/src/runtime.test.ts Migrated all test recipe definitions to use as const satisfies RecipeRuntime pattern consistently
engine/transpiler/src/consume/ts/recipe.ts Updated code generation to output recipe definitions using the new type inference pattern
engine/transpiler/src/consume/ts/recipe.test.ts Updated all test expectations to reflect the new code generation pattern
engine/transpiler/src/consume/ts/root.test.ts Updated all test expectations for root-level recipe generation to match the new pattern

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@alexgrozav alexgrozav merged commit 361f934 into main Dec 30, 2025
17 checks passed
@alexgrozav alexgrozav deleted the recipe-runtime-types branch December 30, 2025 09:02
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.

2 participants