TypeScript
JavaScript
Coding
TypeScript: Extra work or life saver?
---
The "Any" Type Trap
When I first started TS, I just put any everywhere.
const user: any = ...
function submit(data: any) ...
Like that might as well use JS right? Don't be lazy lah.
Why Types are Power
Imagine you buy furniture from IKEA but no manual. You try to pasang yourself, confirm senget one.
TypeScript is the manual. It tells you exactly what props a component needs.
- "Eh, this function needs a string, why you give number?"
- "Bro,
user.namedoesn't exist, maybe you meanuser.fullName?"
Catch bugs before production
The best feeling is when you see red squiggly line in VS Code. It means you saved yourself from a production bug. Better fix now than panic later when client call you at 3am.