diff --git a/src/config.ts b/src/config.ts index 0762931fd..17f645361 100644 --- a/src/config.ts +++ b/src/config.ts @@ -18,18 +18,16 @@ export namespace Config { export type BaseRequestConfig = RequestConfig; export type Error = AxiosError; - export type Authentication = UtilityTypes.XOR< + export type Authentication = UtilityTypes.XOR3< { personalAccessToken: Authentication.PersonalAccessToken; }, - UtilityTypes.XOR< { basic: Authentication.Basic; }, { oauth2: Authentication.OAuth2; } - > >; export interface Middlewares { diff --git a/src/utilityTypes.ts b/src/utilityTypes.ts index 413c0a564..08972b557 100644 --- a/src/utilityTypes.ts +++ b/src/utilityTypes.ts @@ -4,4 +4,13 @@ export namespace UtilityTypes { /** Get the XOR type which could make 2 types exclude each other */ export type XOR = T | U extends object ? (Without & U) | (Without & T) : T | U; + + export type XOR3 = + (T | U | V) extends (infer R) + ? (R extends T ? (U | V) : R) extends R + ? (R extends U ? (T | V) : R) extends R + ? (R extends V ? (T | U) : never) + : never + : never + : never; }