I'm trying to compile typescript files in java.
Here is a ".ts" file which has errors:
alert("hello, typescript");
errrrrrrrrrrrrrrrrrrrrrrrrrror
When I compile in windows shell(cmd):
tsc hello.ts
It will report error with message:
E:/WORKSPACE/test/typescripts/hello.ts(2,0): The name 'errrrrrrrrrrrrrrrrrrrrrrrrror'
does not exist in the current scope
But when I do it in java:
String cmd = "cmd /C tsc hello.ts";
Process p = Runtime.getRuntime().exec(cmd);
String out = IOUtils.toString(p.getInputStream());
String error = IOUtils.toString(p.getErrorStream());
System.out.println("### out: " + out);
System.out.println("### err: " + error);
It prints:
### out:
### err: E:/WORKSPACE/test/typescripts/hello.ts(2,0):
You can see the detail errors is not captured. Where is wrong with my code?
update
I just made sure that the tsc.exe
provided by MS has no such problem, and the one I run in this question is the tsc.cmd
installed from npm npm install typescript