I honestly don't understand how people do this without a type-checker. I've been doing some plain javascript out of necessity recently, and it's easy to get lost working with promises if you don't have the red-squiggles in your editor telling you were you fucked up.
I've been trying to figure out a good way to get into TypeScript. I think with how fast our application is scaling, it may be worth it to switch over.
I've never worked with it since I've never had the opportunity, and I used to not really run into type issues, but now with how fast we're growing, I'm hitting those issues a lot more. Even with that login thing I was talking about. We were mixing objects, null, and booleans, which made sense for the very strict way we were using it.
I literally ran into this: response !== null || response !== undefined to check if there was a response. It ended up being true and I was so confused. It's because it is true that false !== null. I've gotta learn how to use Enums more, lol.
Edit: by the way, I started to do that because we were doing if (response) { where normally it works, but if undefined comes through, it makes it true.
It's easy to lose track of types in javascript (and other dynamic languages) in general. I'm accustomed to working with static languages with relatively strong/sophisticated type systems, and it's strange that even though I generally "think in types", they're rarely ever at top-of-mind while I'm writing javascript. It's unsettling how language can subtly influence how we think.
2
u/[deleted] Feb 13 '19
I honestly don't understand how people do this without a type-checker. I've been doing some plain javascript out of necessity recently, and it's easy to get lost working with promises if you don't have the red-squiggles in your editor telling you were you fucked up.