Flip
提出詳細
type Formattable = string | number | bigint | boolean | null | undefined type Flip<T> = { [K in keyof T as `${T[K] & Formattable}`]: K }
提出日時 | 2023-09-18 02:11:11 |
---|---|
問題 | Flip |
ユーザー | sankantsu |
ステータス | 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' }>>>, ]