Skip to content

TS2783: 'X' is specified more than once

Error message

                'X' is specified more than once, so this usage will be overwritten.
              

Quick summary

You have a property in both a spread object and an explicit assignment. The explicit value wins, which may not be intended.

Why this happens

  • Spreading an object and then overriding a property with the same name

  • Unintentional property duplication in object literals

Minimal example

✗ Broken code
const defaults = { port: 3000, host: 'localhost' };
const config = { ...defaults, port: 8080 }; // TS2783
✓ Fixed code
const defaults = { port: 3000, host: 'localhost' };
const config = { ...defaults, port: 8080 }; // ✅ intentional override

If the override is intentional, this is fine. Otherwise, remove the duplicate.

How to diagnose

  • Check which properties are in the spread object

  • Check which properties are explicitly set after the spread

How to fix

  • Remove the duplicate property if the spread value is intended

  • Remove the property from the spread if the explicit value is intended

  • Make the override intentional and document it with a comment

← Back to language