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 }>;

Explanation

keyof typeof routes stays 'home' | 'user', and a typo in a property is still reported.

Further reading

Problem with a question

TypeScript · Middle · question 52

Test yourself

Take the TypeScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz