Update type definitions for ICAL and fix type errors.

master
Tom Hacohen 7 years ago
parent bd077ac996
commit 2947607a45

@ -19,7 +19,7 @@ export class JournalViewAddressBook extends React.Component {
return (<div>Loading</div>); return (<div>Loading</div>);
} }
let items: Map<string, any> = new Map(); let items: Map<string, ICAL.Component> = new Map();
for (const syncEntry of this.props.entries) { for (const syncEntry of this.props.entries) {
let comp = new ICAL.Component(ICAL.parse(syncEntry.content)); let comp = new ICAL.Component(ICAL.parse(syncEntry.content));
@ -34,8 +34,7 @@ export class JournalViewAddressBook extends React.Component {
} }
} }
// FIXME: should be ICAL.component let entries = Array.from(items.values()).sort((_a, _b) => {
let entries: Array<any> = Array.from(items.values()).sort((_a: any, _b: any) => {
const a = _a.getFirstPropertyValue('fn'); const a = _a.getFirstPropertyValue('fn');
const b = _b.getFirstPropertyValue('fn'); const b = _b.getFirstPropertyValue('fn');

@ -19,11 +19,15 @@ export class JournalViewCalendar extends React.Component {
return (<div>Loading</div>); return (<div>Loading</div>);
} }
let items: Map<string, any> = new Map(); let items: Map<string, ICAL.Component> = new Map();
for (const syncEntry of this.props.entries) { for (const syncEntry of this.props.entries) {
let comp = new ICAL.Component(ICAL.parse(syncEntry.content)).getFirstSubcomponent('vevent'); let comp = new ICAL.Component(ICAL.parse(syncEntry.content)).getFirstSubcomponent('vevent');
if (comp === null) {
continue;
}
const uid = comp.getFirstPropertyValue('uid'); const uid = comp.getFirstPropertyValue('uid');
if ((syncEntry.action === EteSync.SyncEntryAction.Add) || if ((syncEntry.action === EteSync.SyncEntryAction.Add) ||
@ -34,10 +38,9 @@ export class JournalViewCalendar extends React.Component {
} }
} }
// FIXME: should be ICAL.component let entries = Array.from(items.values()).map((value) => (
let entries: Array<any> = Array.from(items.values()).map((value: string) => (
new ICAL.Event(value) new ICAL.Event(value)
)).sort((a: any, b: any) => { )).sort((a, b) => {
if (a.summary < b.summary) { if (a.summary < b.summary) {
return -1; return -1;
} else if (a.summary > b.summary) { } else if (a.summary > b.summary) {

21
src/ical.js.d.ts vendored

@ -1,5 +1,20 @@
declare var ICAL: any;
declare module 'ical.js' { declare module 'ical.js' {
export = ICAL; function parse(input: string): Array<any>;
class Component {
name: string;
constructor(jCal: Array<any> | string, parent?: Component);
getFirstSubcomponent(name?: string): Component | null;
getFirstPropertyValue(name?: string): string;
}
class Event {
uid: string;
summary: string;
constructor(component?: Component | null,
options?: {strictExceptions: boolean, exepctions: Array<Component|Event>});
}
} }

Loading…
Cancel
Save