How to set typescript type for matchPath return value
问题 I'm trying to use matchPath to extract a route param from the parent container as described in https://stackoverflow.com/a/45492498/3574819 const topicMatch = matchPath(history.location.pathname, { path: '/:topic' }); When I console.log(topicMatch.params) , the object has the topic key set but if I try to access topicMatch.params.topic I get the following error: error TS2339: Property 'topic' does not exist on type '{}'. const RouterApp = withRouter<{}>( class App extends React.Component