TypeScript · Lesson 96 of 120
Common Mistakes
And fixes.
Let's look at the mistakes almost everyone makes when learning TypeScript. Knowing them early saves a lot of confusion.

- Everyone makes them
- Learn early
- Save confusion
Mistakes and fixes
Using any switches off checking, use unknown. Assertions hide bugs, validate instead. Types vanish at runtime, so check outside data. Over complicated types confuse everyone, keep them simple. And turning strict off hides real problems.
| Mistake | Fix |
|---|---|
| any everywhere | unknown + narrowing |
| as on outside data | validate (Zod) |
| Thinking types run | runtime checks |
| Clever types | simple types |
| strict off | strict on |
A good habit
When the compiler complains, read the whole message, and ask what it's protecting you from. Usually, it has found a real bug.
| key | value |
|---|---|
| Read | the whole message |
| Ask | what's it protecting? |
| Usually | a real bug |
| Don't | silence it with any |
Summary
Avoid any, avoid assertions on outside data, and keep strict on. Next, the project.
Key takeaways- No any
- Validate
- Strict
Next up: Project: The Plan — an orders library