Repository navigation
fix(TextArea): correct data.value type in onChange and onInput callbacks - #4546
Open
geeknishantkyeus wants to merge 1 commit into
Open
geeknishantkyeus wants to merge 1 commit into
geeknishantkyeus wants to merge 1 commit into
Conversation
|
@geeknishantkyeus is attempting to deploy a commit to the Semantic UI Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4546 +/- ##
=======================================
Coverage 99.53% 99.53%
=======================================
Files 186 186
Lines 3463 3463
=======================================
Hits 3447 3447
Misses 16 16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
TextArea'sonChangeandonInputcallbacks declareddata.valueasnumber | string | undefined, but the actual runtime value is always a string.This PR types the callback
dataparameter accurately, without touching the publicvalueprop.Why
Runtime reality
In
TextArea.js, look athandleChange:e.targetis a native<textarea>element. Per the HTML spec,<textarea>.valueis always a string — regardless of whether the user typed a number or anything else.So in the callback,
data.valuecan never be a number or undefined. It is always a string.What the type declaration said
In
TextArea.d.ts:And since
TextAreaPropsextendsStrictTextAreaProps, the callback'sdata.valuetype effectively becomes:Impact
TypeScript users have to do unnecessary type narrowing:
This is misleading and hurts developer experience.
How
Used an intersection type on the
dataparameter foronChangeandonInput:Why intersection (
&) and whyvalue?: number | stringwas not changedvalueis an input prop — users can pass a number or a string. Changing it would be a breaking change.data.valueis an output — it comes from inside the component. It should be typed accurately.TextAreaPropsproperties remain intact while onlyvalueis overridden.Verification
Type-check is clean:
Existing tests already expect a string:
So this change is consistent with them — no tests break.
Breaking changes
None. The
value?: number | stringprop is unchanged, and the callback signature is only more accurate.