Instead of stating : boolean, let TypeScript infer the type through assignment.
true or false to isDarkMode. This infers the type as boolean.toggle(). It should toggle isDarkMode between true and false.toggle() twice and log isDarkMode each time.Why it's neat:
TS infers isDarkMode as boolean automatically. Try passing a string to toggle() and see how TS protects you.