Created
March 13, 2023 12:24
-
-
Save barinbritva/ce5cc1f909d44368eb6ba28e597dcf3f to your computer and use it in GitHub Desktop.
typesafe objectEntries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/74891854/3359277 | |
export function typeSafeObjectEntries< | |
T extends { [key: string | number | symbol]: unknown }, | |
K extends keyof T, | |
V extends T[K] | |
>(o: T) { | |
return Object.entries(o) as unknown as [K, V][]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment