Urara-Blog/node_modules/.pnpm-store/v3/files/17/ad3bb3b63aa7834c2eadb9f7040eb32f5ee9a0dc8f04c2da3e7ceafc00c0760d7147657cfd320e22a1906b6e044dda762293f90bea454421a8d1d81ff8d5ce
2022-08-14 01:14:53 +08:00

70 lines
1.2 KiB
Text

---
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.
Despite your best intentions, the `any` type can sometimes leak into your codebase.
The arguments to, and return value of calling an `any` typed variable are not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase.
## Rule Details
This rule disallows calling any variable that is typed as `any`.
Examples of code for this rule:
<!--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`;
```
## Options
```jsonc
// .eslintrc.json
{
"rules": {
"@typescript-eslint/no-unsafe-call": "error"
}
}
```
This rule is not configurable.
## Related To
- [`no-explicit-any`](./no-explicit-any.md)