anyAssignments
Reports assigning a value with type
anyto variables and properties.
✅ This rule is included in the ts logical preset.
The any type in TypeScript is a dangerous “escape hatch” from the type system.
Assigning an any typed value to a variable can defeat TypeScript’s type safety guarantees, allowing unexpected types to propagate through your codebase.
This rule reports assigning any to a variable, destructuring from any[], and spreading any[] into typed arrays.
It also checks generic type arguments to ensure you don’t pass an unsafe any in a generic position.
Examples
Section titled “Examples”const value = someFunction() as any;const data = Object.create(null);const items = [] as any[];const [first, second] = getArray() as any[];const value: Set<string> = new Set<any>();const items: string[] = [...(getItems() as any[])];const value: any = someFunction() as any;const value: unknown = someFunction() as any;const items: any[] = [] as any[];const value: Set<any> = new Set<any>();const items: unknown[] = [...(getItems() as any[])];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.
You might consider using lint disable comments for specific situations instead of completely disabling this rule.