Status Update
Comments
ga...@google.com <ga...@google.com> #2
Hi there, thank you for your report. I am currently investigating this and will come back to you here in due course.
Many thanks!
ga...@google.com <ga...@google.com> #3
Hi there!
Can you please provide any links to our documentation which mention the support for the static property?
Many thanks!
no...@gmail.com <no...@gmail.com> #4
The Apps Script documentation static
keyword:
Scripts using V8 can call object methods and class static methods...
So, although I do not see any specific mention of class static fields, it's perhaps surprising that static methods do not throw any syntax errors (whereas static fields do throw a syntax error).
More background:
The Apps Script documentation
Apps Script is now supported by the V8 runtime that powers Chrome...
The documentation for static
That version of Chrome used V8 engine v4.9. I don't know what specific version of V8 is used by GAS.
ga...@google.com <ga...@google.com> #5
Thank you for the additional information, I shall continue my investigation and update here.
ga...@google.com <ga...@google.com> #6
Hi there!
Apps Script V8 runtime supports EMCA2015 standards which mean static class properties are not supported at the moment. There are two workarounds available:
- Assign the property to the class:
// Caused an error
class MyClass {
static a = 1;
}
// ECMA2015 compatible
class MyClass {}
MyClass.a = 1;
- Develop the Apps Scripts with Clasp:
https://github.com/google/clasp which also supports TypeScript and many other new features.
no...@gmail.com <no...@gmail.com> #7
Understood.
Can you please provide a link to any official documentation which mentions the fact that the Apps Script V8 runtime only supports ECMA2015 standards?
Many thanks!
dm...@gmail.com <dm...@gmail.com> #8
Both of these runtimes allow static class properties. Apps Script does not.
See:
If Google is not going to fix this bug, then the documentation should clearly state that while static class methods are allowed,
static class properties are not allowed. This will save developers time trying to figure out that this standard and well--documented
feature, supported in 2 other environments, is not allowed in Apps Script
Description
Cannot use a static class property without GAS editor barfing and not allowing the file to be saved.
# A small code sample that reliably reproduces the issue. The sample should run as-is or with minimal setup, without external dependencies.
```
class X {
static x = 5;
}
```
# What steps will reproduce the problem?
1. Open up a GAS editor.
2. Type in the code provided.
3. Press Ctrl-s to save to project.
# What is the expected output? What do you see instead? If you see error messages, please provide them.
That no error will be generated and the code will save.
# Please provide any additional information below.
Attached an image of what happens when I attempt to save the file.