TypeScript: final assessment

This covers the whole course. Take it after the last module.

Final quiz

1. What does TypeScript add to JavaScript?
2. Which annotation says a variable may hold a string or nothing?
3. What is an interface?
4. Which keyword makes a class field unchangeable after construction?
5. What is Exclude<'a' | 'b' | 'c', 'a'>?
6. After if (typeof v === 'number') return; what is v's type if it was number | string?
7. What does getProperty<T, K extends keyof T>(o: T, k: K): T[K] return for a key 'age' whose type is number?
8. Which values fit an interface with one method describe(): string?
9. What does Promise.allSettled return?
10. Why prefer a string enum to a numeric one for log levels?
11. Why is a type assertion (as) risky?
12. What does a conditional type do when applied to a union?
13. Which mapped type removes the optional modifier from every property?
14. Why return a Result instead of throwing for expected failures?
15. What is the safest place for an as assertion to a branded type?
16. Why does adding a member to a discriminated union help you find code to update?

Practical assessment: Type an untyped program

Without using hints, take a JavaScript program of about 200 lines that reads orders from JSON and prints invoices, and convert it to strict TypeScript.

Final project

A typed task manager: Write a command-line task manager in TypeScript whose types make it impossible to put a task into an invalid state, with every command parsed from text into a typed command before it runs.

How it is evaluated

To complete this course