niieani / typescript-vs-flowtype

Differences between Flowtype and TypeScript -- syntax and usability
MIT License
1.74k stars 78 forks source link

Class properties #59

Open fizker opened 5 years ago

fizker commented 5 years ago

Moved the section out of TS-only, since both ECMAScript and flow supports it.

niieani commented 5 years ago

This compares type-checked private properties with runtime private properties - they're different, so this PR isn't accurate to that.

We can make a separate section about runtime private properties.

fizker commented 5 years ago

That's not true. The current version incorrectly claims that Flow does not support the concept of both public and private properties; it most certainly does, and it enforces this on a static type-checking level, same as TypeScript.

The actual runtime code is dependent on the compiler used and have nothing to do with Flow nor with static type-checking. There are probably other things that work fine at runtime even though it fails at type-checking time, such as read-only objects and exact objects. They are not mentioned anywhere, so I don't see the point of mentioning this either.


I can rewrite it to split the public and private properties apart. This makes sense since the two systems share the syntax for public properties, with the exception of some syntactic sugar that TypeScript supports.

The part for the private properties could get a note describing that TypeScript does not have actual private properties, if that seems appropriate. But then we move into runtime parts, which seems out of scope of this article.