Languages
[Edit]
EN

TypeScript - how to compile ts file to js

17 points
Created by:
cory
1756

In this short article, we would like to show how to compile *.ts files to *.js files.

To complile TypeScript file to JavaScript file, tsc program is necessary. In the below, you will find single output and multiple output compilation descriptions.

Single *.ts file compilation example

Edit

Simple steps:

  1. Create script.ts file:
  2. Run tsc command:

    or for automatic compilation when script.ts file is changed use:

    Notes:

    • after compliation script.js file should be created,
    • -w parameter enables monitoring and recompilation when file is changed - files watching mode.
  3. Run compiled program

    Output:

Multiple *.ts files to  single *.js file compilation example

Edit

Read this article for more details.

 

See also

Edit
  1. Installation TypeScript Compiler (tsc)

Alternative titles

  1. TypeScript - how to compile TypeScript file to JavaScript file
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

TypeScript

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join