Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure a Sublime Build System for TypeScript

I'm looking to configure a Build System in Sublime Text for TypeScript.

I'm currently using...

{
  "cmd": ["tsc", "$file"],
  "selector": "source.ts"
}

I'd also like to set the 'file_regex' property to handle error messages.

Anyone know what to set this to?

like image 954
Sambo Avatar asked Oct 08 '12 10:10

Sambo


People also ask

How do I make TypeScript support in Sublime Text?

Press Ctrl + shift + p. Type "inst" and select Package Control: Install Package. Type "type" and select "Typescript"

Does sublime support TypeScript?

TypeScript Plugin for Sublime Text. The plugin uses an IO wrapper around the TypeScript language services to provide an enhanced Sublime Text experience when working with TypeScript code.

How do I change the build system in Sublime Text 3?

Select it, hit Ctrl B to build, and then hit Ctrl Shift B to run the resulting program. Or you can use a Build and Run option and call it by hitting Ctrl B , then selecting that option.

How do I set build commands in Sublime Text?

Sublime Text is able to run build programs such as 'make', either when a key in pressed (F7 by default), or when a file is saved. The build system to use can be select from the Tools/Build System menu. If a project is open, the selected build system will be remembered for the project.


2 Answers

Use this on OS-X:

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

EDIT:

Here is the Sublime Build System created for Windows. Tested and working as expected. However you need to include tsc.cmd path in the windows environment, otherwise you should define the root to the Typescript command in the cmd section below:

{
    "cmd": ["tsc","$file"],
    "file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
    "selector": "source.ts",

    "windows": {
        "cmd": ["tsc.cmd", "$file"]
    }
}
like image 78
Endre Simo Avatar answered Oct 03 '22 21:10

Endre Simo


There are two versions now. This one, or this one. Creating your own is easy, by referring to this document.

like image 33
Eugene Ramirez Avatar answered Oct 03 '22 21:10

Eugene Ramirez