TypeScript · evidence
TS0009Keep known evidence through local assertions
Detect immutable local values widened to a broad type and later asserted to a concrete type.
vite-doctor/typescriptevidencewarnNo fix
Why it happens
Widening a known value before asserting a new type separates the unsupported claim from its evidence. This rule follows immutable local aliases within one function; imported types and cross-function flows are outside its analysis.
Fix
Preserve the original inferred type, or validate the value before claiming a different type.
Example
Keep known evidence through local assertions
Before
const value = { id: 1 }; const erased: unknown = value; const user = erased as User
After
const value = { id: 1 }; const user = UserSchema.parse(value)
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --extends auto,typescript/strict --rules typescript/evidence/no-widen-then-assert