Work around TS compiler error about import and var name collisions

This patch does two things, one of which should be uncontroversial, the other maybe not so much:
 - remove redundant imports for classes in the same package
 - replace the compiler error TSC spits out for `var Foo: typeof some.nested.package.Foo` by instead using `import package = some.nested.package` and then changing all references to `Foo` to `package.Foo`

@mbebenita, I couldn't come up with a better solution. Also, I fear that we might even run into this far, far more with future versions of TSC: it doesn't really make sense that they compile references to classes in the same package as `package.Foo` automatically. I think it's likely that they'll just automatically import all required classes automatically, and then compile that to `Foo` just as with explicitly imported classes.