Sobes.tech
Intern

What type does a synchronous function return?

sobes.tech AI

Answer from AI

The return type of a synchronous function is determined by the data type specified in its declaration (if specified) or by the data type actually returned from it. For example:

// Function returns a string
function getString(): string {
  return "Hello";
}

// Function returns a number (type not specified, but clearly visible from the return value)
function getNumber() {
  return 123;
}