sindresorhus / ts-extras

Essential utilities for TypeScript projects
MIT License
587 stars 15 forks source link

Add `objectKeys()` #9

Closed ifiokjr closed 3 years ago

ifiokjr commented 3 years ago

Description

A typed implementation of Object.keys().

This is useful since Object.keys() returns an array of strings. This function returns an array of the type keys of the given object.

@example

import {objectKeys} from 'ts-extras';

type Item = ['a', 'b', 'c'];
declare let: items: Item[];

items = objectKeys({a: 1, b: 2, c: 3}); // This is valid.
sindresorhus commented 3 years ago

Thanks :)