mirror of
https://github.com/type-challenges/type-challenges.git
synced 2025-12-08 19:06:13 +00:00
1.6 KiB
1.6 KiB
OptionalUndefined
by Jesus The Hun @JesusTheHun
Implement the util type OptionalUndefined<T, Props> that turns all the properties of T that can be undefined, into optional properties. In addition, a second -optional- generic Props can be passed to restrict the properties that can be altered.
OptionalUndefined<{ value: string | undefined, description: string }>
// { value?: string | undefined; description: string }
OptionalUndefined<{ value: string | undefined, description: string | undefined, author: string | undefined }, 'description' | 'author'>
// { value: string | undefined; description?: string | undefined, author?: string | undefined }