Skip to content

fix(server): has no properties in common with type ts-problem#244

Merged
dinwwwh merged 4 commits into
mainfrom
fix/server/has-no-properties-in-common-with-type-problem
Mar 15, 2025
Merged

fix(server): has no properties in common with type ts-problem#244
dinwwwh merged 4 commits into
mainfrom
fix/server/has-no-properties-in-common-with-type-problem

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Mar 15, 2025

Summary by CodeRabbit

  • Refactor
    • Improved internal type structures for middleware, procedures, and context to bolster compatibility and flexibility.
  • Tests
    • Updated type assertions across test cases to ensure consistency and reliability, including modifications to expected outcomes in ContextExtendsGuard tests.

These behind-the-scenes improvements streamline integration points and enhance overall robustness, providing a smoother experience for developers using the system.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 15, 2025 2:06am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 15, 2025

Walkthrough

This pull request updates several type assertions across the codebase. The changes primarily refactor Middleware and Procedure types by introducing an intersection with Record<never, never>, and in some cases, simplifying types to any for greater flexibility. Additionally, the $context method in the Builder has been adjusted to return an intersection type to resolve TypeScript compatibility issues, and the conditional type in ContextExtendsGuard has been simplified.

Changes

File(s) Change Summary
packages/server/src/builder-variants.test-d.ts, packages/server/src/builder.test-d.ts, packages/server/src/builder.ts Revised type assertions for Middleware and Procedure types (using intersection with Record<never, never>) and updated the $context method signature in Builder to address type compatibility issues.
packages/server/src/context.ts Simplified ContextExtendsGuard by updating the conditional type from T extends T & U to T extends U.
packages/server/src/implementer-procedure.test-d.ts, packages/server/src/implementer-variants.test-d.ts, packages/server/src/implementer.test-d.ts, packages/server/src/middleware-decorated.test-d.ts, packages/server/src/procedure-decorated.test-d.ts Updated Middleware type assertions in test cases to include an intersection with Record<never, never> and simplified Procedure type assertions to any.

Possibly related PRs

  • unnoq/orpc#226: The changes in the main PR and this PR are related as both involve modifications to the type definitions of the mid variable in the context of middleware, specifically enhancing type flexibility by incorporating intersection types with Record<never, never>.
  • unnoq/orpc#218: The changes in the main PR regarding type assertions for Middleware and Procedure entities are related to the modifications in this PR, which also involves updates to the type definitions for mid in the context of middleware, indicating a direct connection at the code level.
  • unnoq/orpc#187: The changes in the main PR are related to those in this PR as both involve modifications to type assertions for the Middleware and Procedure types, specifically enhancing type flexibility in similar contexts.

Poem

I'm a rabbit on the run through code so bright,
Hopping past type checks in the day and night.
Middleware and Procedures now dance in a mix,
With intersections that solve those tricky type tricks.
Bugs nibble away as the code flows light—
Happy hops in TypeScript, a pure delight!
🐇💻

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

 ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS  Optional dependencies cannot be installed without production dependencies


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76cf4ae and 1c19511.

📒 Files selected for processing (2)
  • packages/server/src/builder.test-d.ts (5 hunks)
  • packages/server/src/context.test-d.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/server/src/builder.test-d.ts
🔇 Additional comments (2)
packages/server/src/context.test-d.ts (2)

29-31: Good addition of test cases for incompatible context types.

These test cases explicitly verify that when contexts have incompatible properties, the ContextExtendsGuard correctly evaluates to never. This helps validate the expected behavior when dealing with mismatched context properties.


33-38: Excellent solution with clear documentation for the TypeScript error.

The added comment and test cases demonstrate a clever solution to the "has no properties in common with type" TypeScript error using Record<never, never>. This pattern allows otherwise incompatible types to work together by creating an empty object type intersection. The tests verify that this technique successfully transforms what would be never types into unknown, enabling more flexible type compatibility.

This approach will help prevent similar type errors throughout the codebase when working with contexts that don't have overlapping properties.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dinwwwh dinwwwh changed the title fix(server): has no properties in common with type problem fix(server): has no properties in common with type ts-problem Mar 15, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 15, 2025

Open in Stackblitz

More templates

@orpc/client

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

@orpc/contract

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

@orpc/openapi-client

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

@orpc/react-query

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

@orpc/openapi

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

@orpc/server

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

@orpc/shared

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

@orpc/solid-query

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

@orpc/standard-server

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

@orpc/standard-server-fetch

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

@orpc/standard-server-node

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

@orpc/svelte-query

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

@orpc/vue-colada

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

@orpc/vue-query

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

@orpc/zod

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

commit: 1c19511

@dinwwwh dinwwwh merged commit ba53a01 into main Mar 15, 2025
dinwwwh referenced this pull request Mar 15, 2025
…blem (#247)

In previous attempt: https://github.com/unnoq/orpc/pull/244 we forgot
cover some cases

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Updated type definitions for configuration and middleware interfaces
to enhance type safety.
- Standardized context handling across core modules to ensure consistent
use of the initial context.
- Resolved underlying compatibility issues, improving overall stability
without impacting runtime functionality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

1 participant