Skip to content

Commit

Permalink
chore: Updates due to typescript update
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbo2002 committed Jul 30, 2024
1 parent f775a72 commit b165309
Show file tree
Hide file tree
Showing 8 changed files with 1,178 additions and 1,414 deletions.
2,431 changes: 1,100 additions & 1,331 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
},
"description": "ical-generator is a small piece of code which generates ical calendar files",
"devDependencies": {
"@eslint/js": "^9.6.0",
"@eslint/js": "^9.8.0",
"@qiwi/semantic-release-gh-pages-plugin": "^5.2.12",
"@sebbo2002/semantic-release-jsr": "^1.0.0-develop.6",
"@sebbo2002/semantic-release-jsr": "^1.0.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
Expand All @@ -20,11 +20,11 @@
"@types/express": "^4.17.21",
"@types/luxon": "^3.4.2",
"@types/mocha": "^10.0.7",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@types/node": "^20.14.10",
"@types/node": "^22.0.0",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"c8": "^10.1.2",
"dayjs": "^1.11.10",
"eslint": "^9.6.0",
"dayjs": "^1.11.12",
"eslint": "^9.8.0",
"eslint-plugin-jsonc": "^2.16.0",
"esm": "^3.2.25",
"license-checker": "^25.0.1",
Expand All @@ -33,15 +33,15 @@
"mochawesome": "^7.1.3",
"moment": "^2.30.1",
"moment-timezone": "^0.5.45",
"nyc": "^15.1.0",
"nyc": "^17.0.0",
"rrule": "^2.8.1",
"semantic-release": "^23.0.5",
"semantic-release": "^24.0.0",
"semantic-release-license": "^1.0.2",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.2",
"tsup": "^8.1.0",
"tsup": "^8.2.3",
"typedoc": "^0.26.3",
"typescript": "^5.5.3",
"typescript": "^5.5.4",
"typescript-eslint": "^8.0.0-alpha.41"
},
"engines": {
Expand Down
20 changes: 10 additions & 10 deletions src/alarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ export default class ICalAlarm {
throw new Error('`event` option required!');
}

data.type !== undefined && this.type(data.type);
'trigger' in data && data.trigger !== undefined && this.trigger(data.trigger);
'triggerBefore' in data && data.triggerBefore !== undefined && this.triggerBefore(data.triggerBefore);
'triggerAfter' in data && data.triggerAfter !== undefined && this.triggerAfter(data.triggerAfter);
data.repeat && this.repeat(data.repeat);
data.attach !== undefined && this.attach(data.attach);
data.description !== undefined && this.description(data.description);
data.summary !== undefined && this.summary(data.summary);
data.attendees !== undefined && this.attendees(data.attendees);
data.x !== undefined && this.x(data.x);
if (data.type !== undefined) this.type(data.type);
if ('trigger' in data && data.trigger !== undefined) this.trigger(data.trigger);
if ('triggerBefore' in data && data.triggerBefore !== undefined) this.triggerBefore(data.triggerBefore);
if ('triggerAfter' in data && data.triggerAfter !== undefined) this.triggerAfter(data.triggerAfter);
if (data.repeat) this.repeat(data.repeat);
if (data.attach !== undefined) this.attach(data.attach);
if (data.description !== undefined) this.description(data.description);
if (data.summary !== undefined) this.summary(data.summary);
if (data.attendees !== undefined) this.attendees(data.attendees);
if (data.x !== undefined) this.x(data.x);
}


Expand Down
26 changes: 13 additions & 13 deletions src/attendee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ export default class ICalAttendee {
throw new Error('No value for `email` in ICalAttendee given!');
}

