Skip to content

Commit

Permalink
[RFR] Migrate TextInput to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed Aug 13, 2019
1 parent 8edeb54 commit ecce93b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ describe('<LongTextInput />', () => {
render={() => <LongTextInput {...defaultProps} />}
/>
);
const input = getByLabelText('resources.posts.fields.body');
const input = getByLabelText(
'resources.posts.fields.body'
) as HTMLInputElement;
expect(input.tagName).toEqual('TEXTAREA');
expect(input.value).toEqual('hello');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ describe('<TextInput />', () => {
render={() => <TextInput {...defaultProps} />}
/>
);
const TextFieldElement = getByLabelText('resources.posts.fields.title');
const TextFieldElement = getByLabelText(
'resources.posts.fields.title'
) as HTMLInputElement;
expect(TextFieldElement.value).toEqual('hello');
expect(TextFieldElement.getAttribute('type')).toEqual('text');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import React, { FunctionComponent } from 'react';
import PropTypes from 'prop-types';
import { useInput, FieldTitle } from 'ra-core';
import { useInput, FieldTitle, InputProps } from 'ra-core';
import { TextFieldProps } from '@material-ui/core/TextField';

import ResettableTextField from './ResettableTextField';
import InputHelperText from './InputHelperText';
Expand All @@ -20,7 +21,9 @@ import sanitizeRestProps from './sanitizeRestProps';
*
* The object passed as `options` props is passed to the <ResettableTextField> component
*/
export const TextInput = ({
export const TextInput: FunctionComponent<
InputProps<TextFieldProps> & Omit<TextFieldProps, 'label' | 'helperText'>
> = ({
label,
options,
resource,
Expand Down

0 comments on commit ecce93b

Please sign in to comment.