Skip to content

anyMemberAccess

Reports member access on a value with type any.

✅ This rule is included in the ts logical and logicalStrict presets.

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
const value: any
value
: any;
const value: any
value
.
any
property
;
declare const
const value: any
value
: any;
const value: any
value
["property"];
declare const
const value: any
value
: any;
const value: any
value
.
any
a
.
any
b
.
any
c
;
declare const
const obj: {
a: number;
}
obj
: {
a: number
a
: number };
declare const
const key: any
key
: any;
const obj: {
a: number;
}
obj
[
const key: any
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 Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.

Made with ❤️‍🔥 around the world by the Flint team and contributors.