I'm trying to use React with TypeScript and Material-UI's components. Unfortunately, I'm getting the errors like this:
Property 'openToYearSelection' does not exist on type
'IntrinsicAttributes & IntrinsicClassAttributes &
Readonly<{ children?: ReactNode; }> …'.
import * as React from 'react';
import DatePicker from 'material-ui/DatePicker';
interface IState {
birthday: any,
}
export default class SampleForm extends React.Component<IProps, IState> {
constructor(props: any) {
super(props);
const { record = {} } = this.props;
this.state = {
birthday: record.birthday || null,
};
}
public birthdayPicker() {
const { birthday } = this.state;
return (
<DatePicker
defaultDate={birthday}
hintText="Birthday"
openToYearSelection={true}
/>
);
}
public render() {
return (
<form style={styles.root}>
{this.header()}
{this.firstName()}
{this.lastName()}
{this.birthdayPicker()}
{this.phoneNumber()}
{this.actionButtons()}
</form>
)
}
}
What's the right way to use Material-UI with TypeScript and React?
Best Answer
I've resolved this problem by adding missing properties to namespaces in
node_modules/@types/material-ui/index.d.ts
file. It worked for me. I don't think that it's a good solution and I'm wondering if there're some better approaches.