4 ms·
I’m also excited for records/tuples, but I’d really happily settle for an intermediate “constAsConst” setting: as in if I assign a const, I’d like to be able to
by eyelidlessness 4y ago
I’m also excited for records/tuples, but I’d really happily settle for an intermediate “constAsConst” setting: as in if I assign a const, I’d like to be able to tell the type checker that it really is constant, that I don’t want to change any data in a collection type, essentially that it should treat the const keyword as an `as const` assertion. I’d have to fight with a bunch of other lint rules, but it’s what I mean ~99.999% of the time if I have my druthers.
- ffhhj 4y agoThey heard yer request yet kept immutable.
- Waterluvian 4y agoMaybe 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.
- eyelidlessness 4y agoAs 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.