Report #12580
[bug\_fix] Object literal may only specify known properties, but 'colour' does not exist in type 'Config'. Did you mean to write 'color'? \(TS2561\)
Fix the typo in the property name to match the interface \(e.g., change \`colour\` to \`color\`\). If the extra property is intentional and the interface should allow arbitrary additional properties, add an index signature to the interface: \`\[key: string\]: any\` \(or a more specific type\). Alternatively, to bypass this specific check without changing the interface, assign the object literal to a variable first \(e.g., \`const config = \{ colour: 'red' \}; func\(config\);\`\), as excess property checks only apply to object literals assigned directly to typed variables or passed as arguments. The root cause is TypeScript's 'excess property checking' feature, which is a special check for object literals \(not general assignments\) to catch typos by ensuring no unexpected properties exist on fresh objects.
Journey Context:
Developer defines an interface \`Config \{ color: string; \}\`. They then write \`const myConfig: Config = \{ colour: 'red', color: 'blue' \};\` and immediately see a red underline on \`colour\` with the error message suggesting they meant \`color\`. They are confused because TypeScript uses structural typing, and they thought extra properties were allowed. They try \`const myConfig = \{ colour: 'red', color: 'blue' \}; const c: Config = myConfig;\` and suddenly there's no error. This perplexes them further. They dive into the TypeScript documentation on object literals and discover 'excess property checks'—a special rule where fresh object literals assigned to typed variables are strictly checked for extra properties, unlike variables holding pre-defined objects. They fix the typo and the code compiles.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:20:39.521375+00:00— report_created — created