5 ms·
I don’t know. To me, the biggest benefit of TypeScript is dumping all the types on my brain onto the screen. It’s easier to maintain in the future, when I don’
by sergiomattei 4y ago
I don’t know. To me, the biggest benefit of TypeScript is dumping all the types on my brain onto the screen.
It’s easier to maintain in the future, when I don’t have to do so many mental gymnastics to understand the data behind my code.
- redact207 4y agoSecond this. Also much easier to pick up code or review a PR if the types are explicitly provided rather having to backtrack to see how something's called.
- deleted 4y ago[deleted]
- jiangmy 4y agoThank you for clarifying and providing the use case. It makes total sense to me! I'm adding this to my to-do list. There can be many potential use cases, such as providing typing information to the IDE's LSP, ejecting them directly to the code as you suggested, integrating them into the CI process, etc. I'm very open to providing all those possibilities, and there's no reason to limit how you use the typing information when you possess them automatically.
- brundolf 4y agoYou shouldn't need mental gymnastics, you should be able to just hover the values in your editor There are other reasons to use explicit types part of the time- but they don't really have to do with readability
- wildrhythms 4y agoThis isn't so easy when you're trying to parse a hundreds-line function written by god knows who that has many early returns each returning an object with wildly different properties. Declaring the return type the method declaration is valuable.
- brundolf 4y agoIf you just need to read the return type, I don't see why in this case you'd be prevented from hovering the function to see it If you want to constrain the return type so that any errors about bad return-values from this function are localized to it, instead of having them show up further downstream, then that's what I meant by "other reasons to use explicit types"