If
introduction#
Implement a utils If which accepts condition C, a truthy return type T, and a falsy return type F. C is expected to be either true or false while T and F can be any type.
For example:
ts
View on GitHubts
start point#
tsTry/* _____________ Your Code Here _____________ */typeIf <C ,T ,F > = any;Â/* _____________ Test Cases _____________ */typecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <If <true, 'a', 'b'>, 'a'>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <If <false, 'a', 2>, 2>>];
take the challengetsTry/* _____________ Your Code Here _____________ */typeIf <C ,T ,F > = any;Â/* _____________ Test Cases _____________ */typecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <If <true, 'a', 'b'>, 'a'>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <If <false, 'a', 2>, 2>>];