Subsequent property declarations must have the same type

Hi,
I am doing the exercise where I need to define an interface for the object but I am having an issue and the error says

Subsequent property declarations must have the same type

following is my code

interface Employee  {
 name: string;
 salary: number;
 address: object
}

let employee = {name:'John Smith',salary:50_000,address:{street:'Flinders st',city:'Melbourne',zipCode:3144,},};

What am I missing or doing wrong? Why can’t the interface have a different type of types?

I am assuming this is TypeScript due to the type annotations (in spite of the JavaScript category).

I tried this over in TypeScript playground and it did not give me any errors - I feel like you must be skipping some of the code that is triggering the issue. As written, you are not even declaring that employee is an Employee object.

1 Like