I am trying to include a property declaration in the window.history object, but I received a TypeScript error message
This is my code:
const historyInstance = createHashHistory(); // npm hoistory module
window.history.historyInstance = historyInstance;
// ↑ the error occurred here
Here is my types.ts
file:
interface IHistory extends History {
historyInstance: any;
}
interface Window {
history: IHistory;
// ↑ (property) Window.history: History
// All declarations of 'history' must have identical modifiers.ts(2687)
// Subsequent property declarations must have the same type. Property // 'history' must be of type 'History', but here has type 'IHistory'.ts(2717)
}