Skip to content

anyMemberAccess

Reports member access on a value with type any.

✅ This rule is included in the ts logical preset.

Accessing a member of a value typed as any creates a potential type safety hole and source of bugs. TypeScript cannot verify that the member exists or what type it has. This rule disallows member access on any variable that is typed as any.

This includes:

  • Property access on any typed values (e.g., anyValue.property)
  • Element access on any typed values (e.g., anyValue[0])
  • Using any typed values as computed property keys (e.g., obj[anyKey])
declare const value: any;
value.property;
declare const value: any;
value["property"];
declare const value: any;
value.a.b.c;
declare const obj: { a: number };
declare const key: any;
obj[key];

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.