microsoft / TypeScript-New-Handbook

Incubation repository for the new TypeScript handbook 🐣
MIT License
649 stars 27 forks source link

Clarification on omitting types #30

Closed elibarzilay closed 1 year ago

elibarzilay commented 4 years ago

There are two big reasons not to omit types:

In addition, the Date() example shows another case for explicit types: what if I know that it returns a string, but others won't and I want to be explicit about wanting a string? Adding a : string would be good in this case.

So, I changed "best" to "often preferred", and added the last thing as an example. (Demonstrating the two points would be more verbose, so not done.)