TypeScript Foundations
Add static types to JavaScript with TypeScript: model data precisely, narrow untrusted input safely, write reusable generic code and compile in strict mode.
4 objectives 6 steps about 145 min
Learn it step by step
Read the lessons in order, try the practice checks, then prove the skill with the knowledge check.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Annotate functions, objects and arrays where inference is not enough, and model domain data with type aliases, interfaces, literal types and unions.
- Narrow union and unknown values with typeof, in, equality checks, type predicates and discriminated unions, and validate untrusted runtime data such as API responses before relying on its type.
- Write generic functions and types, and derive types with keyof, typeof, indexed access and utility types such as Partial, Pick, Omit and Record.
- Configure a strict tsconfig, run type checks as part of the build, and consume typed third-party packages and declaration files.
Lesson plan
6 steps, about 145 min · 5 of 5 lessons available so far
- Why Types: Annotations, Inference and the Compiler Concept · 20 min
- Modeling Data with Unions, Literals and Interfaces Worked example · 25 min
- Narrowing and Validating Data You Do Not Control Worked example · 25 min
- Generics and Types Built from Other Types Concept · 25 min
- Lab: Convert a JavaScript Module to Strict TypeScript Lab · 30 min
- Check: Type Puzzles and Compiler Errors Knowledge check · 8 questions
Practise it
Convert the async search UI to TypeScript with strict and noUncheckedIndexedAccess enabled, model the API result as a discriminated union of success and error states, validate responses at runtime with a schema, and reach zero type errors without any.
References
Hard prerequisites
Unlocks
Nothing depends on this skill yet.
On these roadmaps
Progress and evidence for this skill are shared across all of them.