Typescript Utility Pick

es404020 - Sep 5 '21 - - Dev Community

Pick

Constructs a type by picking the set of properties Keys (string literal or union of string literals) from Type.


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

type TodoPreview = Pick<Todo, "title" | "completed">;

const todo: TodoPreview = {
  title: "Clean room",
  completed: false,
};

todo;


Enter fullscreen mode Exit fullscreen mode

reference:Offical typescript docs

Released:
2.1

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player