Skip to content

no-any ​

any is not allowed.

Why: any switches off type checking for everything it touches, and it spreads: a value read from an any is any too. unknown says the same thing ("I don't know what this is") but makes you check before using it.

✕ Rejectedno-any
ts
export function length(value: any): number {
  return value.length;
}
✓ Accepted0 diagnostics
ts
export function length(value: unknown): number {
  if (typeof value === "string" || Array.isArray(value)) return value.length;
  return 0;
}

For structured data, validate it into a real type with validate<T>.

Quick fix: Replace any with unknown, then narrow where the value is used.

What the rule can't see: any that you don't write yourself. Lib's is no-hidden-any's: MessageEvent without a type argument, Function, history.state; and std's strict-lib ("types": ["@evobug_com/safe-ts-std/strict-lib"] in tsconfig.json) makes JSON.parse, response.json(), Array.isArray and new Map() give unknown, so tsc refuses the flow. An untyped library's any stays unseen: wrap the call in unsafe(...), which gives unknown for a function returning any.

MIT OR Apache-2.0 · Docs by Gemini 4 Neon Extra