Closed jakeboone02 closed 1 year ago
https://github.com/s-yadav/react-number-format/issues/799#issuecomment-1742145157
So the type here 'text' | 'tel' | 'password' is intentional. type: 'number' will not work as rnf applies non-numeric formatting in the input itself. And other types also do not make much sense for it as they come with custom HTML input behaviour. Maybe type 'search' can fit here. But this hasn't been asked till now.
try this, this won't work <NumericFormat type="number" thousandSeparator value={123} />
Understood. Thanks for reviewing.
Fixes #799. Issue text replicated below:
Describe the issue and the actual behavior
There is a disconnect between the documentation for the
type
prop, which states that it accepts anystring
, and the actual TypeScript types, which narrow the accepted values to "text", "tel", or "password":https://github.com/s-yadav/react-number-format/blob/e2179f9e9d2c4ddd1ab714ff385412b53e9ed3e7/src/types.ts#L68-L69
Describe the expected behavior
Since
string
is the correct type for thetype
property of HTML5<input>
elements, and browsers fall back to the default behavior oftype="text"
when the type is outside the list of supported values, I believe thetype
prop should be typed astype?: string
.In my testing, all
string
s work as expected during runtime.Provide a CodeSandbox link illustrating the issue
https://codesandbox.io/s/type-demo-forked-p4lh8w?file=/src/App.js
Provide steps to reproduce this issue
type="number"
in a TypeScript project.Please check the browsers where the issue is seen
Not specific to a browser; issue is with TypeScript types.