Skip to content

fix: Correct types for customInput property - #827

Open
splatonov92 wants to merge 3 commits into
s-yadav:masterfrom
splatonov92:fix-customInput-type
Open

fix: Correct types for customInput property#827
splatonov92 wants to merge 3 commits into
s-yadav:masterfrom
splatonov92:fix-customInput-type

Conversation

@splatonov92

Copy link
Copy Markdown

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)

Comment thread src/types.ts Outdated
Omit<InputAttributes, keyof BaseType> &
Omit<BaseType, keyof Props | 'ref'> & {
customInput?: React.ComponentType<BaseType>;
customInput?: React.ComponentType<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;

@s-yadav s-yadav Feb 25, 2024

Copy link
Copy Markdown
Owner

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
Copy Markdown
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

Comment thread src/types.ts

export type InputAttributes = Omit<
React.InputHTMLAttributes<HTMLInputElement>,
'defaultValue' | 'value' | 'children'

Copy link
Copy Markdown
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?

@splatonov92
splatonov92 force-pushed the fix-customInput-type branch from 99d26af to 634c28c Compare August 18, 2024 14:30
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