Skip to content

Instantly share code, notes, and snippets.

View alexandersorokin's full-sized avatar

Alexander Sorokin alexandersorokin

View GitHub Profile
@alexandersorokin
alexandersorokin / conditions.js
Created October 27, 2018 14:39 — forked from miyaokamarina/conditions.js
Type-level conditions in Flow https://is.gd/OPsJBd
type $If<X: boolean, Then, Else = empty> = $Call<
& ((true, Then, Else) => Then)
& ((false, Then, Else) => Else),
X,
Then,
Else,
>;
type $Not<X: boolean> = $If<X, false, true>;
type $And<X: boolean, Y: boolean> = $If<X, Y, false>;