Type Challenges Judge

Get Optional

提出詳細

type GetOptional<T, U extends Required<T> = Required<T>, K extends keyof T = keyof T> = Pick<T, K extends keyof T ? T[K] extends U[K] ? never : K : never>
提出日時2023-08-08 10:43:06
問題Get Optional
ユーザーookkoouu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<GetOptional<{ foo: number; bar?: string }>, { bar?: string }>>, Expect<Equal<GetOptional<{ foo: undefined; bar?: undefined }>, { bar?: undefined }>>, ]