mediumhygiene
TypeScript "any" Usage
Detects usage of the "any" type which disables TypeScript safety.
Why This Is Bad
Using 'any' turns off TypeScript's safety features. It invites bugs and makes refactoring dangerous.
How To Fix
Replace 'any' with proper types:
typescript
// Before (UNSAFE)
function processData(data: any) {
return data.items.map((item: any) => item.name);
}
// After (SAFE)
interface Item {
name: string;
id: number;
}
interface Data {
items: Item[];
}
function processData(data: Data) {
return data.items.map((item) => item.name);
}
// If you truly need flexibility, use 'unknown':
function parseJSON(json: string): unknown {
return JSON.parse(json);
}
// Then narrow with type guards:
if (typeof result === 'object' && result !== null) {
// Now TypeScript knows it's an object
}When You Pass This Check
No 'any' types found. Your code is fully type-safe!
Check If Your Repo Has This Issue
Our free scanner will detect this and 17 other common issues in your codebase.