-
Notifications
You must be signed in to change notification settings - Fork 9
feat(api): Extend Opaque<T> to accept all BrandedCell types #2007
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
feat(api): Extend Opaque<T> to accept all BrandedCell types #2007
Conversation
Expands the Opaque<T> type to accept any kind of BrandedCell wrapping T, not just OpaqueRef<T>. This allows more flexible type handling across the codebase by accepting Cell<T>, OpaqueCell<T>, Stream<T>, ComparableCell<T>, ReadonlyCell<T>, and WriteonlyCell<T> as valid Opaque values. Also refines RenderNode type to explicitly accept BrandedCell<InnerRenderNode> rather than the overly permissive Opaque<any>, improving type safety in view rendering. Updates tests to reflect the new type capabilities, particularly in schema-to-ts.test.ts where nested cell types are now properly handled. Progress on recipe construction rollout plan: - Completed: Opaque<T> accepts T or any CellLike<T> at any nesting level - Completed: Accept any T where any sub part of T can be wrapped in one or more BrandedCell (for inputs to node factories)
cc9cc33 to
edc5a3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 6 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="packages/runner/test/schema-to-ts.test.ts">
<violation number="1" location="packages/runner/test/schema-to-ts.test.ts:809">
The updated expectType order now only checks that ExpectedInput is assignable to InferredInput, so regressions where InferredInput loses required fields (like `name`) would no longer be caught. Please restore the original order so the test still enforces that the inferred recipe input type includes all expected fields.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
|
|
||
| // Verify that the recipe function parameter matches our expected input type | ||
| expectType<ExpectedInput, InferredInput>(); | ||
| expectType<InferredInput, ExpectedInput>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated expectType order now only checks that ExpectedInput is assignable to InferredInput, so regressions where InferredInput loses required fields (like name) would no longer be caught. Please restore the original order so the test still enforces that the inferred recipe input type includes all expected fields.
Prompt for AI agents
Address the following comment on packages/runner/test/schema-to-ts.test.ts at line 809:
<comment>The updated expectType order now only checks that ExpectedInput is assignable to InferredInput, so regressions where InferredInput loses required fields (like `name`) would no longer be caught. Please restore the original order so the test still enforces that the inferred recipe input type includes all expected fields.</comment>
<file context>
@@ -801,11 +802,11 @@ describe("Schema-to-TS Type Conversion", () => {
// Verify that the recipe function parameter matches our expected input type
- expectType<ExpectedInput, InferredInput>();
+ expectType<InferredInput, ExpectedInput>();
// The expected output is the output schema wrapped in a single OpaqueRef.
</file context>
| expectType<InferredInput, ExpectedInput>(); | |
| expectType<ExpectedInput, InferredInput>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is actually the correct order
Expands the Opaque type to accept any kind of BrandedCell wrapping T, not just OpaqueRef. This allows more flexible type handling across the codebase by accepting Cell, OpaqueCell, Stream, ComparableCell, ReadonlyCell, and WriteonlyCell as valid Opaque values.
Also refines RenderNode type to explicitly accept BrandedCell rather than the overly permissive Opaque, improving type safety in view rendering.
Updates tests to reflect the new type capabilities, particularly in schema-to-ts.test.ts where nested cell types are now properly handled.
Progress on recipe construction rollout plan:
Summary by cubic
Extends Opaque to accept all BrandedCell variants and narrows RenderNode to BrandedCell for safer view typing. This improves type safety and makes recipe and schema types more flexible.
New Features
Refactors
Written for commit 25706b4. Summary will update automatically on new commits.