@cloud10designs: teaching TypeScript to new graduates. I’m trying to, but I’m not aware that type guarding is “to protect against potential runtime errors” in the first place. The mental model is something like, “I’ll type guard Because I’ll be pissed. on TS.” Maybe that’s fine at first, but it’s a moot point because runtime errors can only be gained through experience with JS. @cloud10designs: If you only write TypeScript, you can probably get away with “I’m going to get mad at TS. If you only write TypeScript, you can probably get by with “because TS will get mad at me” to some extent, but I wonder how you can learn when to do that, or how to write smartly without needing a type guard in the first place by applying processing earlier…


This page is auto-translated from /nishio/怒られないように振る舞うメンタルモデル using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I’m very happy to spread my thought to non-Japanese readers.