Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community that shares solutions with each other.

If you think you have something to add here.

you are welcome with your fresh ideas - List Articles

TypeScript - how to compile ts file to js

0 contributions
14 points

To complile TypeScript file to JavaScript file tsc programm is necessary.

1. Single *.ts file compilation example

  1. Create Script.ts file:
    for(let i = 0; i < 5; ++i)
        console.log('Hello world!');
  2. Run tsc command
    $ tsc Script.ts

    or for automatic compilation on Script.ts file changed use:

    $ tsc -w Script.ts

    Notes:

    • after compliation Script.js file should be created
    • -w parameter enables file changed watching
  3. Run compiled program
    $ node Script.js

    Output:

    Hello world!
    Hello world!
    Hello world!
    Hello world!
    Hello world!

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

Read this article for more details.

0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more