Compiling the typescript file using the build command in SUBLIME2/3

Source: Internet
Author: User

Typescript is a superset of JavaScript built-in, adding optional static types and object-oriented programming to help us develop large web applications. Sublime Text is a code editor, with a beautiful user interface and strong plug-in support, through the Sublime to write Typesript can let us go to the duck, Sublime support the build function, can compile some common language, However, the compilation of Typesript to JavaScript cannot be completed. But it doesn't matter, we can use the manual settings to make these two big artifacts tightly linked together. First, we're going to use NPM to install the typescript package globally. We have been able to compile the typescript file with the. TS by using the TSC command at the command line. For example: But this is a lot of inconvenience, if we can fully compile in the editor is not more simple and friendly. So the next step is to add typescript compile functionality to sublime. Open Sublime Text--Tools--build system--new build system Next, paste the following code into the newly opened window
1 {2     "cmd": ["TSC","$file"],3     "File_regex":"(. *\\.ts?) \\s\\ ([0-9]+) \ \ ([0-9]+) \ \) \\:\\s (...) $",4     "selector":"source.ts",5 6     "Windows": {7         "cmd": ["Tsc.cmd","--target","ES5","$file"]8     }9}

Select Save and add to the default path, the file name is Typescript.sublime-build

To do this we have achieved the goal of compiling the typescript file in sublime text, and then we'll test

After writing a typescript file, press CTRL + B at the same time, if the [finished in 1.4s] Prompt field is displayed below, the generated JS file will be visible in the current directory if the file is compiled successfully.

This is the end of the tutorial, I hope you have fun ~

Compiling the typescript file using the build command in SUBLIME2/3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.