Skip to content

Commit

Permalink
[TextField] fix typescript complications when 'component' prop is pas…
Browse files Browse the repository at this point in the history
…sed to FormHelpterTextProps
  • Loading branch information
AlexAndriyanenko committed Apr 13, 2020
1 parent 8e2f0cc commit 30c689a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/material-ui/src/TextField/TextField.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface BaseTextFieldProps
/**
* Props applied to the [`FormHelperText`](/api/form-helper-text/) element.
*/
FormHelperTextProps?: Partial<FormHelperTextProps>;
FormHelperTextProps?: FormHelperTextProps<React.ElementType>;
/**
* If `true`, the input will take up the full width of its container.
*/
Expand Down
20 changes: 19 additions & 1 deletion packages/material-ui/src/TextField/TextField.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import TextField from '@material-ui/core/TextField';
import TextField, { TextFieldProps } from '@material-ui/core/TextField';

{
// https://github.com/mui-org/material-ui/issues/12999
Expand Down Expand Up @@ -67,3 +67,21 @@ function FocusHandlerTest() {

return null;
}

function createElementTextFieldTest() {
const customElement = <div></div>;

// $ExpectError
React.createElement<TextFieldProps>(TextField, {
FormHelperTextProps: {
component: 'div',
},
});

// $ExpectError
React.createElement<TextFieldProps>(TextField, {
FormHelperTextProps: {
component: customElement,
},
});
}

0 comments on commit 30c689a

Please sign in to comment.