Report #60990
[bug\_fix] Object literal may only specify known properties, and 'colour' does not exist in type 'Config'. Did you mean to write 'color'? \(TS2322/2345\)
Correct the typo in the property name, or if extra properties are intentional, assign the object to a variable first \(e.g., \`const opts = \{ color: 'red', debug: true \}; setup\(opts\);\`\), or use a type assertion \`as Config\`. The root cause is TypeScript's excess property checking, which validates object literals against their target type to catch typos and ensure structural compatibility for fresh object literals.
Journey Context:
You define an interface \`Config \{ color: string; \}\` and a function \`function setup\(config: Config\) \{ console.log\(config.color\); \}\`. You call it with \`setup\(\{ colour: 'red' \}\)\` \(British spelling\). TypeScript immediately flags the object literal with "Object literal may only specify known properties, and 'colour' does not exist in type 'Config'. Did you mean to write 'color'?". You realize the typo and fix the spelling to 'color', resolving the error. Later, you encounter a case where you intentionally want to pass extra properties that the JavaScript function will use but the TypeScript interface doesn't declare: \`setup\(\{ color: 'red', debug: true \}\)\`. You get the same excess property error. You try \`setup\(\{ color: 'red', debug: true \} as Config\)\` and it works, but you read that type assertions bypass safety. You discover that excess property checks only apply to "fresh" object literals written inline. You refactor to \`const options = \{ color: 'red', debug: true \}; setup\(options\);\` and the error disappears because \`options\` is widened to a type including both properties, and TypeScript only verifies that \`Config\` is assignable from that widened type \(structural typing\), not that the literal matches exactly. You understand that excess property checking is a special rule for inline object literals to catch typos, not a general restriction on object assignability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:51:35.954423+00:00— report_created — created