TypeScript · TS0011

Preserve known values in local declarations

Detect local annotations that discard known values or object keys.
TS0011vite-doctor/typescriptevidencewarnNo fix

Run this rule

pnpm vite-doctor . --extends auto,typescript/strict --rules typescript/evidence/no-known-value-widening

Why it matters

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.

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>
Copyright © 2026