Skip to content

Instantly share code, notes, and snippets.

@wojtekKrol
wojtekKrol / TypeSafeDynamicKeys.ts
Created January 11, 2024 14:39
TypeScript utility for type-safe dynamic key lookup
export const myObject = {
a: 1,
b: 2,
c: 3,
};
const ObjectKeys = <Obj extends Object>(obj: Obj): (keyof Obj)[] => {
return Object.keys(obj) as (keyof Obj)[];
};