Home > Mobile >  Change script file extension in Apps Script online IDE
Change script file extension in Apps Script online IDE

Time:07-17

I've created a script using Apps Script in Google Sheets, and would like to code in TypeScript. I gather to do this you need to rename the default .gs file to .ts.

How does one accomplish that in the online IDE? It doesn't seem to let you rename the extension:

Animation showing a rename attempt from Code.js to Code.ts producing Code.ts.js

I tried the "classic editor" with similar results. I don't want to install Node (which requires Administrator privileges) and CLASP (which requires granting access to my Google account) just to rename a file!

There are hints the online editor supports TypeScript (e.g. autocomplete lists parameter types):

Example of autocomplete showing typed parameters

But if I try creating typed variables or parameters in my .gs file I get linter and syntax errors:

let foo:string = 'hello';

Syntax error Unexpected token ':'

CodePudding user response:

Typescript is currently not supported in Apps script editor. There is however, a feature request for the same here: https://issuetracker.google.com/issues/238057231

You may add a 1 or comment in the tracker explaining benefits from a business point of view, if you're interested.

  • Related