TypeScript·Intermediate·Coding·1 min read
How does Record<K, V> differ from an indexed signature written by hand?
Short interview answer
Record<K, V> is a builtin generic utility that produces the same mapped-object shape as a hand-written { [key: K]: V } index signature, but is more concise and communicates intent clearly, especially when K is a union of string literals rather than plain string.
Example
type Roles = 'admin' | 'editor' | 'viewer';type Permissions = Record<Roles, string[]>;// { admin: string[]; editor: string[]; viewer: string[] } — all keys requiredKey takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.