Stage 1 · Lesson 8 of 8
TypeScript: classes, interfaces and structural types
TypeScript types are structural: any object with the right shape fits an , whether or not it says implements. Interfaces and types disappear when the code runs, so you cannot check them at run time; use a , a kind field shared by every variant, when you need to tell types apart.
Classes still exist at run time. The private keyword is only checked by the compiler, while #field is private at run time too. Much TypeScript code prefers plain functions and object literals to classes, and that is fine: the design ideas in this roadmap apply to modules and functions just as much.
Common trapexpecting instanceof to work on an interface, or building deep class hierarchies where a union type and a few functions would read better.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking the Object Oriented Design Interview
Design Gurus · Intermediate · Subscription
Its opening chapters teach the four OOP ideas applied inside real designs, with UML and running code
- CourseFreeMIT 6.102: Software Construction
MIT · Intermediate
Free MIT readings: Abstract Data Types, Rep Invariants and Interfaces and Subtyping are this stage at university depth