I have an API which denormalizes data causing circular dependency. Is there a way to refactor the following using abstract classes, interfaces, composition or other techniques where I wouldn't need to create N partial classes for each entity to avoid a circular dependency in my Angular application's type definitions?
model.ts
export abstract class Model {
// ... Model related data members and functions
}
person.ts
import { Model } from './model';
import { Site } from './site';
export class Person extends Model {
// ... Data
site: Site; // Partially or Fully saturated site entity
}
site.ts
import { Model } from './model';
import { Person } from './person';
export class Site extends Model {
// ... Data
people: Person[]; // array of partially saturated people entities, site is left undefined
}
I would like to maintain a single definition for each model, instead of redefining Site
, Person
, etc each time there is a dependency like this.