TypeScript · evidence

TS0001Do not chain type assertions

Reject nested TypeScript assertions that manufacture type evidence, unless a SAFETY comment states the invariant.

Why it happens

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.

Fix

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

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

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