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 }>>, ]