In Google Apps Script, I'm using the Advanced Calendar Service, which uses a default symbol "Calendar", but I renamed it to "CalendarService". What do I need to do include this name change when using the type definitions for Apps Script in a TypeScript project?
Modifying the type definition file directly is something that I'd rather not do as it's an installed npm package.
// ./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;
As it stands, the naming creates two issues:
- Usage of the advanced service isn't correctly picked up by the TypeScript compiler
- I can't have a global
Calendar
(maybe an issue that can be treated separately, but I'd like to use that name)
class Calendar {
id: string;
constructor(id) {
this.id = id;
}
getEvent(eventId): GoogleAppsScript.Calendar.Schema.Event {
// TypeScript cannot find `CalendarService`
return CalendarService.Events.get(this.id, eventId);
}
}
question from:
https://stackoverflow.com/questions/65852230/rename-interface-from-imported-type 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…