typescript function arguments interface code example
Example 1: typescript interface function
interface IEmployee {
empCode: number;
empName: string;
getSalary: (number) => number;
getManagerName(number): string;
}
Example 2: ts interface optional parameter
interface Person {
name: string;
age: number;
phone?: string;
}
let p: Person = {name: "Ashlee", age: 29};
console.log(p);
Example 3: typescript interface
interface LabeledValue {
label: string;
}
function printLabel(labeledObj: LabeledValue) {
console.log(labeledObj.label);
}
let myObj = { size: 10, label: "Size 10 Object" };
printLabel(myObj);Try