Last active
December 4, 2018 13:01
-
-
Save lusbuab/c2efe3728102aa8651fa3ed14a47f934 to your computer and use it in GitHub Desktop.
This file contains 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
import { Record } from 'immutable' | |
interface PersonProps { | |
firstName: string | |
lastName: string | |
} | |
const defaultPersonProps: PersonProps = { | |
firstName: '', | |
lastName: '', | |
} | |
class Person extends Record(defaultPersonProps) implements PersonProps { | |
public readonly firstName!: string | |
public readonly lastName!: string | |
public constructor(values?: Partial<PersonProps>) { | |
values ? super(values) : super() | |
} | |
get fullName() { | |
return `${this.firstName} ${this.lastName}`.trim() | |
} | |
} | |
const jane = new Person({ firstName: 'Jane', lastName: 'Doe' }) | |
console.log(`Hi, this is ${jane.fullName}!`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment