3 ms·
> Local-scoped mutability is not typically an issue. But our refactoring tools really don't reveal the extend of variables, so while I may be confident in this
by KirinDave 9y ago
> Local-scoped mutability is not typically an issue.
But our refactoring tools really don't reveal the extend of variables, so while I may be confident in this outcome in the case where I write it, I leave a bit of a caveat that's difficult to document for subsequent developers.
Same with my use of const that was noted above, it's more a message to future developers than a useful assertion (const does very, very little in js).
If we were using Purescript or Haskell where I could assert this caveat with types, I'd do that instead. Even in Clojure, where it's actually kinda painful to leak the mutable contexts, I might do it. Too easy to lose control of stuff during a refactor in Typescript, so I don't.