🔤Statically Typed Language
Also known as Static Typing, Statically Typed
A language that checks the type of each value before it runs.
Think of it like
Think of it like jars with labels. The sugar jar only takes sugar, and you find out at once if you pour in salt.
Example
Jack says age is a number, then tries to store the text "thirty" in it. TypeScript stops him before the code ever runs.
Why it matters
Type checks catch a whole class of bugs early. They also help editors suggest the right names.
Definition
Example code
typescript
let age: number = 30;
age = "thirty";
// error TS2322: Type 'string' is not assignable to type 'number'.Common mistake
Key takeaways
- 1Checked first. Types are tested before the code runs.
- 2Fixed types. A number box stays a number box.
- 3Fewer surprises. Type slips never reach the user.