- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2022 01:02 AM
Hey guys,
I am exited about the Tokyo new Ecmascript features and playing with creating classes in Script Includes etc and over all it is good and promising. However, I have realised that arrow functions are not working inside a class in Script Include. Is everyone having this issue and reasons for it? Arrow functions are working inside the Business Rules though. See the following class that works great except the arror function! This arror function doesn't compile:
getInfo2 = () => `${this.name} is ${this.age} years old!`;
This is really important as using other libraries code will have arrow functions and without it we are back to olden times 😉
let Person = class Person {
//#isPrivate; // Private field not supported yet
constructor(name, age) {
this.name = name;
this.age = age;
}
// This works!
getInfo() {
return `${this.name} is ${this.age} years old!`;
}
// This has compile issue complains about the = sighn???
getInfo2 = () => `${this.name} is ${this.age} years old!`;
};
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 03:05 AM
That is just a linter error, one can save the record with that error. However it seems in scopes the only way Script Includes are recognized and included into a context is if those contain the Class.create()
instruction. And this was like this since forever, not linked with ES12.
All in all, after creating Script Include Person
containing code
var Person = Class.create();
Person = class {
//#isPrivate; // Private field not supported yet
constructor(name, age) {
this.name = name;
this.age = age;
}
// This works!
getInfo() {
return `${this.name} is ${this.age} years old!`;
}
// This has compile issue complains about the = sighn???
getInfo2 = () => `${this.name} is ${this.age} years old!`;
};
I can successfully run
var p = new Person('N1', 35);
gs.debug(p.getInfo2());
in Scripts - Background:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2022 02:11 AM
Hi Rahman,
what is the scope of your script include?
I believe the new ES6+ works only in scoped applications given that Javascript mode is selected to ECMAScript 2021(ES12).
Please mark my answer as HELPFUL / CORRECT if this help to resolve your issue.
Regards,
Vamsi S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2022 04:44 PM
Hi,
It is scoped app mate. If I am that excited and have gone that far then it means I know at least that bit 😉
thanks for the reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2022 05:17 PM
class Person {
//#isPrivate; // Private field not supported yet
constructor(name, age) {
this.name = name;
this.age = age;
}
// This works!
getInfo() {
return `${this.name} is ${this.age} years old!`;
}
// This has compile issue complains about the = sighn???
getInfo2 = () => `${this.name} is ${this.age} years old!`;
};
works in Scripts - Background.
Isn't let Person = class Person ...
redundant anyway?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2022 05:20 PM
Actually
let Person = class Person2 {...
or
let Person = class {...
also work.
So probably when converting
let Person = class Person {...
a redefinition of Person conflict is (wrongly) detected?