From ec8a1d901724f06a4b9c1f43871179c29bc6ba14 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 16 Dec 2017 23:12:24 +0000 Subject: [PATCH] Fix react-router related types. --- src/Journal/JournalAddressBook.tsx | 6 ++++-- src/Journal/JournalCalendar.tsx | 6 ++++-- src/Journal/index.tsx | 4 +++- src/Pim/PimMain.tsx | 14 ++++++++------ src/Pim/index.tsx | 4 +++- src/SideMenu/index.tsx | 4 +++- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Journal/JournalAddressBook.tsx b/src/Journal/JournalAddressBook.tsx index 2dee19f..7a24da6 100644 --- a/src/Journal/JournalAddressBook.tsx +++ b/src/Journal/JournalAddressBook.tsx @@ -5,6 +5,8 @@ import * as EteSync from '../api/EteSync'; import { routeResolver } from '../App'; +import { History } from 'history'; + import AddressBook from '../components/AddressBook'; import Contact from '../components/Contact'; @@ -18,7 +20,7 @@ class JournalAddressBook extends React.PureComponent { props: { journal: EteSync.Journal, entries: {[key: string]: ContactType}, - history?: any, + history?: History, }; constructor(props: any) { @@ -29,7 +31,7 @@ class JournalAddressBook extends React.PureComponent { contactClicked(contact: ContactType) { const uid = contact.uid; - this.props.history.push( + this.props.history!.push( routeResolver.getRoute('journals._id.items._id', { journalUid: this.props.journal.uid, itemUid: uid })); } diff --git a/src/Journal/JournalCalendar.tsx b/src/Journal/JournalCalendar.tsx index 38d9999..eed33d9 100644 --- a/src/Journal/JournalCalendar.tsx +++ b/src/Journal/JournalCalendar.tsx @@ -1,6 +1,8 @@ import * as React from 'react'; import { Route, Switch, withRouter } from 'react-router'; +import { History } from 'history'; + import { routeResolver } from '../App'; import { historyPersistor } from '../persist-state-history'; @@ -22,7 +24,7 @@ class JournalCalendar extends React.PureComponent { props: { journal: EteSync.Journal, entries: {[key: string]: EventType}, - history?: any, + history?: History, }; constructor(props: any) { @@ -33,7 +35,7 @@ class JournalCalendar extends React.PureComponent { eventClicked(event: EventType) { const uid = event.uid; - this.props.history.push( + this.props.history!.push( routeResolver.getRoute('journals._id.items._id', { journalUid: this.props.journal.uid, itemUid: uid })); } diff --git a/src/Journal/index.tsx b/src/Journal/index.tsx index e44a409..c5c7412 100644 --- a/src/Journal/index.tsx +++ b/src/Journal/index.tsx @@ -13,9 +13,11 @@ import { syncEntriesToItemMap, syncEntriesToCalendarItemMap } from '../journal-p import { SyncInfo } from '../SyncGate'; +import { match } from 'react-router'; + interface PropsType { syncInfo: SyncInfo; - match: any; + match: match; } interface PropsTypeInner extends PropsType { diff --git a/src/Pim/PimMain.tsx b/src/Pim/PimMain.tsx index dc9222c..bd7ceca 100644 --- a/src/Pim/PimMain.tsx +++ b/src/Pim/PimMain.tsx @@ -5,6 +5,8 @@ import { Tabs, Tab } from 'material-ui/Tabs'; import * as ICAL from 'ical.js'; +import { Location, History } from 'history'; + import Container from '../widgets/Container'; import AddressBook from '../components/AddressBook'; @@ -25,8 +27,8 @@ class PimMain extends React.PureComponent { props: { contacts: Array, events: Array, - location?: any, - history?: any, + location?: Location, + history?: History, }; state: { @@ -44,24 +46,24 @@ class PimMain extends React.PureComponent { eventClicked(event: ICAL.Event) { const uid = event.uid; - this.props.history.push( + this.props.history!.push( routeResolver.getRoute('pim.events._id', { eventUid: uid })); } contactClicked(contact: ContactType) { const uid = contact.uid; - this.props.history.push( + this.props.history!.push( routeResolver.getRoute('pim.contacts._id', { contactUid: uid })); } floatingButtonClicked() { if (this.state.tab === addressBookTitle) { - this.props.history.push( + this.props.history!.push( routeResolver.getRoute('pim.contacts.new') ); } else if (this.state.tab === calendarTitle) { - this.props.history.push( + this.props.history!.push( routeResolver.getRoute('pim.events.new') ); } diff --git a/src/Pim/index.tsx b/src/Pim/index.tsx index 428067f..fb2f98c 100644 --- a/src/Pim/index.tsx +++ b/src/Pim/index.tsx @@ -7,6 +7,8 @@ import * as EteSync from '../api/EteSync'; import { createSelector } from 'reselect'; +import { History } from 'history'; + import { ContactType, EventType } from '../pim-types'; import Container from '../widgets/Container'; @@ -67,7 +69,7 @@ class Pim extends React.PureComponent { props: { etesync: CredentialsData; syncInfo: SyncInfo; - history: any; + history: History; }; constructor(props: any) { diff --git a/src/SideMenu/index.tsx b/src/SideMenu/index.tsx index 442aef2..d1bc550 100644 --- a/src/SideMenu/index.tsx +++ b/src/SideMenu/index.tsx @@ -10,6 +10,8 @@ import LogoutIcon from 'material-ui/svg-icons/action/power-settings-new'; const logo = require('../images/logo.svg'); +import { History } from 'history'; + import SideMenuJournals from './SideMenuJournals'; import { routeResolver, getPalette } from '../App'; @@ -26,7 +28,7 @@ interface PropsType { interface PropsTypeInner extends PropsType { journals: JournalsType; - history: any; + history: History; } class SideMenu extends React.PureComponent {