Skip to content

Instantly share code, notes, and snippets.

@lusbuab
Last active December 4, 2018 13:01
Show Gist options
  • Save lusbuab/c2efe3728102aa8651fa3ed14a47f934 to your computer and use it in GitHub Desktop.
Save lusbuab/c2efe3728102aa8651fa3ed14a47f934 to your computer and use it in GitHub Desktop.
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