fix(AuthForm): type submit payload with the schema output - #6816
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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
test/components/AuthForm.spec.tsParsing error: Unexpected token { 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 |
commit: |
43101e7 to
735ce1b
Compare
735ce1b to
4f30bcd
Compare
🔗 Linked issue
Resolves #6814
❓ Type of change
📚 Description
AuthFormtypes itssubmitemit from the localstate, which follows the schema input, while theonSubmitprop it forwards toFormfollows the schema output. A field likerememberMe: z.boolean().default(false)makes those differ (optional going in, required coming out), and the two signatures get intersected in the template, so a handler typed with the output is rejected:What the form submits is the transformed data, so the output is the right type here. Typing the emit with
FormData<T>lines it up with the prop and the error goes away. Schemas without defaults or transforms are unaffected, their input and output are identical.📝 Checklist