Type Challenges Judge

Required Keys

提出詳細

type RequiredKeys<T extends object> = keyof { [P in keyof T as {} extends Pick<T, P> ? never:P]: T[P]; };
提出日時2022-06-28 10:32:35
問題Required Keys
ユーザーwaki285
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<RequiredKeys<{ a: number; b?: string }>, 'a'>>, Expect<Equal<RequiredKeys<{ a: undefined; b?: undefined }>, 'a'>>, Expect<Equal<RequiredKeys<{ a: undefined; b?: undefined; c: string; d: null }>, 'a' | 'c' | 'd'>>, Expect<Equal<RequiredKeys<{}>, never>>, ]