Currently utilizing typescript 3.1.6
.
Is it possible to define get and set methods using arrow functions like this:
export class foo {
/* attributures ... */
/* constructor ... */
/* ---- Example ---- */
get bar = ():string => this.anAttributeToGet;
set baz = (attr: string) => this.anAttributeToSet = attr;
/* ---- ( This code snippet is for demonstration purposes only ) ---- */
}
Instead of using function statements like this:
export class foo {
/* attributures ... */
/* constructor ... */
/* ---- Example ---- */
get bar():string{return this.anAttributeToGet;}
set baz(attr: string){this.anAttributeToSet = attr;}
/* ---- Example ---- */
}