TypeScript · evidence
TS0011Preserve known values in local declarations
Detect local annotations that discard known values or object keys.
vite-doctor/typescriptevidencewarnNo fix
Why it happens
Broad annotations can discard useful evidence from an initializer. This rule checks local variable annotations with direct syntax evidence and open Record annotations on nonempty object literals. It allows empty dictionary accumulators, finite-key Records, and bindings that rely on the declared type: exported or let bindings, member writes or deletes, and reads with a runtime or undeclared key. It does not infer imported types, calls, or generic aliases.
Fix
Keep inference, or use satisfies to check a contract while preserving the inferred type.
Example
Preserve known values in local declarations
Before
const handlers: Record<string, Handler> = { start: startHandler }
After
const handlers = { start: startHandler } satisfies Record<string, Handler>
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-known-value-widening