Check out example codes for "typescript function". It will help you in understanding the concepts better.

Code Example 1

export interface callback {
  handleChange: Function;
  filterFunction: Function;
  setStateFunction: Function;
}

The global type Function serves this purpose.

Additionally, if you intend to invoke this callback with 0 arguments and will ignore its return value, the type () => void matches all functions taking no arguments.

Code Example 2

// Named function
function add(x: number, y: number): number {
  return x + y;
}

// Anonymous function
let myAdd = function (x: number, y: number): number {
  return x + y;
};

Code Example 3

function sayName({ first, last = 'Smith' }: {first: string; last?: string }): void {
  const name = first + ' ' + last;
  console.log(name);
}

sayName({ first: 'Bob' });

Code Example 4

function add(x: number, y: number): number {
  return x + y;
}

Learn ReactJs, React Native from akashmittal.com