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