skip to content
Alvin Lucillo

Using Pick

/ 1 min read

Pick is a utility type that allows you to create a type based on another type’s selected properties. In the example below, PublicUser does not include password.

type User = {
	id: string;
	name: string;
	password: string;
};

type PublicUser = Pick<User, "id" | "name">;

const u: PublicUser = {
	id: "1",
	name: "User1",
};