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
anytyped values - Constructor calls with
newonanytyped values - Tagged template literals using
anytyped 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.
Examples
Section titled “Examples”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();declare const value: () => void;value();declare const object: { method(): void };object.method();declare class Constructor {}new Constructor();const tag = (strings: TemplateStringsArray, ...values: unknown[]) => strings[0];tag`template`;interface SafeFunction extends Function { (): void;}declare const value: SafeFunction;value();Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
@typescript-eslint/no-unsafe-call - Oxlint:
typescript/no-unsafe-call