News for hackers. Stuff that matters.
Re:Public and private class fields by 21 on Thursday December 13, 2018 @12:47PM (#18674323)
Why not use the private/public keywords like in TypeScript?

Was this # thing voted by the community or something?

Re:Public and private class fields by mathias on Thursday December 13, 2018 @01:05PM (#18674492)
The article links to the explanation by the proposal champions: https://github.com/tc39/proposal-class-fields/blob/master/PR...
Re:Public and private class fields by lucideer on Thursday December 13, 2018 @12:54PM (#18674383)
The justification is that they needed a unique accessor, because:

- attempting to access a non-existent private property using `this.prop` would create a public property "prop" in JS, which they claim would be a source of bugs.

- they also wanted to allow creating a public property on a subclass with the same name as a private property on a parent class—having the accessors the same could be confusing.

That said, they could still have had keywords for definition with an alternative accessor. # is definitely not idiomatic; it's extremely ugly.