In the previous article, , we looked at three of the commonly used utility types in Typescript. Utility types in Typescript - Part 1 In this article, we will consider some more examples of built-in utility types provided by Typescript and how we can use them in code. Pick<T, Keys> The utility type creates a new type with only the specified of the input type . Pick Keys T interface Point { x: number; y: number; z: number; } type PointXY = Pick<Point, "x" | "y">; // { // x: number; // y: number; // } In the code above, we have an interface which has as keys. Using the utility type we can create a type by only picking the keys from the interface. Point 'x' | 'y' | 'z' Pick PointXY 'x' | 'y' The utility type is useful if we need to get a subset of properties from an object as seen in the example below. Pick interface User { name: string; age: number; email: string; password: string; address: string; city: string; } type UserAddress = Pick<User, "address" | "city">; const address: UserAddress = { address: "No 1 ABC Street", city: "Port Harcourt", }; Omit<T, Keys> The utility type creates a new type by picking all properties from the input type and then removing the specified . It does the opposite of . Omit T Keys Pick interface Point { x: number; y: number; z: number; } type PointXY = Omit<Point, "z">; // { // x: number; // y: number; // } The utility type is useful if we need to get rid of certain properties from an object (perhaps sensitive information) as seen with the example below. Omit interface User { name: string; age: number; email: string; password: string; address: string; city: string; } type UserProfile = Omit<User, "address" | "city" | "password">; const profile: UserProfile = { name: "Anderson", age: 27, email: "test@test.com", }; Record<K, T> The utility type creates a new object type. The keys in this new object type are the values passed as while the values are what is passed in as . Record K T type Axes = "x" | "y" | "z"; type Point = Record<Axes, number>; // { // x: number; // y: number; // z: number; // } The Record utility type is useful when we want to type an object whose keys have a similar type of value. A common example is while . normalizing complex data interface UserInfo { id: number; name: string; age: number; } const data: UserInfo[] = [ { id: 1, name: "Ande", age: 28, }, { id: 2, name: "Mosa", age: 25, }, ]; const userList: Record<string, UserInfo> = { "1": { id: 1, name: "Ande", age: 28, }, "2": { id: 2, name: "Mosa", age: 25, }, }; Conclusion In this article and the previous one, we have looked at some commonly used utility types provided by Typescript and how we can use them in code. These utility types help developers to avoid hard-coding types. There are a lot more utility types apart from those mentioned in these articles. The Typescript documentation contains a list of . all the available utility types