# @typescript-eslint/no-unsafe-argument

> Disallow passing a value of type `any` as an argument

The compiler accepts `any` for every parameter. If you pass an `any` to a function that wants a `number`, nothing checks that it's a number. The function then runs with whatever came in.

The rule also reports `any` inside a generic type, such as a `Set<any>` passed where a `Set<string>` is expected, and spreading an `any`, an `any[]` or a tuple with an `any` element into the arguments.

`bun lint --type-aware` turns this rule on in TypeScript files.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. This rule needs types, so turning it on makes `bun lint` type check your code first.

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/no-unsafe-argument" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 3} */}
```ts
declare function resize(width: number, height: number): void;
declare function addTags(tags: Set<string>): void;

const config = JSON.parse("{}");

resize(config.width, 100);
resize(...config.size);
addTags(new Set<any>());
```

Not reported:

{/* good */}
```ts
declare function resize(width: number, height: number): void;
declare function addTags(tags: Set<string>): void;

const config = JSON.parse("{}") as { width: number; size: [number, number] };

resize(config.width, 100);
resize(...config.size);
addTags(new Set<string>());
```

A parameter of type `unknown` or `any` accepts an `any`:

{/* good */}
```ts
declare function log(value: unknown): void;
declare function debug(value: any): void;

log(JSON.parse("{}"));
debug(JSON.parse("{}"));
```

## When not to use it

In a codebase that's still moving from JavaScript to TypeScript, `any` is everywhere and the reports drown out everything else. Turn the rule on once most values have real types.
