# TS2366: Function lacks ending return statement and return type does not include 'undefined'.

> A function with a return type can reach its end without returning. Add a final `return` or `throw`, or include `undefined` in the return type.

## What it means

When a function declares a return type that doesn't include `undefined`, every path through
it must return or throw. A path that falls off the end, such as an `if` without an `else`,
is reported at the return type.

## Example

```ts
export function sign(n: number): string {
  if (n > 0) {
    return "positive";
  } else if (n < 0) {
    return "negative";
  }
}
```

## How to fix

- Return or throw on the remaining path.
- If returning nothing is intended, add `| undefined` to the return type.

Source: https://ts-r.dev/errors/TS2366/
