diff --git a/src/Pim/index.tsx b/src/Pim/index.tsx index e8fa807..f68dc3c 100644 --- a/src/Pim/index.tsx +++ b/src/Pim/index.tsx @@ -13,7 +13,7 @@ import { pure } from 'recompose'; import { History } from 'history'; -import { ContactType, EventType } from '../pim-types'; +import { PimType, ContactType, EventType } from '../pim-types'; import Container from '../widgets/Container'; @@ -72,7 +72,7 @@ const ItemChangeLog = pure((props: any) => { uid, } = props; - const journalItem = syncInfo.get((items[uid] as any).journalUid); + const journalItem = syncInfo.get(items[uid].journalUid); return ( @@ -94,9 +94,9 @@ const CollectionRoutes = withRouter( collections: Array, componentEdit: any, componentView: any, - items: {[key: string]: any}, - onItemSave: (item: Object, journalUid: string, originalContact?: Object) => void; - onItemDelete: (item: Object, journalUid: string) => void; + items: {[key: string]: PimType}, + onItemSave: (item: PimType, journalUid: string, originalContact?: PimType) => void; + onItemDelete: (item: PimType, journalUid: string) => void; onItemCancel: () => void; }; @@ -204,7 +204,7 @@ class Pim extends React.PureComponent { this.onItemSave = this.onItemSave.bind(this); } - onItemSave(item: any, journalUid: string, originalEvent?: any) { + onItemSave(item: PimType, journalUid: string, originalEvent?: PimType) { const syncJournal = this.props.syncInfo.get(journalUid); if (syncJournal === undefined) { @@ -221,7 +221,7 @@ class Pim extends React.PureComponent { }); } - onItemDelete(item: any, journalUid: string) { + onItemDelete(item: PimType, journalUid: string) { const syncJournal = this.props.syncInfo.get(journalUid); if (syncJournal === undefined) { diff --git a/src/pim-types.ts b/src/pim-types.ts index 44b116a..e84a0cf 100644 --- a/src/pim-types.ts +++ b/src/pim-types.ts @@ -1,6 +1,12 @@ import * as ICAL from 'ical.js'; -export class EventType extends ICAL.Event { +export interface PimType { + uid: string; + toIcal(): string; + clone(): PimType; +} + +export class EventType extends ICAL.Event implements PimType { color: string; static fromVCalendar(comp: ICAL.Component) { @@ -33,7 +39,7 @@ export class EventType extends ICAL.Event { } } -export class ContactType { +export class ContactType implements PimType { comp: ICAL.Component; constructor(comp: ICAL.Component) {