Abbreviate lengthy TypeScript Types

自闭症网瘾萝莉.ら 提交于 2019-12-24 10:19:01

问题


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

回答1:


You can define new alias type:

type Sheet = GoogleAppsScript.Spreadsheet.Sheet


来源:https://stackoverflow.com/questions/53198823/abbreviate-lengthy-typescript-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!