I did a Google search and found two other people with the same problem, but no solution so far:
https://stackoverflow.com/questions/44118060/react-router-dom-with-typescript
microsoft/vscode#27235
Minimal code example:
const MyRouterComponent = withRouter(
class MyComponent extends React.Component<RouteComponentProps<any>, any> {
render() {
return <div />;
}
}
)
class MainComponent extends React.Component<any, any> {
render() {
/* This line produces following compile error:
error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<RouteComponentProps<any>, ComponentState...'.
Type '{}' is not assignable to type 'Readonly<RouteComponentProps<any>>'.
Property 'match' is missing in type '{}'.
*/
return <MyRouterComponent />
}
}
I understand what the problem is: MyRouterComponent expects props which I didn't explicitly pass, because withRouter will take care of that. So how does one use withRouter with TS correctly?
@types/xxxxpackage and had problems.Definitions by:inindex.d.ts) so they can respond.I did a Google search and found two other people with the same problem, but no solution so far:
https://stackoverflow.com/questions/44118060/react-router-dom-with-typescript
microsoft/vscode#27235
Minimal code example:
I understand what the problem is:
MyRouterComponentexpects props which I didn't explicitly pass, becausewithRouterwill take care of that. So how does one usewithRouterwith TS correctly?