Maybe I’m doing it wrong but when I try to handle this kind of thing, I get bitten by “readonly” and now I need to put readonly keyword in all kinds of functions. You’d think it could implicitly tell it’s readonly. Or maybe that’s a feature of my “pure” keyword idea.
As an obsessive readonly-er, yeah this pain is real. It basically colors your functions the way async does. There is a TS issue I haven’t checked on in a while about readonly-by-default and a corresponding mutable keyword. I doubt it got much traction, but it’s a shame.
Writing Clojure I really liked that there was a baseline assumption that functions are pure and a clear signal in code when it’s stateful. It doesn’t have to color functions (but ahem it works great for Haskell), but it seems like a reasonable opt-in default that shouldn’t be so painful.