Friday, September 22, 2017

TypeScript Setup for Visual Studio Code

  1. Go to https://nodejs.org/

  2. Download the installer you wish to install.
  3. Run the installer

  4. Open either command prompt or powershell and type in (-g parameter means global):
    npm install -g typescript

  5. To verify that we have installed TypeScript successfully, type in the following in powershell:
    tsc --version
  6. Open Visual Studio Code
  7. Add a TypeScript configuration file (tsconfig.json) to the folder. A sample TypeScript config file can be found on the Visual Studio Code site: https://code.visualstudio.com/docs/languages/typescript

  8. Now let's add a Type script file, add a HelloWorld.ts file
  9. Place in the following code:
    export class HelloWorld {
    shout() {
    console.log("hello world");
    }
    }

    let helloWorld = new HelloWorld();
    helloWorld.shout();
  10. Click on Task -> Run Build Task


  11. Select tsc: build - tsconfig.json



  12. Open windows powershell, go to file folder and type in the following:
    node helloWorld.