When working with TypeScript, how should I handle the scenario where
Cat
has anowner: Person
Person
owns apet: Cat
Cat
import {Person} from './person'
export class Cat {
owner: Person
constructor(){
this.owner = new Person()
}
}
Person
import {Cat} from './cat'
export class Person {
pet: Cat
constructor(){
this.pet = new Cat()
}
}
I am hoping for a solution or pattern that does not involve:
- putting both classes in the same file
- introducing a third class
Please don't tell me that the TypeScript compiler overlooked this case :$