Skip to main content
New aislop v0.9.4: four new Python rules from the SlopCodeBench paper, plus a CLI star prompt and GitHub Discussions. Read more →
ai-slop/double-type-assertion manual fix

Double type assertion.

An `as unknown as X` cast — a double-cast escape hatch used when the compiler refuses a direct `as X`. Smuggles types through without validation.

Bad — what an agent ships
const user = data as unknown as User
Good — what aislop hands back
// Either: declare a parser and validate at runtime
const user = UserSchema.parse(data)
// Or: narrow honestly with type guards
if (isUser(data)) { /* data is User here */ }

When TS rejects a single cast with "Type X is not assignable to Y", agents reach for the double cast as the next escape hatch. Same problem, more hidden.

How this rule is justified.

Rule id

ai-slop/double-type-assertion

Enforcing engine

ai-slop

Detector strategy

Deterministic AST match: flags chained assertions of the form `as unknown as T`.

Legitimate code that is NOT flagged

A single deliberate assertion with a reason, or runtime validation that produces the target type, is not flagged.

Evidence

Provenance: repeated across public scans as the follow-on escape hatch once a direct cast is rejected.