Type Challenges Judge

Get Optional

提出詳細

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