Interface
Little Background
function printMe(obj){
console.log(obj.name);
}
printMe({ name: "Kamal" }); // Kamal
printMe({ age: 20 }); // undefined
// solution to above problem
interface person{
name: string;
age?: Number; // optional
}
function printMe(obj: person){
console.log(obj.name, obj.age || 12);
}
printMe({ name: "Kamal" });Basic Interfaces
Optional Properties
Function types
Array Types
Class Types
Extending Interfaces
Hybrid Interfaces
Last updated