0

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 ':'

7
  • That differ effect is doing my head in. Commented Jul 16, 2022 at 17:19
  • You do know that the Google App Script editor is for javascript? Except for HTML Service files which are HTML. Commented Jul 16, 2022 at 17:22
  • @TheWizEd are you saying the online editor will happily parse and show you parameter types for library functions but break down if you open a .ts file and use them in your own functions? Commented Jul 16, 2022 at 17:24
  • No I'm saying it probably doesn't understand some of the typescript syntax, unless its purely javascript. Commented Jul 16, 2022 at 17:25
  • Maybe take a look at this article Develop Apps Script using TypeScript Commented Jul 16, 2022 at 17:34

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I wish they were clearer about that. I assumed it was supported because it was showing up in the autocomplete.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.