Fix scope error

Fixes part of the error in #138
Eg: this code would give a duplicate variable error
```
var a = {
    foo(): void {
        var bar = 1;
    },
    baz(): void {
        var bar = 1;
    }
};
```