Skip to content

Conversation

@treehill05
Copy link

@treehill05 treehill05 commented Oct 27, 2025

Implementation of #1135

Closes: #1135

Summary by CodeRabbit

  • Refactor
    • Enhanced type safety and precision in builder type definitions for improved schema input constraint handling.

@vercel
Copy link

vercel bot commented Oct 27, 2025

@treehill05 is attempting to deploy a commit to the unnoq-team Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Oct 27, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @treehill05, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving the default type safety for input schemas within the ContractBuilder and Builder classes. By changing the generic type for the input schema from unknown to void, it ensures that operations expecting no input are correctly typed from the outset. This change aims to prevent potential type-related issues and makes the API more robust and predictable for developers.

Highlights

  • Improved Type Safety: The pull request enhances type safety for input schemas by explicitly setting the input type to void where no input is expected, replacing unknown.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Both builder files update their exported instances' type parameters. The oc constant in the contract builder and the os constant in the server builder each change their first Schema type argument from Schema<unknown, unknown> to Schema<void, unknown>, affecting type-level declarations only.

Changes

Cohort / File(s) Summary
Builder Type Parameter Updates
packages/contract/src/builder.ts, packages/server/src/builder.ts
Updated exported builder instances (oc and os) to use Schema<void, unknown> instead of Schema<unknown, unknown> as the first type parameter. Type-level change with no runtime impact.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

  • Both changes are identical in nature and follow a consistent pattern across the two builder files
  • Type-level modifications only; no runtime behavior or logic changes
  • Limited scope: single constant per file affected

Poem

🐰 A schema refined, from unknown to void,
The builders now whisper with clarity's shield,
Two types align in this TypeScript fjord,
Consistency blooms where the generics yield! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "feat: safe typing for input out of the box" directly aligns with the changeset's purpose. Both modified files update the default exported builder instances (oc and os) by changing their first type parameter from Schema<unknown, unknown> to Schema<void, unknown>, which improves type safety for input schemas. The title clearly captures this main change without being verbose, using descriptive language ("safe typing for input") that a teammate scanning the history would immediately understand as a quality improvement to the default builder instances.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces safe typing for input by changing the schema definition from Schema<unknown, unknown> to Schema<void, unknown> in both ContractBuilder and Builder classes. This change ensures that the input schema is explicitly defined as void when no input is expected, enhancing type safety and preventing potential runtime errors.


export const oc = new ContractBuilder<
Schema<unknown, unknown>,
Schema<void, unknown>,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The input schema is now explicitly void when no input is expected. This enforces type safety and prevents unexpected input. Consider adding a comment explaining why void is used here for better understanding.

Suggested change
Schema<void, unknown>,
Schema<void, unknown>,

Record<never, never>,
Record<never, never>,
Schema<unknown, unknown>,
Schema<void, unknown>,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the contract builder, the input schema is now explicitly void when no input is expected. Adding a comment here would also improve code clarity.

Suggested change
Schema<void, unknown>,
Schema<void, unknown>,

@unnoq
Copy link
Owner

unnoq commented Oct 27, 2025

I believe we should consider this as a breaking change, and will not merge this time.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 27, 2025

More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@1145

@orpc/client

npm i https://pkg.pr.new/@orpc/client@1145

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@1145

@orpc/experimental-durable-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-iterator@1145

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@1145

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@1145

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@1145

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@1145

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@1145

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@1145

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@1145

@orpc/experimental-publisher

npm i https://pkg.pr.new/@orpc/experimental-publisher@1145

@orpc/react

npm i https://pkg.pr.new/@orpc/react@1145

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@1145

@orpc/experimental-react-swr

npm i https://pkg.pr.new/@orpc/experimental-react-swr@1145

@orpc/server

npm i https://pkg.pr.new/@orpc/server@1145

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@1145

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@1145

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@1145

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@1145

@orpc/standard-server-fastify

npm i https://pkg.pr.new/@orpc/standard-server-fastify@1145

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@1145

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@1145

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@1145

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@1145

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@1145

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@1145

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@1145

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@1145

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@1145

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@1145

commit: bf6e136

@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@treehill05
Copy link
Author

I believe we should consider this as a breaking change, and will not merge this time.

Agreed. Thanks for taking your time to review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default input typing for routes to use void not unknown

2 participants