> 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.

# no-unsafe-return

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

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ ts.configs.recommendedTypeChecked | `"error"`        |
| ✅ ts.configs.strictTypeChecked      | `"error"`        |


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

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

## Rule Details

Disallow returning a value with type `any` from a function.

Returning an `any`-typed value from a function that has a typed return type undermines type safety, since the caller will trust the return type but the actual value has no type guarantees. This rule also flags returning `any[]` and `Promise<any>` where the function expects more specific types.

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

```typescript
function foo(): string {
  return 1 as any;
}

function bar(): string[] {
  return [] as any[];
}

const fn = (): Set<string> => new Set<any>();
```

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

```typescript
function foo(): string {
  return 'hello';
}

function bar(): unknown {
  return 1 as any; // returning any to unknown is allowed
}

function baz(): any {
  return 1 as any; // explicit any return type is allowed
}
```

## Original Documentation

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