I am trying to use PropTypes with Typescript but getting errors:
Without typescript I was able to use:
class TodoFilterItem extends Component {
constructor (props) {
super(props);
and then at the bottom
TodoFilterItem.propTypes = {
name: PropTypes.string,
filter: PropTypes.string,
filterTodos: PropTypes.any
}
and that worked for just having PropTypes (i.e. no typescript).
However when I add Typescript and I have
class TodoFilterItem extends Component<ITodoFilterItem> {
constructor (props:ITodoFilterItem) {
super(props);
...
I have props as an interface like this:
interface ITodoFilterItem {
filter: string,
name: string,
filterTodos: any
}
and I use the same propTypes:
TodoFilterItem.propTypes = {
filter: PropTypes.string,
name: PropTypes.string,
filterTodos: PropTypes.any
}
I get an error
Property 'propTypes' does not exist on type 'typeof import("/my_adrs/node_modules/@types/prop-types/index")'.
How to address this and be able to use PropTypes with Typescript in React ?