Objects within objects in TypeScript

Objects can contain other objects described by separate interfaces. Let's look at examples.

Let's say we have an interface that describes an object with a city:

typescriptinterface City {
  name: string
}

Let's also make an interface that describes the user. The user will have a name, age, and city, which in turn is an object:

typescriptinterface User {
  name: string,
  age: number,
  city: City
}

Let's create an object with a user:

typescriptlet city: City = {name: 'london'};
let user: User = {name: 'john', age: 30, city: city};

It is not necessary to create a separate variable for the city:

typescriptlet user: User = {
  name: 'john',
  age: 30,
  city: {name: 'london'}
};
Задание 1

Given object:

typescriptlet employee {
  name: 'andrew',
  potision: {
    name: 'programmer'
    salary: 1000,
  },
  addr: {
    country: 'belarus',
    city: 'minsk'
  }
};

Create an interface that describes the structure of this object. Move nested objects into separate interfaces.

Задание 2

Given object:

typescriptlet user: User = {
  name: 'john',
  age: 30,
  parents: {
    mother: {
      name: 'jane',
      age: 30,
      parents: null
    },
    father: {
      name: 'eric',
      age: 30,
      parents: null
    }
  }
}

Create an interface that describes the structure of this object. Move nested objects into separate interfaces.