Build useful typed programs: shape real data, handle missing values and talk to a server safely.
- 28 lessons
- 7 units
- 4 h 19 m in all
- £0, for good
what’s inside.
For people who finished Level 1, or can already write small programs with variables, decisions, loops and functions.
TypeScript Level 2 picks up where Level 1 ended and turns your typed basics into small, useful programs. In 28 lessons you shape data with interfaces, unions and generics, build classes, and fetch replies from Gwecode's practice server, checking each one before you trust it. It ends with a level check: a weekend weather planner that copes with whatever the server sends.
every lesson goes the same way.
- meet it
- guess first
- your turn
- fix it
- nailed it
unit 1
Shapes of data
Describe your data so the checker knows what every value holds.
- Objects8 minKeep related facts together and reach each one with a dot.
- Interfaces9 minName the shape of your objects once and use it everywhere.
- Type aliases8 minGive any type a name that says what it is for.
- Objects working together10 minPass objects to functions, line them up in arrays and nest them.
unit 2
This or that
Let a value be one of several things, and find out which.
unit 3
Maybe, and never
Handle values that might be missing, and lock values that must stay.
unit 4
Lists, pairs and lookups
Work through arrays quickly, pair values up and look things up by name.
unit 5
Build your own types
Write code that works for any type, and build objects from classes.
- Generic functions10 minWrite one function that works for every type and keeps track of which.
- Generic types9 minMake interfaces that wrap any type you choose.
- Classes11 minBuild many objects from one blueprint, each with its own methods.
- Private and implements10 minGuard a class's data, and make it keep an interface's promise.
unit 6
Waiting for answers
Write code that waits for timers and for replies from a server.
unit 7
Trust, but check
Check data as it arrives, and recover when things go wrong.
- unknown9 minHold any value safely until you have checked what it is.
- Errors on purpose10 minRaise your own errors, and catch them before they crash the program.
- Checking data at runtime11 minTurn unknown data into a typed object, or refuse it.
- Putting it all together12 minFetch, check and report, and cope with whatever comes back.