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
| Code | TS7030 |
|---|---|
| Message | Not all code paths return a value. |
| TypeScript's category | error |
| Listed under | Types 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";
}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
ifchain that covers some cases and falls through for the rest. - A
switchwithout adefaultthat 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";
}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
voidoranyis exempt. A@returns {string | undefined}tag does not exempt it, which is how the strict level of the jsconfig generator finds these. - For a
switchover every member of a union, TS7030 is not reported when TypeScript can see that the cases are exhaustive; anifchain over the same members still ends reachable (compare TS2366).
Sources
- TSConfig Reference: noImplicitReturns · TypeScript
- diagnosticMessages.json (TypeScript 5.9.3) · TypeScript on GitHub
Last reviewed 21 October 2026.