TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Compiler does not enforce read only properties

Open diegope opened this issue 11 years ago • 1 comments

Our team hit an issue when turning on strict in our code. Consider the following code:

class bug { public get id() { return 5; } } var b = new bug(); b.id = 10;

In this example, the id property only declares a getter, however, it is still possible to assign a value to it in TS. This is neither a syntax or compile time error in TS (1.4.0). Is there a workaround? Or Is this something that is already being fixed?

Diego

diegope avatar Jun 11 '15 23:06 diegope

see #12

mhegazy avatar Jun 12 '15 00:06 mhegazy