TypeScript Version: 2.1.X (Playground)
Code
interface I { x: number, y: number, z: () => void }
class MyClass implements I {
constructor(public x: number, public y: number) {
}
z() { alert(this.x + this.y) }
}
var x: I = new MyClass(5, 7);
var o = { ...x }
alert(o.z); // undefined
Expected behavior:
Compile error. Either MyClass incorrectly implements I interface requiring to define z as z=()=>alert(this.x + this.y) or at alert(o.z) reporting there is no such a property on o, or report something similar to FlowType.
Actual behavior:
No compiler warnings and runtime error when trying to invoke o.z().
Note:
When I change a definition of I this way: interface I { x: number, y: number, z(): void }, I get an error Property 'z' does not exist on type '{ x: number; y: number; }' as expected.