Skip to content

Files

Latest commit

feb1c94 · Dec 24, 2023

History

History
14 lines (11 loc) · 262 Bytes

keyof-any.md

File metadata and controls

14 lines (11 loc) · 262 Bytes

keyof any

keyof any is a trick to write types that can be used to index objects, i.e., string | number | symbol.

type Record<K extends keyof any, T> = {
  [P in K]: T;
}
type X = Record<'a' | 'b', number>;
// { a: number; b: number; }