DEV Community

Discussion on: Use fake static classes to protect your namespace (js/ts)

Collapse
 
qpwo profile image
Luke Harold Miles

Languages like Go and Rust solve the namespace pollution problem with interfaces and traits respectively, but ts/js has no such feature unfortunately. Also check out clojure's a-la-cart dispatch.

Collapse
 
qpwo profile image
Luke Harold Miles

Another opinion I have is that property getting and method invocation should not look the same. So if typescript does one day add a receiver-function-like feature (unlikely) it should look like this:

const x = point.x
const mag = point->mag()
Enter fullscreen mode Exit fullscreen mode

But the syntax is huge as-is anyway.