Fix strict select subset typing under TS6#2720
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesSelectSubset strict typing and test coverage
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Hi @olup , thanks for making the fix! I'm not sure if it's by design, but I believe the improved EPC check only works for top-level select/omit/include. Adding recursion will probably incur significant type-checking cost, so I think it's a valid trade-off. Looking good to me. |
|
Great ! I'll have a quick look this morning on recursion/performance. |
3816813 to
f5fa064
Compare
|
(message produces by codex under human supervision) I updated the branch to address the recursion/performance concern with a different approach. Instead of using a fixed recursion depth, the new version only applies strict checking along the user-provided selection tree, and only for I also compared this with Drizzle's model. Drizzle's Quick local typechecking perf check:
Average e2e results:
I also checked Validation run locally:
|
|
Checking a couple of details on the where queries before reopening this one |
31aa89e to
371687e
Compare
|
(message produced by codex under human supervision) Small follow-up: I also checked the The selection recursion helper intentionally does not recursively walk arbitrary sub-objects like scalar filter payloads or sort payloads. However, I added explicit type tests for:
Implementation-wise, the patch now applies shallow exactness to Validation rerun:
|
Summary
Fixes a TypeScript 6 / tsgo typing gap where direct client calls accepted unknown nested keys in
selectobjects, even though the explicit args type rejected them.The issue was reported in #2719.
What changed
SelectSubsetforselect,include, andomitproperties so nested keys are checked against the contextual argument shape.selectfields on direct client calls.@ts-expect-error, matching their comments and the now-stricter compile-time behavior.Validation
pnpm --filter @zenstackhq/orm buildpnpm --filter e2e test:typecheckCreated by Codex on human request.
Summary by CodeRabbit
Release Notes
Refactor
select,include,omit, and related query arguments so invalid fields are rejected more precisely, including stricter nested shape validation andnull/undefinedpreservation.Tests
ts-expect-errorassertions for top-level and deeply nestedselect/include/omit, plus negative cases for unsupportedwhere/orderByusage.