'Why do I keep getting Not all code paths return a value here?

I'm trying to understand why I keep getting this error from typescript.

PS. I know I would just use the boolean in this case and not create function, this question is more about typescript.

Not all code paths return a value.

Code:

const isCompleted = (completed: boolean) => {
  if(completed) {
    return true
  } else if(!completed) {
    return false
  }
}

I don't get an error, when I just do this, but I shouldn't get an error either way.

const isCompleted = (completed: boolean) => {
  if(completed) {
    return true
  } else {
    return false
  }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source