Skip to content

Instantly share code, notes, and snippets.

@tamert
Created September 12, 2021 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamert/d7c4f95b4aac0f25b8786d6fb11008de to your computer and use it in GitHub Desktop.
Save tamert/d7c4f95b4aac0f25b8786d6fb11008de to your computer and use it in GitHub Desktop.
Pick
interface Book {
id: number;
title: string;
subject?: 'crime' | 'comedy';
body: string;
}
type BookPreview = Pick<Book, "title" | "subject">;
const book: BookPreview = {
title: "Arsène Lupin, Gentleman Burglar",
subject: 'comedy',
};
console.log(book)
/**
* {
"title": "Arsène Lupin, Gentleman Burglar",
"subject": "comedy"
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment