Type Challenges Judge

If

提出詳細

type If<T extends Boolean, U, K> = T extends true ? U : K
提出日時2025-02-17 08:48:12
問題If
ユーザーbalckowl
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<If<true, 'a', 'b'>, 'a'>>, Expect<Equal<If<false, 'a', 2>, 2>>, ] // @ts-expect-error type error = If<null, 'a', 'b'>