Report #6757
[gotcha] TypeScript excess property checks fail on variables but pass on inline object literals
To bypass the freshness check, assign objects to a variable with the target type before passing them; to enforce strictness, use explicit generic constraints or \`satisfies\` operator instead of type annotations.
Journey Context:
TypeScript performs 'excess property checks' only on 'fresh' object literals assigned directly to a typed parameter. When the object is stored in a variable first, structural typing applies, allowing extra properties. Developers often assume both cases behave identically, leading to runtime bugs when extra properties overwrite downstream logic or cause unexpected serialization. Using \`satisfies\` \(TypeScript 4.9\+\) preserves the specific literal type while checking compatibility, avoiding the narrowing issues of type annotations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:49:48.144257+00:00— report_created — created