TypeScript error

TS7030: A path that returns no value, under noImplicitReturns

  • Error TS7030
  • Reported with noImplicitReturns
  • Tested with TypeScript 5.9

With noImplicitReturns on, a function that returns a value somewhere must return one on every path. A path that reaches the end of the function returns undefined without saying so, and TS7030 points at it.

In a .js file the error lands on the function name, or on the type in its @returns tag when the function has one.

At a glance

CodeTS7030
MessageNot all code paths return a value.
TypeScript's categoryerror
Listed underTypes do not match
Turned on by noImplicitReturns
In .js files Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file

The message is TypeScript's own text from its diagnostic messages file (Apache-2.0).

What it looks like

status.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: status.js(3,17): error TS7030: Not all code paths return a value. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. status.js(3,17): error TS7030: Not all code paths return a value. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. status.js(3,17): error TS7030: Not all code paths return a value. checked 21 October 2026
/** @param {"paid" | "refunded" | "open"} status */
export function label(status) {error TS7030: Not all code paths return a value.
  if (status === "paid") return "Paid";
  if (status === "refunded") return "Refunded";
}
A path through the function that returns nothing, under noImplicitReturns.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": [],
    "noImplicitReturns": true
  },
  "include": ["**/*.js"]
}

What causes it

  • An if chain that covers some cases and falls through for the rest.
  • A switch without a default that returns, or a loop that returns from inside.

How to fix it

Return a value on every path

Add the missing return, or a final one. If undefined is a real result, write return undefined; so the intent is visible.

status.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
/** @param {"paid" | "refunded" | "open"} status */
export function label(status) {
  if (status === "paid") return "Paid";
  if (status === "refunded") return "Refunded";
  return "Open";
}
Every path returns a value.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": [],
    "noImplicitReturns": true
  },
  "include": ["**/*.js"]
}

Gotchas

  • A function whose return type includes void or any is exempt. A @returns {string | undefined} tag does not exempt it, which is how the strict level of the jsconfig generator finds these.
  • For a switch over every member of a union, TS7030 is not reported when TypeScript can see that the cases are exhaustive; an if chain over the same members still ends reachable (compare TS2366).

Sources

Last reviewed 21 October 2026.