Can someone help me understand why I am consistently encountering this error message from typescript?
PS. I am aware that in this scenario I could simply use a boolean and not create a function, but my focus here is on typescript.
I keep receiving the error: "Not all code paths return a value."
Here is the code snippet:
const isCompleted = (completed: boolean) => {
if(completed) {
return true
} else if(!completed) {
return false
}
}
Interestingly, I do not receive an error when using the following code snippet, however, ideally, I should not be getting any errors either way.
const isCompleted = (completed: boolean) => {
if(completed) {
return true
} else {
return false
}
}