jsconfig.json option

noImplicitReturns

  • Default false
  • Since TypeScript 1.8

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

main.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: main.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. main.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. main.js(3,17): error TS7030: Not all code paths return a value. checked 21 October 2026
/** @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";
  }
}
noImplicitReturns on: zero falls off the end.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": [],
    "noImplicitReturns": true
  },
  "include": [
    "*.js"
  ]
}
main.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 {number} n */
export function sign(n) {
  if (n > 0) {
    return "positive";
  }
  if (n < 0) {
    return "negative";
  }
}
noImplicitReturns off: sign(0) returns undefined unnoticed.
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 value with paths that return nothing.

Sources

Last reviewed 20 October 2026.