TypedJS icon indicating copy to clipboard operation
TypedJS copied to clipboard

Objects: Enforce types on properties mentioned

Open goatslacker opened this issue 13 years ago • 1 comments

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.

goatslacker avatar Feb 19 '12 11:02 goatslacker

This would pass in Roy which uses sub-typing.

gregwebs avatar Feb 24 '12 14:02 gregwebs