PartialByKeys
提出詳細
type PartialByKeys<T extends object, K extends PropertyKey = keyof T> = Simplify< Omit<T, K> & Partial<Pick<T, Extract<keyof T, K>>> >;
提出日時 | 2025-09-16 06:49:58 |
---|---|
問題 | PartialByKeys |
ユーザー | balckowl |
ステータス | 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>>>, ]