TS2300

error TS2300: Duplicate identifier ‘name’.

Broken Code ❌

Objects don’t support multiple properties with the same name:

1
2
3
4
const objectLiteral = {
name: 'Benny',
name: 'Sofia'
};

Fixed Code ✔️

To fix the error we have to remove the duplicated property:

1
2
3
const objectLiteral = {
name: 'Sofia'
};