ObjectEntries
提出詳細
type ObjectEntries<T, T2 = Required<T>> = { [P in keyof T2]: [P, [T2[P]] extends [never] ? undefined : T2[P]] }[keyof T2]
提出日時 | 2024-09-11 11:11:09 |
---|---|
問題 | ObjectEntries |
ユーザー | ookkoouu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' interface Model { name: string age: number locations: string[] | null } type ModelEntries = ['name', string] | ['age', number] | ['locations', string[] | null] type cases = [ Expect<Equal<ObjectEntries<Model>, ModelEntries>>, Expect<Equal<ObjectEntries<Partial<Model>>, ModelEntries>>, Expect<Equal<ObjectEntries<{ key?: undefined }>, ['key', undefined]>>, Expect<Equal<ObjectEntries<{ key: undefined }>, ['key', undefined]>>, ]