How to use TypeScript in your ASP.NET MVC Project

9 min readJan 27, 2022

In this article I will walk you through the steps demonstrating how to use TypeScript in your ASP.NET MVC project.

1 — What is TypeScript?

TypeScript is a programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language. TypeScript is designed for the development of large applications and transcompiles to JavaScript.

To learn more about TypeScript you can visit the official website by clicking on this link:

2 — Create a directory for your TypeScript code

In your MVC solution you will need to create a folder where all of your TypeScript files will reside. In this example I am going to call the folder “TSScripts” (You can name this folder anything you would like).

I created the “TSScripts” folder at the root directory of my “TypeScriptProject” project. Below is a screen shot of the folder structures so far.

3 — Create JavaScript output directory

You might be asking yourself why would I need a JavaScript output directory? If I am using TypeScript why would I also need JavaScript?

Those are valid questions and the simple answer is that currently there are no browsers on the market that support/can run typescript and therefore we need to transcompile the TypeScript code to JavaScript so browsers can understand it.

TypeScript works by adding enhanced syntax to JavaScript and then transforming it to JavaScript after the TypeScript compiler does its own checks.

Now we need to create the appScripts folder in our root project directory. This is where the .js files will be outputted to when the TypeScript compiler is done compiling the code.