简体   繁体   English

在TypeScript文件中使用Google Script类型注释变量(使用clasp)

[英]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. 我正在使用clasp工具编写Google Apps脚本(GAS) ,可让您在本地开发可编译为Google脚本的TypeScript文件。

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. 我通过运行npm i -S @types/google-apps-script导入了Google Script类型定义,而我的IDE(VS代码)似乎确实了解Google Script类型。 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 命名空间: GoogleAppsScript
  • module: Spreadsheet 模块: Spreadsheet
  • interface: Spreadsheet 界面: Spreadsheet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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