diff --git a/packages/ra-ui-materialui/src/input/NumberInput.spec.js b/packages/ra-ui-materialui/src/input/NumberInput.spec.tsx
similarity index 98%
rename from packages/ra-ui-materialui/src/input/NumberInput.spec.js
rename to packages/ra-ui-materialui/src/input/NumberInput.spec.tsx
index af8ef048abe..c5166a8ec72 100644
--- a/packages/ra-ui-materialui/src/input/NumberInput.spec.js
+++ b/packages/ra-ui-materialui/src/input/NumberInput.spec.tsx
@@ -1,10 +1,10 @@
import React from 'react';
import { render, cleanup, fireEvent } from '@testing-library/react';
-
-import NumberInput from './NumberInput';
import { Form } from 'react-final-form';
import { required } from 'ra-core/lib';
+import NumberInput from './NumberInput';
+
describe('', () => {
afterEach(cleanup);
@@ -21,7 +21,9 @@ describe('', () => {
render={() => }
/>
);
- const input = getByLabelText('resources.posts.fields.views');
+ const input = getByLabelText(
+ 'resources.posts.fields.views'
+ ) as HTMLInputElement;
expect(input.value).toEqual('12');
expect(input.getAttribute('type')).toEqual('number');
});
diff --git a/packages/ra-ui-materialui/src/input/NumberInput.js b/packages/ra-ui-materialui/src/input/NumberInput.tsx
similarity index 84%
rename from packages/ra-ui-materialui/src/input/NumberInput.js
rename to packages/ra-ui-materialui/src/input/NumberInput.tsx
index 82a95731c53..cd9542f2940 100644
--- a/packages/ra-ui-materialui/src/input/NumberInput.js
+++ b/packages/ra-ui-materialui/src/input/NumberInput.tsx
@@ -1,7 +1,7 @@
-import React from 'react';
+import React, { FunctionComponent } from 'react';
import PropTypes from 'prop-types';
-import TextField from '@material-ui/core/TextField';
-import { useInput, FieldTitle } from 'ra-core';
+import TextField, { TextFieldProps } from '@material-ui/core/TextField';
+import { useInput, FieldTitle, InputProps } from 'ra-core';
import InputHelperText from './InputHelperText';
import sanitizeRestProps from './sanitizeRestProps';
@@ -12,6 +12,10 @@ const parse = value => {
return isNaN(float) ? null : float;
};
+interface Props {
+ step: string | number;
+}
+
/**
* An Input component for a number
*
@@ -24,7 +28,11 @@ const parse = value => {
*
* The object passed as `options` props is passed to the material-ui component
*/
-const NumberInput = ({
+const NumberInput: FunctionComponent<
+ Props &
+ InputProps &
+ Omit
+> = ({
helperText,
label,
options,
@@ -87,7 +95,7 @@ NumberInput.propTypes = {
options: PropTypes.object,
resource: PropTypes.string,
source: PropTypes.string,
- step: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
+ step: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};
NumberInput.defaultProps = {