Various fixes for typescript gulp module.

- Don't cache files that couldn't be read.
- Don't silently ignore some errors.
- Call typechecker while compiling, not while emitting.
- Simplify linker's handling of global namespace.