I'm trying to write a piece of code in TypeScript that boils down to this pattern:
function test(x: {theFlag: boolean} & {readonly theFlag: boolean} ){
x.theFlag = true;
}
But I get the following error on this line x.theFlag = true;
[ts] Cannot assign to 'theFlag' because it is a constant or a read-only property.
I don't know why TypeScript is giving me an error on this. I think logically this should be allowed.
Is there a good workaround to achieve what I'm trying to do?
I'm using TypeScript version 2.7.2.