Skip to content

Instantly share code, notes, and snippets.

@ivankisyov
Created April 4, 2019 04:34
Show Gist options
  • Save ivankisyov/36e4a7dc5648ea65373d79e2bebc0cd5 to your computer and use it in GitHub Desktop.
Save ivankisyov/36e4a7dc5648ea65373d79e2bebc0cd5 to your computer and use it in GitHub Desktop.
[TS] class props and fields
class Point {
    // fields _x, _y
  constructor(private _x: number, private _y: number) {}

  // property x
  get x() {
    console.log(this._x);
    return this._x;
  }

  set x(value: number) {
    this._x = value;
  }

  // method
  drawPoint() {
      ....
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment