anyArguments
Reports calling a function with a value typed as
anyas an argument.
✅ This rule is included in the ts logical preset.
Passing a value typed as any as a function argument defeats TypeScript’s type safety guarantees.
The any type bypasses type checking, allowing unexpected types to propagate through your codebase and potentially cause runtime errors.
This rule also detects spreading arrays or tuples with any typed elements as function arguments.
Examples
Section titled “Examples”declare const value: any;declare function processString(input: string): void;
processString(value);
declare const values: any[];declare function logAll(...items: string[]): void;
logAll(...values);declare const value: string;declare function processString(input: string): void;
processString(value);
declare const values: string[];declare function logAll(...items: string[]): void;
logAll(...values);
// Passing any to unknown is alloweddeclare function acceptUnknown(input: unknown): void;declare const unsafeValue: any;acceptUnknown(unsafeValue);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 types or areas of unsafe code, it may be difficult to enable this rule.
Consider using ESLint disable comments for specific situations while working to improve type safety incrementally.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.