Type Challenges Judge

Get Optional

提出詳細

type GetOptional<T,U=Required<T>> = { [K in keyof T as K extends keyof U ? T[K] extends U[K] ? never : K : never]: T[K] }
提出日時2023-09-22 15:36:10
問題Get Optional
ユーザーsankantsu
ステータス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 }>>, ]