Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
feat: add require only one type
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jun 5, 2020
1 parent 76530f1 commit bf57f3f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/sections/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* For use with parameters that require one of two values
*/

type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &
{
[K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>
}[Keys]

0 comments on commit bf57f3f

Please sign in to comment.