In my React application, I have imported the @types/history
and am utilizing the createBrowserHistory()
function that it offers.
However, I encountered a tslint error:
ERROR in C:/Users/eshan/my-website/src/App.tsx
ERROR in C:/Users/eshan/my-website/src/App.tsx(13,11):
typedef: expected variable-declaration: 'history' to have a typedef
Despite searching for solutions, most of them involve bypassing the tslint rules using /* tslint:disable */
. I am interested in adding type support and resolving the issue instead.
import * as React from 'react';
import { Router, Route, Switch } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import './App.css';
class App extends React.Component {
public render(): JSX.Element {
const history = createBrowserHistory();
return (
<div className='App'>
<Router history={history}>
<Switch>
<Route exact path='/' component={Landing}/>
<Route exact path='/Home' component={Home}/>
</Switch>
</Router>
</div>
);
}
}
export default App;