TypeScript: Support for custom output. Fixed #565