We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Void

The TS-specific void type represents the return value of functions that don't return a value.

function logMessage(message: string): void {
  console.log(message);
  // nothing is returned here!
}

In JavaScript, a function without a return statement returns undefined by default... but that's kinda vague. TypeScript uses the void keyword to indicate that truly nothing is returned.

In other words, void more explicitly communicates the intent that a function returns nothing.

Assignment

Hover the logSystemEvent function to see that it returns void. The problem is, at Support.ai, we don't want to simply log our logs to the console, we want to do other things, like store them in a remote database.

Update the logSystemEvent function to return the log as a string instead of logging it to the console.