type Result1 = IfEquals<string, string, true, false>; // is true
type Result2 = IfEquals<number, string, true, false>; // is false
type Result3 = IfEquals<boolean, boolean, true, false>; // is true
type IsExactlyString<T> = IfEquals<T, string, true, false>;
type IsExactlyNumber<T> = IfEquals<T, number, true, false>;
type TestString = IsExactlyString<string>; // is true
type TestNumber = IsExactlyNumber<number>; // is false
type TestBoolean = IsExactlyString<boolean>; // is false
Conditional type that checks if type
T
is equal to typeP
. IfT
is equal toP
, the type resolves toDo
, otherwiseElse
.