Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A collection of partial types which do not allow for excess properties.
// 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