Is there a reason that this code needs to generate an error?
class Test {
static function main() {
trace("Haxe is great!");
var point3d = {x: 0, y: 0, z: 0};
var point2d: {x: Int, y: Int} = point3d; // { z : Int, y : Int, x : Int } should be { y : Int, x : Int }
}
}
I know some other type systems view “point3d” as a valid object to fit anytime “point2d” is required. See for example Flow
I found this old manual page saying “However please note that if the p3d variable is not typed as Point3D, the compiler will complain saying that there is an extra field z : this is because this field is not required by Point and is then useless.”
Is there any way to tell the compiler to accept my object, other than doing a cast or untyped? (That is: I would still like type checking on the fields that are there, I just want it to ignore extra fields).