create function with typescript code example
Example 1: how to make a parameter optional in typescript
// Optional parameter
function foo(x?: number) {
console.log("x : "+ x);
}
foo();
foo(6);
Example 2: types function typescript
interface Alternate_Syntax_4_Advanced {
title: string;
callback<T extends unknown[], R = unknown>(...args?: T): R;
}