Search code examples
typescriptgoogle-apps-scriptweb-applicationstriggersclasp

Is there a type definition for the doGet/doPost trigger function event object?


I am trying to turn a Google Script into a Web App, using CLASP.

Is there an existing type definition for the "e" object in doGet(e) / doPost(e) that I can use in the typescript /clasp side of things?


Solution

  • Update:

    Latest definitions include events. You may use events like this:

    function doGet(e: GoogleAppsScript.Events.DoGet){
    

    Events seem to be in the works. It doesn't have webapps doget event yet. In the mean time, You can install the latest type(@types/google-apps-script@latest) and add the following interface in the Events module inside google-apps-script-events.d.ts

      export interface WebAppsDoGet { //should be inside module Events
        queryString: string,
        parameter: {[key: string]: string; },
        contextPath: string,
        parameters: {
         [key: string]: string[]; },
        contentLength: number
      }
    

    You can then use it like this:

    function doGet(e: GoogleAppsScript.Events.WebAppsDoGet){