I am trying to use TypeScript with Backbone.js. It "works", but much of the type safety is lost by Backbone's get() and set(). I am trying to write a helper method that would restore type-safety. Something like this:

I'd put this in my model:

object() : IMyModel  {
    return attributes; // except I should use get(), not attributes, per documentation
}

And this in the consumer: var myVar = this.model.object().MyProperty;

With this syntax, I get TypeScript's knowledge that MyProperty exists and is bool, which is awesome. However, the backbone.js docs tell me to use get and set rather than the attributes hash directly. So is there any magic Javascript way to pipe usage of that object through get and set properly?

Edit
Report