CompilerOptions in TSConfig.json -- What are GAS's default settings?

255 views
Skip to first unread message

Michael Wolf

unread,
Dec 20, 2022, 4:32:47 PM12/20/22
to Google Apps Script Community
I realized that a lot of the problems I'm having as I work in my local environment on IntelliJ are probably because I am (implicitly) using inconsistent CompilerOptions in my two environments (synchronized via clasp)
* GAS environment in the cloud
* my local (MacBook) environment

If implicit, inconsistent CompilerOptions are the problem,
then consistent, explicit CompilerOptions could be the solution.

Hey GAS team...  Could you post the CompilerOptions that are currently being used in the GAS cloud environment?  As a ```tsconfig.json``` file?  If so, yeahhh!!!!  I could use it to make my local compiler behave like yours does.  (P.S.  And, if you add your tsconfig.json to the tsconfig/bases GitHub repo, you could add a link to "TypeScript getting started" page and it would help lots of other folks.)

Here's the (non-default) values from my tsconfig.json file.  Since I'm having trouble with 'require' vs 'export/import', and because GAS supports all ES6 features (except Modules), I'm betting that tsc(1) needs some tweaking to be really-modern (but not fully), and I bet the 'target' (not 'targets') and 'module' values are critical.

My ```tsconfig.json``` file...
{
"compilerOptions": {

/* Projects */
// No overrides

/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// Default: ES3
// Allowed: es3 es5 es6/es2015 es2016 es2017 es2018 es2019 es2020 es2021 es2022 esnext

    /* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// Default: CommonJS if target is ES3 or ES5,, 
//                ES6/ES2015 otherwise.
// Allowed: none commonjs amd umd system es6/es2015 es2020 es2022 esnext node16 nodenext
    
/* JavaScript Support */
// No overrides

/* Emit */
// No overrides

/* Interop Constraints */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */

/* Completeness */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

DimuDesigns

unread,
Dec 20, 2022, 9:26:48 PM12/20/22
to Google Apps Script Community
This group is not overseen by any member's of Google's GAS team, and, as far as I know, no one from that team actively engages with this forum (at least not since Eric Koleda left Google).

Moreover, the GAS IDE does not support Typescript. Clasp, however, does support Typescript. In fact, Clasp actually transpiles Typescript code to pure Javascript before pushing it to a GAS project.

I suspect your issue would be better addressed by those folks working on Clasp. Check out Clasp's Github repo. You can post your query under the issue tracker for that repo.   
Reply all
Reply to author
Forward
0 new messages