Report #44167
[bug\_fix] Object literal may only specify known properties, but 'extraProp' does not exist in type 'Config'. Did you mean to write 'extraProp' as a computed property? \(TS2345 or TS2322 depending on context\)
Assign the object to an intermediate variable first to bypass freshness checking: \`const temp = \{ known: 1, extraProp: 2 \}; const config: Config = temp;\`. Alternatively, use a type assertion \`as Config\`, or add the property to the interface definition. Do not use spread syntax alone as it also triggers excess property checks.
Journey Context:
Developer defines an interface \`Config\` with specific allowed properties. They then try to create a configuration object inline: \`const cfg: Config = \{ host: 'localhost', port: 3000, timout: 5000 \}\` \(typo in \`timeout\`\). TypeScript throws an error about excess properties. Developer realizes the typo, but also notices that even intentional extra properties trigger this. They try to use spread syntax \`const cfg: Config = \{ ...base, extra: 1 \}\` but it still fails. The rabbit hole reveals TypeScript's "excess property checking" \(freshness checks\) which only applies to fresh object literals directly assigned to a typed variable or passed as arguments. The fix works because assigning to an intermediate variable \`temp\` removes the "freshness" of the literal; the compiler only checks that \`temp\` is assignable to \`Config\` via structural typing, allowing extra properties \(width subtyping\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:36:16.883586+00:00— report_created — created