problem description
when I use static propTypes and typeScript and connect, typeScript"s type check reports an error.
tells me that the type is missing
the environmental background of the problems and what methods you have tried
I am new to ts. No useful solutions were found
related codes
import React, {PureComponent} from "react";
import { withRouter } from "react-router";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { RootState } from "../../../reducers";
type IProps = {
title: string;
} & ReturnType<typeof mapStateToProps>
class Test extends PureComponent<IProps> {
static propTypes = {
title: PropTypes.string
}
render() {
const { title } = this.props;
return (
<div>hello world! {title}</div>
)
}
}
const mapStateToProps = (state: RootState) => {
return {
state
}
}
export default
connect(mapStateToProps)(Test)
`
what result do you expect? What is the error message actually seen?
"Argument of type" typeof Test" is not assignable to parameter of type "ComponentType < never >".
Type "typeof Test" is not assignable to type" ComponentClass < never, any >".
Types of property "propTypes" are incompatible.
Type "{ title: Requireable<string>; }" is not assignable to type "undefined".