typescriptvisual-studio-code

Typescript file execution using Visual studio code


I have some trouble executing a typescript file. I am using visual studio code to execute typescript files. I have installed and set up visual studio code and typescript. But when I try to execute typescript file (tsc filename.ts) it shows an error. Please help!

Error:

PS D:\01_Hello> tsc app.ts
tsc : The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ tsc app.ts
+ ~~~
    + CategoryInfo          : ObjectNotFound: (tsc:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Solution

  • Visual Studio Code is designed to work with the version of TypeScript you've grabbed via NPM. So here are the steps you need to do...

    1. Install Node
    2. Run npm install -g typescript
    3. Check it worked with tsc -v

    You should now have everything working.