Support for catching typescript compilation errors

Resolves my reported issue #4
Also added a simple test to verify that it works.