Last active
January 19, 2022 01:26
-
-
Save Ray-56/762d862a59e744c8da257cda951e3ff9 to your computer and use it in GitHub Desktop.
Typescript 类型工具集
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
// 反转对象 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