export interface EntityProps { readonly id: Id; } export abstract class Entity implements EntityProps { 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): boolean { return !!other && this.id === other.id; } } // Alias for backward compatibility export type EntityAlias = EntityProps;