Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 1.28 KB

no-unsafe-call.md

File metadata and controls

75 lines (50 loc) · 1.28 KB

no-unsafe-call

Disallows calling a value with type any.

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:

❌ Incorrect

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

declare const typedVar: () => void;
declare const typedNested: { prop: { a: () => void } };

typedVar();
typedNested.prop.a();

(() => {})();

new Map();

String.raw`foo`;

Options

// .eslintrc.json
{
  "rules": {
    "@typescript-eslint/no-unsafe-call": "error"
  }
}

This rule is not configurable.

Related To

Attributes

  • Configs:
    • ✅ Recommended
    • 🔒 Strict
  • 🔧 Fixable
  • 💭 Requires type information