Search code examples
typescriptgoogle-apps-scriptclasp

Abbreviate lengthy TypeScript Types


I'm developing a Google Apps Script (GAS) using Typescript (via the clasp tool).

I imported type definitions by running npm i -S @types/google-apps-script.

Some types are quite lengthy, for example:

let sheet: GoogleAppsScript.Spreadsheet.Sheet

Is there a way to define an abbreviation within a file? e.g.,

declare Sheet = GoogleAppsScript.Spreadsheet.Sheet

Solution

  • You can define new alias type:

    type Sheet = GoogleAppsScript.Spreadsheet.Sheet