Last active
November 25, 2018 01:27
-
-
Save babakness/a1ca775f81097ffae04098a8cfdadc60 to your computer and use it in GitHub Desktop.
A collection of partial types which do not allow for excess properties.
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
// Inspired by https://stackoverflow.com/users/2887218/jcalz | |
export type NoExcessStrictPartial<O, P> = { | |
[K in keyof P]: K extends keyof O ? O[K] : never | |
} | |
export type NoExcessDeepPartialValueFlexType<O, P> = { | |
[K in keyof P]: | |
K extends keyof O | |
? NoExcessDeepPartialValueFlexType<O[K],P[K]> | |
: never | |
} | |
export export type NoExcessDeepPartial<O, P> = { | |
[K in keyof P]: | |
K extends keyof O | |
? O[K] extends P[K] | |
? NoExcessDeepPartial<O[K], P[K]> | |
: never | |
: never | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment