What is the output type of a function declared as `function greet(): string`?

TypeScript Associate Easy

TypeScript Associate — Easy

What is the output type of a function declared as `function greet(): string`?

Key points

  • The return type of the function is explicitly defined as string.
  • This ensures that the function will only return values of type string.
  • The function cannot return any other data type based on the declared return type.

Ready to go further?

Related questions