Basic Types
TypeScript uses the same simple values as JavaScript.
Each one has a type name.
A type is a name tag on a toy.
Bigger types are built from these small ones.
string, number, and boolean
A string is text in quotes.
A number is a count or a size.
A boolean is yes or no. true or false.
These three cover most everyday data.
null and undefined
undefined means a value is missing.
Missing means nobody put anything in the box yet.
null means empty on purpose.
With strict null checks, you must handle them yourself.
Strict means TypeScript is careful and picky.
bigint and symbol
bigint holds huge whole numbers.
Bigger than a normal number can hold safely.
symbol makes a unique tag.
Unique means no other tag is the same.
That is handy for object keys that should never clash.
Writing types vs guessing
You do not need to type every variable.
When TypeScript can see the value, it guesses the type.
That guess is called inference.
Inference means TypeScript figures it out from the value.
When to write the type yourself
Write types on function inputs.
Write types on return values when it helps readers.
Write them on empty variables that start with nothing.
That way TypeScript knows the name tag early.
Learn these simple types first. Bigger types are made by combining them.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.