Double cast
This is how the comment reads inline, under the flagged line.
Why it matters
A double cast is a lie to the type checker. It hides a real mismatch that will show up as a runtime bug.
What to do
Fix the types at the source, or parse and validate the value.
Examples
const u = data as unknown as User;
const u = UserSchema.parse(data);
What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
const u = d as unknown as User;
Left alone
const u = d as User;
Research
`any`, `as unknown as`, non-null `!`, and shapeless types (`Record<string, any>`, `dict[str, Any]`). Each one turns off type checking for the values it touches.
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"double-cast"
],
"severity": {
"double-cast": "low"
}
}
}
as unknown asforces one type into an unrelated one. The compiler said no; this overrides it.