Data Type - Interface (Abstract Type) in Typescript
An interface is a type that describes objects
In TypeScript, two types are compatible if their internal structure is compatible.
An interface can be implemented just by having the same structure that the interface requires, without an explicit implements clause.
interface Person {
firstName: string;
lastName: string;
}
function greeter(person: Person) {
return "Hello, " + person.firstName + " " + person.lastName;
}
let user = { firstName: "Jane", lastName: "User" };
document.body.textContent = greeter(user);