Back to Type Challenges

README.Ja

questions/00268-easy-if/README.ja.md

latest1.9 KB
Original Source
<!--info-header-start--><h1>If </h1><blockquote><p>by Pavel Glushkov <a href="https://github.com/pashutk" target="_blank">@pashutk</a></p></blockquote><p><a href="https://tsch.js.org/268/play/ja" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.md" target="_blank"></a> <a href="./README.zh-CN.md" target="_blank"></a> <a href="./README.ko.md" target="_blank"></a> </p><!--info-header-end-->

条件値CCが truthy である場合の戻り値の型TCが falsy である場合の戻り値の型Fを受け取るIfを実装します。 条件値Ctruefalseのどちらかであることが期待されますが、TF は任意の型をとることができます。

例えば:

ts
type A = If<true, 'a', 'b'>; // expected to be 'a'
type B = If<false, 'a', 'b'>; // expected to be 'b'
<!--info-footer-start-->

<a href="../../README.ja.md" target="_blank"></a> <a href="https://tsch.js.org/268/answer/ja" target="_blank"></a> <a href="https://tsch.js.org/268/solutions" target="_blank"></a> <!--info-footer-end-->