-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Correct types for customInput property #827
base: master
Are you sure you want to change the base?
Conversation
src/types.ts
Outdated
@@ -52,7 +52,7 @@ export type InputAttributes = Omit< | |||
type NumberFormatProps<Props, BaseType = InputAttributes> = Props & | |||
Omit<InputAttributes, keyof BaseType> & | |||
Omit<BaseType, keyof Props | 'ref'> & { | |||
customInput?: React.ComponentType<BaseType>; | |||
customInput?: React.ComponentType<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will force the customInput to be type of Input element. While custom Input can be any component, and the NumberFormatProps inherits from there.
Please check on number_format.spec.tsx, it must be failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me try to fix it, may be I need to rewrite a couple of types
@@ -46,7 +46,7 @@ export type ChangeMeta = { | |||
|
|||
export type InputAttributes = Omit< | |||
React.InputHTMLAttributes<HTMLInputElement>, | |||
'defaultValue' | 'value' | 'children' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FMI: why do you need to omit 'defaultValue' | 'value'
from InputAttributes?
99d26af
to
634c28c
Compare
Describe the issue/change
Any component containing
value
props can not be passed ascustomInput
property. Despite the fact that typing prohibits passing thecustomInput
withvalue
,number_format_base
passes all props includingvalue
tocustomInput
.Add CodeSandbox link to illustrate the issue (If applicable)
Describe specs for failing cases if this is an issue (If applicable)
Describe the changes proposed/implemented in this PR
@ts-ignore
directiveLink Github issue if this PR solved an existing issue
Example usage (If applicable)
Screenshot (If applicable)
Please check which browsers were used for testing