Classes, Interfaces, and Object-oriented Programming, 19 Exercises

There is an implementation for the:

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

That looks like this:

interface Address {
    street:string;
    city:string;
    zipCode:number;
}

interfaceEmployee {
    name:string;
    salary:number;
    address:Address;
}

Is this also valid?

interface Address
{
	street: string;
	city: string;
	zipCode: number;
}

interface Employee extends Address
{
	name: string;
	salary: number;
}

In this case you’ll have access to members without going through [address.] to reference sub-members.

Is one form more desirable than the other?

Thank you.

I see it now. The original data had the address sub-member, so it should be done that way.

Takes a little time for my brain to interpret what my eyes see sometimes. :slight_smile: