Created
September 22, 2020 10:08
-
-
Save JerryC8080/c14d5051a395ea213f14a09dd47f71b7 to your computer and use it in GitHub Desktop.
深度构造类型 DeepRecord
This file contains hidden or 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
/** | |
* MAP: 需要遍历的类型 | |
* MATCH: 断言类型 | |
* TYPE: 需要改变的类型 | |
*/ | |
export type DeepRecord<MAP, MATCH, TO> = { | |
[P in keyof MAP]: MAP[P] extends MATCH ? TO : DeepRecord<MAP[P], MATCH, TO>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment