I am starting to learn typescript, and this is a behavior that I do not understand.
I got this error:
Type 'ComponentClass<{}>' is not assignable to type 'StatelessComponent<void | RouteComponentProps<any>> | ComponentClass<void | RouteComponentProps<a...'. Type 'ComponentClass<{}>' is not assignable to type 'ComponentClass<void | RouteComponentProps<any>>'. Type '{}' is not assignable to type 'void | RouteComponentProps<any>'. Type '{}' is not assignable to type 'RouteComponentProps<any>'.

Here is my application component:
interface AppProps extends React.Props<void> { todos: TodoItemData[]; actions: typeof TodoActions; }; interface AppState { } class App extends React.Component<AppProps, AppState>{ render() {return (<div></div>); } } function mapStateToProps(state: RootState) { return { todos: state.todos }; } function mapDispatchToProps(dispatch) { return { actions: bindActionCreators(TodoActions as any, dispatch) }; } export default connect( mapStateToProps, mapDispatchToProps )(App);
If I changed the app’s App Approprop ad to void or React.Props, I didn’t have any errors, but I always have the AppProps app.
I do not understand why it does not work, AppProps is distributed from React.Props. Have you seen the mistake?
source share