Skip to content
Latchkey

TS7030: Not all code paths return a value - in CI

With noImplicitReturns enabled, some branch of a function returns a value while another implicitly returns undefined.

What this error means

Type-checking fails with TS7030 pointing at a function where one path returns and another does not.

tsc
src/pick.ts(2,29): error TS7030: Not all code paths return a value.

Common causes

How to fix it

Make every branch return

  1. Add returns to the missing branches or a trailing return
ts
function pick(x: number) {
  if (x > 0) return "pos"
  if (x < 0) return "neg"
  return "zero"
}

Return undefined explicitly

  1. If returning nothing is intended, return undefined and reflect it in the type

How to prevent it

  • Keep noImplicitReturns on so missing returns fail in CI rather than producing accidental undefined.

Frequently asked questions

What causes "TS7030 not all paths return"?
Type-checking fails with TS7030 pointing at a function where one path returns and another does not.
How do I fix TS7030 not all paths return?
Make every branch return

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card