Languages
[Edit]
EN

TypeScript - how to install tsc under Windows (TypeScript compiler)

16 points
Created by:
Imaan-Morin
889

In this article, we would like to show how to install TypeScript compiler under Windows.

Quick solution:

npm install -g typescript

Note: typescript package contains tsc command.

 

Detailed desription

  1. Ensure that Node.js and npm command are installed
    (installation and running instruction is here).
  2. Open some terminal as administrator, e.g. Bash
    (an installation instruction is here).
  3. Install TypeScript compiler using:
    npm install -g typescript
    Where: -g flag means global installation.
    Example output:
    john@DESKTOP-PC MINGW64 ~
    $ npm -g install typescript
    C:\Users\john\AppData\Roaming\npm\tsc -> C:\Users\john\AppData\Roaming\npm\node_modules\typescript\bin\tsc
    C:\Users\john\AppData\Roaming\npm\tsserver -> C:\Users\john\AppData\Roaming\npm\node_modules\typescript\bin\tsserver
    + typescript@4.0.3
    updated 1 package in 17.571s

 

*.ts compilation instruction

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

    Note: Script.js file should be created from Script.ts file.

  3. Run compiled program:
    node Script.js

    Output:

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

 

References

  1.  TypeScript Installation - Microsoft Docs

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