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'>