Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annotate variable with Google Script type in TypeScript file (using clasp)

I'm writing a Google Apps Script (GAS) using the clasp tool, which lets you locally develop TypeScript files that compile to Google Scripts.

I imported Google Script type definitions by running npm i -S @types/google-apps-script, and my IDE (VS Code) does indeed seem to understand the Google Script types. I cannot, however, seem to annotate my variables with these type definition. For example,

let ss: Spreadsheet;
ss = SpreadsheetApp.getActive();

Is this possible to annotate my code with these imported type definitions?

like image 855
Dustin Michels Avatar asked Oct 15 '25 15:10

Dustin Michels


1 Answers

Custom type annotations can be used like this:

var ss: GoogleAppsScript.Spreadsheet.Spreadsheet;
  • namespace: GoogleAppsScript
  • module: Spreadsheet
  • interface: Spreadsheet
like image 140
TheMaster Avatar answered Oct 18 '25 06:10

TheMaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!