When working with Google Apps Script, I have implemented the Advanced Calendar Service, originally labeled as "Calendar". However, I have renamed it to "CalendarService". How can I incorporate this name change when utilizing the type definitions for Apps Script in a TypeScript project?
I would prefer not to directly modify the type definition file since it is an npm package that has been installed.
// ./node_modules/@types/google-apps-script/apis/calendar_v3.d.ts
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/google-apps-script/apis/calendar_v3.d.ts
declare namespace GoogleAppsScript {
namespace Calendar {}
interface Calendar {}
}
declare var Calendar: GoogleAppsScript.Calendar;
The current naming convention poses two issues:
- The advanced service usage is not recognized correctly by the TypeScript compiler
- I am unable to globally use the name
Calendar
(this could potentially be a separate issue to address, but I would like to stick with that name)
class Calendar {
id: string;
constructor(id) {
this.id = id;
}
getEvent(eventId): GoogleAppsScript.Calendar.Schema.Event {
// TypeScript does not recognize `CalendarService`
return CalendarService.Events.get(this.id, eventId);
}
}