data.name !== undefined && this.name(data.name);
data.email !== undefined && this.email(data.email);
data.mailto !== undefined && this.mailto(data.mailto);
data.sentBy !== undefined && this.sentBy(data.sentBy);
data.status !== undefined && this.status(data.status);
data.role !== undefined && this.role(data.role);
data.rsvp !== undefined && this.rsvp(data.rsvp);
data.type !== undefined && this.type(data.type);
data.delegatedTo !== undefined && this.delegatedTo(data.delegatedTo);
data.delegatedFrom !== undefined && this.delegatedFrom(data.delegatedFrom);
data.delegatesTo && this.delegatesTo(data.delegatesTo);
data.delegatesFrom && this.delegatesFrom(data.delegatesFrom);
data.x !== undefined && this.x(data.x);
if (data.name !== undefined) this.name(data.name);
if (data.email !== undefined) this.email(data.email);
if (data.mailto !== undefined) this.mailto(data.mailto);
if (data.sentBy !== undefined) this.sentBy(data.sentBy);
if (data.status !== undefined) this.status(data.status);
if (data.role !== undefined) this.role(data.role);
if (data.rsvp !== undefined) this.rsvp(data.rsvp);
if (data.type !== undefined) this.type(data.type);
if (data.delegatedTo !== undefined) this.delegatedTo(data.delegatedTo);
if (data.delegatedFrom !== undefined) this.delegatedFrom(data.delegatedFrom);
if (data.delegatesTo) this.delegatesTo(data.delegatesTo);
if (data.delegatesFrom) this.delegatesFrom(data.delegatesFrom);
if (data.x !== undefined) this.x(data.x);
}


Expand Down
22 changes: 11 additions & 11 deletions src/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ export default class ICalCalendar {
x: []
};

data.prodId !== undefined && this.prodId(data.prodId);
data.method !== undefined && this.method(data.method);
data.name !== undefined && this.name(data.name);
data.description !== undefined && this.description(data.description);
data.timezone !== undefined && this.timezone(data.timezone);
data.source !== undefined && this.source(data.source);
data.url !== undefined && this.url(data.url);
data.scale !== undefined && this.scale(data.scale);
data.ttl !== undefined && this.ttl(data.ttl);
data.events !== undefined && this.events(data.events);
data.x !== undefined && this.x(data.x);
if (data.prodId !== undefined) this.prodId(data.prodId);
if (data.method !== undefined) this.method(data.method);
if (data.name !== undefined) this.name(data.name);
if (data.description !== undefined) this.description(data.description);
if (data.timezone !== undefined) this.timezone(data.timezone);
if (data.source !== undefined) this.source(data.source);
if (data.url !== undefined) this.url(data.url);
if (data.scale !== undefined) this.scale(data.scale);
if (data.ttl !== undefined) this.ttl(data.ttl);
if (data.events !== undefined) this.events(data.events);
if (data.x !== undefined) this.x(data.x);
}


Expand Down
54 changes: 27 additions & 27 deletions src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,33 +212,33 @@ export default class ICalEvent {
throw new Error('`calendar` option required!');
}

data.id && this.id(data.id);
data.sequence !== undefined && this.sequence(data.sequence);
data.start && this.start(data.start);
data.end !== undefined && this.end(data.end);
data.recurrenceId !== undefined && this.recurrenceId(data.recurrenceId);
data.timezone !== undefined && this.timezone(data.timezone);
data.stamp !== undefined && this.stamp(data.stamp);
data.allDay !== undefined && this.allDay(data.allDay);
data.floating !== undefined && this.floating(data.floating);
data.repeating !== undefined && this.repeating(data.repeating);
data.summary !== undefined && this.summary(data.summary);
data.location !== undefined && this.location(data.location);
data.description !== undefined && this.description(data.description);
data.organizer !== undefined && this.organizer(data.organizer);
data.attendees !== undefined && this.attendees(data.attendees);
data.alarms !== undefined && this.alarms(data.alarms);
data.categories !== undefined && this.categories(data.categories);
data.status !== undefined && this.status(data.status);
data.busystatus !== undefined && this.busystatus(data.busystatus);
data.priority !== undefined && this.priority(data.priority);
data.url !== undefined && this.url(data.url);
data.attachments !== undefined && this.attachments(data.attachments);
data.transparency !== undefined && this.transparency(data.transparency);
data.created !== undefined && this.created(data.created);
data.lastModified !== undefined && this.lastModified(data.lastModified);
data.class !== undefined && this.class(data.class);
data.x !== undefined && this.x(data.x);
if (data.id) this.id(data.id);
if (data.sequence !== undefined) this.sequence(data.sequence);
if (data.start) this.start(data.start);
if (data.end !== undefined) this.end(data.end);
if (data.recurrenceId !== undefined) this.recurrenceId(data.recurrenceId);
if (data.timezone !== undefined) this.timezone(data.timezone);
if (data.stamp !== undefined) this.stamp(data.stamp);
if (data.allDay !== undefined) this.allDay(data.allDay);
if (data.floating !== undefined) this.floating(data.floating);
if (data.repeating !== undefined) this.repeating(data.repeating);
if (data.summary !== undefined) this.summary(data.summary);
if (data.location !== undefined) this.location(data.location);
if (data.description !== undefined) this.description(data.description);
if (data.organizer !== undefined) this.organizer(data.organizer);
if (data.attendees !== undefined) this.attendees(data.attendees);
if (data.alarms !== undefined) this.alarms(data.alarms);
if (data.categories !== undefined) this.categories(data.categories);
if (data.status !== undefined) this.status(data.status);
if (data.busystatus !== undefined) this.busystatus(data.busystatus);
if (data.priority !== undefined) this.priority(data.priority);
if (data.url !== undefined) this.url(data.url);
if (data.attachments !== undefined) this.attachments(data.attachments);
if (data.transparency !== undefined) this.transparency(data.transparency);
if (data.created !== undefined) this.created(data.created);
if (data.lastModified !== undefined) this.lastModified(data.lastModified);
if (data.class !== undefined) this.class(data.class);
if (data.x !== undefined) this.x(data.x);
}

