author avatar

adithya.hebbar

Thu May 23 2024

Utility Types:
TypeScript's Utility Types simplify complex type manipulations. For instance, Partial<T> makes all properties of type T optional



interface User {
    id: number;
    name: string;
    email: string;
}

function displayUser(user: Partial<User>) {
    console.log(user);
}

displayuser({ name: "Joe Mama" }); // Partial<T> will make the properties optional hence this is valid


#javascript #typescript