> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# explicit-function-return-type

[Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/explicit-function-return-type': 'error',
    },
  },
]);
```

## Rule Details

Require explicit return types on functions and class methods.

Functions in TypeScript often don't need to be given an explicit return type annotation. Leaving off the return type is less code to read or write and allows the compiler to infer it from the contents of the function. However, explicit return types do make it visually more clear what type is returned by a function and can speed up TypeScript type checking performance in large codebases.

Examples of **incorrect** code for this rule:

```typescript
function test() {
  return;
}

var fn = function () {
  return 1;
};

var arrowFn = () => 'test';

class Test {
  method() {
    return;
  }
}
```

Examples of **correct** code for this rule:

```typescript
function test(): void {
  return;
}

var fn = function (): number {
  return 1;
};

var arrowFn = (): string => 'test';

class Test {
  method(): void {
    return;
  }
}
```

## Original Documentation

- [typescript-eslint: explicit-function-return-type](https://typescript-eslint.io/rules/explicit-function-return-type)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/explicit-function-return-type.ts)
