Declaration support

adds support for tsc's --declaration option (wasn't working before) and has misc fixes and testing improvements.