Let's say we have
x = {a:65, b:634, c:74};
y = {o:453, e:5342, g:543}
z = {o:453, e:5342, b:543}
// Doing this should be okay
const both = {...x, ...y}
// However, when doing this:
const both = {...x, ...z}
I need it to show some error like "Property b cannot be reassigned" or whatever, just don't let it compile. Any suggestions?
Edit: I know I can easily write a function to combine the objects and conditionally raise an exception but the point is that I need to do such kind of checking before runtime. It would be very helpful if it can be done using typescript, eslint or any trick that can check for such condition before runtime...