Why does Object.keys on a Record return string[]?

Charles Stover
5 min readDec 13, 2021

Intuitively, one may expect Object.keys on Record<K, T> to return K[], but it instead returns string[]. Why?

What is a record?

A record of type Keys to Type is an object whose property keys of type Keys are mapped to property values of type Type. For example, a Record<string, number> is an object where any string property will return a number value. For example, obj.someString may return the number 123, because we are accessing a string property of obj: someString.

--

--