diff --git a/packages/ra-ui-materialui/src/input/SelectInput.spec.js b/packages/ra-ui-materialui/src/input/SelectInput.spec.tsx
similarity index 98%
rename from packages/ra-ui-materialui/src/input/SelectInput.spec.js
rename to packages/ra-ui-materialui/src/input/SelectInput.spec.tsx
index c5592c6a3c3..287247196fd 100644
--- a/packages/ra-ui-materialui/src/input/SelectInput.spec.js
+++ b/packages/ra-ui-materialui/src/input/SelectInput.spec.tsx
@@ -1,5 +1,4 @@
import React from 'react';
-import assert from 'assert';
import { render, cleanup, fireEvent } from '@testing-library/react';
import { Form } from 'react-final-form';
import { TranslationContext } from 'ra-core';
@@ -24,7 +23,9 @@ describe('', () => {
render={() => }
/>
);
- const input = getByLabelText('resources.posts.fields.language');
+ const input = getByLabelText(
+ 'resources.posts.fields.language'
+ ) as HTMLInputElement;
expect(input.value).toEqual('ang');
});
@@ -290,7 +291,7 @@ describe('', () => {
});
it('should use optionText with an element value as text identifier', () => {
- const Foobar = ({ record }) => (
+ const Foobar = ({ record }: { record?: any }) => (
);
diff --git a/packages/ra-ui-materialui/src/input/SelectInput.js b/packages/ra-ui-materialui/src/input/SelectInput.tsx
similarity index 94%
rename from packages/ra-ui-materialui/src/input/SelectInput.js
rename to packages/ra-ui-materialui/src/input/SelectInput.tsx
index ea322be0638..051ead7809e 100644
--- a/packages/ra-ui-materialui/src/input/SelectInput.js
+++ b/packages/ra-ui-materialui/src/input/SelectInput.tsx
@@ -1,12 +1,13 @@
-import React, { useCallback } from 'react';
+import React, { useCallback, FunctionComponent } from 'react';
import PropTypes from 'prop-types';
import get from 'lodash/get';
import MenuItem from '@material-ui/core/MenuItem';
import { makeStyles } from '@material-ui/core/styles';
-import { useInput, FieldTitle, useTranslate } from 'ra-core';
+import { useInput, FieldTitle, useTranslate, InputProps } from 'ra-core';
import ResettableTextField from './ResettableTextField';
import InputHelperText from './InputHelperText';
+import { TextFieldProps } from '@material-ui/core/TextField';
const sanitizeRestProps = ({
addLabel,
@@ -47,7 +48,7 @@ const sanitizeRestProps = ({
translateChoice,
validation,
...rest
-}) => rest;
+}: any) => rest;
const useStyles = makeStyles(theme => ({
input: {
@@ -129,7 +130,9 @@ const useStyles = makeStyles(theme => ({
*
*
*/
-const SelectInput = ({
+const SelectInput: FunctionComponent<
+ InputProps & Omit
+> = ({
allowEmpty,
choices,
className,
@@ -176,8 +179,8 @@ const SelectInput = ({
const renderMenuItemOption = useCallback(
choice => {
- if (React.isValidElement(optionText)) {
- return React.cloneElement(optionText, {
+ if (React.isValidElement<{ record: any }>(optionText)) {
+ return React.cloneElement<{ record: any }>(optionText, {
record: choice,
});
}