import * as React from 'react';
import TextField from '@mui/material/TextField';
import { expectType } from '@mui/types';
{
// https://github.com/mui/material-ui/issues/12999
const defaulted = (
);
const standard = (
);
const standardOutlinedClassname = (
);
const filled = (
{
// type inference for event still works?
const value = event.target.value;
expectType(value);
}}
/>
);
const outlined = (
);
}
// https://github.com/mui/material-ui/issues/17369#issuecomment-529622304
function FocusHandlerTest() {
const inputHandler = React.useCallback((event: React.FocusEvent) => {}, []);
// Probably a decent tradeoff. React.EventHandler being bivariant does allow unsound
// types in this case. I should probably be consistent with the strictness stance
// but there are increasing issue reports demanding these unsound types to "write cleaner code"
// so lets see how these are received
const input = ;
// this or a generic `HTMLElement` is probably closer to what we actually use.
const valueHandler = React.useCallback((event: React.FocusEvent<{ value: string }>) => {}, []);
const textfield = ;
// sound narrowing with runtime overhead
const genericHandler = React.useCallback((event: React.FocusEvent) => {
if (event.currentTarget instanceof HTMLInputElement) {
console.assert(event.currentTarget.value === 'foo');
}
}, []);
const element = ;
const fieldHandler = React.useCallback(
(event: React.FocusEvent) => {},
[],
);
const field = ;
return null;
}