Forgot to add - I'm not sure if I got this entirely right, and I'm not currently using the Closure compiler to actually verify the type checks. But I think it should be reasonably close.