Skip to content

anyCalls

Reports calling a value with type any.

✅ This rule is included in the ts logical preset.

Calling a value typed as any creates a potential type safety hole and source of bugs. TypeScript cannot verify that the value is actually a function, what parameters it expects, or what it returns. This rule disallows calling any value that is typed as any or Function.

This includes:

  • Regular function calls on any typed values
  • Constructor calls with new on any typed values
  • Tagged template literals using any typed values as the tag

The Function type behaves almost identically to any when called, so this rule also disallows calling values of type Function that have no call or construct signatures.

declare const value: any;
value();
declare const value: any;
value.property();
declare const value: any;
new value();
declare const value: any;
value`template`;
declare const value: Function;
value();

This rule is not configurable.

If your codebase has many existing any values or areas of unsafe code, enabling this rule may be challenging. It may be more practical to defer enabling this rule until type safety has been improved in those areas. You might consider using lint disable comments for specific situations instead of completely disabling this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.