Get Required
提出詳細
type GetRequired<T, U extends Required<T> = Required<T>, K extends keyof T = keyof T> = Pick<T, K extends keyof T ? T[K] extends U[K] ? K : never : never>
提出日時 | 2023-08-08 10:43:52 |
---|---|
問題 | Get Required |
ユーザー | ookkoouu |
ステータス | 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 }>>, ]