Skip to content

Commit

Permalink
fix: entity constructor typings
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagozf committed Apr 19, 2020
1 parent 52b8043 commit 83a78ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/Entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { cloneDeep } from 'lodash'
import { PartialDeep } from 'type-fest'
import { Object } from './Object'
import { EntityId } from './EntityId'

Expand Down Expand Up @@ -37,12 +38,12 @@ export abstract class Entity<T> implements Object {
protected readonly _id: EntityId
public readonly props: T = {} as T

constructor(props: T, id: EntityId = new EntityId()) {
constructor(props: PartialDeep<T>, id: EntityId = new EntityId()) {
this._id = id
this.populate(props)
}

public populate(props: T): void {
public populate(props: PartialDeep<T>): void {
Object.assign(this.props, cloneDeep(props))
}

Expand Down

0 comments on commit 83a78ec

Please sign in to comment.