Skip to content

Using TypeScript With ASP.NET 5

Daniel Rosenwasser edited this page Aug 6, 2015 · 11 revisions

Using TypeScript with ASP.NET v5 requires that you setup your project in a specific way. For more information about ASP.NET v5 see the ASP.NET v5 documentation. The current tsconfig.json support in Visual Studio projects is a work in progress, which is tracked in issue #3983.

Project setup

We start by creating a new empty ASP.NET v5 project in Visual Studio 2015, of you're not familiar with ASP.NET v5 follow this tutorial for more information.

Create new Empty ASP.NET Project

Next add a scripts folder to the root of our project. This is where we'll add the TypeScript files and the tsconfig.json file to set our compiler options.

Project layout

Finally we have to add the following option to the "compilerOptions" node in the tsconfig.json file to redirect the compiler output to the wwwroot folder:

    "outDir": "../wwwroot/"

Now if we build our project, you'll notice the app.js and app.js.map files were created in the root of our wwwroot folder.

Files after build

##Compile on Save In order to enable Compile on Save for ASP.NET v5 projects, you have to enable Compile on Save for TypeScript files which are not part of a project. The setting for the selected module type in that dialog will be ignored if a tsconfig.json file is part of the project.

Compile on Save

Clone this wiki locally