In JavaScript primitive values don't have any properties. They are not objects.
But in runtime JavaScript wraps primitive values into the corresponding wrapper objects.
When using keyof
with types of primitive values, the operator gets all types of keys from object wrapper (String()
, Number()
, etc.).