Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 708 Bytes

consistent-return.md

File metadata and controls

32 lines (25 loc) · 708 Bytes
description
Require `return` statements to either always or never specify values.

🛑 This file is source code, not the primary documentation location! 🛑

See https://typescript-eslint.io/rules/consistent-return for documentation.

This rule extends the base eslint/consistent-return rule. This version adds support for functions that return void type.

❌ Incorrect

function foo(): undefined {}
function bar(flag: boolean): undefined {
  if (flag) return foo();
  return;
}

✅ Correct

function foo(): void {}
function bar(flag: boolean): void {
  if (flag) return foo();
  return;
}