go-typescript
go-typescript copied to clipboard
How can I make `TranspileCtx` return errors on invalid typescript.
For example, when i try to run this:
export { func: () => { } };
I expect there to be an error because this typescript is not valid, however it just returns invalid javascript.
Compiler Options:
{"alwaysStrict":true,"explainFiles":true,"module":"commonjs","noEmit":true,"noEmitOnError":true,"noErrorTruncation":true,"noLib":true,"target":"es5"}
It looks like the Typescript function we use for transpile only returns the output text, not any diagnostics information so this technically isn't a bug.
https://github.com/microsoft/TypeScript/blob/79a851426c514a12a75b342e8dd2460ee6615f73/src/services/transpile.ts#L220
We could consider using the transpileModule function instead but that would be a breaking change so maybe we just make it configurable.