IK
Interview Knowledge Book
Темы
Практика
Примеры
Песочница
EN
browser
Config table в стиле satisfies
Используйте precise config table, сохраняя literal keys и проверяя expected shape.
index.js
/** * TypeScript version: * const routes = { ... } satisfies Record<string, { path: string }>; * keyof typeof routes remains 'api' | 'admin'. */ const routes = { api: { path: '/v1' }, admin: { path: '/admin' }, }; for (const key of Object.keys(routes)) { console.log(`${key} -> ${routes[key].path}`); }
Запустить
Остановить
Сбросить