/**
Expand Down
15 changes: 3 additions & 12 deletions src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,13 @@ export function formatDate (timezone: string | null, d: ICalDateTimeValue, dateo

let m = d;
if(timezone) {
// @see https://day.js.org/docs/en/plugin/timezone
// @ts-ignore
m = typeof d.tz === 'function' ? d.tz(timezone) : d;
}
else if(floating) {
// m = d;
}

// @ts-ignore
else if (typeof d.utc === 'function') {
// @ts-ignore
m = d.utc();
}
else {
Expand Down Expand Up @@ -314,7 +310,6 @@ export function toDate(value: ICalDateTimeValue): Date {
return new Date(value);
}

// @ts-ignore
if(isLuxonDate(value)) {
return value.toJSDate();
}
Expand All @@ -324,7 +319,7 @@ export function toDate(value: ICalDateTimeValue): Date {

export function isMoment(value: ICalDateTimeValue): value is ICalMomentStub {

// @ts-ignore
// @ts-expect-error _isAMomentObject is a private property
return value != null && value._isAMomentObject != null;
}
export function isMomentTZ(value: ICalDateTimeValue): value is ICalMomentTimezoneStub {
Expand All @@ -342,15 +337,11 @@ export function isLuxonDate(value: ICalDateTimeValue): value is ICalLuxonDateTim
}

export function isMomentDuration(value: unknown): value is ICalMomentDurationStub {

// @ts-ignore
return value !== null && typeof value === 'object' && typeof value.asSeconds === 'function';
return value !== null && typeof value === 'object' && 'asSeconds' in value && typeof value.asSeconds === 'function';
}

export function isRRule(value: unknown): value is ICalRRuleStub {

// @ts-ignore
return value !== null && typeof value === 'object' && typeof value.between === 'function' && typeof value.toString === 'function';
return value !== null && typeof value === 'object' && 'between' in value && typeof value.between === 'function' && typeof value.toString === 'function';
}

export function toJSON(value: ICalDateTimeValue | null | undefined): string | null | undefined {
Expand Down
4 changes: 4 additions & 0 deletions test/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2065,8 +2065,12 @@ describe('ical-generator Event', function () {
}, cal);

const actual = event.toString();
// eslint-disable-next-line no-control-regex
assert.match(actual, new RegExp('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\r\n'), 'with Microsoft CDO alldayevent set');

// eslint-disable-next-line no-control-regex
assert.match(actual, new RegExp('X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE\r\n'), 'with Microsoft MSNCalendar alldayevent flag set');

assert.match(actual, new RegExp(`DTSTART;VALUE=DATE:${luxonStartDate.toFormat('yyyyLLdd')}\r\n`), 'for DTSTART');
assert.match(actual, new RegExp(`DTEND;VALUE=DATE:${luxonEndDate.toFormat('yyyyLLdd')}\r\n`), 'for DTEND');
});
Expand Down

0 comments on commit b165309

Please sign in to comment.