Typescript: interface
interface Owner {
name: string;
gender: string;
}
interface Vehicle {
name: string;
year: Date;
broken: boolean;
owner: Owner;
summary: () => string;
}
const civic: Vehicle = {
name: "civic",
year: new Date(),
broken: true,
owner: { name: "yenonn", gender: "male" },
summary: function (): string {
return `summary: name ${this.name} year: ${this.year} broken: ${this.broken} owned by ${this.owner.name}`;
},
};
console.log(civic.summary());