Created
April 14, 2022 02:30
-
-
Save clo4/59288283b97626b0c996e92938b915fb to your computer and use it in GitHub Desktop.
Create groups of properties that must be provided together
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
| type OptionalGroup<T> = T | { [K in keyof T]?: undefined }; | |
| // deno-fmt-ignore | |
| type OptionalGroups<Sets extends unknown[]> = Sets extends [infer Head, ...infer Rest] | |
| ? Rest extends [] | |
| ? OptionalGroup<Head> | |
| : OptionalGroup<Head> & OptionalGroups<Rest> | |
| : Sets; | |
| export type PropertySets<Base, Sets extends unknown[]> = | |
| & Base | |
| & OptionalGroups<Sets>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment