Re:How an Anti-TypeScript “JavaScript developer” like me bec...
by mushishi on Tuesday March 02, 2021 @02:09PM
(#26319082)
I kinda like what you are saying, but it's not that clear-cut in my experience / skill-level.
One can write code that would work correctly, but trying to express the types as precisely as one would like may be painful and doesn't necessarily be productive.
Sometimes when I feel it is cumbersome to express my intent in typing,
I may feel satisfied enough to make a runtime check, (and perhaps add a note but depends...).
Especially if that functionality is used in scoped area (e.g. module) and not exposed to the rest of the app.
When trying to make a generic and flexible functionality, the typing experience seems get harder and more time-consuming for human to grok, and it may not even be that useful when you look how the code is used.
So I usually try to make typing as good as I can by finding documentation related to what I'm trying to do and banging my head to the wall from a couple of angles, and for some specific parts I may give up and type any.
Perhaps sometimes when typing feels hard it may tell that the abstraction is just plain wrong, so there's that plus side!
One can write code that would work correctly, but trying to express the types as precisely as one would like may be painful and doesn't necessarily be productive.
Sometimes when I feel it is cumbersome to express my intent in typing, I may feel satisfied enough to make a runtime check, (and perhaps add a note but depends...). Especially if that functionality is used in scoped area (e.g. module) and not exposed to the rest of the app.
When trying to make a generic and flexible functionality, the typing experience seems get harder and more time-consuming for human to grok, and it may not even be that useful when you look how the code is used.
So I usually try to make typing as good as I can by finding documentation related to what I'm trying to do and banging my head to the wall from a couple of angles, and for some specific parts I may give up and type any.
Perhaps sometimes when typing feels hard it may tell that the abstraction is just plain wrong, so there's that plus side!