A JavaScript function that reaches its closing brace returns undefined. When some paths return a value and another just ends, that undefined is usually a bug: sign(0) in the example. noImplicitReturns reports the function (TS7030, "Not all code paths return a value").
It is not part of strict; the strict level of the jsconfig generator turns it on.
At a glance
| Write | "noImplicitReturns": true |
|---|---|
| On the command line | --noImplicitReturns |
| Type | boolean |
| Default in TypeScript 5.9 | false |
| TypeScript's description | Enable error reporting for codepaths that do not explicitly return in a function. |
| Generator, relaxed | not written |
| Generator, recommended | not written |
| Generator, strict | true |
The description is quoted from TypeScript's own option list (Apache-2.0); see the notices. The generator rows are what the jsconfig generator writes at each level.
Examples
/** @param {number} n */
export function sign(n) {error TS7030: Not all code paths return a value.
if (n > 0) {
return "positive";
}
if (n < 0) {
return "negative";
}
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": [],
"noImplicitReturns": true
},
"include": [
"*.js"
]
} /** @param {number} n */
export function sign(n) {
if (n > 0) {
return "positive";
}
if (n < 0) {
return "negative";
}
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": [
"*.js"
]
} With a @returns tag
When a function has a JSDoc @returns type that does not include undefined, strict alone already reports a path that falls off the end. This option matters most for functions whose return type is inferred, which in JavaScript is most of them.
Gotchas
- A function that returns nothing on every path is fine; the check is about mixing
return valuewith paths that return nothing.
Sources
- TSConfig Reference: noImplicitReturns · TypeScript
- TypeScript 1.8 release notes · TypeScript handbook
Last reviewed 20 October 2026.