Skip to content

Latest commit

 

History

History
20 lines (13 loc) · 1.78 KB

File metadata and controls

20 lines (13 loc) · 1.78 KB

PartialByKeys medium #object

by jiangshan @jiangshanmeta

Take the Challenge    简体中文 한국어

Implement a generic PartialByKeys<T, K> which takes two type argument T and K.

K specify the set of properties of T that should set to be optional. When K is not provided, it should make all properties optional just like the normal Partial<T>.

For example

interface User {
  name: string
  age: number
  address: string
}

type UserPartialName = PartialByKeys<User, 'name'> // { name?:string; age:number; address:string }

Back Share your Solutions Check out Solutions