DEV Community

es404020
es404020

Posted on

3

Typescript Utility Pick

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

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay