Skip to content

Instantly share code, notes, and snippets.

@KonstantinBozhkov
Last active November 14, 2021 10:53
Show Gist options
  • Save KonstantinBozhkov/ee025676a59c41940acbda5a411ceb22 to your computer and use it in GitHub Desktop.
Save KonstantinBozhkov/ee025676a59c41940acbda5a411ceb22 to your computer and use it in GitHub Desktop.
Typescript inverse key value type
type V = string | symbol | number;
export type InverseKeyValue<T extends { [K in V]: V }> = T extends { [K in infer A]: infer B }
? B extends V
? { [K in B]: A }
: never
: never;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment