Concept
Classes declare their fields with types, and private, protected and public say who may touch them. TypeScript checks the modifiers at compile time; #private fields are enforced at runtime too.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Class fields and access modifiers doing its job.
class Counter {
#count = 0;
readonly name: string;
constructor(name: string, private readonly step = 1) {
this.name = name;
}
increment(): number {
this.#count += this.step;
return this.#count;
}
}Relying on private to hide data from untrusted code. The TypeScript keyword is erased when compiled, and the field is a normal property at runtime. Use #fields when it must hold.
Your roadmap puts these before Class fields and access modifiers, unless you already know them.
Once a session shows you understand Class fields and access modifiers, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Class fields and access modifiers.