fix(sdk): respect @@strict inherited from mixins in type def generation - #2812
Conversation
The strict flag check used hasAttribute, which only inspects attributes declared directly on the type def, while the attributes array is built with getAllAttributes (including mixins). A type def inheriting @@strict from a mixin thus never got \`strict: true\` in the generated schema. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe TypeScript schema generator now detects ChangesInherited strictness detection
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change makes generated schemas honor inherited @@strict behavior from mixins and adds coverage for that case; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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
packages/cli/test/ts-schema-gen.test.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. packages/sdk/src/ts-schema-generator.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. 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 |
Summary
strict: trueflag in generated type-def schemas was gated onhasAttribute(td, '@@strict'), which only inspects attributes declared directly on the type def, while theattributesarray is built withgetAllAttributes(which walks mixins). A type def inheriting@@strictfrom a mixin (type Profile with Strict) carried the attribute in itsattributesarray but never gotstrict: true, so the Zod validation and strict typing paths silently treated it as loose.getAllAttributes(td). The lite-filtered localattributesvariable is deliberately not reused so the flag is emitted regardless of lite mode.Testing
packages/cli/test/ts-schema-gen.test.tsalongside the existing direct-@@stricttest; both pass.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
strict: true.Tests