Currently, I am developing a class for an Angular 2 component that involves the use of Input/Output decorators along with a setter as shown below:
export class ItemDetails {
// Assigning 'item' to a locally scoped property
@Input('item') _item: Item;
originalName: string;
selectedItem: Item;
// Event emitters for save and cancel operations
@Output() saved = new EventEmitter();
@Output() cancelled = new EventEmitter();
// Additional logic using ES6 setter on every update
set _item(value: Item) {
if (value) this.originalName = value.name;
this.selectedItem = Object.assign({}, value);
}
}
Even though I believe this code is correct, I encountered the following error:
error TS2300: Duplicate identifier '_item'
I would appreciate any insights on why this error occurs. Thank you :)