keys

Commons
stable

Type-safe wrapper around Object.keys(). Returns the keys of a plain object typed as (keyof O)[] instead of string[], preserving the original key union.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

o
required
O
The object whose keys are returned. The generic O is inferred from the argument.

API

Return value

The value returned by this util.

An array of the object's own enumerable property keys, typed as (keyof O)[].

Usage

Examples

Ready-to-paste usage snippets.

Type-safe key iteration

typescript