Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add PickEither #13

Open
uladkasach opened this issue Jun 13, 2023 · 1 comment
Open

add PickEither #13

uladkasach opened this issue Jun 13, 2023 · 1 comment

Comments

@uladkasach
Copy link
Member

to start with, allow two options:

type PickOnly<T, U> = {
  [P in keyof T]: T[P];
} & {
  [P in keyof U]?: never;
};

type PickEither<T, U> = PickOnly<T, U> | PickOnly<U, T>;

https://stackoverflow.com/questions/37688318/typescript-interface-possible-to-make-one-or-the-other-properties-required


ideally, allow 2+ options

@uladkasach
Copy link
Member Author

actually, that implementation above does not allow typescript to guarantee that pairs of types are defined together

so, will need a better impelmentation than that to star even

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant