Last active
September 12, 2021 15:14
-
-
Save tamert/8b46327bbb4ef5a659bffed9f1f5ca2c to your computer and use it in GitHub Desktop.
Omit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Book { | |
id: number; | |
title: string; | |
subject?: 'crime' | 'comedy'; | |
body: string; | |
} | |
type BookPreview = Omit<Book, "id" | "body">; | |
const book: BookPreview = { | |
title: "Arsène Lupin, Gentleman Burglar", | |
subject: 'comedy', | |
}; | |
console.log(book) | |
/** | |
* { | |
"title": "Arsène Lupin, Gentleman Burglar", | |
"subject": "comedy" | |
} | |
*/ | |
const newBook: BookPreview = { | |
title: "The Hobbit", | |
}; | |
console.log(newBook) | |
/** | |
* { | |
"title": "The Hobbit" | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment