Skip to content

no-known-value-widening

Preserve a known value's contract instead of widening a local binding to unknown, object, or an unknown-valued dictionary.

Why

Erasing a typed value's fields forces downstream code to rediscover the same contract through casts, reflection, or representation checks.

Fix

Keep the inferred type, select the required domain fields, or use satisfies to check compatibility without erasing evidence.

Examples

Before — flagged A dictionary erases a known tool contract
src/tool.ts
type Tool = { name: string; enabled: boolean };
declare const tool: Tool;
const fields: Record<string, unknown> = tool;
After — preferred Retain the tool's fields
src/tool.ts
type Tool = { name: string; enabled: boolean };
declare const tool: Tool;
const fields = tool;