Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kemsakurai/58bc3ff86df43adde5fc4a2f27a6ca98 to your computer and use it in GitHub Desktop.
Save kemsakurai/58bc3ff86df43adde5fc4a2f27a6ca98 to your computer and use it in GitHub Desktop.
Google Apps Script の client-side API のTypeScript 型定義ファイル

clasp で Google Apps Script を書いているが、client-side API の TypeScript 定義ファイルが見あたらず、探したので探した結果を記載する。


オフィシャルな TypeScript 定義ファイル

公式の TypeScript 定義ファイルはないと思う。
探したが見つからなかった。


個人が作成している 定義ファイル

Gist に UP されていた。
Google Apps Script client-side Typescript definitions


使い方

  • 定義ファイル配置ディレクトリを作成する
    @types という名称のディレクトリを src フォルダ配下に定義ファイルを格納する。

  • compilerOptionsの記載内容を確認する
    compilerOptionstypeRootstypes の指定がないか確認する。
    特になければデフォルトで @typesディレクトリを参照する。

{
   "compilerOptions": {
       "typeRoots" : ["./typings"]
   }
}

後は特に、import 等せずとも型定義が使用できるようになる。


参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment