简体   繁体   中英

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?

Custom type annotations can be used like this:

var ss: GoogleAppsScript.Spreadsheet.Spreadsheet;
  • namespace: GoogleAppsScript
  • module: Spreadsheet
  • interface: Spreadsheet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM