Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

splatonov92
Copy link

Describe the issue/change

Any component containing value props can not be passed as customInput property. Despite the fact that typing prohibits passing the customInput with value, number_format_base passes all props including value to customInput.

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

  • fix customInput type
  • remove @ts-ignore directive

Link Github issue if this PR solved an existing issue

Example usage (If applicable)

Screenshot (If applicable)

Please check which browsers were used for testing

  • Chrome
  • Chrome (Android)
  • Safari (OSX)
  • Safari (iOS)
  • Firefox
  • Firefox (Android)

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>>;
Copy link
Owner

@s-yadav s-yadav Feb 25, 2024

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.

Copy link
Author

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'
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants