Required Keys
提出詳細
type RequiredKeys<T> = keyof { [K in keyof T as {} extends Pick<T, K> ? never : K]: T[K] }
提出日時 | 2023-08-13 12:38:07 |
---|---|
問題 | Required Keys |
ユーザー | tekihei2317 |
ステータス | 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>>, ]