Type Challenges Judge

Get Required

提出詳細

type GetRequired<T extends object> = { [P in keyof T as {} extends Pick<T, P> ? never:P]: T[P]; }
提出日時2022-06-28 10:30:13
問題Get Required
ユーザーwaki285
ステータス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 }>>, ]