Interview practice question
Typing an object with dynamic keys
Frontend Engineering · TypeScript · Beginner
You have an object mapping product IDs to prices, with unknown keys. How would you type it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Record<string, number>.
- Index signature { [id: string]: number }.
- noUncheckedIndexedAccess for safety.
- Map<string, number> alternative.
- Literal key unions when known.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.