Tagged articles
2 articles
Page 1 of 1
Code Mala Tang
Code Mala Tang
Sep 5, 2024 · Frontend Development

Why Object.keys Fails in TypeScript and How to Fix It

This article explains why iterating over object keys with Object.keys in TypeScript often yields unexpected results, analyzes the underlying type‑system reasons, and presents four practical solutions—including type assertions, type predicates, generic functions, and wrapper utilities—to reliably access object properties.

Object.keysType SafetyTypeScript
0 likes · 6 min read
Why Object.keys Fails in TypeScript and How to Fix It
ELab Team
ELab Team
Feb 24, 2022 · Frontend Development

How to Recursively Extract All Keys from a TypeScript Interface with DeepKeyOf

This article explains how TypeScript's built‑in keyof operator can be extended with a recursive generic type called DeepKeyOf to enumerate every nested property path of an interface, illustrating the concept of type gymnastics, showing step‑by‑step implementations, and highlighting practical benefits for type‑safe code.

DeepKeyOfGeneric TypesTypeScript
0 likes · 14 min read
How to Recursively Extract All Keys from a TypeScript Interface with DeepKeyOf