Skip to content

Instantly share code, notes, and snippets.

@Ray-56
Last active January 19, 2022 01:26
Show Gist options
  • Save Ray-56/762d862a59e744c8da257cda951e3ff9 to your computer and use it in GitHub Desktop.
Save Ray-56/762d862a59e744c8da257cda951e3ff9 to your computer and use it in GitHub Desktop.
Typescript 类型工具集
// 反转对象 key value
type ReverseObject<T extends Record<keyof T, keyof any>> = {
[P in T[keyof T]]: {
[K in keyof T]: T[K] extends P ? K : never;
}[keyof T];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment