type User = {
id: string
email: string
plan: 'free' | 'pro'
}
const user = response.body as unknown as User
sendWelcomeEmail(user.email)
Deterministic AST match: flags chained assertions of the form `as unknown as T`.
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.
Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.
type User = {
id: string
email: string
plan: 'free' | 'pro'
}
const user = response.body as unknown as User
sendWelcomeEmail(user.email)
Deterministic AST match: flags chained assertions of the form `as unknown as T`.
const user = UserSchema.parse(response.body)
sendWelcomeEmail(user.email)
Replace the double assertion with runtime validation, a parser, or a type guard. If you really need an assertion, assert once to a concrete type and document why the compiler cannot know it.
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.
ai-slop/double-type-assertion
ai-slop
Deterministic AST match: flags chained assertions of the form `as unknown as T`.
A single deliberate assertion with a reason, or runtime validation that produces the target type, is not flagged.
Provenance: repeated across public scans as the follow-on escape hatch once a direct cast is rejected.