Fix FormError component TypeScript error: make name prop truly optional with default '_form'#117
Conversation
|
|
|
📝 Storybook Preview: View Storybook This preview will be updated automatically when you push new changes to this PR.
|
… '_form' Co-authored-by: jaruesink <4207065+jaruesink@users.noreply.github.com>
FormError component. Let me first examine the component's implementation and then look at how it's being used in the LoginForm.tsx file.Looking at your FormError component code, I can see the i...|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@codegen-sh please use npm to patch my components package with a summary message, don't publish it to npm we'll do that when it gets merged |
1 similar comment
|
@codegen-sh please use npm to patch my components package with a summary message, don't publish it to npm we'll do that when it gets merged |
- Fixed FormError component TypeScript error by making name prop truly optional - Resolved type conflict between Omit and intersection types - Enables usage without props: <FormError /> - Maintains backward compatibility with existing code Co-authored-by: Jake Ruesink <jake@lambdacurry.com>
Problem
The
FormErrorcomponent was causing a TypeScript error when used without props, even though it has a default value for thenameprop:Root Cause
The issue was in the
FormErrorPropstype definition:This created a type conflict where:
Omit<FormErrorFieldProps, 'control'>keptnameas required (from the originalFormErrorFieldProps)& { name?: string }tried to make it optionalnamerequiredSolution
Replaced the problematic
Omit+ intersection approach with an explicit type definition:This makes the
nameprop truly optional while maintaining all functionality and type safety.Validation
The fix enables all these usage patterns to work correctly:
.d.tsshowsname?: string(properly optional)namedefaults to'_form'Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
storybook.js.org/usr/local/bin/node /home/REDACTED/work/forms/forms/node_modules/storybook/bin/index.cjs build(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.