TypeScript · TS0001

Do not chain type assertions

Reject nested TypeScript assertions that manufacture type evidence, unless a SAFETY comment states the invariant.
TS0001vite-doctor/typescriptevidencewarnSuggestion

Run this rule

pnpm vite-doctor . --rules typescript/evidence/no-chained-type-assertions

Why it matters

Each assertion asks the compiler to trust the author. Chaining assertions can erase the original type before claiming an unrelated result type, so neither the compiler nor a reviewer can verify the conversion.

Keep the original precise type, narrow it with a type guard, or parse untrusted input into the target type. When the chain is necessary, state the invariant in a SAFETY comment immediately before the statement.

Example

Parse before narrowing

Before

const user = input as object as User

After

const user = UserSchema.parse(input)

Document a necessary chain

Before

const driver = db as unknown as SqlDriver

After

// SAFETY: every supported Drizzle SQLite database has the run and all methods of SqlDriver.
const driver = db as unknown as SqlDriver
Copyright © 2026