Closed
Description
TypeScript Version: 2.0.3, 2.1.0-dev.20160927
Code
// A *self-contained* demonstration of the problem follows...
'use strict';
interface RO { readonly x: number; }
interface RW { x: number; }
const ro: RO = Object.freeze({ x: 3 });
function modifyX(input: RW) {
input.x = 5;
}
// No type error
// Throws exception
modifyX(ro);
Expected behavior:
The call modifyX(ro)
should give a type error, as ro
has a readonly property but the interface to modifyX
requires a modifiable field.
Actual behavior:
No type error.