Despite your best intentions, the any
type can sometimes leak into your codebase.
Member access on any
typed variables is not checked at all by TypeScript, so it creates a potential safety hole, and source of bugs in your codebase.
This rule disallows member access on any variable that is typed as any
.
Examples of incorrect code for this rule:
declare const anyVar: any;
declare const nestedAny: { prop: any };
anyVar.a;
anyVar.a.b;
anyVar['a'];
anyVar['a']['b'];
nestedAny.prop.a;
nestedAny.prop['a'];
const key = 'a';
nestedAny.prop[key];
Examples of correct code for this rule:
declare const properlyTyped: { prop: { a: string } };
nestedAny.prop.a;
nestedAny.prop['a'];
const key = 'a';
nestedAny.prop[key];
no-explicit-any
- TSLint:
no-unsafe-any