Stage 1 · Lesson 5 of 9
TypeScript types and interfaces
adds to . It catches mistakes such as a misspelt property or a missing argument before the app runs. Learn to add types to function parameters and return values.
Describe the shape of objects with type or interface. Use union types such as 'idle' | 'loading' | 'error', which say "one of these values". Turn on strict mode in tsconfig.json from the first day, and let TypeScript work out the types of local variables.
A union where each option has a shared kind field is a . It models states such as loading or loaded, and TypeScript narrows the type inside each branch.
Common trapreaching for any whenever the compiler complains, which switches the checking off exactly where you needed it.
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 JavaScript Fundamentals
Design Gurus · Beginner · $50
Beginner JavaScript with an exercise after most lessons
- GuideFreeJavaScript.info
Ilya Kantor
Free and thorough: Part 1 is the language, skip the browser chapters in Part 2