EduFlow
Advanced TypeScript Patterns

Checkpoint: Patterns for Real Codebases

Five questions on this section. Answer all of them, then see your score and why each answer is right or wrong.

Question 1 of 5

What is wrong with this code?

TypeScript
const id = JSON.parse(body).orderId as OrderId;
cancelOrder(id);
Question 2 of 5

A caller of charge(): Result<Receipt, PaymentError> writes if (result.error) showError(result.error). What happens?

Question 3 of 5

Cartwheel’s server renders the initial cart into the page as JSON. Bad data there means a broken deploy, not something a customer can fix. How should the client handle it?

Question 4 of 5

What is the problem with this emitter method?

TypeScript
on(event: keyof Events, handler: (payload: Events[keyof Events]) => void): void
Question 5 of 5

You add 'on-hold' to OrderStatus. Which lookup table fails to compile until it gets an 'on-hold' entry?

5 questions unanswered