Skip to content

A better way to define readonly properties ? #1737

Closed
@NN---

Description

@NN---

Current solution involves a lot of boilerplate code:

class A {
 constructor(a: number) {
  this._a = a;
 }

 private _a: number;
 get a(): number { return _a; }

It would be nice to have something simpler.
Now you can define properties from the constructor, why not define getter there as well ?

class A {
 constructor(get a: number) {
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions