Outbound Link Summary:
4 years ago
p3k dots

The looming implementation of private fields to JavaScript as described in tc39/proposal-class-fields might be a convincing argument for a lot of people (including myself) to switch to TypeScript.

Just compare for yourself:

// ECMAScript
class X {
  #foo;
  method() {
    console.log(this.#foo);
    // This fails with an error
    //console.log(this['#foo']);
  }
}
// TypeScript
class Animal {
  private name: string;
  constructor(theName: string) { this.name = theName; }
}

Relevant: