Google Apps脚本是否支持@TyPedef?

发布于 2025-02-11 11:47:17 字数 828 浏览 1 评论 0原文

如果在库中描述了@TyPedef,则似乎自动完成似乎无法正如导入库的文件上的预期工作;对象类型变成任何。是否有任何解决方案可以将对象的结构告诉另一个脚本?

请注意,我不想使用诸如Typescript之类的非气体技术。谢谢。

/**
 * @typedef {Object} myVegetable
 * @property {string} name
 * @property {number} price
 */
/** @type {myVegetable} */
var myVegetable = { name: "carrot", price: 1 };

img1- @typedef在同一文件中按预期工作。

img2- type myVegetable变成了任何导入库的文件。

If @typedef is described in a library it seems that autocomplete doesn't work as expected on a file which imports library; object type is turned into any. Is there any solution to tell object's structure to another script?

Please note that I don't want to use non-gas technique like TypeScript. Thanks.

/**
 * @typedef {Object} myVegetable
 * @property {string} name
 * @property {number} price
 */
/** @type {myVegetable} */
var myVegetable = { name: "carrot", price: 1 };

enter image description here

img1 - @typedef works as expected in same file.

enter image description here

img2 - type myVegetable is turned into any on file which imports library.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最笨的告白 2025-02-18 11:47:17

仅天然气不支持打字稿

Google Apps脚本(GAS)而不添加其他工具不支持打字稿。基于文章使用toxpercript使用typescript 开发应用程序脚本使用clasp。但是,这需要您安装以下内容以启用您的本地开发环境:

  1. Apps脚本Visual Studio代码的节点和NPM
  2. clasp
  3. 类型定义
  4. (用于打字稿IDE自动完成))

参考:

有关更多详细信息,您可以查看以下链接:

  1. 使用Typecript 开发应用脚本
  2. /apps-script/guides/clasp“ rel =“ nofollow noreferrer”>命令行界面使用clasp

GAS Alone Does Not Support Typescript

Google Apps Script (GAS) does not support typescript without adding additional tools. Based on the article Develop Apps Script using TypeScript, you may incorporate typescript in GAS with clasp. However, this requires you to install the following to enable your local development environment:

  1. Node and npm
  2. Clasp
  3. Type definitions for Apps Script
  4. Visual Studio Code (for TypeScript IDE autocompletion)

References:

For further details, you may view the following links:

  1. Develop Apps Script using TypeScript
  2. Command Line Interface using clasp
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文