Partial and Pick
Partial Pick
π¨βπΌ We need to create types for updating user data. Some fields should be
optional, and we only want to allow updating specific fields.
type Article = {
id: string
title: string
body: string
updatedAt: Date
}
type ArticlePatch = Partial<Pick<Article, 'title' | 'body'>>
π¨ Open
and:
- Use
Partial<User>to create a type where all properties are optional - Use
Pick<User, 'name' | 'email'>to create a type with only name and email - Combine them to create
UserUpdatethat only allows updating name and email


