typescript define function on type code example
Example 1: typescript default parameter
function sayName({ first, last = 'Smith' }: {first: string; last?: string }): void {
const name = first + ' ' + last;
console.log(name);
}
sayName({ first: 'Bob' });
Example 2: typescript function type
interface Date {
toString(): string;
setTime(time: number): number;
// ...
}