If you use typescript and modify the cat speak code to use an explicit if, you get a compile error.
constcat={sound:'meow',speak(this:{sound:string}){returnthis.sound}}constspeak=cat.speakspeak()// <= Compile error: void is not assignable to { sound: string }.
Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
If you use typescript and modify the cat speak code to use an explicit if, you get a compile error.
It's pretty nice that this will happen at compile time and not runtime.