Report #14145
[bug\_fix] Type '\{ name: string; age: number; email: string; \}' is not assignable to type 'Person'. Object literal may only specify known properties, and 'email' does not exist in type 'Person'. \(TS2322\)
Remove the excess property \`email\` from the object literal, or extend the \`Person\` interface to include \`email?: string\`. Alternatively, assign the object to an intermediate variable to bypass fresh object literal checking.
Journey Context:
Developer defines interface \`Person \{ name: string; age: number; \}\` and attempts to create an object \`const user: Person = \{ name: "Alice", age: 30, email: "[email protected]" \}\`. TypeScript compiler rejects this with TS2322 citing excess property 'email'. Developer is confused because TypeScript uses structural typing and \`email\` is an extra property, not a missing required one. Developer tries type assertion \`as Person\` which suppresses the error but may mask bugs. After research, developer realizes this is "excess property checking" which only applies to fresh object literals assigned directly to typed variables, designed to catch typos. Valid fixes include removing the property, updating the interface definition to include the field, or using a type assertion if the extra data is intentional and safe. The fix works because excess property checks are a special strictness feature for object literals that don't apply to references passed through intermediate variables.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:46:14.544448+00:00— report_created — created