TypeScript · Middle · Question 52 of 75
What does as const satisfies Record<string, Route> give you for a config object?
const routes = {
home: { path: '/' },
user: { path: '/users/:id' },
} as const satisfies Record<string, { path: string }>;- ✓Correct answer: Validation against the shape while keeping the exact literal keys and values
- 2It converts the object to a
Recordand loses literal keys - 3It freezes the object at runtime
Explanation
keyof typeof routes stays 'home' | 'user', and a typo in a property is still reported.