SpinTheMic
Pro

Interview practice question

Typing a reducer's actions

Frontend Engineering · TypeScript · Intermediate

How would you type actions for a reducer so each action's payload is checked?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Discriminated union of action types.
  • type field as discriminator.
  • Narrowing in switch gives correct payload.
  • Exhaustiveness check.
  • Action creators typed.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics