Skip to contentSlop Block

no-chained-type-assertions

Error

Do not chain type assertions such as x as unknown as User.

const user = input as object as User;Do not chain type assertions
const user = input as unknown as User;Do not chain type assertions
// ast-grep-ignore: no-chained-type-assertions-typescript

How to fix

The compiler trusts x as unknown as User without checking the value. Parse the value at the boundary, or fix the type at its source.