Skip to content

fix: Refactor ValueToResponseSchema type logic to account for return type something | undefined#1763

Open
deadlinecode wants to merge 1 commit intoelysiajs:mainfrom
deadlinecode:patch-1
Open

fix: Refactor ValueToResponseSchema type logic to account for return type something | undefined#1763
deadlinecode wants to merge 1 commit intoelysiajs:mainfrom
deadlinecode:patch-1

Conversation

@deadlinecode
Copy link

@deadlinecode deadlinecode commented Feb 27, 2026

Refactor ValueToResponseSchema type to ensure only returning empty 200 schema on undefined or void. If it is something | undefined type response as infered return type.

Should fix #1762

Summary by CodeRabbit

  • Refactor
    • Improved internal type handling logic for response schema generation to ensure more precise type definitions.

Refactor ValueToResponseSchema type to improve type extraction logic.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbaf6b7 and e03ae05.

📒 Files selected for processing (1)
  • src/types.ts

Walkthrough

A conditional type in ValueToResponseSchema<Value> has been refined to properly handle response types that are unions with undefined or void. The new logic excludes these values and only includes the 200 status when a concrete, non-never type remains, fixing type inference in client-server interactions.

Changes

Cohort / File(s) Summary
Response Schema Type Logic
src/types.ts
Updated R200 conditional type handling to use `Exclude<R200, undefined

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Poem

🐰 When types with undefined did wrongly fade,
To unknown mists in schemas strayed,
A clever Exclude came out to play,
Now concrete types shine bright of day! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: refactoring ValueToResponseSchema type logic to handle return types that are unions with undefined.
Linked Issues check ✅ Passed The code changes directly address issue #1762 by refactoring ValueToResponseSchema to correctly infer 200 response schemas when return types include undefined unions.
Out of Scope Changes check ✅ Passed The change is a minimal, focused fix to src/types.ts that directly addresses the linked issue with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@deadlinecode
Copy link
Author

Return type something | undefined is now actually typed as something | undefined | null but i think this comes from elysia because of the json stringification and should be correct like this?

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.

With a response being something | undefined elysia/eden always returns unknown as data type

1 participant