core tests
This commit is contained in:
@@ -3,7 +3,15 @@ export interface EntityProps<Id = string> {
|
||||
}
|
||||
|
||||
export abstract class Entity<Id> implements EntityProps<Id> {
|
||||
protected constructor(readonly id: Id) {}
|
||||
protected constructor(readonly id: Id) {
|
||||
// Make the id property truly immutable at runtime
|
||||
Object.defineProperty(this, 'id', {
|
||||
value: id,
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
});
|
||||
}
|
||||
|
||||
equals(other?: Entity<Id>): boolean {
|
||||
return !!other && this.id === other.id;
|
||||
|
||||
Reference in New Issue
Block a user