TypeScript types Object.keys to return string[] instead of (keyof T)[] due to its structural type system. Because an object typed as T may contain additional properties at runtime that TypeScript isn't aware of, returning keyof T would be unsafe — it could lead to accessing undefined validators or properties. The post explains
Sort: