I've a "constants.ts" file which has below code:
export const PLACEMENT_ID = 'placementId';
export const TIMESTAMP = 'timeStamp';
In my type script code, I'm trying to use the constants as keys while creating a dictionary and then convert it to JSON to write it to a file.
import * as c from './constants';
let obj = JSON.stringify({ c.PLACEMENT_ID: "bob", c.TIMESTAMP: 34 });
console.log(obj);
let parsedData = JSON.parse(obj);
console.log(parsedData[c.PLACEMENT_ID]);
console.log(parsedData[c.TIMESTAMP]);
Its throwing error:
An object literal cannot have multiple properties with the same name in strict mode.
I couldn't find any particular reason why is it throwing that error.