How to setup TypeScript environment in Visual Stud

2020-04-20 03:47发布

问题:

I am using the community edition Visual Studio 2015. I want to setup the environment to use TypeScript to be used in an asp.net webforms application. I see lots of guidance in doing it using Visual Studio Code but not in Visual Studio. I was following the methods given at http://mobilemancer.com/2015/08/14/getting-started-typescript-1-5-in-visual-studio-2015/ However I don't see the option for NPM Configuration file under DNX. I see it only under C#, so probably it is server side while DNX represents client side. I have installed Visual Studio 2015 Update 3 as well as .Net Core 1.0

Thanks

回答1:

It's actually pretty straight forward:

  1. Install TypeScript from Tools -> Extension and Updates
  2. Add tsconfig.json at the root of the web form project. Refer to this link for more info on the TypeScript configuration file.
  3. Add TypeScript file (*.ts) to your application
  4. Add link to the transpiled JavaScript file in your page. You can define where the JavaScript file is created in the tsconfig.json file.

If you need to use NPM, then your original reference link works just fine.