Nicolas S.Xu
Nicolas S.Xu

Reputation: 14544

How to compile TypeScript and run the result .js file in one build in sublime Text 3?

I've already successfully installed TypeScript plugin on Sublime Text 3. After the plugin is installed, it has a build system added to the menu.

enter image description here

You can just use "Command + B" to build .ts file.

What I want is to compile .ts to .js and run the result js file using "node xxx.js" in one "Command + B" command.

How do I configure sublime text 3 build system to do it?

Upvotes: 3

Views: 1243

Answers (1)

Ben Creasy
Ben Creasy

Reputation: 4146

Assuming that both tsc and node are in your system PATH, the following configuration should work:

{
  "cmd": ["tsc $file && node $file_base_name.js"],
  "shell": true,
  "selector": "*.ts"
}

See Build Systems – Configuration for more on what is going on here.

Upvotes: 1

Related Questions