Skip to content

Instantly share code, notes, and snippets.

@remcoder
Created October 1, 2012 19:48
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save remcoder/3814020 to your computer and use it in GitHub Desktop.
Save remcoder/3814020 to your computer and use it in GitHub Desktop.
Sublime Text 2 build system for Typescript
{
"selector": "source.ts",
"cmd": ["tsc", "$file"],
"file_regex": "^(.+?) \\((\\d+),(\\d+)\\)(: .+)$",
"line_regex": "\\((\\d+),(\\d+)\\)",
"osx": {
"path": "/usr/local/bin:/opt/local/bin"
}
}
@claudio-silva
Copy link

Didn't work for me.
Solved it by changing the file_regex to "^(.+?) ((\d+),(\d+)): (.+)$"
(please note the space after (.+?) )

@claudio-silva
Copy link

Sorry for the bad formatting above.
Here is the revised code:

"file_regex": "^(.+?) \\((\\d+),(\\d+)\\): (.+)$"

@matbee-eth
Copy link

osx only?

@pstjvn
Copy link

pstjvn commented Oct 5, 2012

The OSX part is to assign the correct path from where tsc can be invoked, works on Linux as well. Indeed the regex proposed by claudio-silva works for error navigation with f4.

@nacho4d
Copy link

nacho4d commented Oct 9, 2012

I've tried the code with @claudio-silva modification but I can't get "Next Result" (F4) to work :( Am I missing something here?.

typescript.sublime-build:

{
    "cmd": ["tsc","$file"],
    "file_regex": "^(.+?) \\((\\d+),(\\d+)\\): (.+)$",
    "selector": "source.ts",
    "osx": {
       "path": "/usr/local/bin:/opt/local/bin"
    }
}

greeter.ts:

function greeter(person: string) {
     return "Hello, " + person;
}
var user = "Jane User";
document.body.innerHTML = greeter(us-er);

results:

/Users/ignacio/Desktop/greeter.ts(6,34): The name 'us' does not exist in the current scope
/Users/ignacio/Desktop/greeter.ts(6,37): The name 'er' does not exist in the current scope
/Users/ignacio/Desktop/greeter.ts(6,26): Supplied parameters do not match any signature of call target
[Finished in 1.1s with exit code 1]

I get errors as expected but the F4 key seems to do nothing, Is this normal? I wrote this here because I wasn't sure of if this is a thing of the build script or Sublime.

@nacho4d
Copy link

nacho4d commented Oct 9, 2012

Nevermind, I found that this works for me :)

{
    "cmd": ["tsc","$file"],
    "file_regex": "^(.+?) \\((\\d+),(\\d+)\\)(: .+)$",
    "line_regex": "\\((\\d+),(\\d+)\\)",
    "selector": "source.ts",
    "osx": {
       "path": "/usr/local/bin:/opt/local/bin"
    }
}

@remcoder
Copy link
Author

updated according to your suggestions. thx!

@pstjvn
Copy link

pstjvn commented Dec 26, 2012

It seems the format has been changed slightly in 0.8.1. Currently the following works:

"file_regex": "^(.+?)\\((\\d+),(\\d+)\\): (.+)$"

The space after the file name is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment