News for hackers. Stuff that matters.
Re:All I Want for Christmas Is These Seven TypeScript Improv... by CGamesPlay on Monday December 26, 2022 @01:40AM (#34135323)
Any property access could be a getter function, and TypeScript doesn't know which properties are getters and which aren't [0]. Similarly for Proxies, anything could be a proxy and the design goal of Proxies is that they cannot be differentiated from regular values.

But imagine that TypeScript in addition to pure functions you can also tag objects as "POD objects" or "JavaScript objects". The POD ("plain old data") objects can't be proxies or have impure getter methods, and only POD objects can be passed to pure functions. The "pure" keyword actually means "pure if all arguments are POD objects" (this is to avoid having to write N purity overloads for an N-ary function).

You want to call a pure method from your impure method, and pass it one of your arguments. Your arguments now need to be declared to be POD objects, which means they are incompatible with the rest of your code base. This has to go all the way up... it's basically "colored functions" except it's colored objects this time, and the colors are completely incompatible (async functions can call sync functions, but impure functions can't call pure functions with impure arguments, and pure functions can't call impure functions at all).

[0] https://www.typescriptlang.org/play?#code/C4TwDgpgBAkgYgewVA...

Re:All I Want for Christmas Is These Seven TypeScript Improv... by 411111111111111 on Monday December 26, 2022 @03:43AM (#34135888)
> Any property access could be a getter function, and TypeScript doesn't know which properties are getters and which aren't

I'm aware. That doesn't make it impossible to differentiate as Webstorm shows by coloring the bar differently for fooA vs fooB in your example. But yes, it would have to be implemented as part of that pure feature.