TypeScript: How to strictly type a dynamic object keyed by enum values without using any?

3 hours ago 1
ARTICLE AD BOX

I’m working with TypeScript and trying to create a strongly typed object where the keys come from an enum, and the values have a fixed structure. I want full type safety and autocomplete, and I want to avoid using any or type assertions.

enum Status { Active = 'active', Inactive = 'inactive', Pending = 'pending', } type StatusConfig = { label: string; color: string; }; const statusMap = { active: { label: 'Active', color: 'green' }, inactive: { label: 'Inactive', color: 'red' }, pending: { label: 'Pending', color: 'orange' }, };
Read Entire Article