Incorrect type inference of object spread, when spreaded object is referenced via interface and created by class instantiation #13409
Labels
Design Limitation
Constraints of the existing architecture prevent this from being fixed
TypeScript Version: 2.1.X (Playground)
Code
Expected behavior:
Compile error. Either MyClass incorrectly implements
I
interface requiring to definez
asz=()=>alert(this.x + this.y)
or atalert(o.z)
reporting there is no such a property ono
, 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 errorProperty 'z' does not exist on type '{ x: number; y: number; }'
as expected.The text was updated successfully, but these errors were encountered: