Type Challenges Judge

PartialByKeys

提出詳細

type PartialByKeys_<T, K extends keyof T = keyof T> = Partial<T> & Omit<T, K>; type PartialByKeys<T, K extends keyof T = keyof T> = MergeInsertions< PartialByKeys_<T, K> >; export type MergeInsertions<T> = T extends object ? { [K in keyof T]: MergeInsertions<T[K]> } : T;
提出日時2023-05-25 04:31:27
問題PartialByKeys
ユーザーmrsekut
ステータスWrong Answer
テストケース
import type { Equal, Expect } from '@type-challenges/utils' interface User { name: string age: number address: string } interface UserPartialName { name?: string age: number address: string } interface UserPartialNameAndAge { name?: string age?: number address: string } type cases = [ Expect<Equal<PartialByKeys<User, 'name'>, UserPartialName>>, Expect<Equal<PartialByKeys<User, 'name' | 'unknown'>, UserPartialName>>, Expect<Equal<PartialByKeys<User, 'name' | 'age'>, UserPartialNameAndAge>>, Expect<Equal<PartialByKeys<User>, Partial<User>>>, ]