Created
September 12, 2021 14:35
-
-
Save tamert/225e7293350d515e28908168b204abff to your computer and use it in GitHub Desktop.
Required
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; | |
} | |
class BookRepository { | |
constructor(private model: Book | {} = {}) {} | |
create( model: Required<Book> ) { | |
// Create model | |
this.model = Object.assign(this.model, model); | |
console.log(this.model); | |
} | |
} | |
let book: BookRepository = new BookRepository(); | |
book.create({ | |
id: 13, | |
subject: 'comedy', | |
title: 'Arsène Lupin, Gentleman Burglar', | |
body: 'Leblanc`s creation, gentleman thief Arsène Lupin, is everything you would expect from a French aristocrat - witty, charming, brilliant, sly ... and possibly the greatest thief in the world.' | |
}); | |
/** | |
* { | |
"id": 13, | |
"subject": "comedy", | |
"title": "Arsène Lupin, Gentleman Burglar", | |
"body": "Leblanc`s creation, gentleman thief Arsène Lupin, is everything you would expect from a French aristocrat - witty, charming, brilliant, sly ... and possibly the greatest thief in the world." | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment