Type Challenges Judge

Diff

提出詳細

type Diff<O, O1> = { [K in Exclude<keyof (O & O1), keyof (O | O1)>]: K extends keyof O ? O[K] : K extends keyof O1 ? O1[K] : never }
提出日時2023-08-12 01:18:58
問題Diff
ユーザーtekihei2317
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type Foo = { name: string age: string } type Bar = { name: string age: string gender: number } type Coo = { name: string gender: number } type cases = [ Expect<Equal<Diff<Foo, Bar>, { gender: number }>>, Expect<Equal<Diff<Bar, Foo>, { gender: number }>>, Expect<Equal<Diff<Foo, Coo>, { age: string; gender: number }>>, Expect<Equal<Diff<Coo, Foo>, { age: string; gender: number }>>, ]