TypedJS
TypedJS copied to clipboard
Objects: Enforce types on properties mentioned
It's a little late for me so I don't have a good code sample. I'll get one tomorrow.
In the meantime this seems to be failing:
//+ foo: { hello: String } -> String
function foo(o) {
return o.hello;
}
foo({ hello: 'foo', world: 'bar' }); // will fail because world is not typed.
You could make an argument that it should throw a TypeError but I'd like for there to be an option.
This would pass in Roy which uses sub-typing.