export type If = T extends true ? TRUE : FALSE /** * WARNING: https://github.com/ts-essentials/ts-essentials/blob/5aa1f264e77fb36bb3f673c49f00927c7c181a7f/lib/types.ts#L440 * @see https://stackoverflow.com/a/52473108/1815209 with comments * @see https://github.com/millsp/ts-toolbelt/blob/319e551/sources/Any/Equals.ts#L15 */ export type IsEqual = (() => T extends A ? 1 : 2) extends (() => T extends B ? 1 : 2) ? true : false export type IfEqual = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? TRUE : FALSE /** * @example * ``` * // Expect: true * type test1 = BooleanNot * // Expect: false * type test2 = BooleanNot * ``` */ export type BooleanNot = T extends true ? false : true /** * @example * ``` * // Expect: true * type test1 = BooleanAnd * // Expect: false * type test2 = BooleanAnd * // Expect: false * type test3 = BooleanAnd * // Expect: false * type test4 = BooleanAnd * ``` */ export type BooleanAnd = T extends true ? (U extends true ? true : false) : false /** * @example * ``` * // Expect: false * type test1 = BooleanNand * // Expect: true * type test2 = BooleanNand * // Expect: true * type test3 = BooleanNand * // Expect: true * type test4 = BooleanNand * ``` */ export type BooleanNand = T extends true ? (U extends true ? false : true) : true /** * @example * ``` * // Expect: true * type test1 = BooleanOr * // Expect: false * type test2 = BooleanOr * // Expect: true * type test3 = BooleanOr * // Expect: true * type test4 = BooleanOr * ``` */ export type BooleanOr = T extends true ? true : (U extends true ? true : false) /** * @example * ``` * // Expect: false * type test1 = BooleanNor * // Expect: true * type test2 = BooleanNor * // Expect: false * type test3 = BooleanNor * // Expect: false * type test4 = BooleanNor * ``` */ export type BooleanNor = T extends true ? false : (U extends true ? false : true) /** * @example * ``` * // Expect: true * type test1 = BooleanXor * // Expect: false * type test2 = BooleanXor * // Expect: true * type test3 = BooleanXor * // Expect: false * type test4 = BooleanXor * ``` */ export type BooleanXor = T extends true ? (U extends true ? false : true) : (U extends true ? true : false) /** * @example * ``` * // Expect: false * type test1 = BooleanXnor * // Expect: true * type test2 = BooleanXnor * // Expect: false * type test3 = BooleanXnor * // Expect: true * type test4 = BooleanXnor * ``` */ export type BooleanXnor = T extends true ? (U extends true ? true : false) : (U extends true ? false : true)