Skip to content

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

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

fix(contract, server): has no properties in common with type ts-problem#247
dinwwwh merged 2 commits into
mainfrom
fix/server/has-no-properties-in-common-with-type-ts-problem-2

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Mar 15, 2025

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

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.

@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 9:13am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 15, 2025

Walkthrough

This pull request updates several method signatures across the contract and server packages to improve type compatibility. In the contract package, the $meta method of the ContractBuilder now returns an intersected type (U & Record<never, never>), addressing TypeScript errors. In the server package, both the middleware method in the Builder class and related methods in the RouterImplementer interface and Implementer type have been modified to replace TCurrentContext with TInitialContext. The implement function signature has also been simplified with a unified default context type.

Changes

File(s) Change Summary
packages/contract/src/builder.ts Updated the $meta method signature in ContractBuilder to return an intersected type (U & Record<never, never>) for better type compatibility and to resolve specific TypeScript errors.
packages/server/src/builder.ts,
packages/server/src/implementer.ts
Updated middleware-related method signatures to replace TCurrentContext with TInitialContext in parameters and return types. Additionally, modified the $context method (adding & Record<never, never>) and simplified the implement function signature with a default context type.
packages/contract/src/builder.test-d.ts Updated type assertion for the $meta method test to reflect the new return type (ContractBuilder<..., MetaDef & Record<never, never>>).
packages/server/src/builder.test-d.ts Updated type expectations in middleware tests to change context type from CurrentContext to InitialContext and adjusted expected return types accordingly.
packages/server/src/implementer.test-d.ts Changed type expectations in middleware tests to transition from CurrentContext to InitialContext, affecting assertions for both context and mid.

Possibly related PRs

  • unnoq/orpc#244: The changes in the main PR, specifically the modification of the $meta method's return type to include & Record<never, never>, are directly related to the changes in the retrieved PR, which also involve similar type adjustments to include intersection types for better type compatibility.

Poem

I'm a bouncy rabbit on a brave new type quest,
Hopping through signatures to make our code the best.
With context renamed and intersections in place,
Our builders and middleware now set a faster pace.
Coding with carrots and a joyful, clever cheer,
I leap ahead—happy to see our changes here! 🐇

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 95400e7 and 6c67526.

📒 Files selected for processing (3)
  • packages/contract/src/builder.test-d.ts (1 hunks)
  • packages/server/src/builder.test-d.ts (3 hunks)
  • packages/server/src/implementer.test-d.ts (3 hunks)
🔇 Additional comments (7)
packages/contract/src/builder.test-d.ts (1)

27-29: Type modification looks good.

The addition of & Record<never, never> to the expected return type of the $meta method ensures TypeScript treats MetaDef as an object type. This helps address the TypeScript error mentioned in the PR description where types had "no properties in common."

packages/server/src/implementer.test-d.ts (3)

44-44: Context type update is correct.

Changed the expected type check from CurrentContext to InitialContext, which matches the PR objective of fixing TypeScript type compatibility issues.


60-63: Middleware type parameter correctly updated.

This change aligns with the modification of the middleware method signature in the implementation, ensuring the test correctly verifies that the middleware function now works with InitialContext rather than CurrentContext.


80-81: Consistent type update in the second test case.

This modification maintains consistency with the previous type changes, ensuring all middleware-related type assertions use InitialContext.

packages/server/src/builder.test-d.ts (3)

160-160: Context type update in builder test.

The expected type for the middleware's context parameter has been updated from CurrentContext to InitialContext, matching the changes to the actual implementation.


176-176: Middleware return type correctly updated.

The expected type of the middleware function now uses InitialContext instead of CurrentContext as its first type parameter, ensuring type compatibility with the implementation.


187-187: Second middleware test case updated consistently.

This change completes the pattern of updating all middleware-related types from CurrentContext to InitialContext across the builder tests.

✨ 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.

@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@247

@orpc/contract

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

@orpc/openapi-client

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

@orpc/openapi

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

@orpc/react-query

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

@orpc/server

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

@orpc/shared

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

@orpc/solid-query

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

@orpc/standard-server

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

@orpc/standard-server-fetch

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

@orpc/standard-server-node

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

@orpc/svelte-query

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

@orpc/vue-colada

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

@orpc/vue-query

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

@orpc/zod

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

commit: 6c67526

@dinwwwh dinwwwh changed the title fix(server): has no properties in common with type ts-problem fix(contract, server): has no properties in common with type ts-problem Mar 15, 2025
@dinwwwh dinwwwh merged commit 9dfcee8 into main Mar 15, 2025
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