Type Challenges Judge

Flip

提出詳細

type Flip<T> = { [P in keyof T as T[P] extends true ? "true" : T[P] extends false ? "false" : T[P] extends string | number | symbol ? T[P] : never ]: P }
提出日時2023-08-13 08:58:48
問題Flip
ユーザーookkoouu
ステータスAccepted
テストケース
import type { Equal, Expect, NotEqual } from '@type-challenges/utils' type cases = [ Expect<Equal<{ a: 'pi' }, Flip<{ pi: 'a' }>>>, Expect<NotEqual<{ b: 'pi' }, Flip<{ pi: 'a' }>>>, Expect<Equal<{ 3.14: 'pi'; true: 'bool' }, Flip<{ pi: 3.14; bool: true }>>>, Expect<Equal<{ val2: 'prop2'; val: 'prop' }, Flip<{ prop: 'val'; prop2: 'val2' }>>>, ]