Closed
Description
TypeScript Version: 2.0.0, 2.0.3, nightly (2.1.0-dev.20161010)
Code
// A *self-contained* demonstration of the problem follows...
'use strict';
interface X { readonly [key: string]: string }
const x: X = Object.freeze({
"a": "A",
"b": "B",
"c": "C"
});
// Error: TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
x["a"] = "B";
// No error - but runtime exception
// TypeError: Cannot assign to read only property 'a' of object '#<Object>'
delete x["a"];
Expected behavior:
delete x["a"];
should give a compile-time error (as it predictably leads to a runtime error later on).
Actual behavior:
No compile-time error is given.
Design Limitation (?)
I understand that this may be a design limitation as in #11180, in this case, this is another vote for the --strictReadonlyChecks flag discussed in #11180.