Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextField] Fix TypeScript FormHelperText.component prop #20529

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 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,10 @@ export interface BaseTextFieldProps
/**
* Props applied to the [`FormHelperText`](/api/form-helper-text/) element.
*/
FormHelperTextProps?: Partial<FormHelperTextProps>;
FormHelperTextProps?: FormHelperTextProps<
React.ElementType,
{ component: React.ElementType | JSX.Element }
oliviertassinari marked this conversation as resolved.
Show resolved Hide resolved
>;
/**
* If `true`, the input will take up the full width of its container.
*/
Expand Down
10 changes: 9 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,11 @@ function FocusHandlerTest() {

return null;
}

function createElementTextFieldTest() {
// $ExpectError
const stringParam = <TextField FormHelperTextProps={{ component: 'some-wrong-element' }} />;

// $ExpectError
const numberParam = <TextField FormHelperTextProps={{ component: 1234 }} />;
}