Fika-Tarkov/mods/Raid Review/user/mods/raid_review__0.3.0/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-call.md

59 lines
1.2 KiB
Markdown

---
description: 'Disallow calling a value with type `any`.'
---
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-unsafe-call** for documentation.
The `any` type in TypeScript is a dangerous "escape hatch" from the type system.
Using `any` disables many type checking rules and is generally best used only as a last resort or when prototyping code.
Despite your best intentions, the `any` type can sometimes leak into your codebase.
Calling an `any`-typed value as a function creates a potential type safety hole and source of bugs in your codebase.
This rule disallows calling any value that is typed as `any`.
## Examples
<!--tabs-->
### ❌ Incorrect
```ts
declare const anyVar: any;
declare const nestedAny: { prop: any };
anyVar();
anyVar.a.b();
nestedAny.prop();
nestedAny.prop['a']();
new anyVar();
new nestedAny.prop();
anyVar`foo`;
nestedAny.prop`foo`;
```
### ✅ Correct
```ts
declare const typedVar: () => void;
declare const typedNested: { prop: { a: () => void } };
typedVar();
typedNested.prop.a();
(() => {})();
new Map();
String.raw`foo`;
```
## Related To
- [`no-explicit-any`](./no-explicit-any.md)