Skip to content

Instantly share code, notes, and snippets.

@obedparla
Created November 7, 2021 11:49
Show Gist options
  • Save obedparla/71aa775999bb4d91ad193d72f61202dc to your computer and use it in GitHub Desktop.
Save obedparla/71aa775999bb4d91ad193d72f61202dc to your computer and use it in GitHub Desktop.
Correctly gets all Object.keys types for TypeScript (both keys and values types)
export const objectGetTypedKeys = Object.keys as <T extends object>(
obj: T
) => Array<keyof T>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment