DEV Community

es404020
es404020

Posted on

2

Typescript Utility Partial

Partial

Constructs a type with all properties of Type set to optional. This utility will return a type that represents all subsets of a given type.

example

interface Todo {
  title: string;
  description: string;
}

function updateTodo(todo: Todo, fieldsToUpdate: Partial<Todo>) {
  return { ...todo, ...fieldsToUpdate };
}

const todo1 = {
  title: "organize desk",
  description: "clear clutter",
};

const todo2 = updateTodo(todo1, {
  description: "throw out trash",
})
Enter fullscreen mode Exit fullscreen mode

Released:
2.1

Reference :Typescript official docs

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more