Type Challenges Judge

Get Required

提出詳細

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