How can I parse error messages from TypeScript in Sublime Text 2?
I am trying to set up Sublime Text 2 build system for TypeScript. I followed the directions I found here . In fact, the call to the compiler works, however it does not raise error messages correctly.
Here is my TypeScript program:
function greeter(person: string) {
return "Hello, " + person;
}
var user = "Jane User";
document.body.innerHTML = greeter(us-er);
When I compile from the command line, I see the following output:
C: /data/helloworld.ts (5,34): name 'us' does not exist in current scope C: /data/helloworld.ts (5.37): name "er" does not exist in current scope C: / data /helloworld.ts(5,26): The parameters supplied do not match any target target signature
When I build from Sublime Text 2 I see the following output:
C: /Data/helloworld.ts (5.34): [Completed in 0.6 sec.]
I have tried different variations of the regex file as mentioned in the original question, all with the same result. My current version of the file looks like this:
{
"selector": "source.ts",
"cmd": ["tsc.cmd", "--target","ES5", "$file"],
"file_regex": "^(.+?)\\(([0-9]+,[0-9]+)\\)\\: (.+)$"
}
When I test the regex with the Python Regex Tool , this version matches the 3 parts correctly. However, Sublime Text refuses to show me the actual error message.
Can anyone point out what I am doing wrong?
This is very frustrating, especially since one site even shows an example of Sublime Text displaying the error message correctly.
This is with Sublime Text 2.01 64-bit on Windows 7 64-bit.
source to share
It looks like the process ends before flushing the output buffer. You can check this with:
{
"selector": "source.ts",
"cmd": ["tsc.cmd", "--target","ES5", "$file"],
"file_regex": "(.*)"
}
You should only get something like
C:/Data/helloworld.ts(5,34): [Finished in 0.6s]
To fix this problem, you can try to put some delay in the batch file tsc.cmd
:
@echo off
:: Run the compiler
node "C:\typescript\tsc.js" %*
:: Waits for 500ms
ping 1.1.1.1 -n 1 -w 500
EDIT: See Markus's comment on using Windows Script Host instead of node. This fixes the problem. Further research reveals that this is actually a known issue with node on Windows: see here and.
source to share