Primitive Types: string, number, boolean
Annotate variables with TypeScript's three core primitives.
Primitive Types: string, number, boolean is a free TypeScript Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the TypeScript Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Welcome
Annotating Variables
let username: string = 'Alice';
let score: number = 100;
let isLoggedIn: boolean = true;Type Inference
let city = 'Istanbul'; // inferred as string
let price = 9.99; // inferred as number
let enabled = false; // inferred as booleanType Errors at Compile Time
let count: number = 10;
count = 'ten'; // Error: Type 'string' is not assignable to type 'number'The string Type
let greeting: string = 'Hello';
console.log(greeting.toUpperCase()); // 'HELLO'
console.log(greeting.length); // 5The number Type
let age: number = 25;
let pi: number = 3.14159;
let hex: number = 0xFF;The boolean Type
let isDone: boolean = false;
let hasAccess: boolean = true;
// isDone = 1; // Error — not a booleanTemplate Literals Work with string
let name: string = 'World';
let n: number = 42;
let msg = `Hello ${name}, you scored ${n}`;Primitive vs Wrapper Objects
// Correct
let a: string = 'hello';
// Avoid
let b: String = new String('hello'); // wrapper objectType Annotations on Function Parameters
function add(a: number, b: number): number {
return a + b;
}
add(2, 3); // OK
// add(2, '3'); // ErrorWhen to Skip Annotations
// Both are fine:
const x = 5; // inferred number
const y: number = 5; // explicit numberQuick Check
Recap
Frequently asked questions
Is the “Primitive Types: string, number, boolean” lesson free?
Yes — the full text of “Primitive Types: string, number, boolean” is free to read here on the web, and the TypeScript Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the TypeScript Academy course, upgrade to CoddyKit PRO.
What will I learn in “Primitive Types: string, number, boolean”?
Annotate variables with TypeScript's three core primitives. You practise TypeScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start TypeScript Academy?
No prior experience is required. TypeScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Primitive Types: string, number, boolean” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this TypeScript Academy lesson?
Yes. Every TypeScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Primitive Types: string, number, boolean
- The any Type and Why to Avoid It
- unknown vs any: The Safer Choice
- null, undefined, and Strict Null Checks