Type Challenges Judge

Get Required

提出詳細

type IsRequired<T, K extends PropertyKey> = Omit<T, K> extends T ? false : true type GetRequired<T> = { [K in keyof T as IsRequired<T, K> extends true ? K : never]: T[K] }
提出日時2023-08-13 12:09:50
問題Get Required
ユーザーtekihei2317
ステータス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 }>>, ]